From 1bff75311b2ba7e6800b2c5ae6fe3644d05f3772 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Sun, 31 Jul 2022 21:27:52 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20WarningView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PHP Monitor.xcodeproj/project.pbxproj | 14 ++++++- phpmon/Domain/Menu/MainMenu+Startup.swift | 2 +- .../Domain/SwiftUI/Warning/WarningView.swift | 39 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 phpmon/Domain/SwiftUI/Warning/WarningView.swift diff --git a/PHP Monitor.xcodeproj/project.pbxproj b/PHP Monitor.xcodeproj/project.pbxproj index 0ddd998..b5bf5e6 100644 --- a/PHP Monitor.xcodeproj/project.pbxproj +++ b/PHP Monitor.xcodeproj/project.pbxproj @@ -91,6 +91,7 @@ C42759682627662800093CAE /* NSMenuExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42759662627662800093CAE /* NSMenuExtension.swift */; }; C42800AA28452AA10099C999 /* StatusMenu+Items.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42800A928452AA10099C999 /* StatusMenu+Items.swift */; }; C42800AB28452AA50099C999 /* StatusMenu+Items.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42800A928452AA10099C999 /* StatusMenu+Items.swift */; }; + C4297F7A28970D59004C4630 /* WarningView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4297F7928970D59004C4630 /* WarningView.swift */; }; C42C49DB27C2806F0074ABAC /* MainMenu+FixMyValet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C42C49DA27C2806F0074ABAC /* MainMenu+FixMyValet.swift */; }; C42CFB1627DFDE7900862737 /* nginx-site.test in Resources */ = {isa = PBXBuildFile; fileRef = C42CFB1527DFDE7900862737 /* nginx-site.test */; }; C42CFB1827DFDFDC00862737 /* nginx-site-isolated.test in Resources */ = {isa = PBXBuildFile; fileRef = C42CFB1727DFDFDC00862737 /* nginx-site-isolated.test */; }; @@ -342,6 +343,7 @@ C42337A2281F19F000459A48 /* Xdebug.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Xdebug.swift; sourceTree = ""; }; C42759662627662800093CAE /* NSMenuExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSMenuExtension.swift; sourceTree = ""; }; C42800A928452AA10099C999 /* StatusMenu+Items.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StatusMenu+Items.swift"; sourceTree = ""; }; + C4297F7928970D59004C4630 /* WarningView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WarningView.swift; sourceTree = ""; }; C42C49DA27C2806F0074ABAC /* MainMenu+FixMyValet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MainMenu+FixMyValet.swift"; sourceTree = ""; }; C42CFB1527DFDE7900862737 /* nginx-site.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "nginx-site.test"; sourceTree = ""; }; C42CFB1727DFDFDC00862737 /* nginx-site-isolated.test */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "nginx-site-isolated.test"; sourceTree = ""; }; @@ -449,8 +451,8 @@ C4F780AD25D80B37000DBC97 /* PhpExtensionTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhpExtensionTest.swift; sourceTree = ""; }; C4F8C0A322D4F12C002EFE61 /* DateExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateExtension.swift; sourceTree = ""; }; C4F8C0A522D4FA41002EFE61 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; - C4FACE82288F1F9700FC478F /* OnboardingWC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingWC.swift; sourceTree = ""; }; C4FACE7F288F1C0D00FC478F /* PrefsWC+Hotkey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrefsWC+Hotkey.swift"; sourceTree = ""; }; + C4FACE82288F1F9700FC478F /* OnboardingWC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingWC.swift; sourceTree = ""; }; C4FBFC512616485F00CDB8E1 /* PhpVersionDetectionTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhpVersionDetectionTest.swift; sourceTree = ""; }; C4FE011028084FC200D1DE6D /* SelectionVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectionVC.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -678,6 +680,14 @@ path = Extensions; sourceTree = ""; }; + C4297F7828970D4E004C4630 /* Warning */ = { + isa = PBXGroup; + children = ( + C4297F7928970D59004C4630 /* WarningView.swift */, + ); + path = Warning; + sourceTree = ""; + }; C44067F327E256560045BD4E /* Cells */ = { isa = PBXGroup; children = ( @@ -1041,6 +1051,7 @@ C4EE55B027708BB2001DF387 /* SwiftUI */ = { isa = PBXGroup; children = ( + C4297F7828970D4E004C4630 /* Warning */, C4E9D2BE2878B32D008FFDAD /* Onboarding */, C4B609182853AAA700C95265 /* Domains */, C4B609172853AA9E00C95265 /* Menu */, @@ -1292,6 +1303,7 @@ C41C1B4922B00A9800E7CF16 /* MenuBarImageGenerator.swift in Sources */, C4F30B03278E16BA00755FCE /* HomebrewService.swift in Sources */, 54D9E0B427E4F51E003B9AD9 /* Key.swift in Sources */, + C4297F7A28970D59004C4630 /* WarningView.swift in Sources */, C4C0E8E227F88B13002D32A9 /* ValetSiteScanner.swift in Sources */, C42F26732805B4B400938AC7 /* DomainListable.swift in Sources */, 5420395F2613607600FB00FA /* Preferences.swift in Sources */, diff --git a/phpmon/Domain/Menu/MainMenu+Startup.swift b/phpmon/Domain/Menu/MainMenu+Startup.swift index c0d834d..1c2aa55 100644 --- a/phpmon/Domain/Menu/MainMenu+Startup.swift +++ b/phpmon/Domain/Menu/MainMenu+Startup.swift @@ -90,7 +90,7 @@ extension MainMenu { // Present first launch screen if needed #warning("The launch screen will be presented every time you launch the app.") - if Stats.successfulLaunchCount >= 1 { + if Stats.successfulLaunchCount >= 1 && !isRunningSwiftUIPreview { Log.info("Should present the first launch screen!") DispatchQueue.main.async { OnboardingWC.show() diff --git a/phpmon/Domain/SwiftUI/Warning/WarningView.swift b/phpmon/Domain/SwiftUI/Warning/WarningView.swift new file mode 100644 index 0000000..645c167 --- /dev/null +++ b/phpmon/Domain/SwiftUI/Warning/WarningView.swift @@ -0,0 +1,39 @@ +// +// WarningView.swift +// PHP Monitor +// +// Created by Nico Verbruggen on 31/07/2022. +// Copyright © 2022 Nico Verbruggen. All rights reserved. +// + +import SwiftUI + +struct WarningView: View { + @State var title: String + @State var description: String + + var body: some View { + HStack { + Image(systemName: "exclamationmark.triangle.fill") + .resizable() + .frame(width: 25, height: 25) + .padding() + VStack(alignment: .leading) { + Text(title) + .fontWeight(.bold) + .padding(.bottom, 1) + Text(description) + .font(.body) + } + }.padding() + } +} + +struct WarningView_Previews: PreviewProvider { + static var previews: some View { + WarningView( + title: "Helpers not written", + description: "The helper files in `/usr/local/bin` could not be written because PHP Monitor does not have permission to write there." + ) + } +}