MessageItemFactory

fun MessageItemFactory(prevMessage: UikitBaseMessage?, message: UikitBaseMessage, nextMessage: UikitBaseMessage?, modifier: Modifier = Modifier, contentAlignment: Alignment = when (message) { is UikitTimelineMessage, is UikitAdminMessage -> { Alignment.Center } else -> { if (message.isMine) { Alignment.CenterEnd } else { Alignment.CenterStart } } }, messageGroupingPosition: MessageGroupingPosition = message.messageGroupingPosition(prevMessage, nextMessage), onMessageClick: (UikitBaseMessage) -> Unit = {}, onMessageLongClick: (UikitBaseMessage) -> Unit = {}, myTextMessageItem: @Composable (message: UikitUserMessage) -> Unit = { MyTextMessageItem( message = it, onMessageClick = onMessageClick, onMessageLongClick = onMessageLongClick, messageGroupingPosition = messageGroupingPosition ) }, myFileMessageItem: @Composable (message: UikitFileMessage) -> Unit = { MyFileMessageItem( message = it, onMessageClick = onMessageClick, onMessageLongClick = onMessageLongClick, messageGroupingPosition = messageGroupingPosition ) }, myMediaMessageItem: @Composable (message: UikitFileMessage) -> Unit = { MyMediaMessageItem( message = it, onMessageClick = onMessageClick, onMessageLongClick = onMessageLongClick, messageGroupingPosition = messageGroupingPosition ) }, myUnknownMessageItem: @Composable (message: UikitBaseMessage) -> Unit = { MyUnknownMessageItem( message = it, onMessageClick = onMessageClick, onMessageLongClick = onMessageLongClick, messageGroupingPosition = messageGroupingPosition ) }, otherTextMessageItem: @Composable (message: UikitUserMessage) -> Unit = { OtherTextMessageItem( message = it, onMessageClick = onMessageClick, onMessageLongClick = onMessageLongClick, messageGroupingPosition = messageGroupingPosition ) }, otherFileMessageItem: @Composable (message: UikitFileMessage) -> Unit = { OtherFileMessageItem( message = it, onMessageClick = onMessageClick, onMessageLongClick = onMessageLongClick, messageGroupingPosition = messageGroupingPosition ) }, otherMediaMessageItem: @Composable (message: UikitFileMessage) -> Unit = { OtherMediaMessageItem( message = it, onMessageClick = onMessageClick, onMessageLongClick = onMessageLongClick, messageGroupingPosition = messageGroupingPosition ) }, otherUnknownMessageItem: @Composable (message: UikitBaseMessage) -> Unit = { OtherUnknownMessageItem( message = it, onMessageClick = onMessageClick, onMessageLongClick = onMessageLongClick, messageGroupingPosition = messageGroupingPosition ) }, adminMessageItem: @Composable (message: UikitAdminMessage) -> Unit = { AdminMessageItem(message = it) }, timelineMessageItem: @Composable (message: UikitTimelineMessage) -> Unit = { TimelineMessageItem(message = it) })

A factory Composable to create a message item based on the message type.

Since

1.0.0

Parameters

message

The UikitBaseMessage to display.

modifier

The modifier to be applied to the view.

contentAlignment

The alignment of the content. By default, it's Alignment.Center for UikitTimelineMessage and UikitAdminMessage, and Alignment.CenterEnd for the current user's message, and Alignment.CenterStart for other users' messages.

messageGroupingPosition

The position of the message in the message group.

onMessageClick

The handler for when the message is clicked.

onMessageLongClick

The handler for when the message is long clicked.

myTextMessageItem

The Composable to display the current user's UikitUserMessage. Defaults to MyTextMessageItem.

myFileMessageItem

The Composable to display the current user's UikitFileMessage. Defaults to MyFileMessageItem.

myMediaMessageItem

The Composable to display the current user's media UikitFileMessage. Defaults to MyMediaMessageItem.

myUnknownMessageItem

The Composable to display the current user's unknown message of UikitBaseMessage type. Defaults to MyUnknownMessageItem.

otherTextMessageItem

The Composable to display other users' UikitUserMessage. Defaults to OtherTextMessageItem.

otherFileMessageItem

The Composable to display other users' UikitFileMessage. Defaults to OtherFileMessageItem.

otherMediaMessageItem

The Composable to display other users' media UikitFileMessage. Defaults to OtherMediaMessageItem.

otherUnknownMessageItem

The Composable to display other users' unknown message of UikitBaseMessage type. Defaults to OtherUnknownMessageItem.

adminMessageItem

The Composable to display UikitAdminMessage. Defaults to AdminMessageItem.

timelineMessageItem

See also