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(), snackbarHostState: SnackbarHostState = remember { SnackbarHostState() }, viewModelContract: ChannelViewModelContract = viewModel<ChannelViewModel>( factory = ChannelViewModel.factory( ChannelViewModelParams( channelUrl = channelUrl ) ) ), 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 -> FailurePlaceholder( onRetryClick = { viewModelContract.prepare() } ) }, empty: @Composable () -> Unit = { ScreenPlaceholder( icon = painterResource(id = R.drawable.icon_message), text = stringResource(id = R.string.sb_text_channel_message_empty) ) }, messageMenuDialog: @Composable (UikitBaseMessage, MessageMenuDialogContract) -> Unit = { message, contract -> MessageMenuDialog( message = message, messageMenuDialogContract = contract, onItemClick = { it.onClick() }, onDismissRequest = { dialogState.dismissMessageMenuDialog() } ) }, messageInputBottomSheet: @Composable (MessageInputBottomSheetContract) -> Unit = { contract -> MessageInputBottomSheet( messageInputBottomSheetContract = contract, onItemClick = { // TODO(nathan) : show toast when something went wrong(it was in previous version) it.onClick() }, onDismissRequest = { messageInputState.clear() } ) }, messageItem: @Composable (prevMessage: UikitBaseMessage?, message: UikitBaseMessage, nextMessage: UikitBaseMessage?, onMessageClick: (UikitBaseMessage) -> Unit, onMessageLongClick: (UikitBaseMessage) -> Unit) -> Unit = { prevMessage, message, nextMessage, onMessageClick, onMessageLongClick -> MessageItemFactory( prevMessage, message, nextMessage, onMessageClick = onMessageClick, onMessageLongClick = onMessageLongClick ) }, messageInput: @Composable (messageInputState: MessageInputState) -> Unit = { state -> ChannelMessageInput( state = state, viewModelContract = viewModelContract ) })

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.

viewModelContract

The ChannelViewModelContract 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