From d72fa02ac63f8b545512932f2e6e6ca527b851fc Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Wed, 27 Mar 2024 10:50:32 +0200 Subject: [PATCH] Fixes #2609 - Add trophy icon next to the winning poll option (#2610) * Fixes #2609 - Add trophy icon next to the winning poll option * Address PR comments --- .../images/poll-winner.imageset/Contents.json | 16 ++++++++++++++++ .../poll-winner.imageset/poll-winner.svg | 10 ++++++++++ ElementX/Sources/Generated/Assets.swift | 1 + .../RoomScreen/View/Polls/PollOptionView.swift | 18 +++++++++++++++--- .../test_pollOptionView-iPad-en-GB.1.png | 4 ++-- .../test_pollOptionView-iPad-pseudo.1.png | 4 ++-- .../test_pollOptionView-iPhone-15-en-GB.1.png | 4 ++-- .../test_pollOptionView-iPhone-15-pseudo.1.png | 4 ++-- changelog.d/2609.change | 1 + 9 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 ElementX/Resources/Assets.xcassets/images/poll-winner.imageset/Contents.json create mode 100644 ElementX/Resources/Assets.xcassets/images/poll-winner.imageset/poll-winner.svg create mode 100644 changelog.d/2609.change diff --git a/ElementX/Resources/Assets.xcassets/images/poll-winner.imageset/Contents.json b/ElementX/Resources/Assets.xcassets/images/poll-winner.imageset/Contents.json new file mode 100644 index 0000000000..6ac8a97944 --- /dev/null +++ b/ElementX/Resources/Assets.xcassets/images/poll-winner.imageset/Contents.json @@ -0,0 +1,16 @@ +{ + "images" : [ + { + "filename" : "poll-winner.svg", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "preserves-vector-representation" : true, + "template-rendering-intent" : "template" + } +} diff --git a/ElementX/Resources/Assets.xcassets/images/poll-winner.imageset/poll-winner.svg b/ElementX/Resources/Assets.xcassets/images/poll-winner.imageset/poll-winner.svg new file mode 100644 index 0000000000..5870cea782 --- /dev/null +++ b/ElementX/Resources/Assets.xcassets/images/poll-winner.imageset/poll-winner.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ElementX/Sources/Generated/Assets.swift b/ElementX/Sources/Generated/Assets.swift index 0d3120d350..2d45e58b76 100644 --- a/ElementX/Sources/Generated/Assets.swift +++ b/ElementX/Sources/Generated/Assets.swift @@ -43,6 +43,7 @@ internal enum Asset { internal static let mediaPause = ImageAsset(name: "images/media-pause") internal static let mediaPlay = ImageAsset(name: "images/media-play") internal static let notificationsPromptGraphic = ImageAsset(name: "images/notifications-prompt-graphic") + internal static let pollWinner = ImageAsset(name: "images/poll-winner") internal static let waitingGradient = ImageAsset(name: "images/waiting-gradient") } } diff --git a/ElementX/Sources/Screens/RoomScreen/View/Polls/PollOptionView.swift b/ElementX/Sources/Screens/RoomScreen/View/Polls/PollOptionView.swift index bfc70591ed..de9a78cbce 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/Polls/PollOptionView.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/Polls/PollOptionView.swift @@ -14,6 +14,7 @@ // limitations under the License. // +import Compound import SwiftUI struct PollOptionView: View { @@ -39,9 +40,20 @@ struct PollOptionView: View { .frame(maxWidth: .infinity, alignment: .leading) if showVotes { - Text(L10n.commonPollVotesCount(pollOption.votes)) - .font(isFinalWinningOption ? .compound.bodySMSemibold : .compound.bodySM) - .foregroundColor(isFinalWinningOption ? .compound.textPrimary : .compound.textSecondary) + if isFinalWinningOption { + HStack(spacing: 4) { + CompoundIcon(asset: Asset.Images.pollWinner) + .foregroundColor(.compound.iconAccentTertiary) + + Text(L10n.commonPollVotesCount(pollOption.votes)) + .font(.compound.bodySMSemibold) + .foregroundColor(.compound.textPrimary) + } + } else { + Text(L10n.commonPollVotesCount(pollOption.votes)) + .font(.compound.bodySM) + .foregroundColor(.compound.textSecondary) + } } } diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPad-en-GB.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPad-en-GB.1.png index b148c9bd15..db76bd77f2 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPad-en-GB.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPad-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d81cd655a0c738cad2b456efc640c37e9b65cd8692e6e8d3e543b12f904ae4d7 -size 98899 +oid sha256:8a5c9342e65f0c2bea1627e0c22c1a02184ea19741505df0b5b3b4504c29c300 +size 99626 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPad-pseudo.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPad-pseudo.1.png index 1b3e6eeebc..53a3aea27d 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPad-pseudo.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPad-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b77b83603ad4ca5b3083f5d12a322aaf47fe9a93ffd9fecbdbe157f9c8a14219 -size 114513 +oid sha256:14e52190430b1b052f4afbeaf215920113d08fef8664661b97bfa00436f286ba +size 115312 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPhone-15-en-GB.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPhone-15-en-GB.1.png index 22c8d2ffc5..ef55a741cd 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPhone-15-en-GB.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPhone-15-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6645504124fe64a3374a117512540deddb07a2354a6a36df409c6f77764b5f42 -size 56089 +oid sha256:5147fe5f373d38125a6768b9d9f96988a25755d21c4a1eadc4ead76c6cddecba +size 56849 diff --git a/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPhone-15-pseudo.1.png b/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPhone-15-pseudo.1.png index 435c4a4f18..44471651e1 100644 --- a/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPhone-15-pseudo.1.png +++ b/PreviewTests/__Snapshots__/PreviewTests/test_pollOptionView-iPhone-15-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e03246347b59115c7ec2df9411bbc8eaf439cd24b5697e926783e2b69f313eb9 -size 71551 +oid sha256:102e94a24fd386047e2677d8e9c582bb9accf47b474d227717b77960bbc432a6 +size 72110 diff --git a/changelog.d/2609.change b/changelog.d/2609.change new file mode 100644 index 0000000000..249435e1f3 --- /dev/null +++ b/changelog.d/2609.change @@ -0,0 +1 @@ +Add trophy icon next to the winning poll option \ No newline at end of file