Browse Source

add pfps to the participants view

remove-participants
William Casarin 2 years ago
parent
commit
e1e1022b7b
  1. 58
      damus/Views/ParicipantsView.swift

58
damus/Views/ParicipantsView.swift

@ -30,23 +30,7 @@ struct ParticipantsView: View {
} }
} }
ForEach(originalParticipants) { participant in ForEach(originalParticipants) { participant in
HStack { ParticipantView(damus_state: damus, participant: participant, participants: $participants)
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.append(participant)
}
}
} }
Spacer() Spacer()
} }
@ -54,23 +38,49 @@ struct ParticipantsView: View {
} }
} }
struct ParticipantView: View { struct ParticipantView: View {
let damus: DamusState let damus_state: DamusState
let participant: ReferencedId let participant: ReferencedId
@State var isParticipating: Bool = true @Binding var participants: [ReferencedId]
@State var participating: Bool = true
var pubkey: String {
participant.id
}
var body: some View { var body: some View {
HStack { HStack {
let pk = participant.ref_id ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles)
let prof = damus.profiles.lookup(id: pk)
Text(Profile.displayName(profile: prof, pubkey: pk)) VStack(alignment: .leading) {
let profile = damus_state.profiles.lookup(id: pubkey)
ProfileName(pubkey: pubkey, profile: profile, damus: damus_state, show_friend_confirmed: false, show_nip5_domain: false)
if let about = profile?.about {
Text(FollowUserView.markdown.process(about))
.lineLimit(3)
.font(.footnote)
}
}
Spacer() Spacer()
Image(systemName: "checkmark.circle.fill") Image(systemName: "checkmark.circle.fill")
.foregroundColor(isParticipating ? .purple : .gray) .font(.system(size: 30))
.foregroundColor(participating ? .purple : .gray)
} }
.onTapGesture { .onTapGesture {
isParticipating.toggle() if participants.contains(participant) {
participants = participants.filter {
$0 != participant
}
participating = false
} else {
participants.append(participant)
participating = true
}
} }
} }
} }

Loading…
Cancel
Save