@Composable public fun buildDefaultChannelOptionsState( selectedChannel: Channel, isMuted: Boolean, ownCapabilities: Set<String>, ): List<ChannelOptionState> { val canLeaveChannel = ownCapabilities.contains(ChannelCapabilities.LEAVE_CHANNEL) val canDeleteChannel = ownCapabilities.contains(ChannelCapabilities.DELETE_CHANNEL) return listOfNotNull( ChannelOptionState( title = stringResource(id = R.string.stream_compose_selected_channel_menu_view_info), titleColor = ChatTheme.colors.textHighEmphasis, iconPainter = painterResource(id = R.drawable.stream_compose_ic_person), iconColor = ChatTheme.colors.textLowEmphasis, action = ViewInfo(selectedChannel) ), if (canLeaveChannel) { ChannelOptionState( title = stringResource(id = R.string.stream_compose_selected_channel_menu_leave_group), titleColor = ChatTheme.colors.textHighEmphasis, iconPainter = painterResource(id = R.drawable.stream_compose_ic_person_remove), iconColor = ChatTheme.colors.textLowEmphasis, action = LeaveGroup(selectedChannel) ) } else null, if (isMuted) { ChannelOptionState( title = stringResource(id = R.string.stream_compose_selected_channel_menu_unmute_channel), titleColor = ChatTheme.colors.textHighEmphasis, iconPainter = painterResource(id = R.drawable.stream_compose_ic_unmute), iconColor = ChatTheme.colors.textLowEmphasis, action = UnmuteChannel(selectedChannel) ) } else { ChannelOptionState( title = stringResource(id = R.string.stream_compose_selected_channel_menu_mute_channel), titleColor = ChatTheme.colors.textHighEmphasis, iconPainter = painterResource(id = R.drawable.stream_compose_ic_mute), iconColor = ChatTheme.colors.textLowEmphasis, action = MuteChannel(selectedChannel) ) }, if (canDeleteChannel) { ChannelOptionState( title = stringResource(id = R.string.stream_compose_selected_channel_menu_delete_conversation), titleColor = ChatTheme.colors.errorAccent, iconPainter = painterResource(id = R.drawable.stream_compose_ic_delete), iconColor = ChatTheme.colors.errorAccent, action = DeleteConversation(selectedChannel) ) } else null, ChannelOptionState( title = stringResource(id = R.string.stream_compose_selected_channel_menu_dismiss), titleColor = ChatTheme.colors.textHighEmphasis, iconPainter = painterResource(id = R.drawable.stream_compose_ic_clear), iconColor = ChatTheme.colors.textLowEmphasis, action = Cancel, ) ) }
Builds the default list of channel options, based on the current user and the state of the channel.