mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
Add authenticating step
This commit is contained in:
parent
74237f8fc1
commit
908e7ba3ea
6 changed files with 36 additions and 12 deletions
|
|
@ -436,6 +436,11 @@ class AppState: ObservableObject {
|
|||
guard let availableXcode = availableXcodes.first(where: { $0.version == id }) else { return }
|
||||
|
||||
installationPublishers[id] = signInIfNeeded()
|
||||
.handleEvents(
|
||||
receiveSubscription: { [unowned self] _ in
|
||||
self.setInstallationStep(of: availableXcode.version, to: .authenticating)
|
||||
}
|
||||
)
|
||||
.flatMap { [unowned self] in
|
||||
// signInIfNeeded might finish before the user actually authenticates if UI is involved.
|
||||
// This publisher will wait for the @Published authentication state to change to authenticated or unauthenticated before finishing,
|
||||
|
|
|
|||
|
|
@ -35,12 +35,11 @@ struct XcodeCommands: Commands {
|
|||
|
||||
struct InstallButton: View {
|
||||
@EnvironmentObject var appState: AppState
|
||||
@State private var isLoading = false
|
||||
|
||||
let xcode: Xcode?
|
||||
|
||||
var body: some View {
|
||||
ProgressButton(isInProgress: isLoading) {
|
||||
Button {
|
||||
install()
|
||||
} label: {
|
||||
Text("Install")
|
||||
|
|
@ -49,7 +48,6 @@ struct InstallButton: View {
|
|||
}
|
||||
|
||||
private func install() {
|
||||
isLoading = true
|
||||
guard let xcode = xcode else { return }
|
||||
appState.checkMinVersionAndInstall(id: xcode.id)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ struct InstallationStepDetailView: View {
|
|||
showsAdditionalDescription: true
|
||||
)
|
||||
|
||||
case .unarchiving, .moving, .trashingArchive, .checkingSecurity, .finishing:
|
||||
case .authenticating, .unarchiving, .moving, .trashingArchive, .checkingSecurity, .finishing:
|
||||
ProgressView()
|
||||
.scaleEffect(0.5)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ struct InstallationStepRowView: View {
|
|||
controlSize: .small,
|
||||
style: .spinning
|
||||
)
|
||||
case .unarchiving, .moving, .trashingArchive, .checkingSecurity, .finishing:
|
||||
case .authenticating, .unarchiving, .moving, .trashingArchive, .checkingSecurity, .finishing:
|
||||
ProgressView()
|
||||
.scaleEffect(0.5)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4446,6 +4446,23 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"Authenticating" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "Authenticating"
|
||||
}
|
||||
},
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "認証中"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"AutomaticallyCreateSymbolicLink" : {
|
||||
"localizations" : {
|
||||
"ar" : {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import Foundation
|
|||
|
||||
// A numbered step
|
||||
public enum XcodeInstallationStep: Equatable, CustomStringConvertible {
|
||||
case authenticating
|
||||
case downloading(progress: Progress)
|
||||
case unarchiving
|
||||
case moving(destination: String)
|
||||
|
|
@ -22,6 +23,8 @@ public enum XcodeInstallationStep: Equatable, CustomStringConvertible {
|
|||
|
||||
public var message: String {
|
||||
switch self {
|
||||
case .authenticating:
|
||||
return localizeString("Authenticating")
|
||||
case .downloading:
|
||||
return localizeString("Downloading")
|
||||
case .unarchiving:
|
||||
|
|
@ -39,16 +42,17 @@ public enum XcodeInstallationStep: Equatable, CustomStringConvertible {
|
|||
|
||||
public var stepNumber: Int {
|
||||
switch self {
|
||||
case .downloading: return 1
|
||||
case .unarchiving: return 2
|
||||
case .moving: return 3
|
||||
case .trashingArchive: return 4
|
||||
case .checkingSecurity: return 5
|
||||
case .finishing: return 6
|
||||
case .authenticating: return 1
|
||||
case .downloading: return 2
|
||||
case .unarchiving: return 3
|
||||
case .moving: return 4
|
||||
case .trashingArchive: return 5
|
||||
case .checkingSecurity: return 6
|
||||
case .finishing: return 7
|
||||
}
|
||||
}
|
||||
|
||||
public var stepCount: Int { 6 }
|
||||
public var stepCount: Int { 7 }
|
||||
}
|
||||
|
||||
func localizeString(_ key: String, comment: String = "") -> String {
|
||||
|
|
|
|||
Loading…
Reference in a new issue