EventDetailBar.swift (3575B)
1 // 2 // EventDetailBar.swift 3 // damus 4 // 5 // Created by William Casarin on 2023-01-08. 6 // 7 8 import SwiftUI 9 10 struct EventDetailBar: View { 11 let state: DamusState 12 let target: NoteId 13 let target_pk: Pubkey 14 15 @ObservedObject var bar: ActionBarModel 16 17 init(state: DamusState, target: NoteId, target_pk: Pubkey) { 18 self.state = state 19 self.target = target 20 self.target_pk = target_pk 21 self._bar = ObservedObject(wrappedValue: make_actionbar_model(ev: target, damus: state)) 22 23 } 24 25 var body: some View { 26 HStack { 27 if bar.boosts > 0 { 28 NavigationLink(value: Route.Reposts(reposts: .reposts(state: state, target: target))) { 29 let nounString = pluralizedString(key: "reposts_count", count: bar.boosts) 30 let noun = Text(nounString).foregroundColor(.gray) 31 Text("\(Text(verbatim: bar.boosts.formatted()).font(.body.bold())) \(noun)", comment: "Sentence composed of 2 variables to describe how many reposts. In source English, the first variable is the number of reposts, and the second variable is 'Repost' or 'Reposts'.") 32 } 33 .buttonStyle(PlainButtonStyle()) 34 } 35 36 if bar.quote_reposts > 0 { 37 NavigationLink(value: Route.QuoteReposts(quotes: .quotes(state: state, target: target))) { 38 let nounString = pluralizedString(key: "quoted_reposts_count", count: bar.quote_reposts) 39 let noun = Text(nounString).foregroundColor(.gray) 40 Text("\(Text(verbatim: bar.quote_reposts.formatted()).font(.body.bold())) \(noun)", comment: "Sentence composed of 2 variables to describe how many quoted reposts. In source English, the first variable is the number of reposts, and the second variable is 'Repost' or 'Reposts'.") 41 } 42 .buttonStyle(PlainButtonStyle()) 43 } 44 45 if bar.likes > 0 && !state.settings.onlyzaps_mode { 46 NavigationLink(value: Route.Reactions(reactions: .likes(state: state, target: target))) { 47 let nounString = pluralizedString(key: "reactions_count", count: bar.likes) 48 let noun = Text(nounString).foregroundColor(.gray) 49 Text("\(Text(verbatim: bar.likes.formatted()).font(.body.bold())) \(noun)", comment: "Sentence composed of 2 variables to describe how many reactions there are on a post. In source English, the first variable is the number of reactions, and the second variable is 'Reaction' or 'Reactions'.") 50 } 51 .buttonStyle(PlainButtonStyle()) 52 } 53 54 if bar.zaps > 0 { 55 NavigationLink(value: Route.Zaps(target: .note(id: target, author: target_pk))) { 56 let nounString = pluralizedString(key: "zaps_count", count: bar.zaps) 57 let noun = Text(nounString).foregroundColor(.gray) 58 Text("\(Text(verbatim: bar.zaps.formatted()).font(.body.bold())) \(noun)", comment: "Sentence composed of 2 variables to describe how many zap payments there are on a post. In source English, the first variable is the number of zap payments, and the second variable is 'Zap' or 'Zaps'.") 59 } 60 .buttonStyle(PlainButtonStyle()) 61 } 62 } 63 } 64 } 65 66 struct EventDetailBar_Previews: PreviewProvider { 67 static var previews: some View { 68 EventDetailBar(state: test_damus_state, target: .empty, target_pk: .empty) 69 } 70 }