mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user