mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Implement share popover for iPad
This commit is contained in:
parent
eb83b0418c
commit
25c1009136
@ -7,12 +7,12 @@
|
||||
<key>WriteFreely-MultiPlatform (iOS).xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>0</integer>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
<key>WriteFreely-MultiPlatform (macOS).xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
|
@ -89,13 +89,6 @@ struct PostEditorView: View {
|
||||
PostEditorStatusToolbarView(post: post)
|
||||
}
|
||||
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
||||
Button(action: {
|
||||
sharePost()
|
||||
}, label: {
|
||||
Image(systemName: "square.and.arrow.up")
|
||||
})
|
||||
.disabled(post.postId == nil)
|
||||
|
||||
Button(action: {
|
||||
publishPost()
|
||||
}, label: {
|
||||
@ -106,6 +99,12 @@ struct PostEditorView: View {
|
||||
!model.account.isLoggedIn ||
|
||||
!model.hasNetworkConnection
|
||||
)
|
||||
Button(action: {
|
||||
sharePost()
|
||||
}, label: {
|
||||
Image(systemName: "square.and.arrow.up")
|
||||
})
|
||||
.disabled(post.postId == nil)
|
||||
}
|
||||
}
|
||||
.onChange(of: post.hasNewerRemoteCopy, perform: { _ in
|
||||
@ -158,8 +157,20 @@ struct PostEditorView: View {
|
||||
"\(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)
|
||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||
activityView.popoverPresentationController?.permittedArrowDirections = .up
|
||||
activityView.popoverPresentationController?.sourceView = UIApplication.shared.windows.first
|
||||
activityView.popoverPresentationController?.sourceRect = CGRect(
|
||||
x: UIScreen.main.bounds.width,
|
||||
y: -125,
|
||||
width: 200,
|
||||
height: 200
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user