mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user