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>
83 lines
2.9 KiB
Swift
83 lines
2.9 KiB
Swift
//
|
|
// ShareAction.swift
|
|
// damus
|
|
//
|
|
// Created by eric on 3/8/23.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct ShareAction: View {
|
|
let event: NostrEvent
|
|
let bookmarks: BookmarksManager
|
|
let userProfile: ProfileModel
|
|
@State private var isBookmarked: Bool = false
|
|
|
|
@Binding var show_share: Bool
|
|
|
|
@Environment(\.dismiss) var dismiss
|
|
|
|
init(event: NostrEvent, bookmarks: BookmarksManager, show_share: Binding<Bool>, userProfile: ProfileModel) {
|
|
let bookmarked = bookmarks.isBookmarked(event)
|
|
self._isBookmarked = State(initialValue: bookmarked)
|
|
|
|
self.bookmarks = bookmarks
|
|
self.event = event
|
|
self.userProfile = userProfile
|
|
self._show_share = show_share
|
|
}
|
|
|
|
var body: some View {
|
|
|
|
VStack {
|
|
Text("Share Note", comment: "Title text to indicate that the buttons below are meant to be used to share a note with others.")
|
|
.padding()
|
|
.font(.system(size: 17, weight: .bold))
|
|
|
|
Spacer()
|
|
|
|
HStack(alignment: .top, spacing: 25) {
|
|
|
|
ShareActionButton(img: "link", text: NSLocalizedString("Copy Link", comment: "Button to copy link to note")) {
|
|
dismiss()
|
|
UIPasteboard.general.string = "https://damus.io/" + Bech32Object.encode(.nevent(NEvent(noteid: event.id, relays: userProfile.getRelayStrings())))
|
|
}
|
|
|
|
let bookmarkImg = isBookmarked ? "bookmark.fill" : "bookmark"
|
|
let bookmarkTxt = isBookmarked ? NSLocalizedString("Remove Bookmark", comment: "Button text to remove bookmark from a note.") : NSLocalizedString("Add Bookmark", comment: "Button text to add bookmark to a note.")
|
|
ShareActionButton(img: bookmarkImg, text: bookmarkTxt) {
|
|
dismiss()
|
|
self.bookmarks.updateBookmark(event)
|
|
isBookmarked = self.bookmarks.isBookmarked(event)
|
|
}
|
|
|
|
ShareActionButton(img: "globe", text: NSLocalizedString("Broadcast", comment: "Button to broadcast note to all your relays")) {
|
|
dismiss()
|
|
notify(.broadcast(event))
|
|
}
|
|
|
|
ShareActionButton(img: "upload", text: NSLocalizedString("Share Via...", comment: "Button to present iOS share sheet")) {
|
|
show_share = true
|
|
dismiss()
|
|
}
|
|
|
|
}
|
|
|
|
Spacer()
|
|
|
|
HStack {
|
|
BigButton(NSLocalizedString("Cancel", comment: "Button to cancel a repost.")) {
|
|
dismiss()
|
|
}
|
|
}
|
|
}
|
|
.onAppear() {
|
|
userProfile.subscribeToFindRelays()
|
|
}
|
|
.onDisappear() {
|
|
userProfile.unsubscribeFindRelays()
|
|
}
|
|
}
|
|
}
|
|
|