diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index efa525d..da6888c 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -1358,9 +1358,9 @@ C43931C329C4BD510069165B /* PhpManager */ = { isa = PBXGroup; children = ( + C4D5576329C77CC5001A44CD /* PhpVersionManagerWindowController.swift */, C43931C429C4BD610069165B /* PhpFormulaeManager.swift */, C48DDD0C29C75C9E00D032D9 /* BlockingOverlayView.swift */, - C4D5576329C77CC5001A44CD /* PhpVersionManagerWindowController.swift */, ); path = PhpManager; sourceTree = ""; diff --git a/phpmon/Common/Helpers/PMWindowController.swift b/phpmon/Common/Helpers/PMWindowController.swift index e35ae7e..a8393d7 100644 --- a/phpmon/Common/Helpers/PMWindowController.swift +++ b/phpmon/Common/Helpers/PMWindowController.swift @@ -37,13 +37,13 @@ class PMWindowController: NSWindowController, NSWindowDelegate { extension NSWindowController { - public func positionWindowInTopLeftCorner() { + public func positionWindowInTopLeftCorner(offsetY: CGFloat = 0, offsetX: CGFloat = 0) { guard let frame = NSScreen.main?.frame else { return } guard let window = self.window else { return } window.setFrame(NSRect( - x: frame.size.width - window.frame.size.width - 20, - y: frame.size.height - window.frame.size.height - 40, + x: frame.size.width - window.frame.size.width - 20 + offsetX, + y: frame.size.height - window.frame.size.height - 40 + offsetY, width: window.frame.width, height: window.frame.height ), display: true) diff --git a/phpmon/Domain/SwiftUI/PhpManager/BlockingOverlayView.swift b/phpmon/Domain/SwiftUI/PhpManager/BlockingOverlayView.swift index 8128778..a816b28 100644 --- a/phpmon/Domain/SwiftUI/PhpManager/BlockingOverlayView.swift +++ b/phpmon/Domain/SwiftUI/PhpManager/BlockingOverlayView.swift @@ -44,7 +44,7 @@ struct BlockingOverlayView: View { .padding(.top, -4) } } - } + }.background(Color.white) .disabled(isBlocking) } } diff --git a/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeManager.swift b/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeManager.swift index 267c060..8a50856 100644 --- a/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeManager.swift +++ b/phpmon/Domain/SwiftUI/PhpManager/PhpFormulaeManager.swift @@ -35,7 +35,7 @@ struct PhpFormulaeView: View { self.status = PhpFormulaeStatus( busy: true, - title: "Checking for updates", + title: "Checking for updates!", description: "Checking if any PHP version is outdated..." ) @@ -47,8 +47,53 @@ struct PhpFormulaeView: View { } var body: some View { - BlockingOverlayView(busy: self.status.busy, title: self.status.title, text: self.status.description) { - VStack { + VStack { + HStack(alignment: .center, spacing: 15) { + Image(systemName: "arrow.down.to.line.circle.fill") + .resizable() + .frame(width: 40, height: 40) + .foregroundColor(Color.blue) + .padding(12) + VStack(alignment: .leading, spacing: 5) { + Text("phpman.description".localizedForSwiftUI) + .font(.system(size: 12)) + .frame(maxWidth: .infinity, alignment: .leading) + Text("phpman.disclaimer".localizedForSwiftUI) + .font(.system(size: 12)) + .frame(maxWidth: .infinity, alignment: .leading) + } + } + .padding(10) + + Divider() + + HStack(alignment: .center, spacing: 15) { + Button { + Task { // Reload warnings + Task { @MainActor in + self.status.busy = true + self.status.title = "Checking for updates!" + self.status.description = "Checking if any PHP version is outdated..." + } + await self.handler.refreshPhpVersions(loadOutdated: true) + Task { @MainActor in + self.status.busy = false + } + } + } label: { + Image(systemName: "arrow.clockwise") + .buttonStyle(.automatic) + .controlSize(.large) + } + .focusable(false) + + Text("phpman.refresh.button.description".localizedForSwiftUI) + .foregroundColor(.gray) + .font(.system(size: 11)) + } + .padding(10) + + BlockingOverlayView(busy: self.status.busy, title: self.status.title, text: self.status.description) { List(Array(formulae.phpVersions.enumerated()), id: \.1.name) { (index, formula) in HStack { Image(systemName: formula.icon) @@ -96,7 +141,7 @@ struct PhpFormulaeView: View { .padding(.vertical, 10) } } - }.frame(width: 500, height: 500) + }.frame(width: 600, height: 600) } } @@ -105,7 +150,7 @@ struct PhpFormulaeView_Previews: PreviewProvider { PhpFormulaeView( formulae: Brew.shared.formulae, handler: FakeBrewFormulaeHandler() - ).frame(width: 600, height: 500) + ).frame(width: 600, height: 600) } } diff --git a/phpmon/Domain/SwiftUI/PhpManager/PhpVersionManagerWindowController.swift b/phpmon/Domain/SwiftUI/PhpManager/PhpVersionManagerWindowController.swift index be8ac72..e786a30 100644 --- a/phpmon/Domain/SwiftUI/PhpManager/PhpVersionManagerWindowController.swift +++ b/phpmon/Domain/SwiftUI/PhpManager/PhpVersionManagerWindowController.swift @@ -34,7 +34,7 @@ class PhpVersionManagerWindowController: PMWindowController { window.titlebarAppearsTransparent = true window.delegate = delegate ?? windowController window.contentView = NSHostingView(rootView: windowController.view) - window.setContentSize(NSSize(width: 600, height: 480)) + window.setContentSize(NSSize(width: 600, height: 800)) App.shared.versionManagerWindowController = windowController } @@ -45,7 +45,7 @@ class PhpVersionManagerWindowController: PMWindowController { } App.shared.versionManagerWindowController?.showWindow(self) - App.shared.versionManagerWindowController?.window?.setCenterPosition(offsetY: 70) + App.shared.versionManagerWindowController?.positionWindowInTopLeftCorner() NSApp.activate(ignoringOtherApps: true) } diff --git a/phpmon/Domain/SwiftUI/Warning/WarningListView.swift b/phpmon/Domain/SwiftUI/Warning/WarningListView.swift index 075bb4a..b664d8c 100644 --- a/phpmon/Domain/SwiftUI/Warning/WarningListView.swift +++ b/phpmon/Domain/SwiftUI/Warning/WarningListView.swift @@ -51,10 +51,14 @@ struct WarningListView: View { Divider() HStack(alignment: .center, spacing: 15) { - Button("warnings.refresh.button".localizedForSwiftUI) { + Button { Task { // Reload warnings await self.warningManager.checkEnvironment() } + } label: { + Image(systemName: "arrow.clockwise") + .buttonStyle(.automatic) + .controlSize(.large) } Text("warnings.refresh.button.description".localizedForSwiftUI) .foregroundColor(.gray) diff --git a/phpmon/Localizable.strings b/phpmon/Localizable.strings index d5256fe..5d3fdff 100644 --- a/phpmon/Localizable.strings +++ b/phpmon/Localizable.strings @@ -20,7 +20,7 @@ "mi_no_php_linked" = "No PHP version linked!"; "mi_fix_php_link" = "Fix Automatically..."; "mi_no_php_linked_explain" = "What's This?"; -"mi_php_version_manager" = "Install & Upgrade PHP Versions..."; +"mi_php_version_manager" = "PHP Version Manager..."; "mi_diagnostics" = "Diagnostics"; "mi_active_services" = "Active Services"; @@ -88,6 +88,14 @@ "mi_xdebug_actions" = "Actions"; "mi_xdebug_disable_all" = "Disable All Modes"; +// PHPMAN + +"phpman.title" = "PHP Manager"; +"phpman.description" = "**PHP Manager** lets you install different PHP versions via Homebrew."; +"phpman.disclaimer" = "PHP Manager may ask for administrative privileges to take ownership of certain folders during certain operations. If you prefer it, you can also manually install PHP versions via the terminal."; +"phpman.refresh.button" = "Search for Updates"; +"phpman.refresh.button.description" = "You can press this button to check (again) if any updates are available to installed PHP versions. When you first open this window, PHP Monitor already does this check."; + // GENERIC "generic.ok" = "OK";