From 13715930af765c58cecb80fe240fcb1d621f403f Mon Sep 17 00:00:00 2001 From: Daniel Chick Date: Tue, 17 Oct 2023 18:14:51 -0500 Subject: [PATCH 1/4] Update InstallButton with progress view and styling from list row --- Xcodes/Backend/XcodeCommands.swift | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Xcodes/Backend/XcodeCommands.swift b/Xcodes/Backend/XcodeCommands.swift index 76e9924..9967abb 100644 --- a/Xcodes/Backend/XcodeCommands.swift +++ b/Xcodes/Backend/XcodeCommands.swift @@ -34,16 +34,26 @@ struct XcodeCommands: Commands { struct InstallButton: View { @EnvironmentObject var appState: AppState + @State private var isLoading = false + let xcode: Xcode? - + var body: some View { Button(action: install) { - Text("Install") - .help("Install") - } + if isLoading { + ProgressView() + .colorInvert() + .controlSize(.small) + } else { + Text("Install") + .textCase(.uppercase) + .help("InstallDescription") + } + }.buttonStyle(AppStoreButtonStyle(primary: false, highlighted: false)) } - + private func install() { + isLoading = true guard let xcode = xcode else { return } appState.checkMinVersionAndInstall(id: xcode.id) } From 5b1cc4a93de44bb90f7cfe48c904c26732b34660 Mon Sep 17 00:00:00 2001 From: Daniel Chick Date: Tue, 17 Oct 2023 18:15:18 -0500 Subject: [PATCH 2/4] Swap button to InstallButton --- Xcodes/Frontend/XcodeList/XcodeListViewRow.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Xcodes/Frontend/XcodeList/XcodeListViewRow.swift b/Xcodes/Frontend/XcodeList/XcodeListViewRow.swift index 555c361..4757977 100644 --- a/Xcodes/Frontend/XcodeList/XcodeListViewRow.swift +++ b/Xcodes/Frontend/XcodeList/XcodeListViewRow.swift @@ -110,10 +110,7 @@ struct XcodeListViewRow: View { .buttonStyle(AppStoreButtonStyle(primary: true, highlighted: selected)) .help("OpenDescription") case .notInstalled: - Button("Install") { appState.checkMinVersionAndInstall(id: xcode.id) } - .textCase(.uppercase) - .buttonStyle(AppStoreButtonStyle(primary: false, highlighted: selected)) - .help("InstallDescription") + InstallButton(xcode: xcode) case let .installing(installationStep): InstallationStepRowView( installationStep: installationStep, From 4649ba0c8a9cf36fe89933782afa6500c5f9f7f6 Mon Sep 17 00:00:00 2001 From: Daniel Chick Date: Sat, 25 Nov 2023 19:19:59 -0600 Subject: [PATCH 3/4] Reuse ProgressButton --- Xcodes/Backend/XcodeCommands.swift | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Xcodes/Backend/XcodeCommands.swift b/Xcodes/Backend/XcodeCommands.swift index 9967abb..5071f30 100644 --- a/Xcodes/Backend/XcodeCommands.swift +++ b/Xcodes/Backend/XcodeCommands.swift @@ -39,16 +39,12 @@ struct InstallButton: View { let xcode: Xcode? var body: some View { - Button(action: install) { - if isLoading { - ProgressView() - .colorInvert() - .controlSize(.small) - } else { - Text("Install") - .textCase(.uppercase) - .help("InstallDescription") - } + ProgressButton(isInProgress: isLoading) { + install() + } label: { + Text("Install") + .textCase(.uppercase) + .help("InstallDescription") }.buttonStyle(AppStoreButtonStyle(primary: false, highlighted: false)) } From 9622b563b34db85095f7676abae357509972bd3a Mon Sep 17 00:00:00 2001 From: Daniel Chick Date: Tue, 5 Dec 2023 17:20:41 -0600 Subject: [PATCH 4/4] Move button styling to not affect the info pane --- Xcodes/Backend/XcodeCommands.swift | 3 +-- Xcodes/Frontend/XcodeList/XcodeListViewRow.swift | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Xcodes/Backend/XcodeCommands.swift b/Xcodes/Backend/XcodeCommands.swift index 5071f30..75773bb 100644 --- a/Xcodes/Backend/XcodeCommands.swift +++ b/Xcodes/Backend/XcodeCommands.swift @@ -43,9 +43,8 @@ struct InstallButton: View { install() } label: { Text("Install") - .textCase(.uppercase) .help("InstallDescription") - }.buttonStyle(AppStoreButtonStyle(primary: false, highlighted: false)) + } } private func install() { diff --git a/Xcodes/Frontend/XcodeList/XcodeListViewRow.swift b/Xcodes/Frontend/XcodeList/XcodeListViewRow.swift index 4757977..55f431c 100644 --- a/Xcodes/Frontend/XcodeList/XcodeListViewRow.swift +++ b/Xcodes/Frontend/XcodeList/XcodeListViewRow.swift @@ -111,6 +111,8 @@ struct XcodeListViewRow: View { .help("OpenDescription") case .notInstalled: InstallButton(xcode: xcode) + .textCase(.uppercase) + .buttonStyle(AppStoreButtonStyle(primary: false, highlighted: false)) case let .installing(installationStep): InstallationStepRowView( installationStep: installationStep,