damus

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

commit a9f62960ecd130666c8e47b0b85da5612abe9973
parent 150bbb1eb2d051756420e8242c51e56e8e4d4dc1
Author: ericholguin <eric.holguinsanchez@gmail.com>
Date:   Mon, 27 Feb 2023 23:53:54 -0700

Add additional info to recommended relay view

Changelog-Added: Add additional info to recommended relay view
Closes: #703

Diffstat:
Mdamus/Views/Relays/RecommendedRelayView.swift | 50+++++++++++++++++++++++++++++++++++++-------------
1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/damus/Views/Relays/RecommendedRelayView.swift b/damus/Views/Relays/RecommendedRelayView.swift @@ -25,25 +25,49 @@ struct RecommendedRelayView: View { } var body: some View { - HStack { - Text(relay) - Spacer() + ZStack { + HStack { + RelayType(is_paid: damus.relay_metadata.lookup(relay_id: relay)?.is_paid ?? false) + Text(relay).layoutPriority(1) + + if let meta = damus.relay_metadata.lookup(relay_id: relay) { + NavigationLink ( destination: + RelayDetailView(state: damus, relay: relay, nip11: meta) + ){ + EmptyView() + } + .opacity(0.0) + + Spacer() + Image(systemName: "info.circle") + .foregroundColor(Color.accentColor) + } + } + } + .swipeActions { if add_button { if let privkey = damus.keypair.privkey { - Button(NSLocalizedString("Add", comment: "Button to add recommended relay server.")) { - guard let ev_before_add = damus.contacts.event else { - return - } - guard let ev_after_add = add_relay(ev: ev_before_add, privkey: privkey, current_relays: damus.pool.descriptors, relay: relay, info: .rw) else { - return - } - process_contact_event(state: damus, ev: ev_after_add) - damus.pool.send(.event(ev_after_add)) - } + AddAction(privkey: privkey) } } } } + + func AddAction(privkey: String) -> some View { + Button { + guard let ev_before_add = damus.contacts.event else { + return + } + guard let ev_after_add = add_relay(ev: ev_before_add, privkey: privkey, current_relays: damus.pool.descriptors, relay: relay, info: .rw) else { + return + } + process_contact_event(state: damus, ev: ev_after_add) + damus.pool.send(.event(ev_after_add)) + } label: { + Label(NSLocalizedString("Add Relay", comment: "Button to add recommended relay server."), systemImage: "plus.circle") + } + .tint(.accentColor) + } } struct RecommendedRelayView_Previews: PreviewProvider {