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.text.style.TextOverflow
20import androidx.compose.ui.unit.dp
21import soy.iko.opencode.data.model.Command
23/** Bottom sheet that lists slash-commands; selecting one invokes it. */
24@OptIn(ExperimentalMaterial3Api::class)
26fun CommandPickerSheet(
27 commands: List<Command>,
28 onSelect: (Command) -> Unit,
29 onDismiss: () -> Unit,
31 ModalBottomSheet(onDismissRequest = onDismiss) {
34 style = MaterialTheme.typography.titleMedium,
35 modifier = Modifier.padding(start = 24.dp, end = 24.dp, bottom = 8.dp),
37 if (commands.isEmpty()) {
39 "No commands reported by the server.",
40 style = MaterialTheme.typography.bodyMedium,
41 color = MaterialTheme.colorScheme.onSurfaceVariant,
42 modifier = Modifier.padding(horizontal = 24.dp, vertical = 16.dp),
45 LazyColumn(modifier = Modifier.fillMaxWidth().heightIn(max = 420.dp)) {
46 items(commands, key = { it.name }) { cmd ->
50 .clickable { onSelect(cmd); onDismiss() }
51 .padding(horizontal = 24.dp, vertical = 12.dp),
53 androidx.compose.foundation.layout.Row(
54 verticalAlignment = androidx.compose.ui.Alignment.CenterVertically,
56 Icon(Icons.AutoMirrored.Filled.PlaylistPlay, contentDescription = null)
59 style = MaterialTheme.typography.bodyLarge,
63 cmd.displayDescription,
64 style = MaterialTheme.typography.bodySmall,
65 color = MaterialTheme.colorScheme.onSurfaceVariant,
67 overflow = TextOverflow.Ellipsis,
68 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