damus

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

commit d59331bc3c3221a864d7be8bf779ddf3a652bc2e
parent abd5856f21c3a6724aa560fde073386aa27ef973
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 13 Jan 2023 10:07:27 -0800

Only show EventDetailBar if we have tips/likes/reposts

Diffstat:
Mdamus/Models/ActionBarModel.swift | 4++++
Mdamus/Views/ActionBar/EventDetailBar.swift | 31++++++++++++++++++++-----------
Mdamus/Views/EventView.swift | 2+-
3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/damus/Models/ActionBarModel.swift b/damus/Models/ActionBarModel.swift @@ -29,6 +29,10 @@ class ActionBarModel: ObservableObject { self.our_tip = our_tip } + var is_empty: Bool { + return likes == 0 && boosts == 0 && tips == 0 + } + var tipped: Bool { return our_tip != nil } diff --git a/damus/Views/ActionBar/EventDetailBar.swift b/damus/Views/ActionBar/EventDetailBar.swift @@ -14,20 +14,29 @@ struct EventDetailBar: View { var body: some View { HStack { - Text("\(bar.boosts)") - .font(.body.bold()) - Text("Reposts") - - NavigationLink(destination: ReactionsView(damus_state: state, model: ReactionsModel(state: state, target: target))) { - Text("\(bar.likes)") + if bar.boosts > 0 { + Text("\(bar.boosts)") .font(.body.bold()) - Text("Reactions") + Text("Reposts") + .foregroundColor(.gray) + } + + if bar.likes > 0 { + NavigationLink(destination: ReactionsView(damus_state: state, model: ReactionsModel(state: state, target: target))) { + Text("\(bar.likes)") + .font(.body.bold()) + Text("Reactions") + .foregroundColor(.gray) + } + .buttonStyle(PlainButtonStyle()) } - .buttonStyle(PlainButtonStyle()) - Text("\(bar.tips)") - .font(.body.bold()) - Text("Tips") + if bar.tips > 0 { + Text("\(bar.tips)") + .font(.body.bold()) + Text("Tips") + .foregroundColor(.gray) + } } } } diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift @@ -252,7 +252,7 @@ struct EventView: View { let bar = make_actionbar_model(ev: event, damus: damus) - if size == .selected { + if size == .selected && !bar.is_empty { EventDetailBar(state: damus, target: event.id, bar: bar) Divider() .padding([.bottom], 4)