From e1e1022b7b31d6d90adb0069da6fd799291b85db Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 19 Jan 2023 10:40:27 -0800 Subject: [PATCH] add pfps to the participants view --- damus/Views/ParicipantsView.swift | 58 ++++++++++++++++++------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/damus/Views/ParicipantsView.swift b/damus/Views/ParicipantsView.swift index 37bb17f..4559faf 100644 --- a/damus/Views/ParicipantsView.swift +++ b/damus/Views/ParicipantsView.swift @@ -30,23 +30,7 @@ struct ParticipantsView: View { } } ForEach(originalParticipants) { participant in - 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.append(participant) - } - } + ParticipantView(damus_state: damus, participant: participant, participants: $participants) } Spacer() } @@ -54,23 +38,49 @@ struct ParticipantsView: View { } } + struct ParticipantView: View { - let damus: DamusState + let damus_state: DamusState 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 { HStack { - let pk = participant.ref_id - let prof = damus.profiles.lookup(id: pk) - Text(Profile.displayName(profile: prof, pubkey: pk)) + ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles) + + 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() + Image(systemName: "checkmark.circle.fill") - .foregroundColor(isParticipating ? .purple : .gray) + .font(.system(size: 30)) + .foregroundColor(participating ? .purple : .gray) } .onTapGesture { - isParticipating.toggle() + if participants.contains(participant) { + participants = participants.filter { + $0 != participant + } + participating = false + } else { + participants.append(participant) + participating = true + } } } }