use gradient on nip05 badge

This commit is contained in:
ericholguin
2023-03-25 14:31:28 -06:00
parent 159d0fa2b5
commit 1b60524070

View File

@@ -24,27 +24,45 @@ struct NIP05Badge: View {
self.clickable = clickable self.clickable = clickable
} }
var nip05_color: Color { var nip05_color: Bool {
return get_nip05_color(pubkey: pubkey, contacts: contacts) return use_nip05_color(pubkey: pubkey, contacts: contacts)
} }
var body: some View { var body: some View {
HStack(spacing: 2) { HStack(spacing: 2) {
Image(systemName: "checkmark.seal.fill") if nip05_color {
.font(.footnote) LINEAR_GRADIENT
.foregroundColor(nip05_color) .mask(Image(systemName: "checkmark.seal.fill")
.resizable()
).frame(width: 14, height: 14)
} else {
Image(systemName: "checkmark.seal.fill")
.font(.footnote)
.foregroundColor(.gray)
}
if show_domain { if show_domain {
if clickable { if clickable {
Text(nip05.host) if nip05_color {
.foregroundColor(nip05_color) Text(nip05.host)
.onTapGesture { .foregroundStyle(LINEAR_GRADIENT)
if let nip5url = nip05.siteUrl { .onTapGesture {
openURL(nip5url) if let nip5url = nip05.siteUrl {
openURL(nip5url)
}
} }
} } else {
Text(nip05.host)
.foregroundColor(.gray)
.onTapGesture {
if let nip5url = nip05.siteUrl {
openURL(nip5url)
}
}
}
} else { } else {
Text(nip05.host) Text(nip05.host)
.foregroundColor(nip05_color) .foregroundColor(.gray)
} }
} }
} }
@@ -52,8 +70,8 @@ struct NIP05Badge: View {
} }
} }
func get_nip05_color(pubkey: String, contacts: Contacts) -> Color { func use_nip05_color(pubkey: String, contacts: Contacts) -> Bool {
return contacts.is_friend_or_self(pubkey) ? .accentColor : .gray return contacts.is_friend_or_self(pubkey) ? true : false
} }
struct NIP05Badge_Previews: PreviewProvider { struct NIP05Badge_Previews: PreviewProvider {