mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-27 11:46:58 +02:00
Customize TimePollView for poll.end events
This commit is contained in:
@@ -131,6 +131,7 @@ final class TimelinePollCoordinator: Coordinator, Presentable, PollAggregatorDel
|
||||
closed: poll.isClosed,
|
||||
totalAnswerCount: poll.totalAnswerCount,
|
||||
type: pollKindToTimelinePollType(poll.kind),
|
||||
eventType: parameters.pollEvent.eventType == .pollStart ? .started : .ended,
|
||||
maxAllowedSelections: poll.maxAllowedSelections,
|
||||
hasBeenEdited: poll.hasBeenEdited,
|
||||
hasDecryptionError: poll.hasDecryptionError)
|
||||
|
||||
@@ -32,6 +32,11 @@ enum TimelinePollType {
|
||||
case undisclosed
|
||||
}
|
||||
|
||||
enum TimelinePollEventType {
|
||||
case started
|
||||
case ended
|
||||
}
|
||||
|
||||
struct TimelinePollAnswerOption: Identifiable {
|
||||
var id: String
|
||||
var text: String
|
||||
@@ -62,6 +67,7 @@ struct TimelinePollDetails {
|
||||
var closed: Bool
|
||||
var totalAnswerCount: UInt
|
||||
var type: TimelinePollType
|
||||
var eventType: TimelinePollEventType
|
||||
var maxAllowedSelections: UInt
|
||||
var hasBeenEdited = true
|
||||
var hasDecryptionError: Bool
|
||||
@@ -70,6 +76,7 @@ struct TimelinePollDetails {
|
||||
closed: Bool,
|
||||
totalAnswerCount: UInt,
|
||||
type: TimelinePollType,
|
||||
eventType: TimelinePollEventType,
|
||||
maxAllowedSelections: UInt,
|
||||
hasBeenEdited: Bool,
|
||||
hasDecryptionError: Bool) {
|
||||
@@ -78,6 +85,7 @@ struct TimelinePollDetails {
|
||||
self.closed = closed
|
||||
self.totalAnswerCount = totalAnswerCount
|
||||
self.type = type
|
||||
self.eventType = eventType
|
||||
self.maxAllowedSelections = maxAllowedSelections
|
||||
self.hasBeenEdited = hasBeenEdited
|
||||
self.hasDecryptionError = hasDecryptionError
|
||||
@@ -94,6 +102,10 @@ struct TimelinePollDetails {
|
||||
return type == .disclosed && totalAnswerCount > 0 && hasCurrentUserVoted
|
||||
}
|
||||
}
|
||||
|
||||
var representsPollEndedEvent: Bool {
|
||||
eventType == .ended
|
||||
}
|
||||
}
|
||||
|
||||
struct TimelinePollViewState: BindableState {
|
||||
|
||||
@@ -22,6 +22,7 @@ enum MockTimelinePollScreenState: MockScreenState, CaseIterable {
|
||||
case closedDisclosed
|
||||
case openUndisclosed
|
||||
case closedUndisclosed
|
||||
case closedPollEnded
|
||||
|
||||
var screenType: Any.Type {
|
||||
TimelinePollDetails.self
|
||||
@@ -37,6 +38,7 @@ enum MockTimelinePollScreenState: MockScreenState, CaseIterable {
|
||||
closed: self == .closedDisclosed || self == .closedUndisclosed ? true : false,
|
||||
totalAnswerCount: 20,
|
||||
type: self == .closedDisclosed || self == .openDisclosed ? .disclosed : .undisclosed,
|
||||
eventType: self == .closedPollEnded ? .ended : .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
hasDecryptionError: false)
|
||||
|
||||
@@ -151,6 +151,7 @@ struct TimelinePollAnswerOptionButton_Previews: PreviewProvider {
|
||||
closed: closed,
|
||||
totalAnswerCount: 100,
|
||||
type: type,
|
||||
eventType: .started,
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
hasDecryptionError: false)
|
||||
|
||||
@@ -31,6 +31,12 @@ struct TimelinePollView: View {
|
||||
let poll = viewModel.viewState.poll
|
||||
|
||||
VStack(alignment: .leading, spacing: 16.0) {
|
||||
if poll.representsPollEndedEvent {
|
||||
Text(VectorL10n.pollTimelineEndedText)
|
||||
.font(theme.fonts.footnote)
|
||||
.foregroundColor(theme.colors.tertiaryContent)
|
||||
}
|
||||
|
||||
Text(poll.question)
|
||||
.font(theme.fonts.bodySB)
|
||||
.foregroundColor(theme.colors.primaryContent) +
|
||||
|
||||
Reference in New Issue
Block a user