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}") } } is UikitUserMessage -> { message.ogMetaData?.url ?.run { if (startsWith("http://") || startsWith("https://")) this else "https://$this" } ?.let { url -> context.startActivity(Intent(Intent.ACTION_VIEW, url.toUri())) } } 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 ) ) ), onEmojiReactionClick: (UikitBaseMessage, String, Boolean) -> Unit = { message, key, isAdded -> viewModelContract.toggleReaction(message, key, isAdded) }, onEmojiReactionLongClick: (UikitBaseMessage, UiKitReaction) -> Unit = { message, reaction -> dialogState.showEmojiReactedUserDialog(message, reaction) }, onEmojiReactionMoreButtonClick: (UikitBaseMessage) -> Unit = { message -> dialogState.showEmojiListDialog(message) }, 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.dismissDialog() } ) }, 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, onEmojiReactionClick = onEmojiReactionClick, onEmojiReactionLongClick = onEmojiReactionLongClick, onEmojiReactionMoreButtonClick = onEmojiReactionMoreButtonClick, ) }, messageInput: @Composable (messageInputState: MessageInputState) -> Unit = { state -> ChannelMessageInput( state = state, viewModelContract = viewModelContract ) }, emojiListDialog: @Composable (message: UikitBaseMessage, onEmojiClick: (UiKitEmoji, Boolean) -> Unit, onDismiss: () -> Unit) -> Unit = { message, onEmojiClick, onDismiss -> EmojiListDialog( message = message, onEmojiClick = onEmojiClick, onDismiss = onDismiss ) }, emojiReactedUserDialog: @Composable (message: UikitBaseMessage, channel: UikitGroupChannel, reaction: UiKitReaction, onDismissRequest: () -> Unit) -> Unit = { message, channel, reaction, onDismissRequest -> EmojiReactedUserDialog( defaultReaction = reaction, channel = channel, reactions = message.reactions, onDismiss = onDismissRequest ) })

Represents the screen for showing a messages in a UikitGroupChannel.

Since

1.0.0

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.

onEmojiReactionClick

The handler for when a emoji reaction is clicked in a message. Defaults to toggling the reaction.

onEmojiReactionLongClick

The handler for when a emoji reaction is long clicked in a message. Defaults to showing the EmojiReactedUserDialog with the list of users who reacted with that emoji.

onEmojiReactionMoreButtonClick

The handler for when a emoji reaction more button is clicked in a message. Defaults to showing the EmojiListDialog with the list of emojis that can be reacted to the message.

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.

emojiListDialog

The emoji list dialog to be displayed. Defaults to EmojiListDialog.

emojiReactedUserDialog

The reaction user dialog to be displayed. Defaults to EmojiReactedUserDialog.

See also