Only show EventDetailBar if we have tips/likes/reposts

This commit is contained in:
William Casarin
2023-01-13 10:07:27 -08:00
parent abd5856f21
commit d59331bc3c
3 changed files with 25 additions and 12 deletions

View File

@@ -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
}

View File

@@ -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)
}
}
}
}

View File

@@ -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)