#compose I'm using paging 3 with compose to display a lazy list and I can display loading, error and...
a
#compose I'm using paging 3 with compose to display a lazy list and I can display loading, error and refreshing states but my problem that I want to display an empty view when there is no data (list size = 0)
Copy code
@Composable
fun HandlePagingError( loadState: CombinedLoadStates, onNoInternet: @Composable () -> Unit = {}, onEmptyView: @Composable () -> Unit = {} ) { when { loadState.refresh is LoadState.Loading -> { CircleLoading(loadingState = true, circleSize = 20.dp) } loadState.append is LoadState.NotLoading && loadState.append.endOfPaginationReached -> { onEmptyView() } loadState.append is LoadState.Loading -> { CircleLoading(loadingState = true, circleSize = 20.dp) } loadState.refresh is LoadState.Error -> { // val e = loadState.append as LoadState.Error onNoInternet() } loadState.append is LoadState.Error -> { val e = loadState.append as LoadState.Error val v = loadState.append.endOfPaginationReached Log.i("HandlePagingError: ", v.toString()) val error = getNetworkErrorFromThrowable(e.error) val messageError = when (error) { is Result.NetworkError.Generic -> getErrorType(error.type) Result.NetworkError.NoInternet -> stringResource(id = R.string.error_no_more_data) } TextUi( modifier = Modifier.fillMaxWidth(), text = messageError, textAlign = TextAlign.Center ) } } }
I wanna display this bell icon only when there is no data.