Messages

fun Messages(messagesState: MessageListState, messagesLazyListState: MessagesLazyListState, threadMessagesStart: ThreadMessagesStart = ThreadMessagesStart.BOTTOM, onMessagesStartReached: () -> Unit, onLastVisibleMessageChanged: (Message) -> Unit, onScrolledToBottom: () -> Unit, onMessagesEndReached: (String) -> Unit, onScrollToBottom: (() -> Unit) -> Unit, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(vertical = 16.dp), helperContent: @Composable BoxScope.() -> Unit = { DefaultMessagesHelperContent( messagesState = messagesState, messagesLazyListState = messagesLazyListState, scrollToBottom = onScrollToBottom, ) }, loadingMoreContent: @Composable () -> Unit = { DefaultMessagesLoadingMoreIndicator() }, itemModifier: (index: Int, item: MessageListItemState) -> Modifier = { _, _ -> Modifier }, itemContent: @Composable (MessageListItemState) -> Unit)

Builds a list of message items, based on the itemContent parameter and the state provided within messagesState. Also handles the pagination events, by propagating the event to the call site.

Finally, it handles the scrolling behavior, such as when a new message arrives, be it ours or from someone else.

Parameters

messagesState

Current state of messages, like messages to display, if we're loading more and if we've reached the end of the list.

messagesLazyListState

State of the lazy list that represents the list of messages. Useful for controlling the scroll state and focused message offset.

threadMessagesStart

Thread messages start at the bottom or top of the screen. Default: ThreadMessagesStart.BOTTOM.

onMessagesStartReached

Handler for pagination, when the user reaches the start of messages.

onLastVisibleMessageChanged

Handler that notifies us when the user scrolls and the last visible message changes.

onScrolledToBottom

Handler when the user reaches the bottom of the list.

onMessagesEndReached

Handler for pagination, when the user reaches the end of messages.

onScrollToBottom

Handler when the user requests to scroll to the bottom of the messages list.

modifier

Modifier for styling.

contentPadding

Padding values to be applied to the message list surrounding the content inside.

helperContent

Composable that, by default, represents the helper content featuring scrolling behavior based on the list state.

loadingMoreContent

Composable that represents the loading more content, when we're loading the next page.

itemModifier

Modifier for styling the message item container.

itemContent

Composable that represents the item that displays each message.