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 <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-10-30 23:14:27 -07:00
parent 8a15265f84
commit 3651ac6714
2 changed files with 16 additions and 2 deletions

View File

@@ -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

View File

@@ -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