Added new and improved Share sheet

Changelog-Added: New and Improved Share sheet
Closes: #764
This commit is contained in:
ericholguin
2023-03-08 20:49:49 -07:00
committed by William Casarin
parent 8059408d5f
commit 6b6743fcbb
3 changed files with 131 additions and 1 deletions

View File

@@ -28,9 +28,12 @@ struct EventActionBar: View {
@State var sheet: ActionBarSheet? = nil
@State var confirm_boost: Bool = false
@State var show_share_sheet: Bool = false
@State var show_share_action: Bool = false
@ObservedObject var bar: ActionBarModel
@Environment(\.colorScheme) var colorScheme
init(damus_state: DamusState, event: NostrEvent, bar: ActionBarModel? = nil, test_lnurl: String? = nil) {
self.damus_state = damus_state
self.event = event
@@ -88,10 +91,23 @@ struct EventActionBar: View {
Spacer()
EventActionButton(img: "square.and.arrow.up", col: Color.gray) {
show_share_sheet = true
show_share_action = true
}
.accessibilityLabel(NSLocalizedString("Share", comment: "Button to share a post"))
}
.sheet(isPresented: $show_share_action) {
if #available(iOS 16.0, *) {
ShareAction(event: event, bookmarks: damus_state.bookmarks, show_share_sheet: $show_share_sheet, show_share_action: $show_share_action)
.presentationDetents([.height(300)])
.presentationDragIndicator(.visible)
} else {
if let note_id = bech32_note_id(event.id) {
if let url = URL(string: "https://damus.io/" + note_id) {
ShareSheet(activityItems: [url])
}
}
}
}
.sheet(isPresented: $show_share_sheet) {
if let note_id = bech32_note_id(event.id) {
if let url = URL(string: "https://damus.io/" + note_id) {