ThreadList

fun ThreadList(viewModel: ThreadListViewModel, modifier: Modifier = Modifier, currentUser: User? = ChatClient.instance().getCurrentUser(), onUnreadThreadsBannerClick: () -> Unit = { viewModel.load() }, onThreadClick: (Thread) -> Unit = {}, onLoadMore: () -> Unit = { viewModel.loadNextPage() }, unreadThreadsBanner: @Composable (Int) -> Unit = { DefaultUnreadThreadsBanner(it, onClick = onUnreadThreadsBannerClick) }, itemContent: @Composable (Thread) -> Unit = { DefaultThreadItem(it, currentUser, onThreadClick) }, emptyContent: @Composable () -> Unit = { DefaultThreadListEmptyContent(modifier) }, loadingContent: @Composable () -> Unit = { DefaultThreadListLoadingContent(modifier) }, loadingMoreContent: @Composable () -> Unit = { DefaultThreadListLoadingMoreContent() })

Composable rendering a paginated list of threads. Optionally, it renders a banner informing about new threads/thread messages outside of the loaded pages of threads.

Parameters

viewModel

The ThreadListViewModel handling the loading of the threads.

modifier

Modifier instance for general styling.

currentUser

The currently logged User, used for formatting the message in the thread preview.

onUnreadThreadsBannerClick

Action invoked when the user clicks on the "Unread threads" banner. By default, it calls ThreadListViewModel.load to force reload the list of threads, loading the newly created/updated threads.

onThreadClick

Action invoked when the usr clicks on a thread item in the list. No-op by default.

onLoadMore

Action invoked when the current thread page was scrolled to the end, and a next page should be loaded. By default, it calls ThreadListViewModel.loadNextPage to load the next page of threads.

unreadThreadsBanner

Composable rendering the "Unread threads" banner on the top of the list. Override it to provide a custom component to be rendered for displaying the number of new unread threads.

itemContent

Composable rendering each Thread item in the list. Override this to provide a custom component for rendering the items.

emptyContent

Composable shown when there are no threads to display. Override this to provide custom component for rendering the empty state.

loadingContent

Composable shown during the initial loading of the threads. Override this to provide a custom initial loading state.

loadingMoreContent

Composable shown at the bottom of the list during the loading of more threads (pagination). Override this to provide a custom loading component shown during the loading of more items.


fun ThreadList(state: ThreadListState, modifier: Modifier = Modifier, currentUser: User? = ChatClient.instance().getCurrentUser(), onUnreadThreadsBannerClick: () -> Unit, onThreadClick: (Thread) -> Unit, onLoadMore: () -> Unit, unreadThreadsBanner: @Composable (Int) -> Unit = { DefaultUnreadThreadsBanner(it, onClick = onUnreadThreadsBannerClick) }, itemContent: @Composable (Thread) -> Unit = { DefaultThreadItem(it, currentUser, onThreadClick) }, emptyContent: @Composable () -> Unit = { DefaultThreadListEmptyContent(modifier) }, loadingContent: @Composable () -> Unit = { DefaultThreadListLoadingContent(modifier) }, loadingMoreContent: @Composable () -> Unit = { DefaultThreadListLoadingMoreContent() })

Composable rendering a paginated list of threads. Optionally, it renders a banner informing about new threads/thread messages outside of the loaded pages of threads.

Parameters

state

The ThreadListState holding the current thread list state.

modifier

Modifier instance for general styling.

currentUser

The currently logged User, used for formatting the message in the thread preview.

onUnreadThreadsBannerClick

Action invoked when the user clicks on the "Unread threads" banner.

onThreadClick

Action invoked when the usr clicks on a thread item in the list.

onLoadMore

Action invoked when the current thread page was scrolled to the end, and a next page should be loaded.

unreadThreadsBanner

Composable rendering the "Unread threads" banner on the top of the list. Override it to provide a custom component to be rendered for displaying the number of new unread threads.

itemContent

Composable rendering each Thread item in the list. Override this to provide a custom component for rendering the items.

emptyContent

Composable shown when there are no threads to display. Override this to provide custom component for rendering the empty state.

loadingContent

Composable shown during the initial loading of the threads. Override this to provide a custom initial loading state.

loadingMoreContent

Composable shown at the bottom of the list during the loading of more threads (pagination). Override this to provide a custom loading component shown during the loading of more items.