Reset isPresented binding after dismissing picker

This commit is contained in:
Angelo Stavrow 2020-12-11 15:26:40 -05:00
parent c99df92c6b
commit 7e6997a821
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
2 changed files with 6 additions and 1 deletions

View File

@ -17,7 +17,10 @@ struct ActivePostToolbarView: View {
)
.disabled(activePost.status == PostStatus.local.rawValue)
.popover(isPresented: $isPresentingSharingServicePicker) {
PostEditorSharingPicker(sharingItems: createPostUrl())
PostEditorSharingPicker(
isPresented: $isPresentingSharingServicePicker,
sharingItems: createPostUrl()
)
}
Button(action: { publishPost(activePost) }, label: { Image(systemName: "paperplane") })
.disabled(activePost.body.isEmpty || activePost.status == PostStatus.published.rawValue)

View File

@ -1,6 +1,7 @@
import SwiftUI
struct PostEditorSharingPicker: NSViewRepresentable {
@Binding var isPresented: Bool
var sharingItems: [Any] = []
func makeNSView(context: Context) -> some NSView {
@ -32,6 +33,7 @@ struct PostEditorSharingPicker: NSViewRepresentable {
didChoose service: NSSharingService?
) {
sharingServicePicker.delegate = nil
self.owner.isPresented = false
}
}
}