From 7e6997a8210e0dd65eec58c1df656f3e3ca53784 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Fri, 11 Dec 2020 15:26:40 -0500 Subject: [PATCH] Reset isPresented binding after dismissing picker --- macOS/Navigation/ActivePostToolbarView.swift | 5 ++++- macOS/PostEditor/PostEditorSharingPicker.swift | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/macOS/Navigation/ActivePostToolbarView.swift b/macOS/Navigation/ActivePostToolbarView.swift index 991fb2c..417db66 100644 --- a/macOS/Navigation/ActivePostToolbarView.swift +++ b/macOS/Navigation/ActivePostToolbarView.swift @@ -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) diff --git a/macOS/PostEditor/PostEditorSharingPicker.swift b/macOS/PostEditor/PostEditorSharingPicker.swift index 97d2c99..02f7c96 100644 --- a/macOS/PostEditor/PostEditorSharingPicker.swift +++ b/macOS/PostEditor/PostEditorSharingPicker.swift @@ -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 } } }