From 6020bf7b441f81f6986e4ce9083d14ab7c0e4100 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 12 Dec 2023 16:44:30 +0100 Subject: [PATCH] Poll history : add empty state --- .../poll/impl/history/PollHistoryView.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt index e860cd1483..3b22eed41a 100644 --- a/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt +++ b/features/poll/impl/src/main/kotlin/io/element/android/features/poll/impl/history/PollHistoryView.kt @@ -123,6 +123,7 @@ fun PollHistoryView( val filter = PollHistoryFilter.entries[page] val pollHistoryItems = state.pollHistoryForFilter(filter) PollHistoryList( + filter = filter, pollHistoryItems = pollHistoryItems, hasMoreToLoad = state.hasMoreToLoad, isLoading = state.isLoading, @@ -160,6 +161,7 @@ private fun PollHistoryFilterButtons( @Composable private fun PollHistoryList( + filter: PollHistoryFilter, pollHistoryItems: ImmutableList, hasMoreToLoad: Boolean, isLoading: Boolean, @@ -184,6 +186,21 @@ private fun PollHistoryList( modifier = Modifier.padding(vertical = 8.dp, horizontal = 16.dp) ) } + if (pollHistoryItems.isEmpty()) { + item { + val emptyStringResource = if (filter == PollHistoryFilter.PAST) { + stringResource(R.string.screen_polls_history_empty_past) + } else { + stringResource(R.string.screen_polls_history_empty_ongoing) + } + Text( + text = emptyStringResource, + style = ElementTheme.typography.fontBodyLgRegular, + color = ElementTheme.colors.textSecondary, + modifier = Modifier.padding(vertical = 24.dp, horizontal = 16.dp) + ) + } + } if (hasMoreToLoad) { item { Button(