From 3651ac67148c49a7fdf6278018db99abff45d1bb Mon Sep 17 00:00:00 2001 From: William Casarin Date: Sun, 30 Oct 2022 23:14:27 -0700 Subject: [PATCH] Show lud06 lightning tip button If the profile has a lud06 or lud16 field, render a lightning tipping button Changelog-Added: Add lightning tipping button for lud06 profiles Signed-off-by: William Casarin --- damus/Views/ProfilePicView.swift | 2 +- damus/Views/ProfileView.swift | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift index 9053ba91..d1f9ce13 100644 --- a/damus/Views/ProfilePicView.swift +++ b/damus/Views/ProfilePicView.swift @@ -90,7 +90,7 @@ struct ProfilePicView: View { func make_preview_profiles(_ pubkey: String) -> Profiles { let profiles = Profiles() let picture = "http://cdn.jb55.com/img/red-me.jpg" - let profile = Profile(name: "jb55", display_name: "William Casarin", about: "It's me", picture: picture) + let profile = Profile(name: "jb55", display_name: "William Casarin", about: "It's me", picture: picture, website: "https://jb55.com", lud06: nil, lud16: nil) let ts_profile = TimestampedProfile(profile: profile, timestamp: 0) profiles.add(id: pubkey, profile: ts_profile) return profiles diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift index ec01c9cf..5194dd37 100644 --- a/damus/Views/ProfileView.swift +++ b/damus/Views/ProfileView.swift @@ -78,6 +78,15 @@ struct ProfileView: View { //@EnvironmentObject var profile: ProfileModel + func LNButton(_ url: URL) -> some View { + Button(action: { + UIApplication.shared.open(url) + }) { + Label("", systemImage: "bolt.fill") + .foregroundColor(.orange) + } + } + var DMButton: some View { let dm_model = damus_state.dms.lookup_or_create(profile.pubkey) let dmview = DMChatView(damus_state: damus_state, pubkey: profile.pubkey) @@ -99,6 +108,11 @@ struct ProfileView: View { Spacer() + if let lnuri = data?.lightning_uri { + LNButton(lnuri) + .padding([.trailing], 20) + } + DMButton .padding([.trailing], 20) @@ -183,7 +197,7 @@ func test_damus_state() -> DamusState { let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681" let damus = DamusState(pool: RelayPool(), keypair: Keypair(pubkey: pubkey, privkey: "privkey"), likes: EventCounter(our_pubkey: pubkey), boosts: EventCounter(our_pubkey: pubkey), contacts: Contacts(), tips: TipCounter(our_pubkey: pubkey), profiles: Profiles(), dms: DirectMessagesModel()) - let prof = Profile(name: "damus", display_name: "Damus", about: "iOS app!", picture: "https://damus.io/img/logo.png") + let prof = Profile(name: "damus", display_name: "Damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol") let tsprof = TimestampedProfile(profile: prof, timestamp: 0) damus.profiles.add(id: pubkey, profile: tsprof) return damus