Browse Source

Add All / Remove All

remove-participants
Joel Klabo 2 years ago
parent
commit
162e83ff28
  1. 35
      damus/Views/ParicipantsView.swift
  2. 9
      damus/Views/ReplyView.swift

35
damus/Views/ParicipantsView.swift

@ -16,23 +16,47 @@ struct ParticipantsView: View {
var body: some View {
VStack {
Text("Edit participants")
HStack {
Button {
participants = []
} label: {
Text("Remove all")
}
Button {
participants = originalParticipants
} label: {
Text("Add all")
}
}
ForEach(originalParticipants) { participant in
ParticipantView(damus: damus, participant: participant) { participant, added in
if added {
participants.append(participant)
HStack {
let pk = participant.ref_id
let prof = damus.profiles.lookup(id: pk)
Text(Profile.displayName(profile: prof, pubkey: pk))
Spacer()
Image(systemName: "checkmark.circle.fill")
.foregroundColor(participants.contains(participant) ? .purple : .gray)
}
.onTapGesture {
if participants.contains(participant) {
participants = participants.filter {
$0 != participant
}
} else {
participants = participants.filter { $0 != participant }
participants.append(participant)
}
}
}
Spacer()
}
.padding()
}
}
struct ParticipantView: View {
let damus: DamusState
let participant: ReferencedId
let onRemove: (ReferencedId, Bool) -> ()
@State var isParticipating: Bool = true
@ -47,7 +71,6 @@ struct ParticipantView: View {
}
.onTapGesture {
isParticipating.toggle()
onRemove(participant, isParticipating)
}
}
}

9
damus/Views/ReplyView.swift

@ -21,6 +21,8 @@ struct ReplyView: View {
@State var originalParticipants: [ReferencedId] = []
@State var participants: [ReferencedId] = []
@State var participantsShown: Bool = false
var body: some View {
VStack {
Text("Replying to:", comment: "Indicating that the user is replying to the following listed people.")
@ -36,9 +38,14 @@ struct ReplyView: View {
.foregroundColor(.gray)
.font(.footnote)
}
.onTapGesture {
participantsShown.toggle()
}
.sheet(isPresented: $participantsShown) {
ParticipantsView(damus: damus, participants: $participants, originalParticipants: $originalParticipants)
}
ScrollView {
EventView(event: replying_to, highlight: .none, has_action_bar: false, damus: damus, show_friend_icon: true)
ParticipantsView(damus: damus, participants: $participants, originalParticipants: $originalParticipants)
}
PostView(replying_to: replying_to, references: participants)
}

Loading…
Cancel
Save