damus

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

ZapEvent.swift (2198B)


      1 //
      2 //  ZapEvent.swift
      3 //  damus
      4 //
      5 //  Created by William Casarin on 2023-02-03.
      6 //
      7 
      8 import SwiftUI
      9 
     10 struct ZapEvent: View {
     11     let damus: DamusState
     12     let zap: Zapping
     13     let is_top_zap: Bool
     14     
     15     var body: some View {
     16         VStack(alignment: .leading) {
     17             HStack(alignment: .center) {
     18                 Image("zap.fill")
     19                     .foregroundColor(.orange)
     20                 
     21                 Text(verbatim: format_msats(zap.amount))
     22                     .font(.headline)
     23                 
     24                 if is_top_zap {
     25                     Text("Top Zap", comment: "Text indicating that this zap is the one with the highest amount of sats.")
     26                         .font(.caption)
     27                         .foregroundColor(.gray)
     28                         .padding([.top], 2)
     29                 }
     30                 
     31                 if zap.is_private {
     32                     Image("lock")
     33                         .foregroundColor(DamusColors.green)
     34                         .help(NSLocalizedString("Only you can see this message and who sent it.", comment: "Help text on green lock icon that explains that only the current user can see the message of a zap event and who sent the zap."))
     35                 }
     36                 
     37                 if zap.is_pending {
     38                     Image(systemName: "clock.arrow.circlepath")
     39                         .foregroundColor(zap.is_paid ? Color.orange : DamusColors.yellow)
     40                         .help(NSLocalizedString("Only you can see this message and who sent it.", comment: "Help text on green lock icon that explains that only the current user can see the message of a zap event and who sent the zap."))
     41                 }
     42             }
     43 
     44             TextEvent(damus: damus, event: zap.request.ev, pubkey: zap.request.ev.pubkey, options: [.no_action_bar, .no_replying_to])
     45                 .padding([.top], 1)
     46         }
     47     }
     48 }
     49 
     50 
     51 struct ZapEvent_Previews: PreviewProvider {
     52     static var previews: some View {
     53         VStack {
     54             ZapEvent(damus: test_damus_state, zap: .zap(test_zap), is_top_zap: true)
     55             
     56             ZapEvent(damus: test_damus_state, zap: .zap(test_private_zap), is_top_zap: false)
     57         }
     58     }
     59 }