This commit is contained in:
Gabriel 2026-06-07 07:10:46 -04:00 committed by GitHub
commit 93c76ea08a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
@ -19,9 +20,15 @@ import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.dp
import chat.stoat.R
import chat.stoat.api.StoatAPI
import chat.stoat.api.internals.PermissionBit
import chat.stoat.api.internals.has
import chat.stoat.callbacks.Action
import chat.stoat.callbacks.ActionChannel
import chat.stoat.composables.generic.SheetButton
import chat.stoat.core.model.schemas.ChannelType
import chat.stoat.internals.Platform
import chat.stoat.internals.extensions.rememberChannelPermissions
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@Composable
@ -40,6 +47,7 @@ fun ChannelContextSheet(channelId: String, onHideSheet: suspend () -> Unit) {
val clipboardManager = LocalClipboardManager.current
val context = LocalContext.current
val permissions by rememberChannelPermissions(channelId)
val coroutineScope = rememberCoroutineScope()
@ -96,5 +104,33 @@ fun ChannelContextSheet(channelId: String, onHideSheet: suspend () -> Unit) {
}
)
if (
(permissions has PermissionBit.ManageChannel)
&& (channel.channelType != ChannelType.SavedMessages && channel.channelType != ChannelType.DirectMessage)
) {
SheetButton(
headlineContent = {
Text(
text = stringResource(id = R.string.channel_context_sheet_actions_edit_channel),
)
},
leadingContent = {
Icon(
painter = painterResource(id = R.drawable.ic_edit_24dp),
contentDescription = null
)
},
onClick = {
coroutineScope.launch {
onHideSheet()
}
coroutineScope.launch {
delay(100) // wait for the sheet to close or at least start closing
ActionChannel.send(Action.TopNavigate("settings/channel/$channelId"))
}
}
)
}
}

View File

@ -410,6 +410,7 @@
<string name="channel_context_sheet_actions_copy_id">Copy ID</string>
<string name="channel_context_sheet_actions_copy_id_copied">Copied channel ID to clipboard</string>
<string name="channel_context_sheet_actions_mark_read">Mark as read</string>
<string name="channel_context_sheet_actions_edit_channel">Edit Channel</string>
<string name="server_context_sheet_description_empty">There hasn\'t been a description set for this server yet.</string>