|
@ -7,28 +7,6 @@ |
|
|
|
|
|
|
|
|
import SwiftUI |
|
|
import SwiftUI |
|
|
|
|
|
|
|
|
struct ProfileFullName: View { |
|
|
|
|
|
let pubkey: String |
|
|
|
|
|
let profile: Profile? |
|
|
|
|
|
let contacts: Contacts |
|
|
|
|
|
|
|
|
|
|
|
@State var display_name: String? |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
|
HStack { |
|
|
|
|
|
if let real_name = profile?.display_name { |
|
|
|
|
|
Text(real_name) |
|
|
|
|
|
.bold() |
|
|
|
|
|
ProfileName(pubkey: pubkey, profile: profile, prefix: "@", contacts: contacts, show_friend_confirmed: true) |
|
|
|
|
|
.font(.footnote) |
|
|
|
|
|
.foregroundColor(.gray) |
|
|
|
|
|
} else { |
|
|
|
|
|
// ProfileName(pubkey: pubkey, profile: profile, contacts: contacts, show_friend_confirmed: true) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
struct ProfileName: View { |
|
|
struct ProfileName: View { |
|
|
let pubkey: String |
|
|
let pubkey: String |
|
|
let profile: Profile? |
|
|
let profile: Profile? |
|
@ -36,23 +14,27 @@ struct ProfileName: View { |
|
|
let prefix: String |
|
|
let prefix: String |
|
|
|
|
|
|
|
|
let show_friend_confirmed: Bool |
|
|
let show_friend_confirmed: Bool |
|
|
|
|
|
let profiles: Profiles |
|
|
|
|
|
|
|
|
@State var display_name: String? |
|
|
@State var display_name: String? |
|
|
|
|
|
@State var nip05: NIP05? |
|
|
|
|
|
|
|
|
init(pubkey: String, profile: Profile?, contacts: Contacts, show_friend_confirmed: Bool) { |
|
|
init(pubkey: String, profile: Profile?, contacts: Contacts, show_friend_confirmed: Bool, profiles: Profiles) { |
|
|
self.pubkey = pubkey |
|
|
self.pubkey = pubkey |
|
|
self.profile = profile |
|
|
self.profile = profile |
|
|
self.prefix = "" |
|
|
self.prefix = "" |
|
|
self.contacts = contacts |
|
|
self.contacts = contacts |
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
|
|
|
self.profiles = profiles |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
init(pubkey: String, profile: Profile?, prefix: String, contacts: Contacts, show_friend_confirmed: Bool) { |
|
|
init(pubkey: String, profile: Profile?, prefix: String, contacts: Contacts, show_friend_confirmed: Bool, profiles: Profiles) { |
|
|
self.pubkey = pubkey |
|
|
self.pubkey = pubkey |
|
|
self.profile = profile |
|
|
self.profile = profile |
|
|
self.prefix = prefix |
|
|
self.prefix = prefix |
|
|
self.contacts = contacts |
|
|
self.contacts = contacts |
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
|
|
|
self.profiles = profiles |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var friend_icon: String? { |
|
|
var friend_icon: String? { |
|
@ -71,12 +53,26 @@ struct ProfileName: View { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var nip05_color: Color { |
|
|
|
|
|
contacts.is_friend(pubkey) ? .blue : .yellow |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var current_nip05: NIP05? { |
|
|
|
|
|
nip05 ?? profiles.is_validated(pubkey) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var body: some View { |
|
|
var body: some View { |
|
|
HStack { |
|
|
HStack(spacing: 2) { |
|
|
Text(prefix + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) |
|
|
Text(prefix + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) |
|
|
.font(.body) |
|
|
.font(.body) |
|
|
.fontWeight(prefix == "@" ? .none : .bold) |
|
|
.fontWeight(prefix == "@" ? .none : .bold) |
|
|
if let friend = friend_icon { |
|
|
if let nip05 = current_nip05 { |
|
|
|
|
|
Image(systemName: "checkmark.seal.fill") |
|
|
|
|
|
.foregroundColor(nip05_color) |
|
|
|
|
|
Text(nip05.host) |
|
|
|
|
|
.foregroundColor(nip05_color) |
|
|
|
|
|
} |
|
|
|
|
|
if let friend = friend_icon, current_nip05 == nil { |
|
|
Image(systemName: friend) |
|
|
Image(systemName: friend) |
|
|
.foregroundColor(.gray) |
|
|
.foregroundColor(.gray) |
|
|
} |
|
|
} |
|
@ -87,6 +83,7 @@ struct ProfileName: View { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
display_name = Profile.displayName(profile: update.profile, pubkey: pubkey) |
|
|
display_name = Profile.displayName(profile: update.profile, pubkey: pubkey) |
|
|
|
|
|
nip05 = profiles.is_validated(pubkey) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -99,27 +96,31 @@ struct EventProfileName: View { |
|
|
let prefix: String |
|
|
let prefix: String |
|
|
|
|
|
|
|
|
let show_friend_confirmed: Bool |
|
|
let show_friend_confirmed: Bool |
|
|
|
|
|
let profiles: Profiles |
|
|
|
|
|
|
|
|
@State var display_name: String? |
|
|
@State var display_name: String? |
|
|
|
|
|
@State var nip05: NIP05? |
|
|
|
|
|
|
|
|
let size: EventViewKind |
|
|
let size: EventViewKind |
|
|
|
|
|
|
|
|
init(pubkey: String, profile: Profile?, contacts: Contacts, show_friend_confirmed: Bool, size: EventViewKind = .normal) { |
|
|
init(pubkey: String, profile: Profile?, contacts: Contacts, show_friend_confirmed: Bool, profiles: Profiles, size: EventViewKind = .normal) { |
|
|
self.pubkey = pubkey |
|
|
self.pubkey = pubkey |
|
|
self.profile = profile |
|
|
self.profile = profile |
|
|
self.prefix = "" |
|
|
self.prefix = "" |
|
|
self.contacts = contacts |
|
|
self.contacts = contacts |
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
self.size = size |
|
|
self.size = size |
|
|
|
|
|
self.profiles = profiles |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
init(pubkey: String, profile: Profile?, prefix: String, contacts: Contacts, show_friend_confirmed: Bool, size: EventViewKind = .normal) { |
|
|
init(pubkey: String, profile: Profile?, prefix: String, contacts: Contacts, show_friend_confirmed: Bool, profiles: Profiles, size: EventViewKind = .normal) { |
|
|
self.pubkey = pubkey |
|
|
self.pubkey = pubkey |
|
|
self.profile = profile |
|
|
self.profile = profile |
|
|
self.prefix = prefix |
|
|
self.prefix = prefix |
|
|
self.contacts = contacts |
|
|
self.contacts = contacts |
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
self.show_friend_confirmed = show_friend_confirmed |
|
|
self.size = size |
|
|
self.size = size |
|
|
|
|
|
self.profiles = profiles |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var friend_icon: String? { |
|
|
var friend_icon: String? { |
|
@ -138,11 +139,20 @@ struct EventProfileName: View { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var nip05_color: Color { |
|
|
|
|
|
contacts.is_friend(pubkey) ? .blue : .yellow |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var current_nip05: NIP05? { |
|
|
|
|
|
nip05 ?? profiles.is_validated(pubkey) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var body: some View { |
|
|
var body: some View { |
|
|
HStack { |
|
|
HStack(spacing: 2) { |
|
|
if let real_name = profile?.display_name { |
|
|
if let real_name = profile?.display_name { |
|
|
Text(real_name) |
|
|
Text(real_name) |
|
|
.font(.body.weight(.bold)) |
|
|
.font(.body.weight(.bold)) |
|
|
|
|
|
.padding([.trailing], 4) |
|
|
|
|
|
|
|
|
Text("@" + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) |
|
|
Text("@" + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) |
|
|
.foregroundColor(.gray) |
|
|
.foregroundColor(.gray) |
|
@ -153,7 +163,16 @@ struct EventProfileName: View { |
|
|
.fontWeight(.bold) |
|
|
.fontWeight(.bold) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if let frend = friend_icon { |
|
|
if let nip05 = current_nip05 { |
|
|
|
|
|
Image(systemName: "checkmark.seal.fill") |
|
|
|
|
|
.foregroundColor(nip05_color) |
|
|
|
|
|
if !contacts.is_friend(pubkey) { |
|
|
|
|
|
Text(nip05.host) |
|
|
|
|
|
.foregroundColor(nip05_color) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if let frend = friend_icon, current_nip05 == nil { |
|
|
Label("", systemImage: frend) |
|
|
Label("", systemImage: frend) |
|
|
.foregroundColor(.gray) |
|
|
.foregroundColor(.gray) |
|
|
.font(.footnote) |
|
|
.font(.footnote) |
|
@ -165,6 +184,7 @@ struct EventProfileName: View { |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
display_name = Profile.displayName(profile: update.profile, pubkey: pubkey) |
|
|
display_name = Profile.displayName(profile: update.profile, pubkey: pubkey) |
|
|
|
|
|
nip05 = profiles.is_validated(pubkey) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|