ParicipantsView.swift (3704B)
1 // 2 // ParicipantsView.swift 3 // damus 4 // 5 // Created by Joel Klabo on 1/18/23. 6 // 7 8 import SwiftUI 9 10 struct ParticipantsView: View { 11 12 let damus_state: DamusState 13 14 @Binding var references: [ReferencedId] 15 @Binding var originalReferences: [ReferencedId] 16 17 var body: some View { 18 VStack { 19 Text("Replying to", comment: "Text indicating that the view is used for editing which participants are replied to in a note.") 20 .font(.headline) 21 HStack { 22 Spacer() 23 24 Button { 25 // Remove all "p" refs, keep "e" refs 26 references = originalReferences.eRefs 27 } label: { 28 Text("Remove all", comment: "Button label to remove all participants from a note reply.") 29 } 30 .font(.system(size: 14, weight: .bold)) 31 .frame(width: 100, height: 30) 32 .foregroundColor(.white) 33 .background(LINEAR_GRADIENT) 34 .clipShape(Capsule()) 35 36 Button { 37 references = originalReferences 38 } label: { 39 Text("Add all", comment: "Button label to re-add all original participants as profiles to reply to in a note") 40 } 41 .font(.system(size: 14, weight: .bold)) 42 .frame(width: 80, height: 30) 43 .foregroundColor(.white) 44 .background(LINEAR_GRADIENT) 45 .clipShape(Capsule()) 46 47 Spacer() 48 } 49 VStack { 50 ScrollView { 51 ForEach(originalReferences.pRefs) { participant in 52 let pubkey = participant.id 53 HStack { 54 ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles) 55 56 VStack(alignment: .leading) { 57 let profile = damus_state.profiles.lookup(id: pubkey) 58 ProfileName(pubkey: pubkey, profile: profile, damus: damus_state, show_friend_confirmed: false, show_nip5_domain: false) 59 if let about = profile?.about { 60 Text(FollowUserView.markdown.process(about)) 61 .lineLimit(3) 62 .font(.footnote) 63 } 64 } 65 66 Spacer() 67 68 Image(systemName: "checkmark.circle.fill") 69 .font(.system(size: 30)) 70 .foregroundColor(references.contains(participant) ? DamusColors.purple : .gray) 71 } 72 .onTapGesture { 73 if references.contains(participant) { 74 references = references.filter { 75 $0 != participant 76 } 77 } else { 78 if references.contains(participant) { 79 // Don't add it twice 80 } else { 81 references.append(participant) 82 } 83 } 84 } 85 } 86 } 87 } 88 Spacer() 89 } 90 .padding() 91 } 92 }