Skip to content

Commit

Permalink
Nests/stream: Add share button
Browse files Browse the repository at this point in the history
triggers new post with draft
  • Loading branch information
fabianfabian committed Sep 29, 2024
1 parent 8e0bef0 commit 4880c05
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Nostur/LiveEvents/LiveEventDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,19 @@ struct LiveEventDetail: View {
.lineLimit(1)
.truncationMode(.tail)
.frame(maxWidth: 140)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("Share", systemImage: "square.and.arrow.up") {
if !IS_CATALYST && !IS_IPAD {
LiveKitVoiceSession.shared.visibleNest = nil
}
NRState.shared.draft = "\(liveEvent.title ?? "Join") 👇\n\n" + "nostr:" + roomAddress
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
sendNotification(.newTemplatePost)
}
}
}
}
}
#if DEBUG
Text("copy event json")
Expand Down
3 changes: 3 additions & 0 deletions Nostur/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -6923,6 +6923,9 @@
}
}
}
},
"Share" : {

},
"Share highlight" : {
"comment" : "Navigation title for screen to Share a Highlighted Text",
Expand Down
4 changes: 4 additions & 0 deletions Nostur/Screens/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ struct MainView: View {
UserDefaults.standard.setValue("Following", forKey: "selected_subtab")
}
}
.onReceive(receiveNotification(.newTemplatePost)) { _ in
// Note: use NRState.shared.draft = ...
showingNewNote = true
}
.onReceive(receiveNotification(.navigateTo)) { notification in
let destination = notification.object as! NavigationDestination
guard !IS_IPAD || horizontalSizeClass == .compact else { return }
Expand Down
4 changes: 4 additions & 0 deletions Nostur/Utils/Notifications.swift
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,8 @@ extension Notification.Name {
static var hideCreateNestsSheet: Notification.Name {
return Notification.Name("hideCreateNestsSheet")
}

static var newTemplatePost: Notification.Name {
return Notification.Name("newTemplatePost")
}
}

0 comments on commit 4880c05

Please sign in to comment.