Supporter Badges
This commit is contained in:
@@ -15,6 +15,7 @@ struct EventProfileName: View {
|
||||
|
||||
@State var display_name: DisplayName?
|
||||
@State var nip05: NIP05?
|
||||
@State var donation: Int?
|
||||
|
||||
let size: EventViewKind
|
||||
|
||||
@@ -23,6 +24,7 @@ struct EventProfileName: View {
|
||||
self.pubkey = pubkey
|
||||
self.profile = profile
|
||||
self.size = size
|
||||
self._donation = State(wrappedValue: profile?.damus_donation)
|
||||
}
|
||||
|
||||
var friend_type: FriendType? {
|
||||
@@ -45,6 +47,15 @@ struct EventProfileName: View {
|
||||
return profile.reactions == false
|
||||
}
|
||||
|
||||
var supporter: Int? {
|
||||
guard let donation, donation > 0
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return donation
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 2) {
|
||||
switch current_display_name {
|
||||
@@ -73,6 +84,10 @@ struct EventProfileName: View {
|
||||
Image("zap-hashtag")
|
||||
.frame(width: 14, height: 14)
|
||||
}
|
||||
|
||||
if let supporter {
|
||||
SupporterBadge(percent: supporter)
|
||||
}
|
||||
}
|
||||
.onReceive(handle_notify(.profile_updated)) { notif in
|
||||
let update = notif.object as! ProfileUpdate
|
||||
@@ -81,6 +96,7 @@ struct EventProfileName: View {
|
||||
}
|
||||
display_name = Profile.displayName(profile: update.profile, pubkey: pubkey)
|
||||
nip05 = damus_state.profiles.is_validated(pubkey)
|
||||
donation = update.profile.damus_donation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ struct ProfileName: View {
|
||||
|
||||
@State var display_name: DisplayName?
|
||||
@State var nip05: NIP05?
|
||||
@State var donation: Int?
|
||||
|
||||
init(pubkey: String, profile: Profile?, damus: DamusState, show_nip5_domain: Bool = true) {
|
||||
self.pubkey = pubkey
|
||||
@@ -75,6 +76,17 @@ struct ProfileName: View {
|
||||
return profile.reactions == false
|
||||
}
|
||||
|
||||
var supporter: Int? {
|
||||
guard let profile,
|
||||
let donation = profile.damus_donation,
|
||||
donation > 0
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return donation
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 2) {
|
||||
Text(verbatim: "\(prefix)\(name_choice)")
|
||||
@@ -90,6 +102,9 @@ struct ProfileName: View {
|
||||
Image("zap-hashtag")
|
||||
.frame(width: 14, height: 14)
|
||||
}
|
||||
if let supporter {
|
||||
SupporterBadge(percent: supporter)
|
||||
}
|
||||
}
|
||||
.onReceive(handle_notify(.profile_updated)) { notif in
|
||||
let update = notif.object as! ProfileUpdate
|
||||
@@ -98,6 +113,7 @@ struct ProfileName: View {
|
||||
}
|
||||
display_name = Profile.displayName(profile: update.profile, pubkey: pubkey)
|
||||
nip05 = damus_state.profiles.is_validated(pubkey)
|
||||
donation = profile?.damus_donation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,6 +496,9 @@ struct ProfileView_Previews: PreviewProvider {
|
||||
func test_damus_state() -> DamusState {
|
||||
let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681"
|
||||
let damus = DamusState.empty
|
||||
let settings = UserSettingsStore()
|
||||
settings.donation_percent = 100
|
||||
settings.default_zap_amount = 1971
|
||||
|
||||
let prof = Profile(name: "damus", display_name: "damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", banner: "", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol", nip05: "damus.io", damus_donation: nil)
|
||||
let tsprof = TimestampedProfile(profile: prof, timestamp: 0, event: test_event)
|
||||
|
||||
Reference in New Issue
Block a user