Skip to content

Commit

Permalink
Merge pull request #613 from chuganzy/ganzy/rollback-loading
Browse files Browse the repository at this point in the history
Add `authenticating` to the `XcodeInstallationStep`
  • Loading branch information
MattKiazyk authored Oct 13, 2024
2 parents 0f5e42b + 1a3ca60 commit c245a1e
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 12 deletions.
5 changes: 5 additions & 0 deletions Xcodes/Backend/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions Xcodes/Backend/XcodeCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -49,7 +48,6 @@ struct InstallButton: View {
}

private func install() {
isLoading = true
guard let xcode = xcode else { return }
appState.checkMinVersionAndInstall(id: xcode.id)
}
Expand Down
2 changes: 1 addition & 1 deletion Xcodes/Frontend/InfoPane/InstallationStepDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion Xcodes/Frontend/XcodeList/InstallationStepRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
125 changes: 125 additions & 0 deletions Xcodes/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -4446,6 +4446,131 @@
}
}
},
"Authenticating" : {
"extractionState" : "manual",
"localizations" : {
"ar" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"ca" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"el" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"fi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"hi" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
"value" : "認証中"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"pt-BR" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
"value" : "Authenticating"
}
}
}
},
"AutomaticallyCreateSymbolicLink" : {
"localizations" : {
"ar" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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 {
Expand Down

0 comments on commit c245a1e

Please sign in to comment.