diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 3bbf1ee..547a578 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -1162,6 +1162,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 620; + DEBUG = YES; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = phpmon/Info.plist; @@ -1187,6 +1188,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 620; + DEBUG = NO; DEVELOPMENT_TEAM = 8M54J5J787; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = phpmon/Info.plist; diff --git a/phpmon/Common/Helpers/Alert.swift b/phpmon/Common/Helpers/Alert.swift index 5a15af0..963eb7d 100644 --- a/phpmon/Common/Helpers/Alert.swift +++ b/phpmon/Common/Helpers/Alert.swift @@ -7,6 +7,7 @@ import Cocoa +@available(*, deprecated, message: "Use BetterAlert API instead for 5.1 and above") class Alert { public static func present( diff --git a/phpmon/Domain/App/AppDelegate.swift b/phpmon/Domain/App/AppDelegate.swift index 1b1f329..a0e1f74 100644 --- a/phpmon/Domain/App/AppDelegate.swift +++ b/phpmon/Domain/App/AppDelegate.swift @@ -64,6 +64,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele */ override init() { logger.verbosity = .info + #if DEBUG + logger.verbosity = .performance + #endif Log.separator(as: .info) Log.info("PHP MONITOR by Nico Verbruggen") Log.info("Version \(App.version)") diff --git a/phpmon/Domain/Menu/MainMenu+Switcher.swift b/phpmon/Domain/Menu/MainMenu+Switcher.swift index 57f495c..6438ead 100644 --- a/phpmon/Domain/Menu/MainMenu+Switcher.swift +++ b/phpmon/Domain/Menu/MainMenu+Switcher.swift @@ -53,11 +53,14 @@ extension MainMenu { } @MainActor private func suggestFixMyValet(failed version: String) { - let outcome = Alert.present( - messageText: "alert.php_switch_failed.title".localized(version), - informativeText: "alert.php_switch_failed.info".localized(version), - buttonTitle: "alert.php_switch_failed.confirm".localized, - secondButtonTitle: "alert.php_switch_failed.cancel".localized, style: .informational) + let outcome = BetterAlert() + .withInformation( + title: "alert.php_switch_failed.title".localized(version), + subtitle: "alert.php_switch_failed.info".localized(version) + ) + .withPrimary(text: "alert.php_switch_failed.confirm".localized) + .withSecondary(text: "alert.php_switch_failed.cancel".localized) + .didSelectPrimary() if outcome { MainMenu.shared.fixMyValet() } diff --git a/phpmon/Domain/Menu/MainMenu.swift b/phpmon/Domain/Menu/MainMenu.swift index 3d2aedc..9d3891c 100644 --- a/phpmon/Domain/Menu/MainMenu.swift +++ b/phpmon/Domain/Menu/MainMenu.swift @@ -263,17 +263,28 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate @objc func fixMyValet() { if !PhpEnv.shared.availablePhpVersions.contains(PhpEnv.brewPhpVersion) { - Alert.notify(message: "alert.php_formula_missing.title".localized, info: "alert.php_formula_missing.info".localized, style: .warning) + BetterAlert() + .withInformation( + title: "alert.php_formula_missing.title".localized, + subtitle: "alert.php_formula_missing.info".localized + ) + .withPrimary(text: "OK") + .show() + return } - if !Alert.present( - messageText: "alert.fix_my_valet.title".localized, - informativeText: "alert.fix_my_valet.info".localized(PhpEnv.brewPhpVersion), - buttonTitle: "alert.fix_my_valet.ok".localized, - secondButtonTitle: "alert.fix_my_valet.cancel".localized, - style: .warning - ) { + + + if !BetterAlert() + .withInformation( + title: "alert.fix_my_valet.title".localized, + subtitle: "alert.fix_my_valet.info".localized(PhpEnv.brewPhpVersion) + ) + .withPrimary(text: "alert.fix_my_valet.ok".localized) + .withSecondary(text: "alert.fix_my_valet.cancel".localized) + .didSelectPrimary() + { Log.info("The user has chosen to abort Fix My Valet") return } @@ -281,10 +292,14 @@ class MainMenu: NSObject, NSWindowDelegate, NSMenuDelegate, PhpSwitcherDelegate asyncExecution { Actions.fixMyValet() } success: { - Alert.notify( - message: "alert.fix_my_valet_done.title".localized, - info: "alert.fix_my_valet_done.info".localized + BetterAlert() + .withInformation( + title: "alert.fix_my_valet_done.title".localized, + subtitle: "alert.fix_my_valet_done.subtitle".localized, + description: "alert.fix_my_valet_done.desc".localized ) + .withPrimary(text: "alert.fix_my_valet.ok".localized) + .show() } } diff --git a/phpmon/Domain/Notice/BetterAlertVC.swift b/phpmon/Domain/Notice/BetterAlertVC.swift index 61adc7a..1b5d6c4 100644 --- a/phpmon/Domain/Notice/BetterAlertVC.swift +++ b/phpmon/Domain/Notice/BetterAlertVC.swift @@ -65,4 +65,8 @@ class BetterAlertVC: NSViewController { NSApplication.shared.stopModal(withCode: code) } + deinit { + Log.perf("A BetterAlert has been deinitialized.") + } + } diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index 5751d64..23e1bf7 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -218,7 +218,8 @@ problem manually, using your own Terminal app (this just shows you the output)." // Fix My Valet Done "alert.fix_my_valet_done.title" = "Fix My Valet has completed its operations."; -"alert.fix_my_valet_done.info" = "All appropriate services have been stopped and the correct ones restarted, and the latest version of PHP should now be active. You can now try switching to another version of PHP.\n\nIf visiting sites still does not work, you may try running `valet install` again, this can fix a 502 issue (Bad Gateway).\n\nIf Valet is broken and you cannot run `valet install`, you may need to run `composer global update`. Please consult the FAQ on GitHub if you have further issues."; +"alert.fix_my_valet_done.subtitle" = "All appropriate services have been stopped and the correct ones restarted, and the latest version of PHP should now be active. You can now try switching to another version of PHP."; +"alert.fix_my_valet_done.desc" = "If visiting sites still does not work, you may try running `valet install` again, this can fix a 502 issue (Bad Gateway).\n\nIf Valet is broken and you cannot run `valet install`, you may need to run `composer global update`. Please consult the FAQ on GitHub if you have further issues."; // Restore Homebrew Permissions "alert.fix_homebrew_permissions.title" = "About \"Restore Homebrew Permissions\"";