Publish isProcessingRequest flag to switch ProgressView with Button

This commit is contained in:
Angelo Stavrow 2020-10-16 16:19:38 -04:00
parent 22109a47d7
commit 1feeed7354
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
3 changed files with 16 additions and 7 deletions

View File

@ -12,6 +12,7 @@ class WriteFreelyModel: ObservableObject {
@Published var editor = PostEditorModel()
@Published var isLoggingIn: Bool = false
@Published var hasNetworkConnection: Bool = false
@Published var isProcessingRequest: Bool = false
@Published var selectedPost: WFAPost? {
didSet {
if let post = selectedPost {

View File

@ -35,12 +35,16 @@ struct PostListView: View {
Text(pluralizedPostCount(for: showPosts(for: selectedCollection)))
.foregroundColor(.secondary)
Spacer()
Button(action: {
reloadFromServer()
}, label: {
Image(systemName: "arrow.clockwise")
})
.disabled(!model.account.isLoggedIn || !model.hasNetworkConnection)
if model.isProcessingRequest {
ProgressView()
} else {
Button(action: {
reloadFromServer()
}, label: {
Image(systemName: "arrow.clockwise")
})
.disabled(!model.account.isLoggedIn || !model.hasNetworkConnection)
}
}
.padding()
.frame(width: geometry.size.width)

View File

@ -153,7 +153,10 @@ struct PostEditorView: View {
PostEditorStatusToolbarView(post: post)
}
ToolbarItem(placement: .primaryAction) {
Menu(content: {
if model.isProcessingRequest {
ProgressView()
} else {
Menu(content: {
if post.status == PostStatus.local.rawValue {
Menu(content: {
Label("Publish to…", systemImage: "paperplane")
@ -226,6 +229,7 @@ struct PostEditorView: View {
}, label: {
Image(systemName: "ellipsis.circle")
})
}
}
}
.onChange(of: post.hasNewerRemoteCopy, perform: { _ in