mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +02:00
Handle empty poll list case
This commit is contained in:
@@ -37,24 +37,10 @@ struct PollHistory: View {
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
|
||||
ScrollView {
|
||||
LazyVStack(spacing: 32) {
|
||||
let enumeratedPolls = Array(viewModel.viewState.polls.enumerated())
|
||||
|
||||
ForEach(enumeratedPolls, id: \.offset) { _, pollData in
|
||||
PollListItem(pollData: pollData)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Button {
|
||||
#warning("handle action")
|
||||
} label: {
|
||||
Text("Load more polls")
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.top, 32)
|
||||
if viewModel.viewState.polls.isEmpty {
|
||||
noPollsView
|
||||
} else {
|
||||
pollListView
|
||||
}
|
||||
}
|
||||
.padding(.top, 32)
|
||||
@@ -66,6 +52,36 @@ struct PollHistory: View {
|
||||
viewModel.send(viewAction: .viewAppeared)
|
||||
}
|
||||
}
|
||||
|
||||
private var pollListView: some View {
|
||||
ScrollView {
|
||||
LazyVStack(spacing: 32) {
|
||||
let enumeratedPolls = Array(viewModel.viewState.polls.enumerated())
|
||||
|
||||
ForEach(enumeratedPolls, id: \.offset) { _, pollData in
|
||||
PollListItem(pollData: pollData)
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Button {
|
||||
#warning("handle action")
|
||||
} label: {
|
||||
Text("Load more polls")
|
||||
}
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
.padding(.top, 32)
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
}
|
||||
|
||||
private var noPollsView: some View {
|
||||
Text(viewModel.mode == .active ? VectorL10n.pollHistoryNoActivePollText : VectorL10n.pollHistoryNoPastPollText)
|
||||
.font(theme.fonts.body)
|
||||
.foregroundColor(theme.colors.secondaryContent)
|
||||
.frame(maxHeight: .infinity)
|
||||
.padding(.horizontal, 16)
|
||||
}
|
||||
}
|
||||
|
||||
private extension PollHistoryMode {
|
||||
|
||||
Reference in New Issue
Block a user