damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 080aaf2d1be8a4b272efc93a34474e63cfe4099a
parent 0e55b08b6c9215757a3ade4691a4c4d94b6c4396
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 17 Jul 2023 11:01:57 -0700

nip05: show username and support _ usernames

Changelog-Added: Show nostr address username and support abbreviated _ usernames

Diffstat:
Mdamus/Components/NIP05Badge.swift | 22++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/damus/Components/NIP05Badge.swift b/damus/Components/NIP05Badge.swift @@ -43,14 +43,24 @@ struct NIP05Badge: View { } } } - + + var nip05_string: String { + if nip05.username == "_" { + return nip05.host + } else { + return "\(nip05.username)@\(nip05.host)" + } + } + var body: some View { HStack(spacing: 2) { + + Seal - + if show_domain { if clickable { - Text(nip05.host) + Text(nip05_string) .nip05_colorized(gradient: nip05_color) .onTapGesture { if let nip5url = nip05.siteUrl { @@ -58,7 +68,7 @@ struct NIP05Badge: View { } } } else { - Text(nip05.host) + Text(nip05_string) .foregroundColor(.gray) } } @@ -86,6 +96,10 @@ struct NIP05Badge_Previews: PreviewProvider { static var previews: some View { let test_state = test_damus_state() VStack { + NIP05Badge(nip05: NIP05(username: "jb55", host: "jb55.com"), pubkey: test_state.pubkey, contacts: test_state.contacts, show_domain: true, clickable: true) + + NIP05Badge(nip05: NIP05(username: "_", host: "jb55.com"), pubkey: test_state.pubkey, contacts: test_state.contacts, show_domain: true, clickable: true) + NIP05Badge(nip05: NIP05(username: "jb55", host: "jb55.com"), pubkey: test_state.pubkey, contacts: test_state.contacts, show_domain: true, clickable: false) NIP05Badge(nip05: NIP05(username: "jb55", host: "jb55.com"), pubkey: test_state.pubkey, contacts: Contacts(our_pubkey: "sdkfjsdf"), show_domain: true, clickable: false)