From bcf496e15d6e75bbeeefd1c68ff2233cae539bec Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Tue, 1 Dec 2020 16:17:53 -0500 Subject: [PATCH 1/3] Listen for shift-key on launch to run debug code --- Shared/WriteFreely_MultiPlatformApp.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Shared/WriteFreely_MultiPlatformApp.swift b/Shared/WriteFreely_MultiPlatformApp.swift index 4aeb385..29d33cc 100644 --- a/Shared/WriteFreely_MultiPlatformApp.swift +++ b/Shared/WriteFreely_MultiPlatformApp.swift @@ -1,6 +1,21 @@ import SwiftUI @main +struct CheckForDebugModifier { + static func main() { + #if os(macOS) + if NSEvent.modifierFlags.contains(.shift) { + print("Debug launch detected") + // Run debug-mode launch code here + } else { + print("Normal launch detected") + // Don't do anything + } + #endif + WriteFreely_MultiPlatformApp.main() + } +} + struct WriteFreely_MultiPlatformApp: App { @StateObject private var model = WriteFreelyModel() From fb5255cb04974c3c91f3334f40e12a8de71f9827 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Tue, 1 Dec 2020 16:23:15 -0500 Subject: [PATCH 2/3] Clean up SwiftLint warning with multiline string literal --- Shared/Navigation/ContentView.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index ce8f253..dd6272e 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -60,7 +60,8 @@ struct ContentView: View { Alert( title: Text("Connection Error"), message: Text(""" - There is no internet connection at the moment. Please reconnect or try again later. + There is no internet connection at the moment. \ + Please reconnect or try again later. """), dismissButton: .default(Text("OK"), action: { model.isPresentingNetworkErrorAlert = false From a5ab2182eb42820edaebab4ad7f4a7cf87debdc8 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Mon, 7 Dec 2020 15:15:49 -0500 Subject: [PATCH 3/3] Overlay ProgressView on post list while processing network requests --- Shared/Navigation/ContentView.swift | 42 +++++++++++++++++------------ 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index dd6272e..d5c1e4d 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -51,26 +51,34 @@ struct ContentView: View { #endif #if os(macOS) - PostListView(selectedCollection: nil, showAllPosts: model.account.isLoggedIn) - .toolbar { - ToolbarItemGroup(placement: .primaryAction) { - if let selectedPost = model.selectedPost { - ActivePostToolbarView(activePost: selectedPost) - .alert(isPresented: $model.isPresentingNetworkErrorAlert, content: { - Alert( - title: Text("Connection Error"), - message: Text(""" - There is no internet connection at the moment. \ - Please reconnect or try again later. - """), - dismissButton: .default(Text("OK"), action: { - model.isPresentingNetworkErrorAlert = false - }) - ) - }) + ZStack { + PostListView(selectedCollection: nil, showAllPosts: model.account.isLoggedIn) + .toolbar { + ToolbarItemGroup(placement: .primaryAction) { + if let selectedPost = model.selectedPost { + ActivePostToolbarView(activePost: selectedPost) + .alert(isPresented: $model.isPresentingNetworkErrorAlert, content: { + Alert( + title: Text("Connection Error"), + message: Text(""" + There is no internet connection at the moment. \ + Please reconnect or try again later. + """), + dismissButton: .default(Text("OK"), action: { + model.isPresentingNetworkErrorAlert = false + }) + ) + }) + } } + } + if model.isProcessingRequest { + ZStack { + Color(NSColor.controlBackgroundColor).opacity(0.75) + ProgressView() } } + } #else PostListView(selectedCollection: nil, showAllPosts: model.account.isLoggedIn) #endif