Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ internal fun ChannelInfoOption(
internal fun ChannelInfoOptionButton(
@DrawableRes icon: Int,
text: String,
destructive: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier,
) {
Expand All @@ -92,11 +93,13 @@ internal fun ChannelInfoOptionButton(
Icon(
painter = painterResource(icon),
contentDescription = null,
tint = if (destructive) ChatTheme.colors.buttonDestructiveText else ChatTheme.colors.textSecondary,
)
Text(
modifier = Modifier.weight(1f),
text = text,
style = ChatTheme.typography.bodyDefault,
color = if (destructive) ChatTheme.colors.buttonDestructiveText else ChatTheme.colors.textPrimary,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Expand Down Expand Up @@ -172,6 +175,7 @@ private fun ChannelInfoOptionButtonPreview() {
ChannelInfoOptionButton(
icon = R.drawable.stream_design_ic_delete,
text = "Delete",
destructive = true,
onClick = {},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

package io.getstream.chat.android.compose.ui.channel.info

import androidx.compose.material3.LocalContentColor
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand Down Expand Up @@ -104,23 +102,22 @@ private fun ChannelInfoOptionContent(
}

is ChannelInfoViewState.Content.Option.BlockUser -> {
CompositionLocalProvider(LocalContentColor.provides(ChatTheme.colors.accentError)) {
ChannelInfoOptionButton(
icon = R.drawable.stream_design_ic_no_sign,
text = if (option.isBlocked) {
stringResource(UiCommonR.string.stream_ui_channel_info_option_unblock_user)
ChannelInfoOptionButton(
icon = R.drawable.stream_design_ic_no_sign,
text = if (option.isBlocked) {
stringResource(UiCommonR.string.stream_ui_channel_info_option_unblock_user)
} else {
stringResource(UiCommonR.string.stream_ui_channel_info_option_block_user)
},
destructive = false,
onClick = {
if (option.isBlocked) {
onViewAction(ChannelInfoViewAction.UnblockUserClick)
} else {
stringResource(UiCommonR.string.stream_ui_channel_info_option_block_user)
},
onClick = {
if (option.isBlocked) {
onViewAction(ChannelInfoViewAction.UnblockUserClick)
} else {
onViewAction(ChannelInfoViewAction.BlockUserClick)
}
},
)
}
onViewAction(ChannelInfoViewAction.BlockUserClick)
}
},
)
}

is ChannelInfoViewState.Content.Option.PinnedMessages -> {
Expand Down Expand Up @@ -148,31 +145,29 @@ private fun ChannelInfoOptionContent(
}

is ChannelInfoViewState.Content.Option.LeaveChannel -> {
CompositionLocalProvider(LocalContentColor.provides(ChatTheme.colors.accentError)) {
ChannelInfoOptionButton(
icon = R.drawable.stream_design_ic_leave,
text = if (isGroupChannel) {
stringResource(UiCommonR.string.stream_ui_channel_info_option_leave_group)
} else {
stringResource(UiCommonR.string.stream_ui_channel_info_option_leave_conversation)
},
onClick = { onViewAction(ChannelInfoViewAction.LeaveChannelClick) },
)
}
ChannelInfoOptionButton(
icon = R.drawable.stream_design_ic_leave,
text = if (isGroupChannel) {
stringResource(UiCommonR.string.stream_ui_channel_info_option_leave_group)
} else {
stringResource(UiCommonR.string.stream_ui_channel_info_option_leave_conversation)
},
destructive = true,
onClick = { onViewAction(ChannelInfoViewAction.LeaveChannelClick) },
)
}

is ChannelInfoViewState.Content.Option.DeleteChannel -> {
CompositionLocalProvider(LocalContentColor.provides(ChatTheme.colors.accentError)) {
ChannelInfoOptionButton(
icon = R.drawable.stream_design_ic_delete,
text = if (isGroupChannel) {
stringResource(UiCommonR.string.stream_ui_channel_info_option_delete_group)
} else {
stringResource(UiCommonR.string.stream_ui_channel_info_option_delete_conversation)
},
onClick = { onViewAction(ChannelInfoViewAction.DeleteChannelClick) },
)
}
ChannelInfoOptionButton(
icon = R.drawable.stream_design_ic_delete,
text = if (isGroupChannel) {
stringResource(UiCommonR.string.stream_ui_channel_info_option_delete_group)
} else {
stringResource(UiCommonR.string.stream_ui_channel_info_option_delete_conversation)
},
destructive = true,
onClick = { onViewAction(ChannelInfoViewAction.DeleteChannelClick) },
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@ private fun buildGroupChannelActions(
selectedChannel = selectedChannel,
viewModel = viewModel,
),
// Owner pattern: if user can delete, show Delete Group (not Leave)
// Member pattern: if user can leave but not delete, show Leave Group
if (optionVisibility.isLeaveChannelVisible && canLeaveChannel && !canDeleteChannel) {
if (optionVisibility.isLeaveChannelVisible && canLeaveChannel) {
LeaveGroup(
channel = selectedChannel,
label = stringResource(id = R.string.stream_compose_selected_channel_menu_leave_group),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,11 @@ private fun buildChannelOptionList(
add(ChannelInfoViewState.Content.Option.PinnedMessages)
add(ChannelInfoViewState.Content.Option.MediaAttachments)
add(ChannelInfoViewState.Content.Option.FilesAttachments)
if (channelData.ownCapabilities.contains(ChannelCapabilities.LEAVE_CHANNEL)) {
add(ChannelInfoViewState.Content.Option.LeaveChannel)
}
if (channelData.ownCapabilities.contains(ChannelCapabilities.DELETE_CHANNEL)) {
add(ChannelInfoViewState.Content.Option.DeleteChannel)
} else if (channelData.ownCapabilities.contains(ChannelCapabilities.LEAVE_CHANNEL)) {
add(ChannelInfoViewState.Content.Option.LeaveChannel)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ internal class ChannelInfoViewControllerTest {
ChannelInfoViewState.Content.Option.MediaAttachments,
ChannelInfoViewState.Content.Option.FilesAttachments,

ChannelInfoViewState.Content.Option.LeaveChannel,
ChannelInfoViewState.Content.Option.DeleteChannel,
),
),
Expand Down
Loading