damus

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

MaybeAnonPfpView.swift (1505B)


      1 //
      2 //  MaybeAnonPfpView.swift
      3 //  damus
      4 //
      5 //  Created by William Casarin on 2023-02-26.
      6 //
      7 
      8 import SwiftUI
      9 
     10 struct MaybeAnonPfpView: View {
     11     let state: DamusState
     12     let is_anon: Bool
     13     let pubkey: Pubkey
     14     let size: CGFloat
     15     
     16     init(state: DamusState, is_anon: Bool, pubkey: Pubkey, size: CGFloat) {
     17         self.state = state
     18         self.is_anon = is_anon
     19         self.pubkey = pubkey
     20         self.size = size
     21     }
     22     
     23     var body: some View {
     24         ZStack {
     25             if is_anon {
     26                 Image("question")
     27                     .resizable()
     28                     .font(.largeTitle)
     29                     .frame(width: size, height: size)
     30             } else {
     31                 ProfilePicView(pubkey: pubkey, size: size, highlight: .none, profiles: state.profiles, disable_animation: state.settings.disable_animation, show_zappability: true)
     32                     .onTapGesture {
     33                         show_profile_action_sheet_if_enabled(damus_state: state, pubkey: pubkey)
     34                     }
     35                     .onLongPressGesture(minimumDuration: 0.1) {
     36                         UIImpactFeedbackGenerator(style: .medium).impactOccurred()
     37                         state.nav.push(route: Route.ProfileByKey(pubkey: pubkey))
     38                     }
     39             }
     40         }
     41     }
     42 }
     43 
     44 struct MaybeAnonPfpView_Previews: PreviewProvider {
     45     static var previews: some View {
     46         MaybeAnonPfpView(state: test_damus_state, is_anon: true, pubkey: ANON_PUBKEY, size: PFP_SIZE)
     47     }
     48 }