1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-08-07 03:50:08 +02:00

👌 Improve WarningListView and modify body

This commit is contained in:
2023-02-25 15:57:39 +01:00
parent eb664477f9
commit 2eea15aac2
3 changed files with 24 additions and 10 deletions

View File

@ -11,12 +11,22 @@ import SwiftUI
struct WarningListView: View {
@ObservedObject var warningManager: WarningManager
init(empty: Bool = false) {
if empty {
WarningManager.shared.clearWarnings()
init(empty: Bool = false, fake: Bool = false, manager: WarningManager? = nil) {
if manager == nil {
// Use the singleton by default
warningManager = WarningManager.shared
} else {
// Use a provided instance (for e.g. preview purposes)
warningManager = manager!
}
warningManager = WarningManager.shared
if fake {
warningManager.warnings = warningManager.evaluations
}
if empty {
warningManager.clearWarnings()
}
}
var body: some View {
@ -43,7 +53,7 @@ struct WarningListView: View {
HStack(alignment: .center, spacing: 15) {
Button("warnings.refresh.button".localizedForSwiftUI) {
Task { // Reload warnings
await WarningManager.shared.checkEnvironment()
await self.warningManager.checkEnvironment()
}
}
Text("warnings.refresh.button.description".localizedForSwiftUI)
@ -82,11 +92,11 @@ struct WarningListView: View {
struct WarningListView_Previews: PreviewProvider {
static var previews: some View {
WarningListView(empty: true)
WarningListView(empty: true, fake: true, manager: WarningManager())
.frame(width: 600, height: 480)
.previewDisplayName("Empty List")
WarningListView(empty: false)
WarningListView(empty: false, fake: true, manager: WarningManager())
.frame(width: 600, height: 480)
.previewDisplayName("List With All Warnings")
}

View File

@ -10,7 +10,6 @@ import Foundation
import Cocoa
class WarningManager: ObservableObject {
static var shared: WarningManager = WarningManager()
/// These warnings are the ones that are ready to be displayed.
@ -23,6 +22,7 @@ class WarningManager: ObservableObject {
init() {
if isRunningSwiftUIPreview {
/// SwiftUI previews will always list all possible evaluations.
self.warnings = self.evaluations
}
}
@ -98,6 +98,10 @@ class WarningManager: ObservableObject {
await MainMenu.shared.rebuild()
}
/**
Runs through all evaluations and appends any applicable warning results.
Will automatically broadcast these warnings.
*/
private func evaluate() async {
self.temporaryWarnings = []

View File

@ -664,8 +664,8 @@ COMMON TROUBLESHOOTING TIPS
"warnings.arm_compatibility.title" = "You are running PHP Monitor using Rosetta on Apple Silicon, which means your PHP environment is also running via Rosetta.";
"warnings.arm_compatibility.description" = "You appear to be running an ARM-compatible version of macOS, but you are currently running PHP Monitor using Rosetta. While this will work correctly, it is recommended that you use the native version of Homebrew.";
"warnings.files_missing.title" = "Your PHP installation is lacking required configuration files";
"warnings.files_missing.description" = "The following files normally exist on a functional system:
"warnings.files_missing.title" = "Your PHP installation is missing important required configuration files.";
"warnings.files_missing.description" = "The following key configuration files should exist after installing PHP:
• %@