mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
Confirm before cancelling installation
This commit is contained in:
parent
1a830dc9dc
commit
4a33d010a8
6 changed files with 32 additions and 7 deletions
|
|
@ -30,6 +30,7 @@ class AppState: ObservableObject {
|
|||
@Published var isProcessingAuthRequest = false
|
||||
@Published var secondFactorData: SecondFactorData?
|
||||
@Published var xcodeBeingConfirmedForUninstallation: Xcode?
|
||||
@Published var xcodeBeingConfirmedForInstallCancellation: Xcode?
|
||||
@Published var helperInstallState: HelperInstallState = .notInstalled
|
||||
|
||||
// MARK: - Errors
|
||||
|
|
|
|||
|
|
@ -39,6 +39,12 @@ struct Xcode: Identifiable, CustomStringConvertible {
|
|||
|
||||
var id: Version { version }
|
||||
var installed: Bool { installState == .installed }
|
||||
var installing: Bool {
|
||||
switch installState {
|
||||
case .installing: return true
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
|
||||
var description: String {
|
||||
version.xcodeDescription
|
||||
|
|
|
|||
|
|
@ -55,13 +55,13 @@ struct CancelInstallButton: View {
|
|||
var body: some View {
|
||||
Button(action: cancelInstall) {
|
||||
Text("Cancel")
|
||||
.help("Cancel installation")
|
||||
.help("Stop installation")
|
||||
}
|
||||
}
|
||||
|
||||
private func cancelInstall() {
|
||||
guard let xcode = xcode else { return }
|
||||
appState.cancelInstall(id: xcode.id)
|
||||
appState.xcodeBeingConfirmedForInstallCancellation = xcode
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,9 +160,14 @@ struct InstallCommand: View {
|
|||
@FocusedValue(\.selectedXcode) private var selectedXcode: SelectedXcode?
|
||||
|
||||
var body: some View {
|
||||
InstallButton(xcode: selectedXcode.unwrapped)
|
||||
.keyboardShortcut("i", modifiers: [.command, .option])
|
||||
.disabled(selectedXcode.unwrapped?.installed == true)
|
||||
if selectedXcode.unwrapped?.installing == true {
|
||||
CancelInstallButton(xcode: selectedXcode.unwrapped)
|
||||
.keyboardShortcut(".", modifiers: [.command])
|
||||
} else {
|
||||
InstallButton(xcode: selectedXcode.unwrapped)
|
||||
.keyboardShortcut("i", modifiers: [.command, .option])
|
||||
.disabled(selectedXcode.unwrapped?.installState != .notInstalled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,15 @@ struct MainWindow: View {
|
|||
.frame(minWidth: 300, maxWidth: .infinity)
|
||||
.frame(width: isShowingInfoPane ? nil : 0)
|
||||
.isHidden(!isShowingInfoPane)
|
||||
// This alert isn't intentionally placed here,
|
||||
// just trying to put it in a unique part of the hierarchy
|
||||
// since you can't have more than one in the same spot.
|
||||
.alert(item: $appState.xcodeBeingConfirmedForInstallCancellation) { xcode in
|
||||
Alert(title: Text("Are you sure you want to stop the installation of Xcode \(xcode.description)?"),
|
||||
message: Text("Any progress will be discarded."),
|
||||
primaryButton: .destructive(Text("Stop Installation"), action: { self.appState.cancelInstall(id: xcode.id) }),
|
||||
secondaryButton: .cancel(Text("Cancel")))
|
||||
}
|
||||
}
|
||||
.mainToolbar(
|
||||
category: $category,
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ struct InstallationStepView: View {
|
|||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
.foregroundColor(highlighted ? .white : .secondary)
|
||||
.help("Cancel installation")
|
||||
.help("Stop installation")
|
||||
}
|
||||
.frame(minWidth: 80)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,11 @@ struct XcodeListViewRow: View {
|
|||
.buttonStyle(AppStoreButtonStyle(primary: false, highlighted: selected))
|
||||
.help("Install this version")
|
||||
case let .installing(installationStep):
|
||||
InstallationStepView(installationStep: installationStep, highlighted: selected, cancel: { appState.cancelInstall(id: xcode.id) })
|
||||
InstallationStepView(
|
||||
installationStep: installationStep,
|
||||
highlighted: selected,
|
||||
cancel: { appState.xcodeBeingConfirmedForInstallCancellation = xcode }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue