Refine polls UI in the timeline (#1474)

* Add summary view in PollRoomTimelineView

* Add selectedPollOption action

* Handle undisclosed polls

* Add more logics in PollRoomTimelineView

* Refine ended poll UI

* Refine poll layout

* More UI refinements

* Fix layout issue

* Refine progress bar

* Add poll mocks and UI tests

* Cleanup
This commit is contained in:
Alfonso Grillo
2023-08-11 12:25:16 +02:00
committed by GitHub
parent f64159670b
commit 25f66d2557
27 changed files with 465 additions and 144 deletions
@@ -333,16 +333,21 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
count + pair.value.count
}
let maxOptionVotes = votes.map(\.value.count).max()
let options = answers.map { answer in
Poll.Option(id: answer.id,
text: answer.text,
votes: votes[answer.id]?.count ?? 0,
allVotes: allVotes,
isSelected: votes[answer.id]?.contains(userID) ?? false)
let optionVotesCount = votes[answer.id]?.count
return Poll.Option(id: answer.id,
text: answer.text,
votes: optionVotesCount ?? 0,
allVotes: allVotes,
isSelected: votes[answer.id]?.contains(userID) ?? false,
isWinning: optionVotesCount.map { $0 == maxOptionVotes } ?? false)
}
let poll = Poll(question: question,
pollKind: .init(pollKind: pollKind),
kind: .init(pollKind: pollKind),
maxSelections: Int(maxSelections),
options: options,
votes: votes,