mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Polish polls UX (#1684)
* Fix bar color * Remove “final votes” string * Add haptic feedback for polls * Update compound package
This commit is contained in:
@@ -12,7 +12,7 @@ let package = Package(
|
||||
.library(name: "DesignKit", targets: ["DesignKit"])
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/vector-im/compound-ios", revision: "71b0c887880de639c854600a9ada6b5bcc93c719"),
|
||||
.package(url: "https://github.com/vector-im/compound-ios", revision: "cbb4e9edbc6489e883b67d1016eb90705e998ba5"),
|
||||
.package(url: "https://github.com/vector-im/element-design-tokens", exact: "0.0.3"),
|
||||
.package(url: "https://github.com/siteline/SwiftUI-Introspect", from: "0.9.0")
|
||||
],
|
||||
|
||||
@@ -5617,7 +5617,7 @@
|
||||
repositoryURL = "https://github.com/vector-im/compound-ios";
|
||||
requirement = {
|
||||
kind = revision;
|
||||
revision = 71b0c887880de639c854600a9ada6b5bcc93c719;
|
||||
revision = cbb4e9edbc6489e883b67d1016eb90705e998ba5;
|
||||
};
|
||||
};
|
||||
9A472EE0218FE7DCF5283429 /* XCRemoteSwiftPackageReference "SwiftUI-Introspect" */ = {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/vector-im/compound-ios",
|
||||
"state" : {
|
||||
"revision" : "71b0c887880de639c854600a9ada6b5bcc93c719"
|
||||
"revision" : "cbb4e9edbc6489e883b67d1016eb90705e998ba5"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -96,7 +96,6 @@
|
||||
"common_password" = "Password";
|
||||
"common_people" = "People";
|
||||
"common_permalink" = "Permalink";
|
||||
"common_poll_final_votes" = "Final votes: %1$@";
|
||||
"common_poll_total_votes" = "Total votes: %1$@";
|
||||
"common_poll_undisclosed_text" = "Results will show after the poll has ended";
|
||||
"common_privacy_policy" = "Privacy policy";
|
||||
|
||||
@@ -214,10 +214,6 @@ public enum L10n {
|
||||
public static var commonPeople: String { return L10n.tr("Localizable", "common_people") }
|
||||
/// Permalink
|
||||
public static var commonPermalink: String { return L10n.tr("Localizable", "common_permalink") }
|
||||
/// Final votes: %1$@
|
||||
public static func commonPollFinalVotes(_ p1: Any) -> String {
|
||||
return L10n.tr("Localizable", "common_poll_final_votes", String(describing: p1))
|
||||
}
|
||||
/// Total votes: %1$@
|
||||
public static func commonPollTotalVotes(_ p1: Any) -> String {
|
||||
return L10n.tr("Localizable", "common_poll_total_votes", String(describing: p1))
|
||||
|
||||
@@ -40,17 +40,13 @@ struct PollOptionView: View {
|
||||
}
|
||||
}
|
||||
|
||||
progressView
|
||||
PollProgressView(progress: progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private var progressView: some View {
|
||||
PollProgressView(progress: progress)
|
||||
}
|
||||
|
||||
private var progress: Double {
|
||||
switch (showVotes, pollOption.allVotes, pollOption.isSelected) {
|
||||
case (true, let allVotes, _) where allVotes > 0:
|
||||
@@ -74,7 +70,7 @@ private struct PollProgressView: View {
|
||||
GeometryReader { geometry in
|
||||
ZStack(alignment: .leading) {
|
||||
Capsule()
|
||||
.foregroundColor(.compound.borderDisabled)
|
||||
.foregroundColor(.compound._bgEmptyItemAlpha)
|
||||
|
||||
Capsule()
|
||||
.frame(maxWidth: progress * geometry.size.width)
|
||||
|
||||
@@ -23,6 +23,8 @@ struct PollRoomTimelineView: View {
|
||||
@ScaledMetric private var summaryPadding = 32
|
||||
@ScaledMetric private var iconSize = 22
|
||||
|
||||
private let feedbackGenerator = UIImpactFeedbackGenerator(style: .heavy)
|
||||
|
||||
var body: some View {
|
||||
TimelineStyler(timelineItem: timelineItem) {
|
||||
VStack(alignment: .leading, spacing: 16) {
|
||||
@@ -30,8 +32,9 @@ struct PollRoomTimelineView: View {
|
||||
|
||||
ForEach(poll.options, id: \.id) { option in
|
||||
Button {
|
||||
guard let eventID else { return }
|
||||
guard let eventID, !option.isSelected else { return }
|
||||
context.send(viewAction: .selectedPollOption(pollStartID: eventID, optionID: option.id))
|
||||
feedbackGenerator.impactOccurred()
|
||||
} label: {
|
||||
PollOptionView(pollOption: option,
|
||||
showVotes: showVotes,
|
||||
@@ -99,7 +102,7 @@ private extension Poll {
|
||||
var summaryText: String? {
|
||||
guard !hasEnded else {
|
||||
return options.first.map {
|
||||
L10n.commonPollFinalVotes($0.allVotes)
|
||||
L10n.commonPollTotalVotes($0.allVotes)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:6c85ea14e8c7399560a0e1cb808983a60e70431b8eee7c060515df8216b36790
|
||||
size 165644
|
||||
oid sha256:a540ae05fbea15546bcaed5b22ee582b94e83cc0408ed5a56dec25d56fbb3d4b
|
||||
size 165586
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:49703bc56ceb2c05edc04a3a963d22b109e64d644d6eff8f0d0c3bb9694d7177
|
||||
size 162836
|
||||
oid sha256:dc2a885aa81cd5679b42f4f8741a4b861d0f96571bbb9085fe16d051a8fba3b7
|
||||
size 162767
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f28aa90c1921e4a6d47f12ea66a608f1f36e893b46951c9a7b17b7d242598d13
|
||||
size 256763
|
||||
oid sha256:9defbd1b672e4c28f7081357fb57584d6d7a7b619c72f306c07cfb78db6d82b6
|
||||
size 256536
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7ce9878396fbdaae20932741b89c227f1534a5f7cb658f582839579b1802ff8b
|
||||
size 253727
|
||||
oid sha256:c04e8a7f52844ff3408a8a83cf285a58f40bbdeef32a2fda0896bf993ff85c83
|
||||
size 253455
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:854c4b00493f89988906fac51aa3bdc2a019779f5db335c0b0c8d5ffe596b980
|
||||
size 191462
|
||||
oid sha256:06701f44d87783df173d2a54f4df1119b8514865e4b17626c6a2eacdfd8efafd
|
||||
size 191314
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:959f3d9c3f866f5d9175a6a3a078d248a29d0003e5cbb23bf9a9c7750e9de6e7
|
||||
size 180430
|
||||
oid sha256:ceecae18977ab13a9d7cc0f56a26121021d38d97e3c544a56499d1b8885ebe13
|
||||
size 180169
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:dc48fc413d3647e3fe5ab461cf97e869767995a99be8b6d8fe3b8e1d72352449
|
||||
size 275889
|
||||
oid sha256:5363a709d79a849239fceb5d90ea456eb9d66dda3d25b4d89223d7e0c2b4baa0
|
||||
size 276181
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4673fc84f4630c58afd953338b0c5e9dfaf7dc17294bb4727148c6a30eac95c9
|
||||
size 268908
|
||||
oid sha256:5826907aa1fef35d8b051cde817117f494088d2aba909c2f4458edbcd2402d40
|
||||
size 269161
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ packages:
|
||||
path: DesignKit
|
||||
Compound:
|
||||
url: https://github.com/vector-im/compound-ios
|
||||
revision: 71b0c887880de639c854600a9ada6b5bcc93c719
|
||||
revision: cbb4e9edbc6489e883b67d1016eb90705e998ba5
|
||||
# path: ../compound-ios
|
||||
AnalyticsEvents:
|
||||
url: https://github.com/matrix-org/matrix-analytics-events
|
||||
|
||||
Reference in New Issue
Block a user