mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Vote on a poll and end a poll (#1597)
* Fix project file * Add vote and end poll actions * Handle redaction * Fix local echo behavior * Cleanup * Fix UI tests * Add localisation * Cleanup * Fix end poll action style
This commit is contained in:
@@ -29,14 +29,15 @@ struct PollRoomTimelineView: View {
|
||||
|
||||
ForEach(poll.options, id: \.id) { option in
|
||||
Button {
|
||||
context.send(viewAction: .selectedPollOption(poll: poll, optionID: option.id))
|
||||
guard let eventID else { return }
|
||||
context.send(viewAction: .selectedPollOption(pollStartID: eventID, optionID: option.id))
|
||||
} label: {
|
||||
PollOptionView(pollOption: option,
|
||||
showVotes: showVotes,
|
||||
isFinalResult: poll.hasEnded)
|
||||
.foregroundColor(progressBarColor(for: option))
|
||||
}
|
||||
.disabled(poll.hasEnded)
|
||||
.disabled(poll.hasEnded || eventID == nil)
|
||||
}
|
||||
|
||||
summaryView
|
||||
@@ -51,6 +52,10 @@ struct PollRoomTimelineView: View {
|
||||
timelineItem.poll
|
||||
}
|
||||
|
||||
private var eventID: String? {
|
||||
timelineItem.id.eventID
|
||||
}
|
||||
|
||||
private var questionView: some View {
|
||||
HStack(alignment: .top, spacing: 12) {
|
||||
Image(Asset.Images.timelinePoll.name)
|
||||
@@ -102,10 +107,6 @@ private extension Poll {
|
||||
return L10n.commonPollUndisclosedText
|
||||
}
|
||||
}
|
||||
|
||||
var hasEnded: Bool {
|
||||
endDate != nil
|
||||
}
|
||||
}
|
||||
|
||||
struct PollRoomTimelineView_Previews: PreviewProvider {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Compound
|
||||
import SwiftUI
|
||||
|
||||
struct TimelineItemMenuActions {
|
||||
@@ -51,6 +52,7 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
||||
case retryDecryption(sessionID: String)
|
||||
case report
|
||||
case react
|
||||
case endPoll(pollStartID: String)
|
||||
|
||||
var id: Self { self }
|
||||
|
||||
@@ -107,6 +109,7 @@ enum TimelineItemMenuAction: Identifiable, Hashable {
|
||||
case .retryDecryption: return Label(L10n.actionRetryDecryption, systemImage: "arrow.down.message")
|
||||
case .report: return Label(L10n.actionReportContent, systemImage: "exclamationmark.bubble")
|
||||
case .react: return Label(L10n.actionReact, systemImage: "hand.thumbsup")
|
||||
case .endPoll: return Label { Text(L10n.actionEndPoll) } icon: { Image.compound.check.resizable() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user