Polish polls UX (#1684)

* Fix bar color

* Remove “final votes” string

* Add haptic feedback for polls

* Update compound package
This commit is contained in:
Alfonso Grillo
2023-09-11 16:52:26 +02:00
committed by GitHub
parent 1279c11efc
commit f8c785ae51
16 changed files with 27 additions and 33 deletions
@@ -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)
}
}