mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +02:00
Merge branch 'develop' into flescio/1040-poll_detail
# Conflicts: # Riot/Assets/en.lproj/Vector.strings # Riot/Generated/Strings.swift
This commit is contained in:
@@ -85,42 +85,32 @@ struct PollHistory: View {
|
||||
Button {
|
||||
#warning("handle action in next ticket")
|
||||
} label: {
|
||||
Text("Load more polls")
|
||||
Text(VectorL10n.pollHistoryLoadMore)
|
||||
.font(theme.fonts.body)
|
||||
}
|
||||
.disabled(viewModel.viewState.isLoading)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var spinner: some View {
|
||||
ProgressView()
|
||||
.progressViewStyle(CircularProgressViewStyle())
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var noPollsView: some View {
|
||||
if viewModel.viewState.canLoadMoreContent {
|
||||
let days = PollHistoryConstants.chunkSizeInDays
|
||||
|
||||
VStack(spacing: 32) {
|
||||
Text(viewModel.mode == .active ? VectorL10n.pollHistoryNoActivePollPeriodText("\(days)") : VectorL10n.pollHistoryNoPastPollPeriodText("\(days)"))
|
||||
.font(theme.fonts.body)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.horizontal, 16)
|
||||
.accessibilityIdentifier("PollHistory.emptyLoadMoreText")
|
||||
|
||||
loadMoreButton
|
||||
}
|
||||
.frame(maxHeight: .infinity)
|
||||
} else {
|
||||
Text(viewModel.mode == .active ? VectorL10n.pollHistoryNoActivePollText : VectorL10n.pollHistoryNoPastPollText)
|
||||
VStack(spacing: 32) {
|
||||
Text(viewModel.emptyPollsText)
|
||||
.font(theme.fonts.body)
|
||||
.multilineTextAlignment(.center)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
.frame(maxHeight: .infinity)
|
||||
.padding(.horizontal, 16)
|
||||
.accessibilityIdentifier("PollHistory.emptyText")
|
||||
|
||||
if viewModel.viewState.canLoadMoreContent {
|
||||
loadMoreButton
|
||||
}
|
||||
}
|
||||
.frame(maxHeight: .infinity)
|
||||
}
|
||||
|
||||
private var loadingView: some View {
|
||||
|
||||
@@ -48,56 +48,17 @@ struct PollListItem: View {
|
||||
if pollData.closed {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
let winningOptions = pollData.answerOptions.filter(\.winner)
|
||||
|
||||
ForEach(winningOptions) {
|
||||
optionView(winningOption: $0)
|
||||
TimelinePollAnswerOptionButton(poll: pollData, answerOption: $0, action: nil)
|
||||
}
|
||||
|
||||
resultView
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var clipShape: some Shape {
|
||||
RoundedRectangle(cornerRadius: 4.0)
|
||||
}
|
||||
|
||||
private func optionView(winningOption: TimelinePollAnswerOption) -> some View {
|
||||
VStack(alignment: .leading, spacing: 12.0) {
|
||||
HStack(alignment: .top, spacing: 8.0) {
|
||||
Text(winningOption.text)
|
||||
.font(theme.fonts.body)
|
||||
.foregroundColor(theme.colors.primaryContent)
|
||||
.accessibilityIdentifier("PollListData.winningOption")
|
||||
|
||||
Spacer()
|
||||
|
||||
votesText(winningOption: winningOption)
|
||||
}
|
||||
|
||||
ProgressView(value: Double(winningOption.count),
|
||||
total: Double(pollData.totalAnswerCount))
|
||||
.progressViewStyle(LinearProgressViewStyle())
|
||||
.scaleEffect(x: 1.0, y: 1.2, anchor: .center)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.horizontal, 8.0)
|
||||
.padding(.top, 12.0)
|
||||
.padding(.bottom, 12.0)
|
||||
.clipShape(clipShape)
|
||||
.overlay(clipShape.stroke(theme.colors.accent, lineWidth: 1.0))
|
||||
.accentColor(theme.colors.accent)
|
||||
}
|
||||
|
||||
private func votesText(winningOption: TimelinePollAnswerOption) -> some View {
|
||||
Label {
|
||||
Text(winningOption.count == 1 ? VectorL10n.pollTimelineOneVote : VectorL10n.pollTimelineVotesCount(Int(winningOption.count)))
|
||||
.font(theme.fonts.footnote)
|
||||
.foregroundColor(theme.colors.accent)
|
||||
} icon: {
|
||||
Image(uiImage: Asset.Images.pollWinnerIcon.image)
|
||||
}
|
||||
}
|
||||
|
||||
private var resultView: some View {
|
||||
let text = pollData.totalAnswerCount == 1 ? VectorL10n.pollTimelineTotalFinalResultsOneVote : VectorL10n.pollTimelineTotalFinalResults(Int(pollData.totalAnswerCount))
|
||||
|
||||
@@ -133,8 +94,7 @@ struct PollListItem_Previews: PreviewProvider {
|
||||
maxAllowedSelections: 1,
|
||||
hasBeenEdited: false,
|
||||
hasDecryptionError: false)
|
||||
|
||||
|
||||
|
||||
let pollData2 = TimelinePollDetails(id: UUID().uuidString,
|
||||
question: "Do you like polls?",
|
||||
answerOptions: [.init(id: "id", text: "Yes, of course!", count: 18, winner: true, selected: true)],
|
||||
|
||||
Reference in New Issue
Block a user