1package soy.iko.opencode.ui.components
3import androidx.compose.foundation.layout.Box
4import androidx.compose.foundation.layout.Column
5import androidx.compose.foundation.layout.RowScope
6import androidx.compose.foundation.layout.size
7import androidx.compose.material.icons.Icons
8import androidx.compose.material.icons.automirrored.filled.ArrowBack
9import androidx.compose.material3.ExperimentalMaterial3Api
10import androidx.compose.material3.Icon
11import androidx.compose.material3.IconButton
12import androidx.compose.material3.MaterialTheme
13import androidx.compose.material3.Text
14import androidx.compose.material3.TopAppBar
15import androidx.compose.material3.TopAppBarDefaults
16import androidx.compose.material3.TopAppBarScrollBehavior
17import androidx.compose.runtime.Composable
18import androidx.compose.ui.Alignment
19import androidx.compose.ui.Modifier
20import androidx.compose.ui.res.stringResource
21import androidx.compose.ui.text.style.TextOverflow
22import androidx.compose.ui.unit.dp
23import soy.iko.opencode.R
26 * The app's standard top bar: a title (with optional subtitle), an optional up/back button, an
27 * optional inline loading indicator, and trailing actions. Extracted so the many plain
28 * back-title-actions screens share one implementation instead of hand-rolling a [TopAppBar] each.
29 * Screens with a bespoke title (dropdown server switcher, clickable model picker) keep their own bar.
31@OptIn(ExperimentalMaterial3Api::class)
35 onBack: (() -> Unit)? = null,
36 scrollBehavior: TopAppBarScrollBehavior? = null,
37 subtitle: String? = null,
38 loading: Boolean = false,
39 actions: @Composable RowScope.() -> Unit = {},
43 if (subtitle != null) {
45 Text(title, maxLines = 1, overflow = TextOverflow.Ellipsis)
48 style = MaterialTheme.typography.labelMedium,
49 color = MaterialTheme.colorScheme.onSurfaceVariant,
51 overflow = TextOverflow.Ellipsis,
55 Text(title, maxLines = 1, overflow = TextOverflow.Ellipsis)
60 IconButton(onClick = onBack) {
62 Icons.AutoMirrored.Filled.ArrowBack,
63 contentDescription = stringResource(R.string.back),
70 Box(modifier = Modifier.size(40.dp), contentAlignment = Alignment.Center) {
72 size = LoadingSize.Small,
73 color = MaterialTheme.colorScheme.onSurfaceVariant,
79 scrollBehavior = scrollBehavior,
80 colors = TopAppBarDefaults.topAppBarColors(),
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