Package-level declarations
Functions
Link copied to clipboard
fun ChannelItem( channelItem: ItemState.ChannelItemState, currentUser: User?, onChannelClick: (Channel) -> Unit, onChannelLongClick: (Channel) -> Unit, modifier: Modifier = Modifier, leadingContent: @Composable RowScope.(ItemState.ChannelItemState) -> Unit = {
with(ChatTheme.componentFactory) {
ChannelItemLeadingContent(
channelItem = channelItem,
currentUser = currentUser,
)
}
}, centerContent: @Composable RowScope.(ItemState.ChannelItemState) -> Unit = {
with(ChatTheme.componentFactory) {
ChannelItemCenterContent(
channelItem = channelItem,
currentUser = currentUser,
)
}
}, trailingContent: @Composable RowScope.(ItemState.ChannelItemState) -> Unit = {
with(ChatTheme.componentFactory) {
ChannelItemTrailingContent(
channelItem = channelItem,
currentUser = currentUser,
)
}
})
The basic channel item, that shows the channel in a list and exposes single and long click actions.
Link copied to clipboard
fun ChannelList( modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(), viewModel: ChannelListViewModel = viewModel(
factory =
ChannelViewModelFactory(
ChatClient.instance(),
QuerySortByField.descByName("last_updated"),
filters = null,
),
), lazyListState: LazyListState = rememberLazyListState(), onLastItemReached: () -> Unit = remember(viewModel) { { viewModel.loadMore() } }, onChannelClick: (Channel) -> Unit = {}, onChannelLongClick: (Channel) -> Unit = remember(viewModel) { { viewModel.selectChannel(it) } }, onSearchResultClick: (Message) -> Unit = {}, loadingContent: @Composable () -> Unit = {
ChatTheme.componentFactory.ChannelListLoadingIndicator(modifier = modifier)
}, emptyContent: @Composable () -> Unit = {
ChatTheme.componentFactory.ChannelListEmptyContent(modifier = modifier)
}, emptySearchContent: @Composable (String) -> Unit = { searchQuery ->
ChatTheme.componentFactory.ChannelListEmptySearchContent(
searchQuery = searchQuery,
modifier = modifier,
)
}, helperContent: @Composable BoxScope.() -> Unit = {
with(ChatTheme.componentFactory) {
ChannelListHelperContent()
}
}, loadingMoreContent: @Composable LazyItemScope.() -> Unit = {
with(ChatTheme.componentFactory) {
ChannelListLoadingMoreItemContent()
}
}, channelContent: @Composable LazyItemScope.(ItemState.ChannelItemState) -> Unit = { itemState ->
val user by viewModel.user.collectAsState()
with(ChatTheme.componentFactory) {
ChannelListItemContent(
channelItem = itemState,
currentUser = user,
onChannelClick = onChannelClick,
onChannelLongClick = onChannelLongClick,
)
}
}, searchResultContent: @Composable LazyItemScope.(ItemState.SearchResultItemState) -> Unit = { itemState ->
val user by viewModel.user.collectAsState()
with(ChatTheme.componentFactory) {
SearchResultItemContent(
searchResultItem = itemState,
currentUser = user,
onSearchResultClick = onSearchResultClick,
)
}
}, divider: @Composable LazyItemScope.() -> Unit = {
with(ChatTheme.componentFactory) {
ChannelListDividerItem()
}
})
Default ChannelList component, that relies on the ChannelListViewModel to load the data and show it on the UI.
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 = {}, onSearchResultClick: (Message) -> Unit = {}, loadingContent: @Composable () -> Unit = {
ChatTheme.componentFactory.ChannelListLoadingIndicator(modifier = modifier)
}, emptyContent: @Composable () -> Unit = {
ChatTheme.componentFactory.ChannelListEmptyContent(modifier = modifier)
}, emptySearchContent: @Composable (String) -> Unit = { searchQuery ->
ChatTheme.componentFactory.ChannelListEmptySearchContent(
searchQuery = searchQuery,
modifier = modifier,
)
}, helperContent: @Composable BoxScope.() -> Unit = {
with(ChatTheme.componentFactory) {
ChannelListHelperContent()
}
}, loadingMoreContent: @Composable LazyItemScope.() -> Unit = {
with(ChatTheme.componentFactory) {
ChannelListLoadingMoreItemContent()
}
}, channelContent: @Composable LazyItemScope.(ItemState.ChannelItemState) -> Unit = { channelItem ->
with(ChatTheme.componentFactory) {
ChannelListItemContent(
channelItem = channelItem,
currentUser = currentUser,
onChannelClick = onChannelClick,
onChannelLongClick = onChannelLongClick,
)
}
}, searchResultContent: @Composable LazyItemScope.(ItemState.SearchResultItemState) -> Unit = { searchResultItem ->
with(ChatTheme.componentFactory) {
SearchResultItemContent(
searchResultItem = searchResultItem,
currentUser = currentUser,
onSearchResultClick = onSearchResultClick,
)
}
}, divider: @Composable LazyItemScope.() -> Unit = {
with(ChatTheme.componentFactory) {
ChannelListDividerItem()
}
})
Root Channel list component, that represents different UI, based on the current channel state.
Link copied to clipboard
fun Channels( channelsState: ChannelsState, lazyListState: LazyListState, onLastItemReached: () -> Unit, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(), helperContent: @Composable BoxScope.() -> Unit = {
with(ChatTheme.componentFactory) {
ChannelListHelperContent()
}
}, loadingMoreContent: @Composable LazyItemScope.() -> Unit = {
with(ChatTheme.componentFactory) {
ChannelListLoadingMoreItemContent()
}
}, itemContent: @Composable LazyItemScope.(ItemState) -> Unit, divider: @Composable LazyItemScope.() -> Unit = {
with(ChatTheme.componentFactory) {
ChannelListDividerItem()
}
})
Builds a list of ChannelItem elements, based on channelsState and action handlers that it receives.
Link copied to clipboard
Represents the default item divider in channel items.
Link copied to clipboard
fun SearchResultItem( searchResultItemState: ItemState.SearchResultItemState, currentUser: User?, onSearchResultClick: (Message) -> Unit, modifier: Modifier = Modifier, leadingContent: @Composable RowScope.(ItemState.SearchResultItemState) -> Unit = {
with(ChatTheme.componentFactory) {
SearchResultItemLeadingContent(it, currentUser)
}
}, centerContent: @Composable RowScope.(ItemState.SearchResultItemState) -> Unit = {
with(ChatTheme.componentFactory) {
SearchResultItemCenterContent(it, currentUser)
}
}, trailingContent: @Composable RowScope.(ItemState.SearchResultItemState) -> Unit = {
with(ChatTheme.componentFactory) {
SearchResultItemTrailingContent(it)
}
})
The basic search result item that show the message and the channel name in a list and expose click actions.