Merge pull request #150 from writeas/show-progressview-during-network-request

Show ProgressView during network request
This commit is contained in:
Angelo Stavrow 2020-12-11 09:47:45 -05:00 committed by GitHub
commit 1397009a8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 1 deletions

View File

@ -51,7 +51,34 @@ struct ContentView: View {
#endif
#if os(macOS)
PostListView(selectedCollection: model.selectedCollection, showAllPosts: model.showAllPosts)
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

View File

@ -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()