damus

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

UserView.swift (1557B)


      1 //
      2 //  UserView.swift
      3 //  damus
      4 //
      5 //  Created by William Casarin on 2023-01-25.
      6 //
      7 
      8 import SwiftUI
      9 
     10 struct UserViewRow: View {
     11     let damus_state: DamusState
     12     let pubkey: Pubkey
     13 
     14     var body: some View {
     15         UserView(damus_state: damus_state, pubkey: pubkey)
     16             .contentShape(Rectangle())
     17             .background(.clear)
     18     }
     19 }
     20 
     21 struct UserView: View {
     22     let damus_state: DamusState
     23     let pubkey: Pubkey
     24     let spacer: Bool
     25     
     26     @State var about_text: Text? = nil
     27     
     28     init(damus_state: DamusState, pubkey: Pubkey, spacer: Bool = true) {
     29         self.damus_state = damus_state
     30         self.pubkey = pubkey
     31         self.spacer = spacer
     32     }
     33     
     34     var body: some View {
     35         VStack {
     36             HStack {
     37                 ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles, disable_animation: damus_state.settings.disable_animation)
     38             
     39                 VStack(alignment: .leading) {
     40                     ProfileName(pubkey: pubkey, damus: damus_state, show_nip5_domain: false)
     41                     if let about_text {
     42                         about_text
     43                             .lineLimit(3)
     44                             .font(.footnote)
     45                     }
     46                 }
     47                 
     48                 if spacer {
     49                     Spacer()
     50                 }
     51             }
     52         }
     53     }
     54 }
     55 
     56 struct UserView_Previews: PreviewProvider {
     57     static var previews: some View {
     58         UserView(damus_state: test_damus_state, pubkey: test_note.pubkey)
     59     }
     60 }