From 3deae1101c317375dbf1f14ddbcde8e40fa5a6c9 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL <46314705+mnaturel@users.noreply.github.com> Date: Tue, 3 Jan 2023 17:32:41 +0100 Subject: [PATCH] Adding extra data for ended poll --- .../roomprofile/polls/GetPollsUseCase.kt | 37 +++++++++++++++++-- .../features/roomprofile/polls/PollSummary.kt | 4 ++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/GetPollsUseCase.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/GetPollsUseCase.kt index 7346f8769c..6f2a757ed7 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/GetPollsUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/GetPollsUseCase.kt @@ -16,6 +16,7 @@ package im.vector.app.features.roomprofile.polls +import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.map @@ -64,19 +65,49 @@ class GetPollsUseCase @Inject constructor() { id = "id1-ended", // 2022/06/28 UTC+1 creationTimestamp = 1656367200000, - title = "Which charity would you like to support?" + title = "Which charity would you like to support?", + totalVotes = 22, + winnerOptions = listOf( + PollOptionViewState.PollEnded( + optionId = "id1", + optionAnswer = "Cancer research", + voteCount = 13, + votePercentage = 13 / 22.0, + isWinner = true, + ) + ), ), PollSummary.EndedPoll( id = "id2-ended", // 2022/06/26 UTC+1 creationTimestamp = 1656194400000, - title = "Where should we do the offsite?" + title = "Where should we do the offsite?", + totalVotes = 92, + winnerOptions = listOf( + PollOptionViewState.PollEnded( + optionId = "id1", + optionAnswer = "Hawaii", + voteCount = 43, + votePercentage = 43 / 92.0, + isWinner = true, + ) + ), ), PollSummary.EndedPoll( id = "id3-ended", // 2022/06/24 UTC+1 creationTimestamp = 1656021600000, - title = "What type of food should we have at the party?" + title = "What type of food should we have at the party?", + totalVotes = 22, + winnerOptions = listOf( + PollOptionViewState.PollEnded( + optionId = "id1", + optionAnswer = "Brazilian", + voteCount = 13, + votePercentage = 13 / 22.0, + isWinner = true, + ) + ), ), ) } diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/PollSummary.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/PollSummary.kt index 12ac97dc02..f24ac8b8a6 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/PollSummary.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/PollSummary.kt @@ -16,6 +16,8 @@ package im.vector.app.features.roomprofile.polls +import im.vector.app.features.home.room.detail.timeline.item.PollOptionViewState + sealed interface PollSummary { val id: String val creationTimestamp: Long @@ -31,5 +33,7 @@ sealed interface PollSummary { override val id: String, override val creationTimestamp: Long, override val title: String, + val totalVotes: Int, + val winnerOptions: List, ) : PollSummary }