|
@ -23,7 +23,7 @@ struct ProfileFullName: View { |
|
|
.font(.footnote) |
|
|
.font(.footnote) |
|
|
.foregroundColor(.gray) |
|
|
.foregroundColor(.gray) |
|
|
} else { |
|
|
} else { |
|
|
ProfileName(pubkey: pubkey, profile: profile, contacts: contacts, show_friend_confirmed: true) |
|
|
// ProfileName(pubkey: pubkey, profile: profile, contacts: contacts, show_friend_confirmed: true) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -73,8 +73,9 @@ struct ProfileName: View { |
|
|
|
|
|
|
|
|
var body: some View { |
|
|
var body: some View { |
|
|
HStack { |
|
|
HStack { |
|
|
|
|
|
|
|
|
Text(prefix + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) |
|
|
Text(prefix + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) |
|
|
//.foregroundColor(hex_to_rgb(pubkey)) |
|
|
.font(.subheadline) |
|
|
.fontWeight(prefix == "@" ? .none : .bold) |
|
|
.fontWeight(prefix == "@" ? .none : .bold) |
|
|
if let frend = friend_icon { |
|
|
if let frend = friend_icon { |
|
|
Label("", systemImage: frend) |
|
|
Label("", systemImage: frend) |
|
@ -92,4 +93,77 @@ struct ProfileName: View { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Profile Name used when displaying an event in the timeline |
|
|
|
|
|
struct EventProfileName: View { |
|
|
|
|
|
let pubkey: String |
|
|
|
|
|
let profile: Profile? |
|
|
|
|
|
let contacts: Contacts |
|
|
|
|
|
let prefix: String |
|
|
|
|
|
|
|
|
|
|
|
let show_friend_confirmed: Bool |
|
|
|
|
|
|
|
|
|
|
|
@State var display_name: String? |
|
|
|
|
|
|
|
|
|
|
|
init(pubkey: String, profile: Profile?, contacts: Contacts, show_friend_confirmed: Bool) { |
|
|
|
|
|
self.pubkey = pubkey |
|
|
|
|
|
self.profile = profile |
|
|
|
|
|
self.prefix = "" |
|
|
|
|
|
self.contacts = contacts |
|
|
|
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
init(pubkey: String, profile: Profile?, prefix: String, contacts: Contacts, show_friend_confirmed: Bool) { |
|
|
|
|
|
self.pubkey = pubkey |
|
|
|
|
|
self.profile = profile |
|
|
|
|
|
self.prefix = prefix |
|
|
|
|
|
self.contacts = contacts |
|
|
|
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var friend_icon: String? { |
|
|
|
|
|
if !show_friend_confirmed { |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if self.contacts.is_friend(self.pubkey) { |
|
|
|
|
|
return "person.fill.checkmark" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if self.contacts.is_friend_of_friend(self.pubkey) { |
|
|
|
|
|
return "person.fill.and.arrow.left.and.arrow.right" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
|
HStack { |
|
|
|
|
|
if let real_name = profile?.display_name { |
|
|
|
|
|
Text(real_name) |
|
|
|
|
|
.font(.subheadline.weight(.bold)) |
|
|
|
|
|
|
|
|
|
|
|
Text("@" + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) |
|
|
|
|
|
.foregroundColor(.gray) |
|
|
|
|
|
.font(.subheadline) |
|
|
|
|
|
} else { |
|
|
|
|
|
Text(String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) |
|
|
|
|
|
.foregroundColor(.black) |
|
|
|
|
|
.font(.subheadline) |
|
|
|
|
|
.fontWeight(.bold) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if let frend = friend_icon { |
|
|
|
|
|
Label("", systemImage: frend) |
|
|
|
|
|
.foregroundColor(.gray) |
|
|
|
|
|
.font(.footnote) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
.onReceive(handle_notify(.profile_updated)) { notif in |
|
|
|
|
|
let update = notif.object as! ProfileUpdate |
|
|
|
|
|
if update.pubkey != pubkey { |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
display_name = Profile.displayName(profile: update.profile, pubkey: pubkey) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|