ChannelScreen

fun ChannelScreen(navController: NavController?, channelUrl: String, modifier: Modifier = Modifier, onTopBarNavigationIconClick: () -> Unit = { navController?.popBackStack() }, onTopBarActionClick: () -> Unit = { navController?.navigateToChannelSettings(channelUrl) }, onMessageItemClick: (Context, UikitBaseMessage, ImageViewerState) -> Unit = { context, message, state -> when (message) { is UikitFileMessage -> { if (message.isImage) { state.showImage(message) } else if (message.isFile or message.isVideo) { val type = message.type.lowercase() val uri = Uri.parse(message.url) val intent = uri.getViewerIntent(type) context.startActivity(intent) } else { Logger.d("unknown file type: ${message.type}") } } else -> {} } }, onMessageItemLongClick: (UikitBaseMessage, ChannelDialogState) -> Unit = { message, state -> state.showMessageMenuDialog(message) }, onChannelRemoved: (String) -> Unit = { navController?.popBackStack() }, messageInputState: MessageInputState = rememberMessageInputState(), dialogState: ChannelDialogState = rememberChannelDialogState(), imageViewerState: ImageViewerState = rememberImageViewerState(), viewModel: ChannelViewModel = viewModel( factory = ChannelViewModel.factory( ChannelViewModelParams( channelUrl = channelUrl, messageListParams = MessageListParams() ) ) ), topBar: @Composable (state: ChannelTopBarState) -> Unit = { ChannelTopBar( channelCoverModels = it.coverModels, channelTitle = it.title, channelDescription = it.channelDescription, onNavigationIconClick = it.onNavigationIconClick, onActionClick = it.onActionClick ) }, loading: @Composable () -> Unit = {}, failure: @Composable (e: Throwable) -> Unit = { e -> if (e !is ChannelRemovedException) { FailurePlaceholder( onRetryClick = { viewModel.prepare() } ) } }, empty: @Composable () -> Unit = { ScreenPlaceholder( icon = painterResource(id = R.drawable.icon_message), text = stringResource(id = R.string.sb_text_channel_message_empty) ) }, messageItem: @Composable (message: UikitBaseMessage, onMessageClick: (UikitBaseMessage) -> Unit, onMessageLongClick: (UikitBaseMessage) -> Unit) -> Unit = { message, onMessageClick, onMessageLongClick -> MessageItemFactory( message, modifier = Modifier .fillMaxWidth() .padding(vertical = 8.dp), onMessageClick = { dialogState.dismissMessageMenuDialog() onMessageClick(it) }, onMessageLongClick = onMessageLongClick ) }, messageInput: @Composable (messageInputState: MessageInputState) -> Unit = { state -> MessageInput( inputValue = state.inputText, onInputValueChange = { state.inputText = it }, modifier = Modifier .padding(12.dp) .focusRequester(state.focusRequester), onActionClick = { if (state.inputText.isBlank()) return@MessageInput viewModel.sendUserMessage(state.inputText) state.clear() }, onEditModeSaveClick = { messageId -> viewModel.updateUserMessage(messageId, state.inputText) state.clear() }, onEditModeCancelClick = { state.clear() }, messageInputMode = state.inputMode, onMenuClick = { state.showBottomSheet() } ) })

Represents the screen for showing a messages in a UikitGroupChannel.

Since

1.0.0-beta.1

Parameters

channelUrl

The url of the channel.

modifier

The modifier to be applied to the view.

onTopBarNavigationIconClick

The handler for when the navigation icon is clicked.

onTopBarActionClick

The handler for when the action is clicked.

onMessageItemClick

The handler for when a message is clicked. For a UikitFileMessage, the default action is to show the image in an ImageViewer or launch a video/file.

onMessageItemLongClick

The handler for when a message is long clicked. Defaults to showing a MessageMenuDialog.

onChannelRemoved

The handler for when the channel is removed.

messageInputState

The state for the message input.

dialogState

The state for the dialog for a message.

imageViewerState

The state for the ImageViewer.

viewModel

The ChannelViewModel to handle the business logic.

topBar

The top bar to be displayed. Defaults to ChannelTopBar.

loading

The loading screen to be displayed.

failure

The failure screen to be displayed. Defaults to FailurePlaceholder.

empty

The empty screen to be displayed. Defaults to ScreenPlaceholder.

messageItem

The message item to be displayed. Defaults to MessageItemFactory.

messageInput

The message input to be displayed. Defaults to MessageInput.

See also