Implement basic share feature

This commit is contained in:
Angelo Stavrow 2020-09-28 17:29:04 -04:00
parent 9e291af377
commit eb83b0418c
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -152,6 +152,15 @@ struct PostEditorView: View {
self.hideKeyboard()
#endif
}
private func sharePost() {
guard let urlString = model.selectedPost?.slug != nil ?
"\(model.account.server)/\((model.selectedPost?.collectionAlias)!)/\((model.selectedPost?.slug)!)" :
"\(model.account.server)/\((model.selectedPost?.postId)!)" else { return }
guard let data = URL(string: urlString) else { return }
let activityView = UIActivityViewController(activityItems: [data], applicationActivities: nil)
UIApplication.shared.windows.first?.rootViewController?.present(activityView, animated: true, completion: nil)
}
}
struct PostEditorView_EmptyPostPreviews: PreviewProvider {