@Composable public fun ChannelList( channelsState: ChannelsState,currentUser: User?,modifier: Modifier = Modifier,contentPadding: PaddingValues = PaddingValues(0.dp),lazyListState: LazyListState = rememberLazyListState(),onLastItemReached: () -> Unit = {},onChannelClick: (Channel) -> Unit = {},onChannelLongClick: (Channel) -> Unit = {},loadingContent: @Composable () -> Unit = { DefaultChannelListLoadingIndicator(modifier) },emptyContent: @Composable () -> Unit = { DefaultChannelListEmptyContent(modifier) },emptySearchContent: @Composable (String) -> Unit = { searchQuery ->DefaultChannelSearchEmptyContent(searchQuery = searchQuery,modifier = modifier)},helperContent: @Composable BoxScope.() -> Unit = {},loadingMoreContent: @Composable () -> Unit = {DefaultChannelsLoadingMoreIndicator() },itemContent: @Composable (ChannelItemState) -> Unit = { channelItem ->DefaultChannelItem(channelItem = channelItem,currentUser = currentUser,onChannelClick = onChannelClick,onChannelLongClick = onChannelLongClick)},divider: @Composable () -> Unit = { DefaultChannelItemDivider() },) {val (isLoading, _, _, channels, searchQuery) = channelsState when {isLoading -> loadingContent() !isLoading && channels.isNotEmpty() -> Channels( modifier = modifier, contentPadding = contentPadding, channelsState = channelsState, lazyListState = lazyListState, onLastItemReached = onLastItemReached, helperContent = helperContent, loadingMoreContent = loadingMoreContent, itemContent = itemContent, divider = divider searchQuery.isNotEmpty() -> emptySearchContent(searchQuery) else -> emptyContent()} }
Root Channel list component, that represents different UI, based on the current channel state.This is decoupled from ViewModels, so the user can provide manual and custom data handling,as well as define a completely custom UI component for the channel item.If there is no state, no query active or the data is being loaded, we show the [LoadingIndicator].If there are no results or we're offline, usually due to an error in the API or network, we show an [EmptyContent]. If there is data available and it is not empty, we show [Channels].