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
38 changes: 37 additions & 1 deletion app/src/main/java/chat/stoat/sheets/ChannelContextSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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()

Expand Down Expand Up @@ -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"))
}
}
)
}


}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
Loading