nip19: generate nip19 data in ellipsis & share menus

In the ellipsis menu, when the user selects the 'Copy user public key',
an nprofile Bech32 entity will be generated which will include TLV data
with the user's public key and entire relay list, if available.
The nprofile will be added to the user's copy clipboard.

When the user presses the share menu on an event and clicks the 'copy
link' button, a damus link with the nevent for the note will be
generated and copied to the user's clipboard.

Closes: https://github.com/damus-io/damus/issues/1844
Changelog-Changed: Generate nprofile/nevent links in share menus
Lightning-url: LNURL1DP68GURN8GHJ7EM9W3SKCCNE9E3K7MF0D3H82UNVWQHKWUN9V4HXGCTHDC6RZVGR8SW3G
Signed-off-by: kernelkind <kernelkind@gmail.com>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
kernelkind
2024-01-18 14:59:31 -05:00
committed by William Casarin
parent 0650a62791
commit 5840b85213
5 changed files with 50 additions and 8 deletions
+4 -2
View File
@@ -13,6 +13,7 @@ struct EventActionBar: View {
let damus_state: DamusState
let event: NostrEvent
let generator = UIImpactFeedbackGenerator(style: .medium)
let userProfile : ProfileModel
// just used for previews
@State var show_share_sheet: Bool = false
@@ -25,6 +26,7 @@ struct EventActionBar: View {
self.damus_state = damus_state
self.event = event
_bar = ObservedObject(wrappedValue: bar ?? make_actionbar_model(ev: event.id, damus: damus_state))
self.userProfile = ProfileModel(pubkey: event.pubkey, damus: damus_state)
}
var lnurl: String? {
@@ -100,11 +102,11 @@ struct EventActionBar: View {
}
.sheet(isPresented: $show_share_action, onDismiss: { self.show_share_action = false }) {
if #available(iOS 16.0, *) {
ShareAction(event: event, bookmarks: damus_state.bookmarks, show_share: $show_share_sheet)
ShareAction(event: event, bookmarks: damus_state.bookmarks, show_share: $show_share_sheet, userProfile: userProfile)
.presentationDetents([.height(300)])
.presentationDragIndicator(.visible)
} else {
ShareAction(event: event, bookmarks: damus_state.bookmarks, show_share: $show_share_sheet)
ShareAction(event: event, bookmarks: damus_state.bookmarks, show_share: $show_share_sheet, userProfile: userProfile)
}
}
.sheet(isPresented: $show_share_sheet, onDismiss: { self.show_share_sheet = false }) {