1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-06 19:40:08 +02:00

👌 Various fixes

- Fixed issue with Version Manager
- Separate behaviour for previews for Version Manager
- Remove verbose logging when previews are in use

(Note: The latter change may break various other previews. Will need to
investigate this particular issue.)
This commit is contained in:
2023-09-01 01:00:43 +02:00
parent eb566bb523
commit f9acbd34d0
4 changed files with 40 additions and 16 deletions

View File

@ -31,7 +31,10 @@ public class Paths {
}
userName = identity()
Log.info("The current username is `\(userName)`.")
if !isRunningSwiftUIPreview {
Log.info("The current username is `\(userName)`.")
}
}
public func detectBinaryPaths() {

View File

@ -88,10 +88,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
Log.info("Extra CLI mode is on (`~/.config/phpmon/verbose` exists).")
}
Log.separator(as: .info)
Log.info("PHP MONITOR by Nico Verbruggen")
Log.info("Version \(App.version)")
Log.separator(as: .info)
if !isRunningSwiftUIPreview {
Log.separator(as: .info)
Log.info("PHP MONITOR by Nico Verbruggen")
Log.info("Version \(App.version)")
Log.separator(as: .info)
}
self.state = App.shared
self.menu = MainMenu.shared
@ -118,6 +120,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
startup procedure.
*/
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Prevent previews from kicking off a costly boot
if isRunningSwiftUIPreview {
return
}
// Make sure notifications will work
setupNotifications()

View File

@ -9,10 +9,18 @@
import Foundation
class FakeBrewFormulaeHandler: HandlesBrewFormulae {
// swiftlint:disable function_body_length
public func loadPhpVersions(loadOutdated: Bool) async -> [BrewFormula] {
return [
BrewFormula(
name: "php",
name: "php@9.9",
displayName: "PHP 9.9",
installedVersion: nil,
upgradeVersion: "9.9.0",
prerelease: true
),
BrewFormula(
name: "php@8.3",
displayName: "PHP 8.3",
installedVersion: nil,
upgradeVersion: "8.3.0",

View File

@ -28,8 +28,15 @@ struct PhpVersionManagerView: View {
description: "phpman.busy.description.outdated".localized
)
Task { [self] in
await self.initialLoad()
if handler is FakeBrewFormulaeHandler {
Task { [self] in
await self.handler.refreshPhpVersions(loadOutdated: false)
self.status.busy = false
}
} else {
Task { [self] in
await self.initialLoad()
}
}
}
@ -127,7 +134,7 @@ struct PhpVersionManagerView: View {
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 {
HStack(alignment: .center, spacing: 7.0) {
Image(systemName: formula.icon)
.resizable()
.aspectRatio(contentMode: .fit)
@ -143,11 +150,10 @@ struct PhpVersionManagerView: View {
.font(.system(size: 9))
.padding(.horizontal, 5)
.padding(.vertical, 1)
.background(Color.appPrimary)
.background(Color.orange)
.foregroundColor(Color.white)
.clipShape(Capsule())
.fixedSize(horizontal: true, vertical: true)
.frame(maxHeight: 7)
}
}
@ -192,12 +198,12 @@ struct PhpVersionManagerView: View {
}
}
}
.listRowBackground(index % 2 == 0
? Color.gray.opacity(0)
: Color.gray.opacity(0.08)
)
.padding(.vertical, 10)
.listRowBackground(index % 2 == 0 ? Color.gray.opacity(0): Color.gray.opacity(0.08))
.padding(.vertical, 8)
.padding(.horizontal, 8)
}
.edgesIgnoringSafeArea(.top)
.listStyle(PlainListStyle())
}
}.frame(width: 600, height: 600)
}