damus

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

ParticipantsView.swift (2544B)


      1 //
      2 //  ParticipantsView.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     let original_pubkeys: [Pubkey]
     14 
     15     @Binding var filtered_pubkeys: Set<Pubkey>
     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                     filtered_pubkeys = Set(original_pubkeys)
     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                     filtered_pubkeys = []
     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(original_pubkeys) { pubkey in
     52                         HStack {
     53                             UserView(damus_state: damus_state, pubkey: pubkey)
     54                             
     55                             Image("check-circle.fill")
     56                                 .font(.system(size: 30))
     57                                 .foregroundColor(filtered_pubkeys.contains(pubkey) ? .gray : DamusColors.purple)
     58                         }
     59                         .onTapGesture {
     60                             if filtered_pubkeys.contains(pubkey) {
     61                                 filtered_pubkeys.remove(pubkey)
     62                             } else {
     63                                 filtered_pubkeys.insert(pubkey)
     64                             }
     65                         }
     66                     }                    
     67                 }
     68             }
     69             Spacer()
     70         }
     71         .padding()
     72     }
     73 }