1package soy.iko.opencode.ui.chat
3import androidx.compose.foundation.clickable
4import androidx.compose.foundation.layout.Column
5import androidx.compose.foundation.layout.fillMaxWidth
6import androidx.compose.foundation.layout.heightIn
7import androidx.compose.foundation.layout.padding
8import androidx.compose.foundation.lazy.LazyColumn
9import androidx.compose.foundation.lazy.items
10import androidx.compose.material.icons.Icons
11import androidx.compose.material.icons.automirrored.filled.PlaylistPlay
12import androidx.compose.material3.ExperimentalMaterial3Api
13import androidx.compose.material3.Icon
14import androidx.compose.material3.MaterialTheme
15import androidx.compose.material3.ModalBottomSheet
16import androidx.compose.material3.Text
17import androidx.compose.runtime.Composable
18import androidx.compose.ui.Modifier
19import androidx.compose.ui.res.stringResource
20import androidx.compose.ui.semantics.Role
21import androidx.compose.ui.semantics.role
22import androidx.compose.ui.text.style.TextOverflow
23import androidx.compose.ui.unit.dp
24import soy.iko.opencode.data.model.Command
25import soy.iko.opencode.R
27/** Bottom sheet that lists slash-commands; selecting one invokes it. */
28@OptIn(ExperimentalMaterial3Api::class)
30fun CommandPickerSheet(
31 commands: List<Command>,
32 onSelect: (Command) -> Unit,
33 onDismiss: () -> Unit,
35 ModalBottomSheet(onDismissRequest = onDismiss) {
37 stringResource(R.string.commands),
38 style = MaterialTheme.typography.titleMedium,
39 modifier = Modifier.padding(start = 24.dp, end = 24.dp, bottom = 8.dp),
41 if (commands.isEmpty()) {
43 stringResource(R.string.no_commands),
44 style = MaterialTheme.typography.bodyMedium,
45 color = MaterialTheme.colorScheme.onSurfaceVariant,
46 modifier = Modifier.padding(horizontal = 24.dp, vertical = 16.dp),
49 LazyColumn(modifier = Modifier.fillMaxWidth().heightIn(max = 420.dp)) {
50 items(commands, key = { it.name }) { cmd ->
54 .clickable(role = Role.Button) { onSelect(cmd); onDismiss() }
55 .padding(horizontal = 24.dp, vertical = 12.dp),
57 androidx.compose.foundation.layout.Row(
58 verticalAlignment = androidx.compose.ui.Alignment.CenterVertically,
60 Icon(Icons.AutoMirrored.Filled.PlaylistPlay, contentDescription = null)
63 style = MaterialTheme.typography.bodyLarge,
64 modifier = Modifier.padding(start = 8.dp),
68 cmd.displayDescription,
69 style = MaterialTheme.typography.bodySmall,
70 color = MaterialTheme.colorScheme.onSurfaceVariant,
72 overflow = TextOverflow.Ellipsis,
73 modifier = Modifier.padding(start = 28.dp, top = 2.dp),
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list