1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-07 21:20:07 +01:00

🏗 WIP: Warnings window & views

This commit is contained in:
2022-08-09 20:31:17 +02:00
parent ccfb15c83c
commit f90925ee17
8 changed files with 126 additions and 16 deletions

View File

@@ -59,6 +59,9 @@ class App {
/** The window controller of the onboarding window. */
var onboardingWindowController: OnboardingWindowController?
/** The window controller of the warnings window. */
var warningsWindowController: WarningsWindowController?
/** List of detected (installed) applications that PHP Monitor can work with. */
var detectedApplications: [Application] = []

View File

@@ -93,7 +93,8 @@ extension MainMenu {
if Stats.successfulLaunchCount >= 1 && !isRunningSwiftUIPreview {
Log.info("Should present the first launch screen!")
DispatchQueue.main.async {
OnboardingWindowController.show()
// OnboardingWindowController.show()
WarningsWindowController.show()
}
}

View File

@@ -18,7 +18,7 @@ class OnboardingWindowController: PMWindowController {
}
public static func create(delegate: NSWindowDelegate?) {
let windowController = OnboardingWindowController()
let windowController = Self()
windowController.window = NSWindow()
guard let window = windowController.window else { return }

View File

@@ -0,0 +1,33 @@
//
// WarningListView.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 09/08/2022.
// Copyright © 2022 Nico Verbruggen. All rights reserved.
//
import SwiftUI
struct WarningListView: View {
var body: some View {
List {
VStack(alignment: .leading) {
WarningView(
title: "warnings.arm_compatibility_title".localized,
description: "warnings.arm_compatibility.description".localized,
documentationUrl: "https://phpmon.app/documentation/apple-silicon-transition"
)
Divider()
}.frame(height: 90)
}
.navigationTitle("Warnings")
.listStyle(.automatic)
}
}
struct WarningListView_Previews: PreviewProvider {
static var previews: some View {
WarningListView()
}
}

View File

@@ -11,22 +11,29 @@ import SwiftUI
struct WarningView: View {
@State var title: String
@State var description: String
@State var documentationUrl: String?
var body: some View {
HStack {
Image(systemName: "exclamationmark.triangle.fill")
.resizable()
.frame(width: 25, height: 25)
.padding()
.foregroundColor(Color.orange)
VStack(alignment: .leading, spacing: 5) {
Text(title.localizedForSwiftUI)
.fontWeight(.bold)
Text(description.localizedForSwiftUI)
.font(.body)
}
}.padding()
VStack(alignment: .leading) {
HStack(spacing: 5) {
Image(systemName: "exclamationmark.triangle.fill")
.resizable()
.frame(width: 25, height: 25)
.padding()
.foregroundColor(Color.orange)
VStack(alignment: .leading, spacing: 5) {
Text(title.localizedForSwiftUI)
.fontWeight(.bold)
Text(description.localizedForSwiftUI)
.font(.body)
}
if documentationUrl != nil {
Button("Learn More") {
NSWorkspace.shared.open(URL(string: documentationUrl!)!)
}
}
}.padding()
}
}
}

View File

@@ -0,0 +1,45 @@
//
// WarningsWindowController.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 09/08/2022.
// Copyright © 2022 Nico Verbruggen. All rights reserved.
//
import Cocoa
import SwiftUI
class WarningsWindowController: PMWindowController {
// MARK: - Window Identifier
override var windowName: String {
return "Warnings"
}
public static func create(delegate: NSWindowDelegate?) {
let windowController = Self()
windowController.window = NSWindow()
guard let window = windowController.window else { return }
window.title = "warnings.title".localized
window.styleMask = [.titled, .closable, .miniaturizable]
window.titlebarAppearsTransparent = true
window.delegate = delegate ?? windowController
window.contentView = NSHostingView(rootView: WarningListView())
window.setContentSize(NSSize(width: 600, height: 300))
App.shared.warningsWindowController = windowController
}
public static func show(delegate: NSWindowDelegate? = nil) {
if App.shared.warningsWindowController == nil {
Self.create(delegate: delegate)
}
App.shared.warningsWindowController?.showWindow(self)
App.shared.warningsWindowController?.window?.setCenterPosition(offsetY: 70)
NSApp.activate(ignoringOtherApps: true)
}
}

View File

@@ -506,9 +506,14 @@ If you are seeing this message but are confused why this folder has gone missing
// WARNINGS
"warnings.title" = "Warnings";
"warnings.helper_permissions_title" = "Helpers could not be written!";
"warnings.helper_permissions.description" = "The helper files in `/usr/local/bin` could not be written because PHP Monitor does not have permission to write there.";
"warnings.arm_compatibility_title" = "You are running PHP Monitor using 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.";
// ONBOARDING
"onboarding.title" = "Welcome Tour";