From 94fe7df3bd1194e80168bdb59a388593fa0c5af0 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Fri, 15 Mar 2024 23:18:09 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=B1=20Custom=20button=20for=20"upgrade?= =?UTF-8?q?=20all"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 12 ++++- .../SpinnerBackground.colorset/Contents.json | 38 ++++++++++++++ .../StatusColorBlue.colorset/Contents.json | 2 +- .../Contents.json | 38 ++++++++++++++ .../SwiftUI/Common}/BlockingOverlayView.swift | 3 +- .../SwiftUI/Common/CustomButtonStyles.swift | 35 +++++++++++++ .../UI/PhpVersionManagerView.swift | 49 ++++++++++--------- phpmon/de.lproj/Localizable.strings | 2 +- phpmon/en.lproj/Localizable.strings | 2 +- phpmon/fr.lproj/Localizable.strings | 2 +- phpmon/nl.lproj/Localizable.strings | 2 +- phpmon/pt-PT.lproj/Localizable.strings | 2 +- phpmon/vi.lproj/Localizable.strings | 2 +- 13 files changed, 156 insertions(+), 33 deletions(-) create mode 100644 phpmon/Assets.xcassets/SpinnerBackground.colorset/Contents.json create mode 100644 phpmon/Assets.xcassets/StatusColorYellowTranslucent.colorset/Contents.json rename phpmon/{Modules/PHP Version Manager/UI => Domain/SwiftUI/Common}/BlockingOverlayView.swift (96%) create mode 100644 phpmon/Domain/SwiftUI/Common/CustomButtonStyles.swift diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 37350f4..119a26c 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -821,6 +821,10 @@ C4E6840C2AF26B830023ED25 /* BrewTapFormulae.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4E684082AF26B830023ED25 /* BrewTapFormulae.swift */; }; C4E9D2C02878B336008FFDAD /* OnboardingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4E9D2BF2878B336008FFDAD /* OnboardingView.swift */; }; C4E9D90129CBA09E00BD28D4 /* PHP Monitor Self-Updater.app in Resources */ = {isa = PBXBuildFile; fileRef = C4E9D90029CBA09E00BD28D4 /* PHP Monitor Self-Updater.app */; }; + C4EA3C472BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EA3C462BA4F947007B0BA7 /* CustomButtonStyles.swift */; }; + C4EA3C482BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EA3C462BA4F947007B0BA7 /* CustomButtonStyles.swift */; }; + C4EA3C492BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EA3C462BA4F947007B0BA7 /* CustomButtonStyles.swift */; }; + C4EA3C4A2BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EA3C462BA4F947007B0BA7 /* CustomButtonStyles.swift */; }; C4EB53E528551F9B006F9937 /* HeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EB53E428551F9B006F9937 /* HeaderView.swift */; }; C4EB53E728553117006F9937 /* ArrayExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EB53E628553117006F9937 /* ArrayExtension.swift */; }; C4EC1E73279DFCF40010F296 /* Events.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4EC1E72279DFCF40010F296 /* Events.swift */; }; @@ -1153,6 +1157,7 @@ C4E713572570151400007428 /* docs */ = {isa = PBXFileReference; lastKnownFileType = folder; path = docs; sourceTree = ""; }; C4E9D2BF2878B336008FFDAD /* OnboardingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingView.swift; sourceTree = ""; }; C4E9D90029CBA09E00BD28D4 /* PHP Monitor Self-Updater.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = "PHP Monitor Self-Updater.app"; sourceTree = ""; }; + C4EA3C462BA4F947007B0BA7 /* CustomButtonStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomButtonStyles.swift; sourceTree = ""; }; C4EB53E428551F9B006F9937 /* HeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderView.swift; sourceTree = ""; }; C4EB53E628553117006F9937 /* ArrayExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArrayExtension.swift; sourceTree = ""; }; C4EC1E72279DFCF40010F296 /* Events.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Events.swift; sourceTree = ""; }; @@ -1578,7 +1583,6 @@ C4D5576329C77CC5001A44CD /* PhpVersionManagerWindowController.swift */, C43931C429C4BD610069165B /* PhpVersionManagerView.swift */, C42106652AFA9FF400DF3732 /* PhpVersionManagerView+Actions.swift */, - C48DDD0C29C75C9E00D032D9 /* BlockingOverlayView.swift */, ); path = UI; sourceTree = ""; @@ -1963,6 +1967,8 @@ children = ( C44264BD2850B86C007400F1 /* SwiftUIHelper.swift */, C451AFF52969E40F0078E617 /* HelpButton.swift */, + C4EA3C462BA4F947007B0BA7 /* CustomButtonStyles.swift */, + C48DDD0C29C75C9E00D032D9 /* BlockingOverlayView.swift */, ); path = Common; sourceTree = ""; @@ -2565,6 +2571,7 @@ 031E2B692B1525A7007C29E1 /* BrewPhpExtension.swift in Sources */, C4AD38B228ECD9D300FA8D83 /* TestableFileSystem.swift in Sources */, C4EB53E528551F9B006F9937 /* HeaderView.swift in Sources */, + C4EA3C472BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */, C40FE737282ABA4F00A302C2 /* AppVersion.swift in Sources */, C44A874828905BB000498BC4 /* ProgressVC.swift in Sources */, C4CCBA6C275C567B008C7055 /* PMWindowController.swift in Sources */, @@ -2801,6 +2808,7 @@ C471E86E28F9BB650021E251 /* MenuBarIcons.swift in Sources */, C471E86F28F9BB650021E251 /* Stats.swift in Sources */, C4CE7F9829683B43000102CF /* PhpVersionNumberCollection.swift in Sources */, + C4EA3C492BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */, C471E87028F9BB650021E251 /* GlobalKeybindPreference.swift in Sources */, C471E87228F9BB650021E251 /* CheckboxPreferenceView.swift in Sources */, C471E87428F9BB650021E251 /* SelectPreferenceView.swift in Sources */, @@ -2990,6 +2998,7 @@ C41ADCEB2970CCC700120423 /* FSNotifier.swift in Sources */, C471E8CA28F9BB8F0021E251 /* OnboardingWindowController.swift in Sources */, C456A0C92AA614BD0080144F /* PhpPreference.swift in Sources */, + C4EA3C4A2BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */, C4D4CB3A29C109CF00DB9F93 /* InternalSwitcher+Valet.swift in Sources */, C471E8CB28F9BB8F0021E251 /* PreferencesWindowController.swift in Sources */, C471E8CC28F9BB8F0021E251 /* PreferencesWindowController+Hotkey.swift in Sources */, @@ -3272,6 +3281,7 @@ 031E2B6A2B1525A7007C29E1 /* BrewPhpExtension.swift in Sources */, C4998F0B2617633900B2526E /* PreferencesWindowController.swift in Sources */, C485707228BF453800539B36 /* SwiftUIHelper.swift in Sources */, + C4EA3C482BA4F947007B0BA7 /* CustomButtonStyles.swift in Sources */, C4F2E43B27530F750020E974 /* PhpInstallation.swift in Sources */, C4F780BD25D80B65000DBC97 /* Constants.swift in Sources */, C44C198E276E3A1C0072762D /* TerminalProgressWindowController.swift in Sources */, diff --git a/phpmon/Assets.xcassets/SpinnerBackground.colorset/Contents.json b/phpmon/Assets.xcassets/SpinnerBackground.colorset/Contents.json new file mode 100644 index 0000000..a25d8ed --- /dev/null +++ b/phpmon/Assets.xcassets/SpinnerBackground.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.172", + "green" : "0.182", + "red" : "0.182" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/phpmon/Assets.xcassets/StatusColorBlue.colorset/Contents.json b/phpmon/Assets.xcassets/StatusColorBlue.colorset/Contents.json index 4fc8e42..d3c3854 100644 --- a/phpmon/Assets.xcassets/StatusColorBlue.colorset/Contents.json +++ b/phpmon/Assets.xcassets/StatusColorBlue.colorset/Contents.json @@ -24,7 +24,7 @@ "components" : { "alpha" : "1.000", "blue" : "0.988", - "green" : "0.723", + "green" : "0.444", "red" : "0.277" } }, diff --git a/phpmon/Assets.xcassets/StatusColorYellowTranslucent.colorset/Contents.json b/phpmon/Assets.xcassets/StatusColorYellowTranslucent.colorset/Contents.json new file mode 100644 index 0000000..0e195bc --- /dev/null +++ b/phpmon/Assets.xcassets/StatusColorYellowTranslucent.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.300", + "blue" : "0.180", + "green" : "0.841", + "red" : "1.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.300", + "blue" : "0.426", + "green" : "0.809", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/phpmon/Modules/PHP Version Manager/UI/BlockingOverlayView.swift b/phpmon/Domain/SwiftUI/Common/BlockingOverlayView.swift similarity index 96% rename from phpmon/Modules/PHP Version Manager/UI/BlockingOverlayView.swift rename to phpmon/Domain/SwiftUI/Common/BlockingOverlayView.swift index 3f59416..c24e3bd 100644 --- a/phpmon/Modules/PHP Version Manager/UI/BlockingOverlayView.swift +++ b/phpmon/Domain/SwiftUI/Common/BlockingOverlayView.swift @@ -44,7 +44,8 @@ struct BlockingOverlayView: View { .padding(.top, -4) }.padding(60) } - }.background(Color.white) + } + .background(Color.spinnerBackground) .disabled(isBlocking) } } diff --git a/phpmon/Domain/SwiftUI/Common/CustomButtonStyles.swift b/phpmon/Domain/SwiftUI/Common/CustomButtonStyles.swift new file mode 100644 index 0000000..2ac96e8 --- /dev/null +++ b/phpmon/Domain/SwiftUI/Common/CustomButtonStyles.swift @@ -0,0 +1,35 @@ +// +// CustomButtonStyles.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 15/03/2024. +// Copyright © 2024 Nico Verbruggen. All rights reserved. +// + +import SwiftUI + +public struct CustomButtonStyle: ButtonStyle { + @Environment(\.isEnabled) var isEnabled + + public func makeBody(configuration: Self.Configuration) -> some View { + configuration.label + .padding(12) + .foregroundStyle(.white) + .background(.statusColorBlue, in: .rect(cornerRadius: 8, style: .continuous)) + .opacity({ + if configuration.isPressed { + return 0.4 + } + + if !isEnabled { + return 0.2 + } + + return 1.0 + }()) + } +} + +extension ButtonStyle where Self == CustomButtonStyle { + static var custom: CustomButtonStyle { .init() } +} diff --git a/phpmon/Modules/PHP Version Manager/UI/PhpVersionManagerView.swift b/phpmon/Modules/PHP Version Manager/UI/PhpVersionManagerView.swift index 4df0b4d..5e29f3e 100644 --- a/phpmon/Modules/PHP Version Manager/UI/PhpVersionManagerView.swift +++ b/phpmon/Modules/PHP Version Manager/UI/PhpVersionManagerView.swift @@ -94,8 +94,10 @@ struct PhpVersionManagerView: View { VStack { header.padding(10) + Divider() + if self.hasUpdates { - hasUpdatesView + hasUpdatesView.padding(.horizontal, 15) } else { noUpdatesView } @@ -160,44 +162,43 @@ struct PhpVersionManagerView: View { private var hasUpdatesView: some View { Group { - Divider() HStack(alignment: .center, spacing: 15) { Text("phpman.has_updates.description".localizedForSwiftUI) - .foregroundColor(.gray) .font(.system(size: 11)) - Button("phpman.has_updates.button".localizedForSwiftUI, action: { + Button(action: { Task { await self.upgradeAll(self.formulae.upgradeable) } - + }, label: { + Label("phpman.has_updates.button".localizedForSwiftUI, + systemImage: "arrowshape.up.circle.fill") }) + .buttonStyle(.custom) .focusable(false) .disabled(self.status.busy) } .padding(10) } + .background(.statusColorYellowTranslucent) + .cornerRadius(5) } private var noUpdatesView: some View { - Group { - Divider() - - HStack(alignment: .center, spacing: 15) { - Button { - Task { await self.reload() } - } label: { - Image(systemName: "arrow.clockwise") - .buttonStyle(.automatic) - .controlSize(.large) - } - .focusable(false) - .disabled(self.status.busy) - - Text("phpman.refresh.button.description".localizedForSwiftUI) - .foregroundColor(.gray) - .font(.system(size: 11)) + HStack(alignment: .center, spacing: 15) { + Button { + Task { await self.reload() } + } label: { + Image(systemName: "arrow.clockwise") + .buttonStyle(.automatic) + .controlSize(.large) } - .padding(10) + .focusable(false) + .disabled(self.status.busy) + + Text("phpman.refresh.button.description".localizedForSwiftUI) + .foregroundColor(.gray) + .font(.system(size: 11)) } + .padding(10) } private var prereleaseBadge: some View { @@ -205,7 +206,7 @@ struct PhpVersionManagerView: View { .font(.system(size: 9)) .padding(.horizontal, 5) .padding(.vertical, 1) - .background(Color.appPrimary) + .background(Color.statusColorBlue) .foregroundColor(Color.white) .clipShape(Capsule()) .fixedSize(horizontal: true, vertical: true) diff --git a/phpmon/de.lproj/Localizable.strings b/phpmon/de.lproj/Localizable.strings index c7d1334..5171277 100644 --- a/phpmon/de.lproj/Localizable.strings +++ b/phpmon/de.lproj/Localizable.strings @@ -134,7 +134,7 @@ und PHP Monitor neu starten, damit die Erweiterungen sichtbar werden. Wenn das P "phpman.refresh.button" = "Aktualisierungen suchen"; "phpman.refresh.button.description" = "Sie können auf die Schaltfläche Aktualisieren klicken, um zu prüfen, ob Aktualisierungen für die installierten PHP-Versionen verfügbar sind."; -"phpman.has_updates.description" = "Ein oder mehrere Aktualisierungen sind verfügbar. (Bitte beachten Sie, dass PHP Monitor PHP-Versionen immer im Ganzen installiert oder aktualisiert, so dass Sie immer alle Installationen auf einmal aktualisieren)."; +"phpman.has_updates.description" = "**Ein oder mehrere Aktualisierungen sind verfügbar.** Bitte beachten Sie, dass PHP Monitor PHP-Versionen immer im Ganzen installiert oder aktualisiert, so dass Sie immer alle Installationen auf einmal aktualisieren."; "phpman.has_updates.button" = "Alle aktualisieren"; "phpman.warnings.unsupported.title" = "Ihre Version von Homebrew kann Probleme verursachen"; diff --git a/phpmon/en.lproj/Localizable.strings b/phpmon/en.lproj/Localizable.strings index 5dc6b34..4fb8e6e 100644 --- a/phpmon/en.lproj/Localizable.strings +++ b/phpmon/en.lproj/Localizable.strings @@ -158,7 +158,7 @@ and restart PHP Monitor for extensions to become visible. If the problem persist "phpman.refresh.button" = "Search for Updates"; "phpman.refresh.button.description" = "You can press the refresh button to check if any updates are available to installed PHP versions."; -"phpman.has_updates.description" = "One or more updates are available. (Please note that PHP Monitor will always install or update PHP versions in bulk, so you will always upgrade all installations at once.)"; +"phpman.has_updates.description" = "**One or more updates are available.** PHP Monitor will always install or update PHP versions in bulk, so you will always upgrade all installations at once."; "phpman.has_updates.button" = "Upgrade All"; "phpman.warnings.outdated.title" = "This version of PHP Monitor is outdated"; diff --git a/phpmon/fr.lproj/Localizable.strings b/phpmon/fr.lproj/Localizable.strings index 33277a2..0515ddf 100644 --- a/phpmon/fr.lproj/Localizable.strings +++ b/phpmon/fr.lproj/Localizable.strings @@ -150,7 +150,7 @@ et redémarrer PHP Monitor pour que les extensions deviennent visibles. Si le pr "phpman.refresh.button" = "Rechercher des mises à jour"; "phpman.refresh.button.description" = "Vous pouvez appuyer sur le bouton de rafraîchissement pour vérifier si des mises à jour sont disponibles pour les versions de PHP installées."; -"phpman.has_updates.description" = "Une ou plusieurs mises à jour sont disponibles. (Veuillez noter que PHP Monitor installera ou mettra toujours à jour les versions de PHP en bloc, vous mettrez donc à jour toutes les installations en une seule fois.)"; +"phpman.has_updates.description" = "**Une ou plusieurs mises à jour sont disponibles.** PHP Monitor installera ou mettra toujours à jour les versions de PHP en bloc, vous mettrez donc à jour toutes les installations en une seule fois."; "phpman.has_updates.button" = "Tout mettre à jour"; "phpman.warnings.unsupported.title" = "Votre version de Homebrew peut causer des problèmes"; diff --git a/phpmon/nl.lproj/Localizable.strings b/phpmon/nl.lproj/Localizable.strings index b1831a5..e03fa07 100644 --- a/phpmon/nl.lproj/Localizable.strings +++ b/phpmon/nl.lproj/Localizable.strings @@ -135,7 +135,7 @@ en PHP Monitor herstarten om de extensies zichtbaar te maken. Als het probleem z "phpman.refresh.button" = "Zoek naar updates"; "phpman.refresh.button.description" = "Je kunt op de vernieuwen-knop drukken om te controleren of er updates beschikbaar zijn voor geïnstalleerde PHP-versies."; -"phpman.has_updates.description" = "Er zijn één of meer updates beschikbaar. (Houd er rekening mee dat PHP Monitor altijd PHP-versies in bulk installeert of bijwerkt, dus u zult altijd alle installaties tegelijk upgraden.)"; +"phpman.has_updates.description" = "**Er zijn één of meer updates beschikbaar.** PHP Monitor werkt alle versies in één keer bij, hou hier rekening mee."; "phpman.has_updates.button" = "Alles bijwerken"; "phpman.warnings.unsupported.title" = "Uw versie van Homebrew kan problemen veroorzaken"; diff --git a/phpmon/pt-PT.lproj/Localizable.strings b/phpmon/pt-PT.lproj/Localizable.strings index c3c4723..862cdff 100644 --- a/phpmon/pt-PT.lproj/Localizable.strings +++ b/phpmon/pt-PT.lproj/Localizable.strings @@ -134,7 +134,7 @@ e reiniciar o PHP Monitor para que as extensões se tornem visíveis. Se o probl "phpman.refresh.button" = "Procurar atualizações"; "phpman.refresh.button.description" = "Você pode premir o botão de atualização para verificar se há atualizações disponíveis para as versões do PHP instaladas."; -"phpman.has_updates.description" = "Estão disponiveis uma ou mais atualizações. (Por favor, tenha em conta que o PHP Monitor instalará ou atualizará as versões do PHP em bloco, ou seja, atualizará todas as instalações PHP de uma só vez.)"; +"phpman.has_updates.description" = "**Estão disponiveis uma ou mais atualizações.** Por favor, tenha em conta que o PHP Monitor instalará ou atualizará as versões do PHP em bloco, ou seja, atualizará todas as instalações PHP de uma só vez."; "phpman.has_updates.button" = "Atualizar tudo"; "phpman.warnings.unsupported.title" = "A versão instalada do Homebrew pode causar problemas"; diff --git a/phpmon/vi.lproj/Localizable.strings b/phpmon/vi.lproj/Localizable.strings index 3a2b800..89b1544 100644 --- a/phpmon/vi.lproj/Localizable.strings +++ b/phpmon/vi.lproj/Localizable.strings @@ -134,7 +134,7 @@ và khởi động lại PHP Monitor để các tiện ích mở rộng trở n "phpman.refresh.button" = "Tìm kiếm Cập nhật"; "phpman.refresh.button.description" = "Bạn có thể nhấn nút làm mới để kiểm tra xem có sẵn các cập nhật cho các phiên bản PHP đã cài đặt."; -"phpman.has_updates.description" = "Một hoặc nhiều cập nhật có sẵn. (Vui lòng lưu ý rằng PHP Monitor sẽ luôn cài đặt hoặc cập nhật các phiên bản PHP theo lô, vì vậy bạn sẽ luôn nâng cấp tất cả các cài đặt cùng một lúc.)"; +"phpman.has_updates.description" = "**Một hoặc nhiều cập nhật có sẵn.** Vui lòng lưu ý rằng PHP Monitor sẽ luôn cài đặt hoặc cập nhật các phiên bản PHP theo lô, vì vậy bạn sẽ luôn nâng cấp tất cả các cài đặt cùng một lúc."; "phpman.has_updates.button" = "Nâng cấp Tất cả"; "phpman.warnings.unsupported.title" = "Phiên bản Homebrew của bạn có thể gây ra vấn đề";