From 69711bf3163d305a677feddda1c40ae630cbeeb2 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 26 Mar 2024 17:56:25 +0100 Subject: [PATCH] Add trophy icon next the the winner vote in polls. --- changelog.d/2608.misc | 1 + .../poll/api/pollcontent/PollAnswerView.kt | 38 ++++++++++++++----- .../src/main/res/drawable/ic_winner.xml | 28 ++++++++++++++ 3 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 changelog.d/2608.misc create mode 100644 libraries/designsystem/src/main/res/drawable/ic_winner.xml diff --git a/changelog.d/2608.misc b/changelog.d/2608.misc new file mode 100644 index 0000000000..aa2f48b5cc --- /dev/null +++ b/changelog.d/2608.misc @@ -0,0 +1 @@ + Make completed poll more clearly visible diff --git a/features/poll/api/src/main/kotlin/io/element/android/features/poll/api/pollcontent/PollAnswerView.kt b/features/poll/api/src/main/kotlin/io/element/android/features/poll/api/pollcontent/PollAnswerView.kt index 4f230eeaf6..70658e65a8 100644 --- a/features/poll/api/src/main/kotlin/io/element/android/features/poll/api/pollcontent/PollAnswerView.kt +++ b/features/poll/api/src/main/kotlin/io/element/android/features/poll/api/pollcontent/PollAnswerView.kt @@ -41,6 +41,7 @@ import io.element.android.libraries.designsystem.theme.components.LinearProgress import io.element.android.libraries.designsystem.theme.components.Text import io.element.android.libraries.designsystem.theme.progressIndicatorTrackColor import io.element.android.libraries.designsystem.toEnabledColor +import io.element.android.libraries.designsystem.utils.CommonDrawables import io.element.android.libraries.ui.strings.CommonPlurals @Composable @@ -80,16 +81,35 @@ internal fun PollAnswerView( style = if (answerItem.isWinner) ElementTheme.typography.fontBodyLgMedium else ElementTheme.typography.fontBodyLgRegular, ) if (answerItem.showVotes) { - Text( - modifier = Modifier.align(Alignment.Bottom), - text = pluralStringResource( - id = CommonPlurals.common_poll_votes_count, - count = answerItem.votesCount, - answerItem.votesCount - ), - style = if (answerItem.isWinner) ElementTheme.typography.fontBodySmMedium else ElementTheme.typography.fontBodySmRegular, - color = if (answerItem.isWinner) ElementTheme.colors.textPrimary else ElementTheme.colors.textSecondary, + val text = pluralStringResource( + id = CommonPlurals.common_poll_votes_count, + count = answerItem.votesCount, + answerItem.votesCount ) + Row( + modifier = Modifier.align(Alignment.Bottom), + verticalAlignment = Alignment.CenterVertically, + ) { + if (answerItem.isWinner) { + Icon( + resourceId = CommonDrawables.ic_winner, + contentDescription = null, + tint = ElementTheme.colors.iconAccentTertiary, + ) + Spacer(modifier = Modifier.width(2.dp)) + Text( + text = text, + style = ElementTheme.typography.fontBodySmMedium, + color = ElementTheme.colors.textPrimary, + ) + } else { + Text( + text = text, + style = ElementTheme.typography.fontBodySmRegular, + color = ElementTheme.colors.textSecondary, + ) + } + } } } Spacer(modifier = Modifier.height(10.dp)) diff --git a/libraries/designsystem/src/main/res/drawable/ic_winner.xml b/libraries/designsystem/src/main/res/drawable/ic_winner.xml new file mode 100644 index 0000000000..20754ecfe8 --- /dev/null +++ b/libraries/designsystem/src/main/res/drawable/ic_winner.xml @@ -0,0 +1,28 @@ + + + + + + + +