CondensedProfilePicturesView.swift (1299B)
1 // 2 // CondensedProfilePicturesView.swift 3 // damus 4 // 5 // Created by Terry Yiu on 6/19/23. 6 // 7 8 import SwiftUI 9 10 struct CondensedProfilePicturesView: View { 11 let state: DamusState 12 let pubkeys: [Pubkey] 13 let maxPictures: Int 14 15 init(state: DamusState, pubkeys: [Pubkey], maxPictures: Int) { 16 self.state = state 17 self.pubkeys = pubkeys 18 self.maxPictures = min(maxPictures, pubkeys.count) 19 } 20 21 var body: some View { 22 // Using ZStack to make profile pictures floating and stacked on top of each other. 23 ZStack { 24 ForEach((0..<maxPictures).reversed(), id: \.self) { index in 25 ProfilePicView(pubkey: pubkeys[index], size: 32.0, highlight: .none, profiles: state.profiles, disable_animation: state.settings.disable_animation) 26 .offset(x: CGFloat(index) * 20) 27 } 28 } 29 // Padding is needed so that other components drawn adjacent to this view don't get drawn on top. 30 .padding(.trailing, CGFloat((maxPictures - 1) * 20)) 31 } 32 } 33 34 struct CondensedProfilePicturesView_Previews: PreviewProvider { 35 static var previews: some View { 36 CondensedProfilePicturesView(state: test_damus_state, pubkeys: [test_pubkey, test_pubkey, test_pubkey, test_pubkey], maxPictures: 3) 37 } 38 }