Refine loading logic

This commit is contained in:
Alfonso Grillo
2023-01-20 12:25:52 +01:00
parent 729da6d6e3
commit aea4770736
4 changed files with 29 additions and 11 deletions
@@ -33,6 +33,8 @@ struct PollHistory: View {
if viewModel.viewState.loadingState.isLoadingOnLanding {
loadingView
} else if viewModel.viewState.loadingState.isLoading == false, viewModel.viewState.polls.isEmpty {
noPollsView
} else {
pollListView
}
@@ -57,19 +59,30 @@ struct PollHistory: View {
PollListItem(pollData: pollData)
}
.frame(maxWidth: .infinity, alignment: .leading)
Button {
#warning("handle action")
} label: {
Text("Load more polls")
}
.frame(maxWidth: .infinity, alignment: .leading)
loadMoreButton
}
.padding(.top, 32)
.padding(.horizontal, 16)
}
}
private var loadMoreButton: some View {
HStack(spacing: 8) {
if viewModel.viewState.loadingState.isLoading {
ProgressView()
.progressViewStyle(CircularProgressViewStyle())
}
Button {
#warning("handle action")
} label: {
Text("Load more polls")
}
}
.frame(maxWidth: .infinity, alignment: .leading)
}
private var noPollsView: some View {
Text(viewModel.mode == .active ? VectorL10n.pollHistoryNoActivePollText : VectorL10n.pollHistoryNoPastPollText)
.font(theme.fonts.body)