mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-11-07 13:20:05 +01:00
👌 Improve WarningListView and modify body
This commit is contained in:
@@ -11,12 +11,22 @@ import SwiftUI
|
|||||||
struct WarningListView: View {
|
struct WarningListView: View {
|
||||||
@ObservedObject var warningManager: WarningManager
|
@ObservedObject var warningManager: WarningManager
|
||||||
|
|
||||||
init(empty: Bool = false) {
|
init(empty: Bool = false, fake: Bool = false, manager: WarningManager? = nil) {
|
||||||
if empty {
|
if manager == nil {
|
||||||
WarningManager.shared.clearWarnings()
|
// 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 {
|
var body: some View {
|
||||||
@@ -43,7 +53,7 @@ struct WarningListView: View {
|
|||||||
HStack(alignment: .center, spacing: 15) {
|
HStack(alignment: .center, spacing: 15) {
|
||||||
Button("warnings.refresh.button".localizedForSwiftUI) {
|
Button("warnings.refresh.button".localizedForSwiftUI) {
|
||||||
Task { // Reload warnings
|
Task { // Reload warnings
|
||||||
await WarningManager.shared.checkEnvironment()
|
await self.warningManager.checkEnvironment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text("warnings.refresh.button.description".localizedForSwiftUI)
|
Text("warnings.refresh.button.description".localizedForSwiftUI)
|
||||||
@@ -82,11 +92,11 @@ struct WarningListView: View {
|
|||||||
|
|
||||||
struct WarningListView_Previews: PreviewProvider {
|
struct WarningListView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
WarningListView(empty: true)
|
WarningListView(empty: true, fake: true, manager: WarningManager())
|
||||||
.frame(width: 600, height: 480)
|
.frame(width: 600, height: 480)
|
||||||
.previewDisplayName("Empty List")
|
.previewDisplayName("Empty List")
|
||||||
|
|
||||||
WarningListView(empty: false)
|
WarningListView(empty: false, fake: true, manager: WarningManager())
|
||||||
.frame(width: 600, height: 480)
|
.frame(width: 600, height: 480)
|
||||||
.previewDisplayName("List With All Warnings")
|
.previewDisplayName("List With All Warnings")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import Foundation
|
|||||||
import Cocoa
|
import Cocoa
|
||||||
|
|
||||||
class WarningManager: ObservableObject {
|
class WarningManager: ObservableObject {
|
||||||
|
|
||||||
static var shared: WarningManager = WarningManager()
|
static var shared: WarningManager = WarningManager()
|
||||||
|
|
||||||
/// These warnings are the ones that are ready to be displayed.
|
/// These warnings are the ones that are ready to be displayed.
|
||||||
@@ -23,6 +22,7 @@ class WarningManager: ObservableObject {
|
|||||||
|
|
||||||
init() {
|
init() {
|
||||||
if isRunningSwiftUIPreview {
|
if isRunningSwiftUIPreview {
|
||||||
|
/// SwiftUI previews will always list all possible evaluations.
|
||||||
self.warnings = self.evaluations
|
self.warnings = self.evaluations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,6 +98,10 @@ class WarningManager: ObservableObject {
|
|||||||
await MainMenu.shared.rebuild()
|
await MainMenu.shared.rebuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Runs through all evaluations and appends any applicable warning results.
|
||||||
|
Will automatically broadcast these warnings.
|
||||||
|
*/
|
||||||
private func evaluate() async {
|
private func evaluate() async {
|
||||||
self.temporaryWarnings = []
|
self.temporaryWarnings = []
|
||||||
|
|
||||||
|
|||||||
@@ -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.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.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.title" = "Your PHP installation is missing important required configuration files.";
|
||||||
"warnings.files_missing.description" = "The following files normally exist on a functional system:
|
"warnings.files_missing.description" = "The following key configuration files should exist after installing PHP:
|
||||||
|
|
||||||
• %@
|
• %@
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user