diff --git a/AGENTS.md b/AGENTS.md index de24ecf7c..631e6b8e7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -21,10 +21,17 @@ testing once `PLAY_OPEN_TESTING` is on). `scheduled-release.yml` releases `main` still make sense so the two codebases diff side by side. - Track every iOS file in `docs/parity/.md` (see [docs/parity/README.md](docs/parity/README.md)) and update the row in the same commit. -- Visuals are Android-native: Material 3 Expressive components and surfaces (Liquid Glass → - M3 surfaces/tonal elevation, SF Symbols → Material Symbols via `OpenCodeIcons`, SF → Roboto; - BerkeleyMono only for onboarding brand marks). No glass/blur imitation, no web views as the - app shell, no React Native/Flutter/KMP UI. +- Visuals follow the OpenCode desktop design system (`packages/ui` in the opencode repo), not + iOS: Inter for UI text and IBM Plex Mono for code and tool output (bundled, OFL), the + desktop's type scale in sp, flat surfaces with hairline borders instead of tonal elevation + or glass, small radii (`OpenCodeRadius`, `OpenCodeShape.control`), the desktop palette as + the default theme (`BrandPalette`). Use `core/ui` tokens and `OpenCodeSurfaces` + (`OpenCodeAlertDialog`, floating fill + `openCodeHairline`) rather than raw Material + colours or capsules. Behaviour stays Android: Material components' structure, system back + and predictive back, sheets, IME, TalkBack semantics, ≥48 dp targets and font scaling. + Android looks different from iOS on purpose; behaviour, flows and copy still follow iOS. + SF Symbols → Material Symbols via `OpenCodeIcons`; BerkeleyMono only for the wordmark. No + glass/blur imitation, no web views as the app shell, no React Native/Flutter/KMP UI. ## Modules (fixed; never edit `settings.gradle.kts`) @@ -87,14 +94,17 @@ already wired by its parent; keep those names. (composables). Same rules as iOS (answer the press; navigation and closing stay quiet). - Design system (`ai.opencode.core.ui`, `ai.opencode.core.motion`; details in `docs/parity/core-ui.md`): wrap roots in `OpenCodeAppTheme {}`; iOS semantic colours via - `OpenCodeTheme.colors.*`, M3 roles via `MaterialTheme.colorScheme`; iOS text styles via - `OpenCodeTextStyles.*` or `MaterialTheme.typography`; `OpenCodeShape`/`OpenCodeRadius`/ - `OpenCodeSpacing`; iOS springs via `Motion.*.spec()` (respects reduce motion). + `OpenCodeTheme.colors.*` (`border` follows high contrast), M3 roles via + `MaterialTheme.colorScheme`; text styles under iOS names via `OpenCodeTextStyles.*` (desktop + sizes) or `MaterialTheme.typography`; `OpenCodeShape`/`OpenCodeRadius`/`OpenCodeSpacing`; + floating panels, dialogs and popovers via `OpenCodeSurfaces`; iOS springs via + `Motion.*.spec()` (respects reduce motion). - Icons: `OpenCodeIcon(SFSymbol.X, contentDescription)` or `OpenCodeIcon("sf.name", …)`. To add one: a line in `scripts/material-symbols.txt`, run `python3 scripts/fetch-material-symbols.py`, add the `SFSymbol` entry and the core-ui.md row (the coordinator commits shared files). - Buttons: `OpenCodePrimaryButton` (Next/Send), `OpenCodeSecondaryButton` (Back/Skip); red only - for destructive roles. Touch targets ≥ 48dp (`Modifier.openCodeTapTarget`, after `clickable`), + for destructive roles. A raw Material `Button` takes `shape = OpenCodeShape.control` (Material + defaults to a capsule); dialogs use `OpenCodeAlertDialog`. Touch targets ≥ 48dp (`Modifier.openCodeTapTarget`, after `clickable`), `OpenCodeIconButton` for icon controls. - Unfinished features stay behind Experimental, off by default, as on iOS. diff --git a/app/src/main/kotlin/ai/opencode/app/AppView.kt b/app/src/main/kotlin/ai/opencode/app/AppView.kt index 806b25fdf..c698ebc91 100644 --- a/app/src/main/kotlin/ai/opencode/app/AppView.kt +++ b/app/src/main/kotlin/ai/opencode/app/AppView.kt @@ -1,5 +1,11 @@ package ai.opencode.app +import ai.opencode.core.ui.OpenCodeSheetDefaults +import ai.opencode.core.ui.OpenCodeSheetHandle +import ai.opencode.core.ui.OpenCodeSurfaces +import androidx.compose.ui.unit.sp +import ai.opencode.core.ui.OpenCodeRadius +import androidx.compose.foundation.BorderStroke import ai.opencode.core.dependencies.dependency import ai.opencode.core.diagnostics.HidesFromScreenshots import ai.opencode.core.experiments.key @@ -66,7 +72,7 @@ import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.AlertDialog +import ai.opencode.core.ui.OpenCodeAlertDialog import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.CircularProgressIndicator @@ -74,7 +80,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ModalBottomSheet -import androidx.compose.material3.OutlinedTextField +import ai.opencode.core.ui.OpenCodeTextField import androidx.compose.material3.SheetValue import androidx.compose.material3.Surface import androidx.compose.material3.Text @@ -211,7 +217,7 @@ private fun AppAlerts(store: StoreOf) { systemActionError?.let { ErrorAlert("Couldn’t Open Session", it) { store.send(AppFeature.Action.SystemActionErrorDismissed) } } pairingError?.let { ErrorAlert("Couldn’t Pair with Server", it) { store.send(AppFeature.Action.PairingErrorDismissed) } } pendingPairing?.let { pending -> - AlertDialog( + OpenCodeAlertDialog( onDismissRequest = { store.send(AppFeature.Action.PairingCancelled(pending.id)) }, title = { Text(pending.title) }, text = { Text(pending.message) }, @@ -223,7 +229,7 @@ private fun AppAlerts(store: StoreOf) { @Composable private fun ErrorAlert(title: String, message: String, onDismiss: () -> Unit) { - AlertDialog( + OpenCodeAlertDialog( onDismissRequest = onDismiss, title = { Text(title) }, text = { Text(message) }, @@ -315,9 +321,10 @@ private fun PairingActionsButtons(store: StoreOf Unit, ) { Button( onClick = onClick, enabled = enabled, - shape = RoundedCornerShape(16.dp), + // The desktop's button: small radius, not a 16 dp card. + shape = RoundedCornerShape(OpenCodeRadius.fill), + border = border, colors = ButtonDefaults.buttonColors( containerColor = container, contentColor = content, @@ -357,11 +367,17 @@ private fun PairingActionButton( disabledContentColor = content, ), contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 16.dp, vertical = 12.dp), - modifier = Modifier.fillMaxWidth().heightIn(min = 52.dp), + modifier = Modifier.fillMaxWidth().heightIn(min = 48.dp), content = label, ) } +/** + * The pairing buttons' label. Semibold, a step above the desktop's medium button text: on these + * full-width buttons, the screen's two main actions, medium read as softer than the copy above. + */ +private val PairingActionLabel get() = OpenCodeTextStyles.callout.copy(fontWeight = FontWeight.SemiBold) + /** What a new user needs on their computer before the scan can work. */ @Composable private fun SetupSteps(store: StoreOf) { @@ -454,8 +470,12 @@ private fun CopyCommand(command: String, onCopy: (String) -> Unit) { onCopy(command) copied = true }, - shape = RoundedCornerShape(8.dp), - color = MaterialTheme.colorScheme.surfaceContainerHighest, + // The desktop's shell block: a clearly filled box, hairline border. + shape = RoundedCornerShape(OpenCodeRadius.fill), + color = OpenCodeSurfaces.commandFill, + // Explicit: the fill matches `surfaceVariant`, whose content colour is the secondary text. + contentColor = OpenCodeTheme.colors.text, + border = BorderStroke(1.dp, OpenCodeTheme.colors.border), // The label stands in for the visible command (cleared below), read once as a button // (iOS `.accessibilityLabel("Copy \(command)")` on a `Button`). modifier = Modifier.heightIn(min = 48.dp).semantics { @@ -472,11 +492,10 @@ private fun CopyCommand(command: String, onCopy: (String) -> Unit) { Text( command, modifier = Modifier.weight(1f, fill = false).clearAndSetSemantics {}, - // Berkeley Mono's contextual alternates join `//` and `--` into ligatures that - // read as `https: //`; a command to retype is drawn as typed. - style = OpenCodeTextStyles.callout.copy( - fontFamily = OpenCodeFonts.berkeleyMono, - fontSize = OpenCodeTextStyles.subheadline.fontSize, + // The desktop's mono; no contextual alternates, so a command to retype is drawn as typed. + style = OpenCodeTextStyles.footnote.copy( + fontFamily = OpenCodeFonts.monospace, + lineHeight = 20.sp, fontFeatureSettings = "calt 0", ), ) @@ -568,7 +587,7 @@ private fun SavedServerList(store: StoreOf, } } pendingRemoval?.let { server -> - AlertDialog( + OpenCodeAlertDialog( onDismissRequest = { pendingRemoval = null }, title = { Text("Remove ${server.displayName}?") }, text = { Text("This forgets the address and password on this ${ThisDevice.name}. Sessions on the server are not affected.") }, @@ -604,7 +623,7 @@ private fun formatted(message: String): AnnotatedString = buildAnnotatedString { return@buildAnnotatedString } parts.forEachIndexed { index, part -> - if (index % 2 == 1) withStyle(SpanStyle(fontFamily = FontFamily.Monospace)) { append(part) } else append(part) + if (index % 2 == 1) withStyle(SpanStyle(fontFamily = OpenCodeFonts.monospace)) { append(part) } else append(part) } } @@ -694,6 +713,8 @@ private fun ServerFormSheet(store: StoreOf) ModalBottomSheet( onDismissRequest = { store.send(AppFeature.Action.CancelEditingTapped) }, sheetState = sheetState, + dragHandle = { OpenCodeSheetHandle() }, + shape = OpenCodeSheetDefaults.shape, ) { // Its password and headers, out of problem reports and voice screenshots. HidesFromScreenshots() @@ -750,30 +771,30 @@ private fun ServerFormSheet(store: StoreOf) verticalArrangement = Arrangement.spacedBy(16.dp), ) { state.errorMessage?.let { ConnectionErrorCard(store, it, announces = false) } - OutlinedTextField( + OpenCodeTextField( value = state.serverName, onValueChange = { store.send(AppFeature.Action.ServerNameChanged(it)) }, - label = { Text("Name") }, + label = "Name", // Blank keeps the name the address gives, shown as the prompt. - placeholder = { Text(state.credentialNamePrompt) }, + placeholder = state.credentialNamePrompt, singleLine = true, keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.Words, autoCorrectEnabled = false, imeAction = ImeAction.Next), modifier = Modifier.fillMaxWidth(), ) - OutlinedTextField( + OpenCodeTextField( value = state.serverURL, onValueChange = { store.send(AppFeature.Action.ServerURLChanged(it)) }, - label = { Text("Server address") }, - placeholder = { Text("http://192.168.1.20:4096") }, + label = "Server address", + placeholder = "http://192.168.1.20:4096", singleLine = true, keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri, autoCorrectEnabled = false, imeAction = ImeAction.Next), modifier = Modifier.fillMaxWidth(), ) - OutlinedTextField( + OpenCodeTextField( value = state.username, onValueChange = { store.send(AppFeature.Action.UsernameChanged(it)) }, - label = { Text("Username") }, - placeholder = { Text("opencode") }, + label = "Username", + placeholder = "opencode", singleLine = true, keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.None, autoCorrectEnabled = false, imeAction = ImeAction.Next), modifier = Modifier.fillMaxWidth(), @@ -785,15 +806,15 @@ private fun ServerFormSheet(store: StoreOf) // eye sits over it, outside the swap, so TalkBack's focus stays on it. Box { androidx.compose.runtime.key(revealsPassword) { - OutlinedTextField( + OpenCodeTextField( // Its own value, so the new field keeps the caret where it was. value = if (passwordValue.text == state.password) passwordValue else TextFieldValue(state.password, TextRange(state.password.length)), onValueChange = { passwordValue = it if (it.text != state.password) store.send(AppFeature.Action.PasswordChanged(it.text)) }, - label = { Text("Password") }, - placeholder = { Text("Password") }, + label = "Password", + placeholder = "Password", singleLine = true, visualTransformation = if (revealsPassword) VisualTransformation.None else PasswordVisualTransformation(), keyboardOptions = KeyboardOptions( @@ -814,8 +835,8 @@ private fun ServerFormSheet(store: StoreOf) .onFocusChanged { isPasswordFocused = it.isFocused }, ) } - // The outlined field's 8 dp above its border is the label's. - Box(Modifier.matchParentSize().padding(top = 8.dp), contentAlignment = Alignment.CenterEnd) { + // The label sits above the field: the eye centres on the field's 48 dp row. + Box(Modifier.matchParentSize(), contentAlignment = Alignment.BottomEnd) { OpenCodeIconButton( symbol = if (revealsPassword) SFSymbol.EyeSlash else SFSymbol.Eye, contentDescription = if (revealsPassword) "Hide Password" else "Show Password", @@ -884,14 +905,16 @@ private fun ConnectButton(label: String, inProgress: Boolean, enabled: Boolean, disabledContainerColor = MaterialTheme.colorScheme.surfaceContainerHighest, disabledContentColor = colors.secondaryText, ), - contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 20.dp, vertical = 12.dp), - modifier = modifier.fillMaxWidth().heightIn(min = 52.dp), + // The desktop's contrast button: small radius, medium label. + shape = RoundedCornerShape(OpenCodeRadius.fill), + contentPadding = androidx.compose.foundation.layout.PaddingValues(horizontal = 16.dp, vertical = 10.dp), + modifier = modifier.fillMaxWidth().heightIn(min = 48.dp), ) { if (inProgress) { CircularProgressIndicator(Modifier.size(18.dp), strokeWidth = 2.dp, color = colors.secondaryText) Spacer(Modifier.width(10.dp)) } - Text(label, style = OpenCodeTextStyles.headline) + Text(label, style = PairingActionLabel) Spacer(Modifier.weight(1f)) OpenCodeIcon(SFSymbol.ArrowRight, contentDescription = null) } @@ -915,20 +938,20 @@ private fun HeaderFields( Text("Headers", style = OpenCodeTextStyles.caption1.copy(fontWeight = FontWeight.SemiBold), color = OpenCodeTheme.colors.secondaryText) headers.forEachIndexed { index, header -> val nameField: @Composable (Modifier) -> Unit = { modifier -> - OutlinedTextField( + OpenCodeTextField( value = header.name, onValueChange = { value -> update(index) { it.copy(name = value) } }, - placeholder = { Text("Name") }, + placeholder = "Name", singleLine = true, keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.None, autoCorrectEnabled = false, imeAction = ImeAction.Next), modifier = modifier.semantics { contentDescription = "Header ${index + 1} name" }, ) } val valueField: @Composable (Modifier) -> Unit = { modifier -> - OutlinedTextField( + OpenCodeTextField( value = header.value, onValueChange = { value -> update(index) { it.copy(value = value) } }, - placeholder = { Text("Value") }, + placeholder = "Value", singleLine = true, keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.None, autoCorrectEnabled = false, imeAction = ImeAction.Next), modifier = modifier.semantics { contentDescription = "Header ${index + 1} value" }, diff --git a/core/src/main/kotlin/ai/opencode/core/ui/AppTheme.kt b/core/src/main/kotlin/ai/opencode/core/ui/AppTheme.kt index 506aa3065..503e89854 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/AppTheme.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/AppTheme.kt @@ -323,7 +323,7 @@ object ThemePalette { fun definition(theme: AppTheme): ThemeDefinition = when (theme) { AppTheme.System -> system - AppTheme.OpenCode -> opencode + AppTheme.OpenCode -> BrandPalette.opencode AppTheme.TokyoNight -> tokyonight AppTheme.Catppuccin -> catppuccin AppTheme.Dracula -> dracula diff --git a/core/src/main/kotlin/ai/opencode/core/ui/BrandPalette.kt b/core/src/main/kotlin/ai/opencode/core/ui/BrandPalette.kt new file mode 100644 index 000000000..d05433c5b --- /dev/null +++ b/core/src/main/kotlin/ai/opencode/core/ui/BrandPalette.kt @@ -0,0 +1,90 @@ +package ai.opencode.core.ui + +/** + * The OpenCode desktop/web palette (`packages/ui` theme `oc-2`, its `--v2-*` tokens), used for + * [AppTheme.OpenCode] instead of the iOS-generated palette. Neutral and monochrome like the + * desktop app: the accent is the desktop's contrast fill (`--v2-background-bg-contrast` / + * `--v2-background-bg-icon-button-contrast`), blue is kept for links. + * + * Desktop token → field: + * canvas `bg-base`, canvasWeak `bg-deep` (sidebar), codeBand `bg-layer-01`, userBubble + * `bg-layer-02`, surfaceStrong `bg-layer-03`, text/strong `text-base`, textWeak `text-muted`, + * textTertiary `text-faint`, border `border-base` (flattened), borderStrong `border-strong`, + * link `text-accent`, syntax `--syntax-*`, diff `--v2-state-*-success/danger`. + * + * Light-mode divergences from the desktop, each darkened just enough for WCAG AA (4.5:1) on the + * fills it sits on (white, `#FAFAFA` code/drawer, `#EEEEEE` inline code): textTertiary `#808080` + * → `#6E6E6E`, link `#3B5CF6` → `#3A5BF6`, syntax keyword `#C83D8B` → `#C83B8A`, syntax string + * `#198B43` → `#188540`, diff-added text `#198B43` → `#17813E`. Dark mode is the desktop's. + */ +internal object BrandPalette { + private fun hex(value: String, alpha: Double = 1.0): ThemeRGBA { + val v = value.removePrefix("#").toLong(16) + return ThemeRGBA(((v shr 16) and 0xFF) / 255.0, ((v shr 8) and 0xFF) / 255.0, (v and 0xFF) / 255.0, alpha) + } + + val opencode = ThemeDefinition( + id = AppTheme.OpenCode, + title = "OpenCode", + light = ThemeVariant( + canvas = hex("#FFFFFF"), + canvasWeak = hex("#FAFAFA"), + codeBand = hex("#FAFAFA"), + userBubble = hex("#F2F2F2"), + surfaceStrong = hex("#EEEEEE"), + text = hex("#161616"), + bodyText = hex("#242424"), + textStrong = hex("#0A0A0A"), + textWeak = hex("#5C5C5C"), + textTertiary = hex("#6E6E6E"), + border = hex("#E6E6E6"), + borderStrong = hex("#CCCCCC"), + accent = hex("#242424"), + link = hex("#3A5BF6"), + syntaxKeyword = hex("#C83B8A"), + syntaxString = hex("#188540"), + syntaxNumber = hex("#007B80"), + syntaxComment = hex("#5C5C5C"), + syntaxType = hex("#5230C2"), + diffAddedFill = hex("#E7F9EA"), + diffRemovedFill = hex("#FCECEB"), + glassDiffAddedFill = hex("#198B43", 0.12), + glassDiffRemovedFill = hex("#B82D35", 0.10), + diffAddedText = hex("#17813E"), + diffRemovedText = hex("#B82D35"), + swatchCanvas = hex("#FFFFFF"), + swatchRing = hex("#C7C7C7"), + swatchAccent = hex("#242424"), + ), + dark = ThemeVariant( + canvas = hex("#161616"), + canvasWeak = hex("#101010"), + codeBand = hex("#1C1C1C"), + userBubble = hex("#2E2E2E"), + surfaceStrong = hex("#3A3A3A"), + text = hex("#EDEDED"), + bodyText = hex("#DDDDDD"), + textStrong = hex("#FAFAFA"), + textWeak = hex("#AEAEAE"), + textTertiary = hex("#8A8A8A"), + border = hex("#2D2D2D"), + borderStrong = hex("#454545"), + accent = hex("#DBDBDB"), + link = hex("#A2BCFF"), + syntaxKeyword = hex("#F799C6"), + syntaxString = hex("#96E3A6"), + syntaxNumber = hex("#93E9F6"), + syntaxComment = hex("#AEAEAE"), + syntaxType = hex("#9E99F7"), + diffAddedFill = hex("#14361D"), + diffRemovedFill = hex("#461516"), + glassDiffAddedFill = hex("#6BD586", 0.14), + glassDiffRemovedFill = hex("#F17471", 0.14), + diffAddedText = hex("#6BD586"), + diffRemovedText = hex("#F17471"), + swatchCanvas = hex("#161616"), + swatchRing = hex("#454545"), + swatchAccent = hex("#DBDBDB"), + ), + ) +} diff --git a/core/src/main/kotlin/ai/opencode/core/ui/DesignSystemGallery.kt b/core/src/main/kotlin/ai/opencode/core/ui/DesignSystemGallery.kt index c0230e993..c5a73e581 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/DesignSystemGallery.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/DesignSystemGallery.kt @@ -138,8 +138,8 @@ private fun ColorsSection() = Section("Colors") { "canvas" to c.canvas, "groupedCanvas" to c.groupedCanvas, "groupedCard" to c.groupedCard, "userBubble" to c.userBubble, "codeBand" to c.codeBand, "inlineCodeFill" to c.inlineCodeFill, "text" to c.text, "secondaryText" to c.secondaryText, "tertiaryText" to c.tertiaryText, - "border" to c.border, "accent" to c.accent, "link" to c.link, - "sendButton" to c.sendButtonBackground, "destructive" to c.destructive, + "border" to c.border, "accent" to c.accent, "link" to c.link, "signal" to c.signal, + "sendButton" to c.sendButtonBackground, "destructive" to c.destructive, "danger" to c.danger, "syntaxKeyword" to c.syntaxKeyword, "syntaxString" to c.syntaxString, "syntaxNumber" to c.syntaxNumber, "syntaxComment" to c.syntaxComment, "syntaxType" to c.syntaxType, "diffAddedFill" to c.diffAddedFill, "diffRemovedFill" to c.diffRemovedFill, diff --git a/core/src/main/kotlin/ai/opencode/core/ui/DynamicSystemTheme.kt b/core/src/main/kotlin/ai/opencode/core/ui/DynamicSystemTheme.kt index 393439d8d..aded9586f 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/DynamicSystemTheme.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/DynamicSystemTheme.kt @@ -71,7 +71,7 @@ object DynamicSystemTheme { } /** The app's semantic colours for the System theme, read from the wallpaper's [scheme]. */ - fun colors(scheme: ColorScheme, isDark: Boolean, highContrast: Boolean): OpenCodeColors { + fun colors(scheme: ColorScheme, isDark: Boolean, highContrast: Boolean, strongBorders: Boolean = highContrast): OpenCodeColors { val fixed = ThemePalette.system.variant(isDark) val onSurface = scheme.onSurface val bodyResolver: (Double) -> Color = { tone -> @@ -81,11 +81,12 @@ object DynamicSystemTheme { onSurface.copy(alpha = tone.toFloat()) } } - val border = if (highContrast) scheme.outline else scheme.outlineVariant + val border = if (highContrast || strongBorders) scheme.outline else scheme.outlineVariant return OpenCodeColors( theme = AppTheme.System, isDark = isDark, highContrast = highContrast, + strongBorders = strongBorders || highContrast, variant = variant(scheme, fixed), canvas = scheme.surface, groupedCanvas = scheme.surfaceContainer, @@ -103,6 +104,7 @@ object DynamicSystemTheme { sendButtonBackground = scheme.primary, sendButtonForeground = scheme.onPrimary, link = scheme.primary, + signal = scheme.primary, syntaxKeyword = fixed.syntaxKeyword.color, syntaxString = fixed.syntaxString.color, syntaxNumber = fixed.syntaxNumber.color, @@ -113,6 +115,7 @@ object DynamicSystemTheme { diffAddedText = onSurface, diffRemovedText = onSurface, destructive = scheme.error, + danger = scheme.error, bodyTextResolver = bodyResolver, ) } diff --git a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeButtons.kt b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeButtons.kt index 55276ebb6..c63f043bb 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeButtons.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeButtons.kt @@ -1,8 +1,10 @@ package ai.opencode.core.ui +import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.FilledTonalButton @@ -11,6 +13,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -20,12 +23,15 @@ enum class OpenCodeButtonRole { Normal, Destructive } object OpenCodeButtonDefaults { /** - * Height every peer button shares (iOS `.controlSize(.large)` ≈ 50 pt). Hierarchy comes - * from style, never size. + * Height every peer button shares: the 48 dp touch target (denser than iOS's 50 pt `.large`, + * still well above the desktop's 32 px). Hierarchy comes from style, never size. */ - val height: Dp = 52.dp + val height: Dp = 48.dp - val contentPadding = PaddingValues(horizontal = 20.dp, vertical = 12.dp) + val contentPadding = PaddingValues(horizontal = 16.dp, vertical = 10.dp) + + /** The desktop's button radius (`--radius-md`-ish 8 at phone size), not a capsule. */ + val shape: Shape = RoundedCornerShape(OpenCodeRadius.fill) } /** @@ -55,6 +61,7 @@ fun OpenCodePrimaryButton( onClick = onClick, modifier = modifier.heightIn(min = OpenCodeButtonDefaults.height), enabled = enabled, + shape = OpenCodeButtonDefaults.shape, colors = colors, contentPadding = OpenCodeButtonDefaults.contentPadding, content = content, @@ -84,15 +91,19 @@ fun OpenCodeSecondaryButton( role: OpenCodeButtonRole = OpenCodeButtonRole.Normal, content: @Composable RowScope.() -> Unit, ) { + // Desktop neutral button: a light neutral fill with a hairline. + val container = OpenCodeSurfaces.neutralFill val colors = if (role == OpenCodeButtonRole.Destructive) { - ButtonDefaults.filledTonalButtonColors(contentColor = OpenCodeTheme.colors.destructive) + ButtonDefaults.filledTonalButtonColors(containerColor = container, contentColor = OpenCodeTheme.colors.destructive) } else { - ButtonDefaults.filledTonalButtonColors() + ButtonDefaults.filledTonalButtonColors(containerColor = container, contentColor = OpenCodeTheme.colors.text) } FilledTonalButton( onClick = onClick, modifier = modifier.heightIn(min = OpenCodeButtonDefaults.height), enabled = enabled, + shape = OpenCodeButtonDefaults.shape, + border = BorderStroke(1.dp, OpenCodeTheme.colors.border), colors = colors, contentPadding = OpenCodeButtonDefaults.contentPadding, content = content, diff --git a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeColors.kt b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeColors.kt index 53fa8f72e..5f4012557 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeColors.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeColors.kt @@ -25,6 +25,11 @@ class OpenCodeColors( val theme: AppTheme, val isDark: Boolean, val highContrast: Boolean, + /** + * Hairlines draw in the strong border colour: Increase Contrast or Android's high-contrast + * text setting (desktop hairlines are under 3:1 against the canvas). + */ + val strongBorders: Boolean, /** The raw palette, for swatches (`swatchCanvas`, `swatchRing`, `swatchAccent`) and contrast checks. */ val variant: ThemeVariant, /** Plain backgrounds (iOS `systemBackground`). */ @@ -56,6 +61,11 @@ class OpenCodeColors( val sendButtonBackground: Color, val sendButtonForeground: Color, val link: Color, + /** + * Unread and new-item indicators (drawer dots, Catch Up). The desktop draws its unread dot + * in `--v2-background-bg-accent` (blue), not the neutral [accent]; this is the theme's link blue. + */ + val signal: Color, val syntaxKeyword: Color, val syntaxString: Color, val syntaxNumber: Color, @@ -67,6 +77,11 @@ class OpenCodeColors( val diffRemovedText: Color, /** Destructive roles only (iOS `systemRed`: delete, end call). */ val destructive: Color, + /** + * Failure text and glyphs (a failed tool, a run error): the desktop's `--v2-state-fg-danger`, + * deeper than [destructive] in light and softer in dark. Not for fills behind white labels. + */ + val danger: Color, private val bodyTextResolver: (Double) -> Color, ) { /** @@ -87,7 +102,7 @@ class OpenCodeColors( * this uses their concrete values (the [ThemePalette.system] reference palette plus the * UIKit-only fills below). */ - fun resolve(theme: AppTheme, isDark: Boolean, highContrast: Boolean = false): OpenCodeColors { + fun resolve(theme: AppTheme, isDark: Boolean, highContrast: Boolean = false, strongBorders: Boolean = highContrast): OpenCodeColors { val v = ThemePalette.definition(theme).variant(isDark) val system = theme == AppTheme.System val label = v.text @@ -104,6 +119,7 @@ class OpenCodeColors( theme = theme, isDark = isDark, highContrast = highContrast, + strongBorders = strongBorders || highContrast, variant = v, canvas = v.canvas.color, groupedCanvas = (if (isDark) v.canvas else v.canvasWeak).color, @@ -120,11 +136,12 @@ class OpenCodeColors( secondaryText = (if (!system && highContrast) v.text else v.textWeak).color, tertiaryText = (if (!system && highContrast) v.textWeak else v.textTertiary).color, defaultBodyText = bodyResolver(0.92), - border = (if (!system && highContrast) v.borderStrong else v.border).color, + border = (if ((!system && highContrast) || strongBorders) v.borderStrong else v.border).color, accent = v.accent.color, sendButtonBackground = (if (system) label else v.accent).color, sendButtonForeground = (if (system) v.canvas else v.accent.highContrastForeground).color, link = v.link.color, + signal = v.link.color, syntaxKeyword = v.syntaxKeyword.color, syntaxString = v.syntaxString.color, syntaxNumber = v.syntaxNumber.color, @@ -135,6 +152,7 @@ class OpenCodeColors( diffAddedText = (if (system) label else v.diffAddedText).color, diffRemovedText = (if (system) label else v.diffRemovedText).color, destructive = SystemColors.red(isDark).color, + danger = (if (system) SystemColors.red(isDark) else v.diffRemovedText).color, bodyTextResolver = bodyResolver, ) } @@ -163,8 +181,7 @@ internal object SystemColors { * | secondaryContainer / onSecondaryContainer | surfaceStrong (secondary buttons) / text | * | tertiary / onTertiary | link / white (System) or the link's high-contrast foreground (themes) | * | background, surface, surfaceContainerLowest | canvas | - * | surfaceContainerLow | canvasWeak (grouped canvas, light) | - * | surfaceContainer | canvasWeak ↔ userBubble midpoint | + * | surfaceContainerLow, surfaceContainer | System: canvasWeak / canvasWeak ↔ userBubble midpoint; curated themes: the desktop's floating surface ([floating]: canvas in light, a raised step above the canvas in dark), so sheets, menus and tooltips are flat floating panels | * | surfaceContainerHigh, surfaceVariant | userBubble | * | surfaceContainerHighest | surfaceStrong | * | onSurface / onSurfaceVariant | text / secondary text | @@ -181,9 +198,11 @@ fun OpenCodeColors.toColorScheme(): ColorScheme { val textRgba = if (!system && highContrast) v.textStrong else v.text val secondary = (if (!system && highContrast) v.text else v.textWeak).composited(canvas) val outline = v.borderStrong.composited(canvas) - val outlineVariant = (if (!system && highContrast) v.borderStrong else v.border).composited(canvas) + val outlineVariant = (if ((!system && highContrast) || strongBorders) v.borderStrong else v.border).composited(canvas) val error = if (system) SystemColors.red(isDark) else v.diffRemovedText val container = v.canvasWeak.mixedInOklab(v.userBubble, 0.5) + // Desktop floating surfaces (sheets, menus, popovers): white in light, a step up in dark. + val floatingSurface = if (isDark) v.darkFloatingFill() else canvas val primaryContainer = canvas.mixedInOklab(accent, 0.22) val errorContainer = (if (system) SystemColors.red(isDark).withAlpha(0.14) else v.glassDiffRemovedFill).composited(canvas) val surfaceBright = if (isDark) v.surfaceStrong else canvas @@ -214,7 +233,8 @@ fun OpenCodeColors.toColorScheme(): ColorScheme { onSurface = textRgba.color, surfaceVariant = v.userBubble.color, onSurfaceVariant = secondary.color, - surfaceTint = accent.color, + // Flat surfaces (desktop): no tonal-elevation tint; depth comes from hairlines. + surfaceTint = Color.Transparent, inverseSurface = v.text.color, inverseOnSurface = canvas.color, error = error.color, @@ -225,10 +245,10 @@ fun OpenCodeColors.toColorScheme(): ColorScheme { outlineVariant = outlineVariant.color, surfaceBright = surfaceBright.color, surfaceDim = surfaceDim.color, - surfaceContainer = container.color, + surfaceContainer = (if (system) container else floatingSurface).color, surfaceContainerHigh = v.userBubble.color, surfaceContainerHighest = v.surfaceStrong.color, - surfaceContainerLow = v.canvasWeak.color, + surfaceContainerLow = (if (system) v.canvasWeak else floatingSurface).color, surfaceContainerLowest = canvas.color, scrim = Color.Black, ) diff --git a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeFormControls.kt b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeFormControls.kt new file mode 100644 index 000000000..3ca32c1ee --- /dev/null +++ b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeFormControls.kt @@ -0,0 +1,217 @@ +package ai.opencode.core.ui + +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.animateDpAsState +import androidx.compose.animation.core.tween +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.interaction.collectIsPressedAsState +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.offset +import androidx.compose.foundation.layout.requiredSize +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.foundation.selection.toggleable +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.BottomSheetDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.minimumInteractiveComponentSize +import androidx.compose.runtime.Composable +import androidx.compose.runtime.ReadOnlyComposable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.graphics.lerp +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.IntOffset +import androidx.compose.ui.unit.dp + +/** + * The desktop's switch (`packages/ui` `forms/switch`): a rounded-square track with a square + * thumb, no checkmark, 150 ms slides, half opacity when disabled; pressing widens the thumb + * toward the middle like the desktop's hover. Sized up for touch: a 40 × 24 dp track and an + * 18 dp thumb with concentric corners (7 and 4 dp, 3 dp apart), inside a 48 dp target when it + * toggles itself. + * + * Off is light, as on the desktop: a quiet track fill and a light thumb, with the track's + * outline carrying the 3:1 contrast against the row (not a dark thumb). On is the accent with + * its foreground thumb. The System theme takes the same roles from Material You. + * + * A drop-in for Material's `Switch`: the same [checked] / [onCheckedChange] contract (null when + * a parent row is the toggleable, as Material's) and `Role.Switch` semantics. + */ +@Composable +fun OpenCodeSwitch( + checked: Boolean, + onCheckedChange: ((Boolean) -> Unit)?, + modifier: Modifier = Modifier, + enabled: Boolean = true, + interactionSource: MutableInteractionSource? = null, +) { + val source = interactionSource ?: remember { MutableInteractionSource() } + val pressed by source.collectIsPressedAsState() + val colors = switchColors() + + var toggle: Modifier = Modifier + if (onCheckedChange != null) { + toggle = Modifier + .minimumInteractiveComponentSize() + .toggleable( + value = checked, + interactionSource = source, + indication = null, + enabled = enabled, + role = Role.Switch, + onValueChange = onCheckedChange, + ) + } + + val thumbWidthTarget = if (pressed && enabled) SwitchMetrics.pressedThumbWidth else SwitchMetrics.thumbSize + val thumbXTarget = if (checked) { + SwitchMetrics.trackWidth - SwitchMetrics.thumbInset - thumbWidthTarget + } else { + SwitchMetrics.thumbInset + } + val duration = SwitchMetrics.ANIMATION_MILLIS + val thumbWidth by animateDpAsState(thumbWidthTarget, tween(duration), label = "switchThumbWidth") + val thumbX by animateDpAsState(thumbXTarget, tween(duration), label = "switchThumbX") + val trackColor by animateColorAsState( + if (checked) colors.checkedTrack else colors.uncheckedTrack, + tween(duration), + label = "switchTrack", + ) + val borderColor by animateColorAsState( + if (checked) colors.checkedTrack else colors.uncheckedBorder, + tween(duration), + label = "switchBorder", + ) + val thumbColor by animateColorAsState( + if (checked) colors.checkedThumb else colors.uncheckedThumb, + tween(duration), + label = "switchThumb", + ) + + val trackShape = SwitchMetrics.trackShape + val thumbShape = SwitchMetrics.thumbShape + var thumbEdge: Modifier = Modifier + if (colors.thumbEdge != Color.Transparent) { + thumbEdge = Modifier + .shadow(SwitchMetrics.thumbElevation, thumbShape, clip = false, ambientColor = colors.thumbShadow, spotColor = colors.thumbShadow) + .border(SwitchMetrics.thumbEdgeWidth, colors.thumbEdge, thumbShape) + } + Box( + modifier + .then(toggle) + .wrapContentSize(Alignment.Center) + .requiredSize(SwitchMetrics.trackWidth, SwitchMetrics.trackHeight) + .alpha(if (enabled) 1f else SwitchMetrics.DISABLED_ALPHA) + .background(trackColor, trackShape) + .border(SwitchMetrics.borderWidth, borderColor, trackShape), + contentAlignment = Alignment.CenterStart, + ) { + Box( + Modifier + .offset { IntOffset(thumbX.roundToPx(), 0) } + .size(thumbWidth, SwitchMetrics.thumbSize) + .then(thumbEdge) + .background(thumbColor, thumbShape), + ) + } +} + +/** [OpenCodeSwitch]'s resolved colours for the current theme and appearance. */ +private class SwitchColors( + val checkedTrack: Color, + val checkedThumb: Color, + val uncheckedTrack: Color, + val uncheckedBorder: Color, + val uncheckedThumb: Color, + /** A faint edge and shadow that lift a light thumb off a light track; transparent in dark. */ + val thumbEdge: Color, + val thumbShadow: Color, +) + +@Composable +private fun switchColors(): SwitchColors { + val colors = OpenCodeTheme.colors + val scheme = MaterialTheme.colorScheme + // Off reads through its outline: the row colour mixed most of the way to the muted text + // colour is 3:1 or more on the row in every theme (full strength under high contrast). + val outlineStrength = if (colors.strongBorders) 1f else SwitchMetrics.OUTLINE_STRENGTH + val outline = if (colors.theme == AppTheme.System) { + scheme.outline + } else { + lerp(colors.groupedCard, colors.tertiaryText, outlineStrength) + } + val lightThumb = if (colors.isDark) colors.secondaryText else scheme.surfaceContainerLowest + val edge = if (colors.isDark) Color.Transparent else Color.Black.copy(alpha = 0.10f) + return SwitchColors( + checkedTrack = scheme.primary, + checkedThumb = scheme.onPrimary, + uncheckedTrack = scheme.surfaceContainerHighest, + uncheckedBorder = outline, + uncheckedThumb = lightThumb, + thumbEdge = edge, + thumbShadow = Color.Black.copy(alpha = 0.35f), + ) +} + +/** + * A bottom sheet's drag handle as the desktop's resize handle (`components/resize-handle`): a + * 40 × 4 dp pill in the muted icon colour ([OpenCodeColors.tertiaryText], 3:1 or more on the + * sheet). Material's `DragHandle` underneath, so the sheet keeps its band, its "Drag handle" + * label and its expand / collapse / dismiss actions. + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun OpenCodeSheetHandle(modifier: Modifier = Modifier) { + BottomSheetDefaults.DragHandle( + modifier = modifier, + width = OpenCodeSheetHandleDefaults.width, + height = OpenCodeSheetHandleDefaults.height, + shape = OpenCodeShape.capsule, + color = OpenCodeSheetHandleDefaults.color, + ) +} + +/** The handle pill's size and colour, for sheets that draw their own grabber band. */ +object OpenCodeSheetHandleDefaults { + val width: Dp = 40.dp + val height: Dp = 4.dp + + val color: Color + @Composable @ReadOnlyComposable get() = OpenCodeTheme.colors.tertiaryText +} + +/** + * Bottom sheets' container shape: [OpenCodeRadius.sheet] (16 dp) on the top corners, squarer than + * Material's extra-large sheet corner. + */ +object OpenCodeSheetDefaults { + val shape: Shape = RoundedCornerShape(topStart = OpenCodeRadius.sheet, topEnd = OpenCodeRadius.sheet) +} + +/** [OpenCodeSwitch]'s geometry: the desktop switch's proportions at touch size. */ +private object SwitchMetrics { + val trackWidth: Dp = 40.dp + val trackHeight: Dp = 24.dp + val borderWidth: Dp = 1.dp + val thumbInset: Dp = 3.dp + val thumbSize: Dp = 18.dp + val pressedThumbWidth: Dp = 21.dp + val thumbElevation: Dp = 1.dp + val thumbEdgeWidth: Dp = 0.5.dp + val trackShape = RoundedCornerShape(7.dp) + val thumbShape = RoundedCornerShape(OpenCodeRadius.xs) + const val ANIMATION_MILLIS = 150 + const val DISABLED_ALPHA = 0.5f + const val OUTLINE_STRENGTH = 0.85f +} diff --git a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeShapes.kt b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeShapes.kt index a396b2dbd..1b0d5668a 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeShapes.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeShapes.kt @@ -9,32 +9,39 @@ import kotlin.math.max import kotlin.math.min /** - * Corner radii the iOS app uses (surveyed from its `cornerRadius:` / `.rect(cornerRadius:)` - * call sites). iOS draws `.continuous` (squircle) corners; Compose's rounded corners are - * circular, which reads the same at these sizes. + * Corner radii, on this branch the OpenCode desktop's (`--radius-sm` 4, `-md` 6, `-lg` 8, + * `-xl` 10, the 12 px dock), keeping the iOS role names so call sites are unchanged. Sheets + * keep a larger 16 dp top radius so they still read as Android sheets. */ object OpenCodeRadius { - /** Tiny marks: inline code, checkbox insets (6). */ - val xs: Dp = 6.dp - /** Small fills and thumbnails (10). */ - val sm: Dp = 10.dp - /** Tertiary-fill fields and rows (`tertiarySystemFill` boxes, 14). */ - val fill: Dp = 14.dp - /** Inline controls and trays (16). */ - val control: Dp = 16.dp - /** Cards and glass cards (server list, error report, 20). */ - val card: Dp = 20.dp - /** Attachment chips, clipped media, settings tiles (22). */ - val tile: Dp = 22.dp - /** Large panels: connect, server details, What's New cards (26). */ - val panel: Dp = 26.dp - /** Sheets, scanner frame, model list, voice panel (28). */ - val sheet: Dp = 28.dp + /** Tiny marks: inline code, checkbox insets (desktop 4). */ + val xs: Dp = 4.dp + /** Small fills and thumbnails (desktop 6). */ + val sm: Dp = 6.dp + /** Tertiary-fill fields and rows (`tertiarySystemFill` boxes, desktop 8). */ + val fill: Dp = 8.dp + /** Inline controls and trays (desktop 8). */ + val control: Dp = 8.dp + /** Cards and glass cards (server list, error report, desktop 10). */ + val card: Dp = 10.dp + /** Attachment chips, clipped media, settings tiles (desktop 10). */ + val tile: Dp = 10.dp + /** Large panels: connect, server details, What's New cards (desktop dock 12). */ + val panel: Dp = 12.dp + /** Sheets, scanner frame, model list, voice panel (16). */ + val sheet: Dp = 16.dp } -/** Shapes for the iOS forms: capsules and circles stay capsules and circles. */ +/** + * Shapes for the iOS forms. [capsule] and [circle] stay true capsules and circles (grabbers, + * dots, avatars); controls that iOS draws as glass capsules use [control], the desktop's small + * rounded rectangle. + */ object OpenCodeShape { val capsule = RoundedCornerShape(percent = 50) + + /** Buttons, pills and fields (desktop `--radius-md`/`-lg` at phone size). */ + val control = RoundedCornerShape(OpenCodeRadius.fill) val circle = CircleShape val card = RoundedCornerShape(OpenCodeRadius.card) val panel = RoundedCornerShape(OpenCodeRadius.panel) @@ -46,12 +53,13 @@ object OpenCodeShape { } /** - * Material shape scale from the iOS radii: extraSmall 6, small 10, medium 14, large 20, - * extraLarge 28. Material components read these (menus small, cards medium, dialogs and + * Material shape scale from the desktop radii: extraSmall 6, small 6, medium 8, large 10, + * extraLarge 16. Material components read these (text fields and menus extraSmall, dialogs and * sheets extraLarge). */ val OpenCodeShapes = Shapes( - extraSmall = RoundedCornerShape(OpenCodeRadius.xs), + // Text fields and menus: the desktop's 6 px input and context-menu radius. + extraSmall = RoundedCornerShape(OpenCodeRadius.sm), small = RoundedCornerShape(OpenCodeRadius.sm), medium = RoundedCornerShape(OpenCodeRadius.fill), large = RoundedCornerShape(OpenCodeRadius.card), diff --git a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeSurfaces.kt b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeSurfaces.kt new file mode 100644 index 000000000..cf16fc612 --- /dev/null +++ b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeSurfaces.kt @@ -0,0 +1,144 @@ +package ai.opencode.core.ui + +import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.border +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material3.AlertDialog +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ProvideTextStyle +import androidx.compose.material3.SwitchColors +import androidx.compose.material3.SwitchDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.ReadOnlyComposable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import androidx.compose.ui.window.DialogProperties + +/** + * The OpenCode desktop's floating surfaces (`packages/ui` popover, dialog, dock: + * `--surface-raised-stronger-non-alpha`): a flat fill a step off the canvas, a hairline ring and, + * for things that float over content, a small shadow. No tonal elevation. + * + * Material components pick most of this up from the theme ([toColorScheme] maps + * `surfaceContainerLow`/`surfaceContainer` here for the curated themes, so bottom sheets, menus + * and tooltips are floating surfaces); call sites use these for what Material can't express + * (borders, the dialog's fill). + */ +object OpenCodeSurfaces { + /** Dialogs and popovers (desktop dialog ~10–12 px). */ + val dialogShape: Shape = RoundedCornerShape(OpenCodeRadius.panel) + + /** Popovers, menus and floating panels. */ + val popoverShape: Shape = RoundedCornerShape(OpenCodeRadius.card) + + /** The hairline every floating surface wears. */ + val hairline: Dp = 1.dp + + /** A small shadow under surfaces that float over content (desktop `--v2-elevation-raised`). */ + val raisedShadow: Dp = 1.5.dp + + /** Popovers and menus (desktop `--shadow-md`). */ + val popoverShadow: Dp = 4.dp + + /** The floating surface's fill: white in light, a step above the canvas in dark. */ + val color: Color + @Composable @ReadOnlyComposable get() = OpenCodeTheme.colors.floating + + /** + * Neutral and secondary buttons' fill: a light grey that reads as a button on the canvas in + * both modes (`surfaceContainerHighest`, the brand's `surfaceStrong` `#EEEEEE` / `#3A3A3A`; + * labels 15.6:1 / 9.9:1). Worn with the hairline. + */ + val neutralFill: Color + @Composable @ReadOnlyComposable get() = MaterialTheme.colorScheme.surfaceContainerHighest + + /** + * Copy-command and terminal boxes, clearly set off from the canvas: the desktop's + * `--v2-background-bg-layer-03` in light (`#EEEEEE`) and its shell block's `bg-layer-02` in + * dark (`#2E2E2E`). Text on it is 15.6:1 / 11.6:1. + */ + val commandFill: Color + @Composable @ReadOnlyComposable get() = OpenCodeTheme.colors.let { if (it.isDark) it.userBubble else it.variant.surfaceStrong.color } + + /** The floating surface's hairline. */ + val border: BorderStroke + @Composable @ReadOnlyComposable get() = BorderStroke(hairline, OpenCodeTheme.colors.border) +} + +/** + * The floating fill for these colours: the canvas in light (desktop popovers are white), a raised + * step above the canvas in dark ([darkFloatingFill]). The System theme keeps its code band. + */ +val OpenCodeColors.floating: Color + get() = when { + !isDark -> canvas + theme == AppTheme.System -> codeBand.copy(alpha = 1f) + else -> variant.darkFloatingFill().color + } + +/** + * Dark floating fill: the code band lifted about a third of the way to the user bubble (brand + * `#1C1C1C` → `#222222` on the `#161616` canvas), so the composer, request cards, menus and + * panels read as raised, as the desktop's `#1C1C1C` does over its `#101010` background. + */ +internal fun ThemeVariant.darkFloatingFill(): ThemeRGBA = + codeBand.composited(canvas).mixedInOklab(userBubble.composited(canvas), 0.35) + +/** A hairline ring in [shape] (desktop `0 0 0 1px border-base`). */ +@Composable +fun Modifier.openCodeHairline(shape: Shape): Modifier = + border(OpenCodeSurfaces.hairline, OpenCodeTheme.colors.border, shape) + +/** + * Material's [AlertDialog] as the desktop's dialog: floating fill, hairline ring, 12 dp corners, + * no tonal elevation, a 16 sp medium title and 14 sp body. Semantics, buttons and dismissal are + * Material's, unchanged. + */ +@Composable +fun OpenCodeAlertDialog( + onDismissRequest: () -> Unit, + confirmButton: @Composable () -> Unit, + modifier: Modifier = Modifier, + dismissButton: (@Composable () -> Unit)? = null, + icon: (@Composable () -> Unit)? = null, + title: (@Composable () -> Unit)? = null, + text: (@Composable () -> Unit)? = null, + properties: DialogProperties = DialogProperties(), +) { + val shape = OpenCodeSurfaces.dialogShape + AlertDialog( + onDismissRequest = onDismissRequest, + confirmButton = confirmButton, + modifier = modifier.openCodeHairline(shape), + dismissButton = dismissButton, + icon = icon, + title = title?.let { content -> { ProvideTextStyle(OpenCodeTextStyles.headline) { content() } } }, + text = text?.let { content -> { ProvideTextStyle(OpenCodeTextStyles.subheadline) { content() } } }, + shape = shape, + containerColor = OpenCodeSurfaces.color, + tonalElevation = 0.dp, + properties = properties, + ) +} + +/** + * Switch colours for the curated themes. Material draws an off switch's border and thumb in + * `outline` (the desktop's `border-strong`, under 2:1 on cards); here they are [OpenCodeColors.tertiaryText], + * at least 3:1 against every surface a switch sits on and its own track (WCAG 1.4.11): light + * `#6E6E6E` 4.4–5.1:1, dark `#8A8A8A` 3.3–5.2:1. The System theme keeps Material's colours. + */ +object OpenCodeSwitchDefaults { + @Composable + fun colors(): SwitchColors { + val colors = OpenCodeTheme.colors + if (colors.theme == AppTheme.System) return SwitchDefaults.colors() + return SwitchDefaults.colors( + uncheckedThumbColor = colors.tertiaryText, + uncheckedBorderColor = colors.tertiaryText, + uncheckedIconColor = MaterialTheme.colorScheme.surfaceContainerHighest, + ) + } +} diff --git a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTextField.kt b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTextField.kt new file mode 100644 index 000000000..deb483c43 --- /dev/null +++ b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTextField.kt @@ -0,0 +1,389 @@ +package ai.opencode.core.ui + +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.animateDpAsState +import androidx.compose.animation.core.tween +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.interaction.MutableInteractionSource +import androidx.compose.foundation.interaction.collectIsFocusedAsState +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.text.BasicTextField +import androidx.compose.foundation.text.KeyboardActions +import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.ReadOnlyComposable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.Shape +import androidx.compose.ui.graphics.SolidColor +import androidx.compose.ui.graphics.lerp +import androidx.compose.ui.semantics.error +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.input.TextFieldValue +import androidx.compose.ui.text.input.VisualTransformation +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +/** + * The desktop's text input (`packages/ui` `forms/text-input`) at touch size: a 48 dp field with + * 8 dp corners, the page's own fill (a step up in dark) and a hairline edge, a 1.5 dp accent + * ring while focused, the danger colour when [isError], half opacity when disabled. The label + * sits above the field rather than floating inside it, and the placeholder shows whenever the + * field is empty. + * + * A drop-in for Material's `OutlinedTextField` built on [BasicTextField]: the label, placeholder + * and supporting text are part of the field's decoration, so TalkBack reads them with it as it + * does Material's, and IME, selection and autofill behave the same. + */ +@Composable +fun OpenCodeTextField( + value: String, + onValueChange: (String) -> Unit, + modifier: Modifier = Modifier, + label: String? = null, + placeholder: String? = null, + enabled: Boolean = true, + readOnly: Boolean = false, + isError: Boolean = false, + supportingText: String? = null, + leadingIcon: (@Composable () -> Unit)? = null, + trailingIcon: (@Composable () -> Unit)? = null, + textStyle: TextStyle = OpenCodeTextFieldDefaults.textStyle, + singleLine: Boolean = false, + minLines: Int = 1, + maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, + keyboardOptions: KeyboardOptions = KeyboardOptions.Default, + keyboardActions: KeyboardActions = KeyboardActions.Default, + visualTransformation: VisualTransformation = VisualTransformation.None, + interactionSource: MutableInteractionSource? = null, +) { + val source = interactionSource ?: remember { MutableInteractionSource() } + val colors = OpenCodeTextFieldDefaults.colors() + BasicTextField( + value = value, + onValueChange = onValueChange, + modifier = modifier.fieldErrorSemantics(isError, supportingText), + enabled = enabled, + readOnly = readOnly, + textStyle = textStyle.copy(color = colors.text), + cursorBrush = SolidColor(if (isError) colors.error else colors.cursor), + keyboardOptions = keyboardOptions, + keyboardActions = keyboardActions, + visualTransformation = visualTransformation, + interactionSource = source, + singleLine = singleLine, + minLines = minLines, + maxLines = maxLines, + decorationBox = { innerTextField -> + FieldDecoration( + innerTextField = innerTextField, + isEmpty = value.isEmpty(), + label = label, + placeholder = placeholder, + enabled = enabled, + isError = isError, + supportingText = supportingText, + leadingIcon = leadingIcon, + trailingIcon = trailingIcon, + singleLine = singleLine, + textStyle = textStyle, + interactionSource = source, + ) + }, + ) +} + +/** [OpenCodeTextField] for a [TextFieldValue] (caret and selection held by the caller). */ +@Composable +fun OpenCodeTextField( + value: TextFieldValue, + onValueChange: (TextFieldValue) -> Unit, + modifier: Modifier = Modifier, + label: String? = null, + placeholder: String? = null, + enabled: Boolean = true, + readOnly: Boolean = false, + isError: Boolean = false, + supportingText: String? = null, + leadingIcon: (@Composable () -> Unit)? = null, + trailingIcon: (@Composable () -> Unit)? = null, + textStyle: TextStyle = OpenCodeTextFieldDefaults.textStyle, + singleLine: Boolean = false, + minLines: Int = 1, + maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE, + keyboardOptions: KeyboardOptions = KeyboardOptions.Default, + keyboardActions: KeyboardActions = KeyboardActions.Default, + visualTransformation: VisualTransformation = VisualTransformation.None, + interactionSource: MutableInteractionSource? = null, +) { + val source = interactionSource ?: remember { MutableInteractionSource() } + val colors = OpenCodeTextFieldDefaults.colors() + BasicTextField( + value = value, + onValueChange = onValueChange, + modifier = modifier.fieldErrorSemantics(isError, supportingText), + enabled = enabled, + readOnly = readOnly, + textStyle = textStyle.copy(color = colors.text), + cursorBrush = SolidColor(if (isError) colors.error else colors.cursor), + keyboardOptions = keyboardOptions, + keyboardActions = keyboardActions, + visualTransformation = visualTransformation, + interactionSource = source, + singleLine = singleLine, + minLines = minLines, + maxLines = maxLines, + decorationBox = { innerTextField -> + FieldDecoration( + innerTextField = innerTextField, + isEmpty = value.text.isEmpty(), + label = label, + placeholder = placeholder, + enabled = enabled, + isError = isError, + supportingText = supportingText, + leadingIcon = leadingIcon, + trailingIcon = trailingIcon, + singleLine = singleLine, + textStyle = textStyle, + interactionSource = source, + ) + }, + ) +} + +/** + * A search field in the same container as [OpenCodeTextField]: a muted magnifier leading, the + * placeholder as its prompt. The model pickers' custom search rows use [openCodeFieldContainer] + * for the same look. + */ +@Composable +fun OpenCodeSearchField( + value: String, + onValueChange: (String) -> Unit, + placeholder: String, + modifier: Modifier = Modifier, + trailingIcon: (@Composable () -> Unit)? = null, + keyboardOptions: KeyboardOptions = KeyboardOptions.Default, + keyboardActions: KeyboardActions = KeyboardActions.Default, +) { + OpenCodeTextField( + value = value, + onValueChange = onValueChange, + modifier = modifier, + placeholder = placeholder, + leadingIcon = { + OpenCodeIcon( + SFSymbol.Magnifyingglass, + contentDescription = null, + size = OpenCodeTextFieldDefaults.iconSize, + tint = OpenCodeTextFieldDefaults.colors().icon, + ) + }, + trailingIcon = trailingIcon, + singleLine = true, + keyboardOptions = keyboardOptions, + keyboardActions = keyboardActions, + ) +} + +/** + * The field container on its own, for a custom field row (a search capsule with its own clear + * button): fill, hairline (or the focus / error ring), 8 dp corners, and the light-mode lift. + */ +@Composable +fun Modifier.openCodeFieldContainer( + isFocused: Boolean, + isError: Boolean = false, + shape: Shape = OpenCodeTextFieldDefaults.shape, +): Modifier { + val colors = OpenCodeTextFieldDefaults.colors() + val borderColor by animateColorAsState( + when { + isError -> colors.error + isFocused -> colors.focusedBorder + else -> colors.border + }, + tween(FieldMetrics.ANIMATION_MILLIS), + label = "fieldBorder", + ) + val borderWidth by animateDpAsState( + if (isFocused) FieldMetrics.focusedBorderWidth else FieldMetrics.borderWidth, + tween(FieldMetrics.ANIMATION_MILLIS), + label = "fieldBorderWidth", + ) + var lift: Modifier = Modifier + if (colors.shadow != Color.Transparent && !isFocused && !isError) { + lift = Modifier.shadow(FieldMetrics.elevation, shape, clip = false, ambientColor = colors.shadow, spotColor = colors.shadow) + } + return this + .then(lift) + .background(colors.container, shape) + .border(borderWidth, borderColor, shape) +} + +/** [OpenCodeTextField]'s geometry, type and colours. */ +object OpenCodeTextFieldDefaults { + val shape: Shape = OpenCodeShape.control + val minHeight: Dp = 48.dp + val horizontalPadding: Dp = 12.dp + val iconSize: Dp = 18.dp + + val textStyle: TextStyle + @Composable @ReadOnlyComposable get() = OpenCodeTextStyles.callout + + val labelStyle: TextStyle + @Composable @ReadOnlyComposable get() = OpenCodeTextStyles.footnote.copy(fontWeight = FontWeight.Medium) + + @Composable + @ReadOnlyComposable + fun colors(): OpenCodeTextFieldColors { + val colors = OpenCodeTheme.colors + val scheme = MaterialTheme.colorScheme + // Light: the page's own white with the desktop's soft lift. Dark: a step up from the sheet. + val container = if (colors.isDark) { + lerp(scheme.surfaceContainerLow, scheme.surfaceContainerHigh, 0.5f) + } else { + scheme.surfaceContainerLowest + } + val border = if (colors.strongBorders) colors.tertiaryText else scheme.outline + val shadow = if (colors.isDark) Color.Transparent else Color.Black.copy(alpha = 0.25f) + return OpenCodeTextFieldColors( + container = container, + border = border, + focusedBorder = scheme.primary, + error = scheme.error, + text = colors.text, + label = colors.secondaryText, + placeholder = colors.tertiaryText, + icon = colors.tertiaryText, + cursor = scheme.primary, + shadow = shadow, + ) + } +} + +/** [OpenCodeTextField]'s resolved colours for the current theme and appearance. */ +class OpenCodeTextFieldColors( + val container: Color, + val border: Color, + val focusedBorder: Color, + val error: Color, + val text: Color, + val label: Color, + val placeholder: Color, + val icon: Color, + val cursor: Color, + /** The light-mode lift under an idle field; transparent in dark. */ + val shadow: Color, +) + +@Composable +private fun FieldDecoration( + innerTextField: @Composable () -> Unit, + isEmpty: Boolean, + label: String?, + placeholder: String?, + enabled: Boolean, + isError: Boolean, + supportingText: String?, + leadingIcon: (@Composable () -> Unit)?, + trailingIcon: (@Composable () -> Unit)?, + singleLine: Boolean, + textStyle: TextStyle, + interactionSource: MutableInteractionSource, +) { + val colors = OpenCodeTextFieldDefaults.colors() + val focused by interactionSource.collectIsFocusedAsState() + Column( + Modifier.alpha(if (enabled) 1f else FieldMetrics.DISABLED_ALPHA), + verticalArrangement = Arrangement.spacedBy(FieldMetrics.labelSpacing), + ) { + if (label != null) { + Text(label, style = OpenCodeTextFieldDefaults.labelStyle, color = colors.label) + } + val verticalPadding = if (singleLine) 0.dp else FieldMetrics.multilineVerticalPadding + Row( + Modifier + .fillMaxWidth() + .heightIn(min = OpenCodeTextFieldDefaults.minHeight) + .openCodeFieldContainer(isFocused = focused && enabled, isError = isError), + verticalAlignment = if (singleLine) Alignment.CenterVertically else Alignment.Top, + ) { + if (leadingIcon != null) { + Box( + Modifier + .heightIn(min = OpenCodeTextFieldDefaults.minHeight) + .padding(start = OpenCodeTextFieldDefaults.horizontalPadding, end = FieldMetrics.iconSpacing), + contentAlignment = Alignment.Center, + ) { leadingIcon() } + } + val start = if (leadingIcon != null) 0.dp else OpenCodeTextFieldDefaults.horizontalPadding + val end = if (trailingIcon != null) 0.dp else OpenCodeTextFieldDefaults.horizontalPadding + Box( + Modifier + .weight(1f) + .heightIn(min = OpenCodeTextFieldDefaults.minHeight) + .padding(start = start, end = end, top = verticalPadding, bottom = verticalPadding), + contentAlignment = if (singleLine) Alignment.CenterStart else Alignment.TopStart, + ) { + if (isEmpty && placeholder != null) { + Text( + placeholder, + style = textStyle, + color = colors.placeholder, + maxLines = if (singleLine) 1 else Int.MAX_VALUE, + ) + } + innerTextField() + } + if (trailingIcon != null) { + Box( + Modifier.heightIn(min = OpenCodeTextFieldDefaults.minHeight), + contentAlignment = Alignment.Center, + ) { trailingIcon() } + } + } + if (supportingText != null) { + Text( + supportingText, + style = OpenCodeTextStyles.footnote, + color = if (isError) colors.error else colors.label, + ) + } + } +} + +/** Material's error semantics: TalkBack announces the error with the field. */ +private fun Modifier.fieldErrorSemantics(isError: Boolean, supportingText: String?): Modifier { + if (!isError) return this + return semantics { error(supportingText ?: FieldMetrics.DEFAULT_ERROR) } +} + +private object FieldMetrics { + val borderWidth: Dp = 1.dp + val focusedBorderWidth: Dp = 1.5.dp + val elevation: Dp = 1.dp + val labelSpacing: Dp = 6.dp + val iconSpacing: Dp = 8.dp + val multilineVerticalPadding: Dp = 13.dp + const val ANIMATION_MILLIS = 120 + const val DISABLED_ALPHA = 0.5f + const val DEFAULT_ERROR = "Invalid input" +} diff --git a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTheme.kt b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTheme.kt index 3b0716b34..dd3c83ce2 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTheme.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTheme.kt @@ -7,6 +7,10 @@ import android.app.Activity import android.app.UiModeManager import android.content.Context import android.content.ContextWrapper +import android.database.ContentObserver +import android.os.Handler +import android.os.Looper +import android.provider.Settings import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.material3.ColorScheme import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi @@ -21,6 +25,7 @@ import androidx.compose.runtime.State import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableFloatStateOf +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.platform.LocalConfiguration @@ -49,6 +54,7 @@ fun OpenCodeTheme( theme: AppTheme = AppTheme.System, appearance: AppearanceColorScheme = AppearanceColorScheme.System, highContrast: Boolean = rememberHighContrast(), + strongBorders: Boolean = highContrast || rememberHighContrastText(), reduceMotion: Boolean = rememberReduceMotion(), content: @Composable () -> Unit, ) { @@ -59,11 +65,11 @@ fun OpenCodeTheme( val dynamicScheme: ColorScheme? = remember(theme, isDark, context, configuration) { if (theme == AppTheme.System) DynamicSystemTheme.colorScheme(context, isDark) else null } - val colors = remember(theme, isDark, highContrast, dynamicScheme) { + val colors = remember(theme, isDark, highContrast, strongBorders, dynamicScheme) { if (dynamicScheme != null) { - DynamicSystemTheme.colors(dynamicScheme, isDark, highContrast) + DynamicSystemTheme.colors(dynamicScheme, isDark, highContrast, strongBorders) } else { - OpenCodeColors.resolve(theme, isDark, highContrast) + OpenCodeColors.resolve(theme, isDark, highContrast, strongBorders) } } val colorScheme = remember(colors, dynamicScheme) { dynamicScheme ?: colors.toColorScheme() } @@ -152,6 +158,28 @@ fun rememberHighContrast(): Boolean { private const val HIGH_CONTRAST_THRESHOLD = 0.5f +/** + * Android's High contrast text accessibility setting (`Settings.Secure` + * `high_text_contrast_enabled`), live-updating. Only hairlines follow it ([OpenCodeColors.strongBorders]). + */ +@Composable +fun rememberHighContrastText(): Boolean { + val context = LocalContext.current + val resolver = context.contentResolver + fun read() = Settings.Secure.getInt(resolver, HIGH_TEXT_CONTRAST, 0) == 1 + var enabled by remember(resolver) { mutableStateOf(read()) } + DisposableEffect(resolver) { + val observer = object : ContentObserver(Handler(Looper.getMainLooper())) { + override fun onChange(selfChange: Boolean) { enabled = read() } + } + resolver.registerContentObserver(Settings.Secure.getUriFor(HIGH_TEXT_CONTRAST), false, observer) + onDispose { resolver.unregisterContentObserver(observer) } + } + return enabled +} + +private const val HIGH_TEXT_CONTRAST = "high_text_contrast_enabled" + /** Accessors for the design system inside [OpenCodeTheme]. */ object OpenCodeTheme { /** iOS semantic colours (`ThemePalette.*`). */ diff --git a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTopBar.kt b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTopBar.kt new file mode 100644 index 000000000..c395920f9 --- /dev/null +++ b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTopBar.kt @@ -0,0 +1,238 @@ +package ai.opencode.core.ui + +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.windowInsetsPadding +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.LocalContentColor +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.ProvideTextStyle +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.TopAppBarScrollBehavior +import androidx.compose.runtime.Composable +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.derivedStateOf +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clipToBounds +import androidx.compose.ui.draw.drawWithContent +import androidx.compose.ui.geometry.Offset +import androidx.compose.ui.geometry.Size +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.layout.Layout +import androidx.compose.ui.layout.layout +import androidx.compose.ui.layout.onSizeChanged +import androidx.compose.ui.semantics.clearAndSetSemantics +import androidx.compose.ui.semantics.heading +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.text.style.TextOverflow +import androidx.compose.ui.unit.Constraints +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import kotlin.math.max +import kotlin.math.roundToInt + +/** Sizes of the desktop-style title bar ([OpenCodeTopBar], [OpenCodeLargeTopBar]). */ +object OpenCodeTopBarDefaults { + /** The bar's row: the session header's 52 dp (desktop 48 px), room for 48 dp controls. It grows with large text. */ + val height: Dp = 52.dp + + /** A start-aligned title's inset when there's no navigation control (desktop 16 px). */ + val titleInset: Dp = 16.dp +} + +/** + * The OpenCode desktop's title bar (`packages/app` settings and session headers): the pane's own + * canvas, a 16 sp medium title and plain icon controls, over a hairline instead of Material's + * tonal scrolled colour. Replaces Material's `TopAppBar`/`CenterAlignedTopAppBar`. + * + * Without a [scrollBehavior] the hairline always shows (the desktop's mobile settings bar). With + * one (Material's pinned behaviour) it fades in once content scrolls under the bar, on the + * theme's effects spring, as the session header's bar does. + * + * @param navigation the leading control (Back, or a Cancel/Done text button); 48 dp targets. + * @param centerTitle centre the title between the controls (iOS inline titles), else start-aligned. + * @param hairline false hides the hairline (a bar over a camera preview). + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun OpenCodeTopBar( + title: @Composable () -> Unit, + modifier: Modifier = Modifier, + navigation: @Composable () -> Unit = {}, + actions: @Composable RowScope.() -> Unit = {}, + centerTitle: Boolean = false, + scrollBehavior: TopAppBarScrollBehavior? = null, + containerColor: Color = OpenCodeTheme.colors.canvas, + contentColor: Color = OpenCodeTheme.colors.text, + hairline: Boolean = true, + windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, +) { + val overlapped by remember(scrollBehavior) { + derivedStateOf { scrollBehavior == null || scrollBehavior.state.overlappedFraction > 0.01f } + } + val lift by animateFloatAsState( + targetValue = if (hairline && overlapped) 1f else 0f, + animationSpec = MaterialTheme.motionScheme.defaultEffectsSpec(), + label = "top-bar-hairline", + ) + val border = OpenCodeTheme.colors.border + Box( + modifier + .fillMaxWidth() + .background(containerColor) + .drawWithContent { + drawContent() + drawBottomHairline(border, lift) + } + .windowInsetsPadding(windowInsets), + ) { + TopBarRow( + title = title, + navigation = navigation, + actions = actions, + centerTitle = centerTitle, + contentColor = contentColor, + ) + } +} + +/** + * The desktop title bar with a large page title under it (Settings pages): the title (title1, + * 24 sp medium) scrolls up under the bar as the list scrolls, Material's exit-until-collapsed + * behaviour, and the bar's own title and hairline fade in as it goes. Replaces Material 3 + * Expressive's `LargeFlexibleTopAppBar`; [scrollBehavior] must be + * `TopAppBarDefaults.exitUntilCollapsedScrollBehavior()`, connected to the page's nested scroll. + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun OpenCodeLargeTopBar( + title: String, + scrollBehavior: TopAppBarScrollBehavior, + modifier: Modifier = Modifier, + navigation: @Composable () -> Unit = {}, + actions: @Composable RowScope.() -> Unit = {}, + containerColor: Color = OpenCodeTheme.colors.canvas, + contentColor: Color = OpenCodeTheme.colors.text, + windowInsets: WindowInsets = TopAppBarDefaults.windowInsets, +) { + val state = scrollBehavior.state + // TalkBack reads whichever copy of the title is showing (Material's large bars do the same). + val collapsed by remember(state) { derivedStateOf { state.collapsedFraction >= 0.5f } } + val border = OpenCodeTheme.colors.border + Column( + modifier + .fillMaxWidth() + .background(containerColor) + .drawWithContent { + drawContent() + drawBottomHairline(border, state.collapsedFraction) + } + .windowInsetsPadding(windowInsets), + ) { + TopBarRow( + title = { + Text( + title, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + modifier = Modifier + .graphicsLayer { alpha = ((state.collapsedFraction - 0.5f) * 2f).coerceIn(0f, 1f) } + .then(if (collapsed) Modifier.semantics { heading() } else Modifier.clearAndSetSemantics {}), + ) + }, + navigation = navigation, + actions = actions, + centerTitle = false, + contentColor = contentColor, + ) + Box( + Modifier + .fillMaxWidth() + .clipToBounds() + .layout { measurable, constraints -> + val placeable = measurable.measure(constraints.copy(minHeight = 0, maxHeight = Constraints.Infinity)) + val height = (placeable.height + state.heightOffset).roundToInt().coerceIn(0, placeable.height) + layout(placeable.width, height) { placeable.place(0, height - placeable.height) } + }, + ) { + Text( + title, + style = OpenCodeTextStyles.title1, + color = contentColor, + modifier = Modifier + .fillMaxWidth() + // The title's full height is how far the bar collapses. + .onSizeChanged { state.heightOffsetLimit = -it.height.toFloat() } + .padding(start = OpenCodeTopBarDefaults.titleInset, end = OpenCodeTopBarDefaults.titleInset, top = 4.dp, bottom = 12.dp) + .graphicsLayer { alpha = 1f - state.collapsedFraction } + .then(if (collapsed) Modifier.clearAndSetSemantics {} else Modifier.semantics { heading() }), + ) + } + } +} + +/** The title bar's Back control: a plain chevron with a 48 dp target. */ +@Composable +fun OpenCodeTopBarBackButton(onClick: () -> Unit, modifier: Modifier = Modifier) { + OpenCodeIconButton(SFSymbol.ChevronBackward, contentDescription = "Back", onClick = onClick, modifier = modifier, style = OpenCodeIconButtonStyle.Standard) +} + +/** The bar's row: navigation, title, actions, at least [OpenCodeTopBarDefaults.height] tall. */ +@Composable +private fun TopBarRow( + title: @Composable () -> Unit, + navigation: @Composable () -> Unit, + actions: @Composable RowScope.() -> Unit, + centerTitle: Boolean, + contentColor: Color, +) { + CompositionLocalProvider(LocalContentColor provides contentColor) { + Layout( + contents = listOf( + { Box(Modifier.padding(start = 4.dp)) { navigation() } }, + { ProvideTextStyle(OpenCodeTextStyles.headline.copy(color = contentColor)) { title() } }, + { Row(Modifier.padding(end = 4.dp)) { actions() } }, + ), + modifier = Modifier.fillMaxWidth().heightIn(min = OpenCodeTopBarDefaults.height), + ) { (navigationMeasurables, titleMeasurables, actionMeasurables), constraints -> + val loose = constraints.copy(minWidth = 0, minHeight = 0) + val nav = navigationMeasurables.first().measure(loose) + val action = actionMeasurables.first().measure(loose) + val width = constraints.maxWidth + // A navigation control brings its own padding; a bare title starts at the desktop inset. + val navWidth = if (nav.width > 4.dp.roundToPx()) nav.width else OpenCodeTopBarDefaults.titleInset.roundToPx() + val gap = 4.dp.roundToPx() + val titleWidth = if (centerTitle) { + width - 2 * max(navWidth, action.width) - 2 * gap + } else { + width - navWidth - action.width - 2 * gap + } + val text = titleMeasurables.first().measure(loose.copy(maxWidth = max(titleWidth, 0))) + val height = max(constraints.minHeight, maxOf(nav.height, text.height, action.height)) + layout(width, height) { + nav.place(0, (height - nav.height) / 2) + action.place(width - action.width, (height - action.height) / 2) + val x = if (centerTitle) (width - text.width) / 2 else navWidth + if (nav.width > 4.dp.roundToPx()) gap else 0 + text.place(x, (height - text.height) / 2) + } + } + } +} + +private fun androidx.compose.ui.graphics.drawscope.DrawScope.drawBottomHairline(color: Color, alpha: Float) { + if (alpha <= 0f) return + val px = OpenCodeSurfaces.hairline.toPx() + drawRect(color = color, topLeft = Offset(0f, size.height - px), size = Size(size.width, px), alpha = alpha.coerceIn(0f, 1f)) +} diff --git a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTypography.kt b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTypography.kt index 58e9f46e3..f95565681 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTypography.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/OpenCodeTypography.kt @@ -11,13 +11,41 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.sp -/** Font families. Everything is the system sans (Roboto / the device font); iOS uses SF. */ +/** + * Font families. This branch uses the OpenCode desktop's fonts: Inter (variable) for UI text and + * IBM Plex Mono for code and tool output (`packages/ui` `--font-family-sans` / `-mono`). Both are + * OFL-1.1 (`docs/licenses/`). + */ object OpenCodeFonts { - /** The platform sans-serif, the Android counterpart of SF Pro. */ - val system: FontFamily = FontFamily.Default + /** + * Inter at the desktop's weights: Normal → 440 (`--font-weight-regular`), Medium → 530 + * (`--font-weight-medium`), SemiBold → 600, Bold → 670 (`--font-weight-bold`). + */ + @OptIn(ExperimentalTextApi::class) + val system: FontFamily = FontFamily( + listOf( + FontWeight.Light to 340, + FontWeight.Normal to 440, + FontWeight.Medium to 530, + FontWeight.SemiBold to 600, + FontWeight.Bold to 670, + FontWeight.ExtraBold to 760, + ).map { (weight, axis) -> + Font( + R.font.inter, + weight = weight, + variationSettings = FontVariation.Settings(FontVariation.weight(axis)), + ) + }, + ) - /** Monospace for code (iOS: SF Mono via `.monospaced()`). */ - val monospace: FontFamily = FontFamily.Monospace + /** IBM Plex Mono for code, tool output and paths (desktop `--font-family-mono`). */ + val monospace: FontFamily = FontFamily( + Font(R.font.plex_mono_regular, FontWeight.Normal), + Font(R.font.plex_mono_medium, FontWeight.Medium), + Font(R.font.plex_mono_semibold, FontWeight.SemiBold), + Font(R.font.plex_mono_semibold, FontWeight.Bold), + ) /** * Berkeley Mono (variable), only for onboarding's brand marks, exactly as iOS restricts @@ -36,43 +64,46 @@ object OpenCodeFonts { } /** - * iOS Dynamic Type text styles at the default size (Large), in sp. iOS points and Android - * dp are within 2 % physically (163 vs 160 per inch), so the sizes port 1:1 and keep iOS's - * relative scale; sp also follows the system font scale like Dynamic Type. + * The text styles under iOS's Dynamic Type names (so ported views still say `.footnote`), sized + * to the OpenCode desktop scale. sp follows the system font scale like Dynamic Type. * * Use these by name when porting a view that says `.font(.footnote)`; Material components * pick them up through [OpenCodeTypography]'s role mapping. */ object OpenCodeTextStyles { - private fun style(size: Int, lineHeight: Int, weight: FontWeight = FontWeight.Normal) = TextStyle( + private fun style(size: Int, lineHeight: Int, weight: FontWeight = FontWeight.Normal, tracking: Double = 0.0) = TextStyle( fontFamily = OpenCodeFonts.system, fontWeight = weight, fontSize = size.sp, lineHeight = lineHeight.sp, - letterSpacing = TextUnit.Unspecified, + letterSpacing = if (tracking == 0.0) TextUnit.Unspecified else tracking.sp, ) - /** `.largeTitle` 34/41. */ - val largeTitle = style(34, 41) - /** `.title` (title1) 28/34. */ - val title1 = style(28, 34) - /** `.title2` 22/28. */ - val title2 = style(22, 28) - /** `.title3` 20/25. */ - val title3 = style(20, 25) - /** `.headline` 17/22 semibold. */ - val headline = style(17, 22, FontWeight.SemiBold) - /** `.body` 17/22. */ - val body = style(17, 22) - /** `.callout` 16/21. */ - val callout = style(16, 21) - /** `.subheadline` 15/20. */ - val subheadline = style(15, 20) - /** `.footnote` 13/18. */ + // The desktop scale (13/14/16/20 px at weights 440/530/670) stretched for a phone held + // closer than a monitor: body text one step up (15 sp), titles medium-weight and tightly + // tracked like the desktop's `text-16/20-medium`. Everything stays in sp, so font scaling works. + + /** `.largeTitle`: 28/34 medium. */ + val largeTitle = style(28, 34, FontWeight.Medium, -0.4) + /** `.title` (title1): 24/30 medium. */ + val title1 = style(24, 30, FontWeight.Medium, -0.32) + /** `.title2`: 20/26 medium (desktop `text-20-medium`). */ + val title2 = style(20, 26, FontWeight.Medium, -0.32) + /** `.title3`: 18/24 medium. */ + val title3 = style(18, 24, FontWeight.Medium, -0.16) + /** `.headline`: 16/22 medium (desktop `text-16-medium`). */ + val headline = style(16, 22, FontWeight.Medium, -0.16) + /** `.body`: 15/23 (desktop markdown 14 px / 160 %). */ + val body = style(15, 23) + /** `.callout`: 15/21. */ + val callout = style(15, 21) + /** `.subheadline`: 14/20 (desktop `text-14`). */ + val subheadline = style(14, 20) + /** `.footnote`: 13/18 (desktop `text-12`, 13 px). */ val footnote = style(13, 18) - /** `.caption` (caption1) 12/16. */ + /** `.caption` (caption1): 12/16. */ val caption1 = style(12, 16) - /** `.caption2` 11/13. */ + /** `.caption2`: 11/13. */ val caption2 = style(11, 13) } @@ -104,11 +135,11 @@ val OpenCodeTypography: Typography = with(OpenCodeTextStyles) { headlineSmall = title3, titleLarge = title3, titleMedium = headline, - titleSmall = subheadline.copy(fontWeight = FontWeight.SemiBold), + titleSmall = subheadline.copy(fontWeight = FontWeight.Medium), bodyLarge = body, bodyMedium = subheadline, bodySmall = footnote, - labelLarge = body.copy(fontWeight = FontWeight.SemiBold), + labelLarge = subheadline.copy(fontWeight = FontWeight.Medium), labelMedium = caption1.copy(fontWeight = FontWeight.Medium), labelSmall = caption2.copy(fontWeight = FontWeight.Medium), ) diff --git a/core/src/main/kotlin/ai/opencode/core/ui/TapTarget.kt b/core/src/main/kotlin/ai/opencode/core/ui/TapTarget.kt index b81df4322..1ec317f4d 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/TapTarget.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/TapTarget.kt @@ -1,7 +1,9 @@ package ai.opencode.core.ui +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.BorderStroke +import androidx.compose.material3.OutlinedIconButton import androidx.compose.foundation.layout.size -import androidx.compose.material3.FilledTonalIconButton import androidx.compose.material3.IconButton import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.MaterialTheme @@ -62,7 +64,11 @@ enum class OpenCodeIconButtonStyle { /** Bare glyph (toolbar icons; iOS plain buttons inside a shared glass bar). */ Standard, - /** Tonal circle (iOS `openCodeGlassCircle`: a standalone round glass control). */ + /** + * A standalone control (iOS `openCodeGlassCircle`). On this branch it is the desktop's + * neutral icon button: a rounded square on the base surface with a hairline ring, or a + * filled rounded square when tinted. The name is kept so call sites match iOS. + */ Circle, } @@ -95,16 +101,17 @@ fun OpenCodeIconButton( OpenCodeIcon(symbol, contentDescription = contentDescription, size = iconSize) } OpenCodeIconButtonStyle.Circle -> { - val container = tint ?: MaterialTheme.colorScheme.surfaceContainerHighest - FilledTonalIconButton( + val container = tint ?: OpenCodeSurfaces.neutralFill + OutlinedIconButton( onClick = onClick, modifier = face, enabled = enabled, - shape = OpenCodeShape.circle, - colors = IconButtonDefaults.filledTonalIconButtonColors( + shape = RoundedCornerShape(OpenCodeRadius.card), + colors = IconButtonDefaults.outlinedIconButtonColors( containerColor = container, contentColor = tint?.highContrastForeground() ?: OpenCodeTheme.colors.text, ), + border = if (tint == null) BorderStroke(1.dp, OpenCodeTheme.colors.border) else null, ) { OpenCodeIcon(symbol, contentDescription = contentDescription, size = iconSize) } diff --git a/core/src/main/kotlin/ai/opencode/core/ui/ThemeSharedKeys.kt b/core/src/main/kotlin/ai/opencode/core/ui/ThemeSharedKeys.kt index f75ff0360..27884f47d 100644 --- a/core/src/main/kotlin/ai/opencode/core/ui/ThemeSharedKeys.kt +++ b/core/src/main/kotlin/ai/opencode/core/ui/ThemeSharedKeys.kt @@ -10,8 +10,8 @@ import ai.opencode.core.sharing.SharedKey * mutate only from the Settings reducer, and only when the value changes. */ object ThemeSharedKeys { - /** The chosen theme; [AppTheme.System] by default. */ - val appTheme = SharedKey.appStorage("appearance-theme", AppTheme.System) + /** The chosen theme; [AppTheme.OpenCode] (the desktop brand palette) by default on this branch. */ + val appTheme = SharedKey.appStorage("appearance-theme", AppTheme.OpenCode) /** System / Light / Dark override; [AppearanceColorScheme.System] by default. */ val appearanceColorScheme = SharedKey.appStorage("appearance-color-scheme", AppearanceColorScheme.System) diff --git a/core/src/main/res/font/inter.ttf b/core/src/main/res/font/inter.ttf new file mode 100644 index 000000000..e31b51e3e Binary files /dev/null and b/core/src/main/res/font/inter.ttf differ diff --git a/core/src/main/res/font/plex_mono_medium.ttf b/core/src/main/res/font/plex_mono_medium.ttf new file mode 100644 index 000000000..33c546f68 Binary files /dev/null and b/core/src/main/res/font/plex_mono_medium.ttf differ diff --git a/core/src/main/res/font/plex_mono_regular.ttf b/core/src/main/res/font/plex_mono_regular.ttf new file mode 100644 index 000000000..0c9770d51 Binary files /dev/null and b/core/src/main/res/font/plex_mono_regular.ttf differ diff --git a/core/src/main/res/font/plex_mono_semibold.ttf b/core/src/main/res/font/plex_mono_semibold.ttf new file mode 100644 index 000000000..8f8998a13 Binary files /dev/null and b/core/src/main/res/font/plex_mono_semibold.ttf differ diff --git a/core/src/test/kotlin/ai/opencode/core/ui/ThemePaletteTests.kt b/core/src/test/kotlin/ai/opencode/core/ui/ThemePaletteTests.kt index 14921dd65..afe572e13 100644 --- a/core/src/test/kotlin/ai/opencode/core/ui/ThemePaletteTests.kt +++ b/core/src/test/kotlin/ai/opencode/core/ui/ThemePaletteTests.kt @@ -84,9 +84,17 @@ class ThemePaletteTests { if (theme == AppTheme.System) continue val def = ThemePalette.definition(theme) - // Dark swatch accent dot sits at L ~= 0.78; light swatch accent dot sits at L ~= 0.52. - assertTrue("${theme.title} dark swatchAccent L=${def.dark.swatchAccent.oklch.first}", abs(def.dark.swatchAccent.oklch.first - 0.78) < 0.015) - assertTrue("${theme.title} light swatchAccent L=${def.light.swatchAccent.oklch.first}", abs(def.light.swatchAccent.oklch.first - 0.52) < 0.015) + if (theme == AppTheme.OpenCode) { + // Android diverges from iOS on purpose here: the OpenCode theme is the desktop's + // palette (BrandPalette), whose accent is the monochrome contrast fill, so its + // swatch dot is near-black in light and near-white in dark. + assertTrue("${theme.title} dark swatchAccent L=${def.dark.swatchAccent.oklch.first}", def.dark.swatchAccent.oklch.first > 0.85) + assertTrue("${theme.title} light swatchAccent L=${def.light.swatchAccent.oklch.first}", def.light.swatchAccent.oklch.first < 0.35) + } else { + // Dark swatch accent dot sits at L ~= 0.78; light swatch accent dot sits at L ~= 0.52. + assertTrue("${theme.title} dark swatchAccent L=${def.dark.swatchAccent.oklch.first}", abs(def.dark.swatchAccent.oklch.first - 0.78) < 0.015) + assertTrue("${theme.title} light swatchAccent L=${def.light.swatchAccent.oklch.first}", abs(def.light.swatchAccent.oklch.first - 0.52) < 0.015) + } // Swatch ring maintains a crisp perceptual lightness step from swatchCanvas, and the // three ThemeSwatchTile palette dots (swatchCanvas, swatchAccent, syntaxKeyword) are distinct. diff --git a/devtools/src/main/kotlin/ai/opencode/devtools/DevToolsView.kt b/devtools/src/main/kotlin/ai/opencode/devtools/DevToolsView.kt index 5872e0c62..efd04fd7b 100644 --- a/devtools/src/main/kotlin/ai/opencode/devtools/DevToolsView.kt +++ b/devtools/src/main/kotlin/ai/opencode/devtools/DevToolsView.kt @@ -1,12 +1,17 @@ package ai.opencode.devtools +import ai.opencode.core.ui.OpenCodeIconButtonStyle +import ai.opencode.core.ui.OpenCodeIconButton import ai.opencode.core.diagnostics.DiagnosticsEvent import ai.opencode.core.diagnostics.MotionWatchEvent import ai.opencode.core.store.StoreOf import ai.opencode.core.store.collectState import ai.opencode.core.tuning.AnimationTimeScale import ai.opencode.core.ui.OpenCodeIcon +import ai.opencode.core.ui.OpenCodeSwitchDefaults import ai.opencode.core.ui.OpenCodeTheme +import ai.opencode.core.ui.OpenCodeTopBar +import ai.opencode.core.ui.OpenCodeTopBarBackButton import ai.opencode.core.ui.SFSymbol import ai.opencode.devtools.perf.TimeScaleLabel import androidx.activity.compose.BackHandler @@ -16,13 +21,13 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.foundation.lazy.items @@ -33,7 +38,6 @@ import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.FilterChip import androidx.compose.material3.HorizontalDivider -import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold @@ -43,7 +47,6 @@ import androidx.compose.material3.SingleChoiceSegmentedButtonRow import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.material3.TextButton -import androidx.compose.material3.TopAppBar import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -98,11 +101,11 @@ fun DevToolsView( Scaffold( modifier = modifier, topBar = { - TopAppBar( + OpenCodeTopBar( title = { Text(title, Modifier.semantics { heading() }) }, - navigationIcon = { + navigation = { val back = if (state.route != DevToolsFeature.Route.Main) ({ send(DevToolsFeature.Action.BackTapped) }) else onClose - if (back != null) IconButton(onClick = back) { OpenCodeIcon(SFSymbol.ChevronBackward, "Back") } + if (back != null) OpenCodeTopBarBackButton(onClick = back) }, actions = { Actions(state, send) }, ) @@ -134,20 +137,25 @@ private fun Actions(state: DevToolsFeature.State, send: (DevToolsFeature.Action) DevToolsFeature.Route.Troubleshooting, DevToolsFeature.Route.Network -> { var menu by remember { mutableStateOf(false) } Box { - IconButton(onClick = { menu = true }, enabled = state.events.isNotEmpty()) { OpenCodeIcon(SFSymbol.SquareAndArrowUp, "Share") } + OpenCodeIconButton(SFSymbol.SquareAndArrowUp, "Share", onClick = { menu = true }, style = OpenCodeIconButtonStyle.Standard, enabled = state.events.isNotEmpty()) DropdownMenu(menu, onDismissRequest = { menu = false }) { DropdownMenuItem(text = { Text("Text") }, onClick = { menu = false; send(DevToolsFeature.Action.ShareTimelineTapped(json = false)) }) DropdownMenuItem(text = { Text("JSON") }, onClick = { menu = false; send(DevToolsFeature.Action.ShareTimelineTapped(json = true)) }) } } - IconButton(onClick = { send(DevToolsFeature.Action.ClearTapped) }, enabled = state.events.isNotEmpty() || state.motionJumps.isNotEmpty()) { - OpenCodeIcon(SFSymbol.Trash, "Clear", tint = MaterialTheme.colorScheme.error) - } + OpenCodeIconButton( + SFSymbol.Trash, + "Clear", + onClick = { send(DevToolsFeature.Action.ClearTapped) }, + style = OpenCodeIconButtonStyle.Standard, + tint = MaterialTheme.colorScheme.error, + enabled = state.events.isNotEmpty() || state.motionJumps.isNotEmpty(), + ) } DevToolsFeature.Route.Logs -> { - IconButton(onClick = { send(DevToolsFeature.Action.Reload) }) { OpenCodeIcon(SFSymbol.ArrowClockwise, "Refresh") } - IconButton(onClick = { send(DevToolsFeature.Action.CopyLogTapped) }) { OpenCodeIcon(SFSymbol.DocOnDoc, "Copy") } - IconButton(onClick = { send(DevToolsFeature.Action.ShareLogTapped) }) { OpenCodeIcon(SFSymbol.SquareAndArrowUp, "Share") } + OpenCodeIconButton(SFSymbol.ArrowClockwise, "Refresh", onClick = { send(DevToolsFeature.Action.Reload) }, style = OpenCodeIconButtonStyle.Standard) + OpenCodeIconButton(SFSymbol.DocOnDoc, "Copy", onClick = { send(DevToolsFeature.Action.CopyLogTapped) }, style = OpenCodeIconButtonStyle.Standard) + OpenCodeIconButton(SFSymbol.SquareAndArrowUp, "Share", onClick = { send(DevToolsFeature.Action.ShareLogTapped) }, style = OpenCodeIconButtonStyle.Standard) } else -> Unit } @@ -306,7 +314,7 @@ private fun SwitchRow( Text(title, style = MaterialTheme.typography.bodyLarge, color = if (enabled) MaterialTheme.colorScheme.onSurface else OpenCodeTheme.colors.secondaryText) if (subtitle != null) Text(subtitle, style = MaterialTheme.typography.bodySmall, color = OpenCodeTheme.colors.secondaryText) } - Switch(checked = checked, onCheckedChange = null, enabled = enabled) + Switch(checked = checked, onCheckedChange = null, enabled = enabled, colors = OpenCodeSwitchDefaults.colors()) } } diff --git a/devtools/src/main/kotlin/ai/opencode/devtools/traces/ProblemReportSheet.kt b/devtools/src/main/kotlin/ai/opencode/devtools/traces/ProblemReportSheet.kt index 7a5432e10..c609ce797 100644 --- a/devtools/src/main/kotlin/ai/opencode/devtools/traces/ProblemReportSheet.kt +++ b/devtools/src/main/kotlin/ai/opencode/devtools/traces/ProblemReportSheet.kt @@ -7,6 +7,9 @@ import ai.opencode.core.store.observe import ai.opencode.core.ui.OpenCodeIcon import ai.opencode.core.ui.OpenCodeIconSize import ai.opencode.core.ui.OpenCodePrimaryButton +import ai.opencode.core.ui.OpenCodeShape +import ai.opencode.core.ui.OpenCodeSurfaces +import ai.opencode.core.ui.OpenCodeSwitchDefaults import ai.opencode.core.ui.OpenCodeTextStyles import ai.opencode.core.ui.OpenCodeTheme import ai.opencode.core.ui.SFSymbol @@ -18,7 +21,6 @@ import androidx.compose.animation.fadeOut import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically import androidx.compose.foundation.clickable -import androidx.compose.foundation.selection.toggleable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -34,8 +36,8 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.selection.toggleable import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll import androidx.compose.material3.CircularProgressIndicator @@ -157,7 +159,7 @@ private fun NoteField(note: String, enabled: Boolean, onChange: (String) -> Unit minLines = 3, maxLines = 6, keyboardOptions = KeyboardOptions(capitalization = KeyboardCapitalization.Sentences), - shape = RoundedCornerShape(14.dp), + shape = OpenCodeShape.panel, colors = TextFieldDefaults.colors( focusedContainerColor = MaterialTheme.colorScheme.surfaceContainerHighest, unfocusedContainerColor = MaterialTheme.colorScheme.surfaceContainerHighest, @@ -173,8 +175,9 @@ private fun NoteField(note: String, enabled: Boolean, onChange: (String) -> Unit @Composable private fun ScreenshotToggle(isOn: Boolean, enabled: Boolean, onChange: (Boolean) -> Unit) { Surface( - shape = RoundedCornerShape(14.dp), - color = MaterialTheme.colorScheme.surfaceContainerHighest, + shape = OpenCodeShape.panel, + color = OpenCodeSurfaces.color, + border = OpenCodeSurfaces.border, modifier = Modifier.fillMaxWidth(), ) { Row( @@ -187,7 +190,7 @@ private fun ScreenshotToggle(isOn: Boolean, enabled: Boolean, onChange: (Boolean verticalAlignment = Alignment.CenterVertically, ) { Text("Include Screenshot", style = OpenCodeTextStyles.body, modifier = Modifier.weight(1f)) - Switch(checked = isOn, onCheckedChange = null, enabled = enabled) + Switch(checked = isOn, onCheckedChange = null, enabled = enabled, colors = OpenCodeSwitchDefaults.colors()) } } } @@ -215,8 +218,9 @@ private fun Footer(report: State.Report, send: (Action) -> Unit) { } State.Report.Phase.Sent -> Surface( - shape = RoundedCornerShape(14.dp), - color = MaterialTheme.colorScheme.surfaceContainerHighest, + shape = OpenCodeShape.panel, + color = OpenCodeSurfaces.color, + border = OpenCodeSurfaces.border, modifier = Modifier.fillMaxWidth().testTag("problem-report-sent"), ) { Row(Modifier.padding(start = 14.dp), verticalAlignment = Alignment.CenterVertically) { diff --git a/devtools/src/main/kotlin/ai/opencode/devtools/tuning/TuningPanel.kt b/devtools/src/main/kotlin/ai/opencode/devtools/tuning/TuningPanel.kt index 3e7855db0..e25aafe32 100644 --- a/devtools/src/main/kotlin/ai/opencode/devtools/tuning/TuningPanel.kt +++ b/devtools/src/main/kotlin/ai/opencode/devtools/tuning/TuningPanel.kt @@ -5,13 +5,17 @@ import ai.opencode.core.motion.MotionSpring import ai.opencode.core.motion.rememberReduceMotion import ai.opencode.core.store.StoreOf import ai.opencode.core.store.collectState +import ai.opencode.core.tuning.TunableDescriptor import ai.opencode.core.tuning.TuneKind import ai.opencode.core.tuning.TuneValue -import ai.opencode.core.tuning.TunableDescriptor import ai.opencode.core.tuning.TuningStore import ai.opencode.core.tuning.TuningTitle import ai.opencode.core.ui.OpenCodeIcon import ai.opencode.core.ui.OpenCodeIconSize +import ai.opencode.core.ui.OpenCodeShape +import ai.opencode.core.ui.OpenCodeSurfaces +import ai.opencode.core.ui.OpenCodeSwitchDefaults +import ai.opencode.core.ui.OpenCodeTextStyles import ai.opencode.core.ui.OpenCodeTheme import ai.opencode.core.ui.SFSymbol import ai.opencode.core.ui.openCodeTapTarget @@ -28,7 +32,7 @@ import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.scaleIn import androidx.compose.animation.scaleOut -import androidx.compose.foundation.BorderStroke +import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.gestures.awaitEachGesture import androidx.compose.foundation.gestures.awaitFirstDown @@ -44,6 +48,7 @@ import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.displayCutout import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.imeAnimationTarget import androidx.compose.foundation.layout.offset @@ -53,19 +58,21 @@ import androidx.compose.foundation.layout.systemBars import androidx.compose.foundation.layout.union import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn +import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.foundation.text.BasicText +import androidx.compose.foundation.text.TextAutoSize import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.FilterChip import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme -import androidx.compose.foundation.text.BasicText -import androidx.compose.foundation.text.TextAutoSize -import androidx.compose.ui.unit.sp +import androidx.compose.material3.SegmentedButton +import androidx.compose.material3.SegmentedButtonDefaults +import androidx.compose.material3.SingleChoiceSegmentedButtonRow import androidx.compose.material3.Slider import androidx.compose.material3.SliderDefaults import androidx.compose.material3.Surface @@ -92,19 +99,12 @@ import androidx.compose.ui.input.pointer.util.VelocityTracker import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalLayoutDirection -import androidx.compose.material3.SegmentedButton -import androidx.compose.material3.SegmentedButtonDefaults -import androidx.compose.material3.SingleChoiceSegmentedButtonRow -import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.selected -import androidx.compose.foundation.layout.wrapContentHeight -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.background -import ai.opencode.core.ui.OpenCodeTextStyles +import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.onClick import androidx.compose.ui.semantics.role +import androidx.compose.ui.semantics.selected import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.stateDescription import androidx.compose.ui.text.font.FontFamily @@ -113,6 +113,7 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import kotlin.math.PI import kotlin.math.roundToInt import kotlin.math.sqrt @@ -412,10 +413,10 @@ private fun PanelForm( val title = if (state.showsAll) "All" else tuning.context.displayTitle Surface( modifier = modifier.semantics { contentDescription = "Tuning Panel" }, - shape = RoundedCornerShape(20.dp), - tonalElevation = 6.dp, - shadowElevation = 8.dp, - border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant), + shape = OpenCodeShape.panel, + color = OpenCodeSurfaces.color, + shadowElevation = 6.dp, + border = OpenCodeSurfaces.border, ) { Column(Modifier.width(width).heightIn(max = maxHeight)) { PanelHeader(store, state, title, changed, groups, drag) @@ -516,10 +517,10 @@ private fun TuningPill(state: TuningFeature.State, expand: () -> Unit, modifier: contentAlignment = Alignment.Center, ) { Surface( - shape = CircleShape, - tonalElevation = 6.dp, - shadowElevation = 8.dp, - border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant), + shape = OpenCodeShape.control, + color = OpenCodeSurfaces.color, + shadowElevation = 6.dp, + border = OpenCodeSurfaces.border, ) { Row( Modifier.height(34.dp).padding(horizontal = 12.dp), @@ -558,11 +559,10 @@ private fun TuningTab(side: TuningPlacement.Side, pullOut: () -> Unit, modifier: ) { Surface( modifier = Modifier.size(TuningPlacementLayout.TAB_GLASS_WIDTH.dp, TuningPlacementLayout.TabSize.height.dp), - shape = CircleShape, - color = MaterialTheme.colorScheme.surfaceContainerHigh, - tonalElevation = 6.dp, - shadowElevation = 8.dp, - border = BorderStroke(1.dp, MaterialTheme.colorScheme.outlineVariant), + shape = OpenCodeShape.control, + color = OpenCodeSurfaces.color, + shadowElevation = 6.dp, + border = OpenCodeSurfaces.border, ) { Box(contentAlignment = Alignment.Center) { OpenCodeIcon( @@ -751,6 +751,7 @@ private fun TunableRow(descriptor: TunableDescriptor, override: TuneValue?, set: checked = (current as? TuneValue.Bool)?.value ?: false, onCheckedChange = { set(TuneValue.Bool(it)) }, modifier = Modifier.semantics { contentDescription = descriptor.label }, + colors = OpenCodeSwitchDefaults.colors(), ) if (isChanged) ValueText("Reset", true) { set(null) } } diff --git a/docs/licenses/IBMPlexMono-OFL.txt b/docs/licenses/IBMPlexMono-OFL.txt new file mode 100644 index 000000000..c35c4c618 --- /dev/null +++ b/docs/licenses/IBMPlexMono-OFL.txt @@ -0,0 +1,93 @@ +Copyright © 2017 IBM Corp. with Reserved Font Name "Plex" + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/licenses/Inter-OFL.txt b/docs/licenses/Inter-OFL.txt new file mode 100644 index 000000000..9b2ca37b3 --- /dev/null +++ b/docs/licenses/Inter-OFL.txt @@ -0,0 +1,92 @@ +Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION AND CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/parity/core-ui.md b/docs/parity/core-ui.md index 26b3505bc..3843b4fc0 100644 --- a/docs/parity/core-ui.md +++ b/docs/parity/core-ui.md @@ -6,13 +6,77 @@ files: `OpenCode/Core/Theme/`, `OpenCode/Core/Motion/`, `OpenCode/Core/RollingNu [core.md](core.md). Status values: `todo`, `partial: `, `done`, `n/a: `. + +**Visual divergence (on purpose):** behaviour, tokens' names and APIs port iOS, but the look is +the OpenCode desktop design system (`packages/ui`, theme `oc-2`), not iOS's SF / Liquid Glass: + +- Fonts: Inter (variable; Normal 440, Medium 530, SemiBold 600, Bold 670) for UI text, + IBM Plex Mono for code, tool output and commands (`res/font`, OFL in `docs/licenses/`). + `OpenCodeTextStyles` keep the iOS names at the desktop's sizes (body 15, subheadline 14, + footnote 13, headline 16 medium, titles medium with tight tracking), all in sp. +- Colour: `AppTheme.OpenCode` is `BrandPalette` (desktop v2 neutrals, monochrome contrast + accent, blue links; five light values darkened just enough for WCAG AA) and is the default + theme. Curated themes keep their palettes; System is Material You. For curated themes + `surfaceContainerLow`/`surfaceContainer` are the desktop floating surface (canvas in light; + in dark the code band lifted a third of the way to the user bubble, `darkFloatingFill`, about + `#222222` in `BrandPalette`) and `surfaceTint` is transparent, so Material sheets, menus and + tooltips are flat. `OpenCodeColors.signal` (the link blue; desktop `--v2-background-bg-accent`) + colours unread and new-item marks, since the brand `accent` is neutral; `OpenCodeColors.danger` + (`diffRemovedText`, desktop `--v2-state-fg-danger`) colours failure text and glyphs, while + `destructive` stays systemRed for destructive actions and fills. `OpenCodeColors.strongBorders`: hairlines use `borderStrong` under + Increase Contrast or Android's High contrast text (`rememberHighContrastText`). +- Shapes: `OpenCodeRadius` xs 4, sm 6, fill/control 8, card/tile 10, panel 12, sheet 16; + Material `Shapes` extraSmall 6, small 6, medium 8, large 10, extraLarge 16; + `OpenCodeShape.control` (8) for buttons, pills and fields; capsule/circle only for true + capsules (grabbers, dots, avatars). +- Surfaces (`ui/OpenCodeSurfaces.kt`): floating fill + 1 dp hairline (`openCodeHairline`) + + small shadow; `OpenCodeAlertDialog` (desktop dialog over Material's `AlertDialog`). +- Controls: buttons 48 dp, 8 dp corners; `OpenCodeSecondaryButton` is the neutral hairline + button; `OpenCodeIconButton(style = Circle)` is a 10 dp rounded square with a hairline. + `OpenCodeSwitch` (`ui/OpenCodeFormControls.kt`) is the desktop switch (`forms/switch`): a + 40 × 24 dp track and an 18 dp thumb with concentric corners (7 / 4 dp, 3 dp inset), no + checkmark, 150 ms slides, half opacity disabled, press widens the thumb (desktop hover). + Off is light like the desktop (quiet `surfaceContainerHighest` track, light thumb with a + faint edge); its outline (row colour 85 % of the way to `tertiaryText`, full under high + contrast) carries the 3:1 contrast. On is `primary` / `onPrimary`; System uses Material You. + `OpenCodeSheetHandle` is every bottom sheet's drag handle: the desktop resize handle's + 40 × 4 dp pill in `tertiaryText` over Material's `DragHandle` (its band and TalkBack + actions stay); custom grabbers use `OpenCodeSheetHandleDefaults`. Sheets take + `OpenCodeSheetDefaults.shape` (16 dp top corners, `OpenCodeRadius.sheet`). + `OpenCodeTextField` / `OpenCodeSearchField` (`ui/OpenCodeTextField.kt`) are the desktop text + input (`forms/text-input`) over `BasicTextField`: the label sits above the field (no floating + label), placeholder shown while empty, 48 dp minimum height, 8 dp corners, 12 dp padding, + callout text. Fill is white in light (with a 1 dp shadow, desktop `elevation-input`) and a + step above the sheet in dark; a 1 dp `outline` border (`tertiaryText` under high contrast). + Focus is a 1.5 dp `primary` ring, error a `error` ring plus a footnote note under the field + (TalkBack reads it via `error()`), disabled half opacity. Custom bare fields inside their own + containers (composer, drawer search, browser bar, share dock) keep their containers; the + model picker's search rows use `Modifier.openCodeFieldContainer`. +- Call orb (`feature/voice` `LivingOrbView`, `WispOrbShaders`): unchanged from iOS (the + desktop has no orb), so it keeps iOS's blue-black glass, dots, glow and shadow on the call card. +- Call card (`feature/voice` `FloatingCall`, `VoiceCallSurfaceDefaults`): one step off the + page (`card`: 5% toward the text colour in light, 6% in dark) with a hairline and a soft + 20 dp shadow, so it separates from the canvas in both themes; the controls are 12 dp rounded + squares (`controlFill` + hairline, ink when on, theme red for End) instead of tonal circles. +- Title bars (`ui/OpenCodeTopBar.kt`, Android-only): the desktop's settings/session header + instead of Material's `TopAppBar`s: flat canvas, 52 dp row, headline title (start or + centred), bare back arrow (`OpenCodeTopBarBackButton`), 1 dp bottom hairline that fades in + once content scrolls under it (always shown without a scroll behaviour). `OpenCodeLargeTopBar` + is the large-title variant (title1 under the row; Material's `exitUntilCollapsed` behaviour + scrolls it away and fades the small title in), used by Settings pages. +- Camera screens (pairing scanner, composer camera) are always dark and keep the phone-camera + conventions where the desktop's shapes look worse over a live photo: round translucent + controls with a faint white hairline, and four bold round-capped viewfinder corners (5 dp, + 44 dp arms, following the 16 dp window radius just outside the window, scene dimmed outside it). Their bars, panels and hint text use the desktop tokens. +- Welcome illustration: the phone mock depicts the restyled Android app (flat header, desktop + greys, hairline composer) rather than the iOS app's glass chrome. Paths below are relative to `core/src/main/kotlin/ai/opencode/core/`. ## Files | iOS file | Lines | Kotlin file(s) | Status | Notes | | --- | ---: | --- | --- | --- | -| `OpenCode/Core/Theme/Theme.swift` | 792 | `ui/AppTheme.kt`, `ui/OpenCodeColors.kt`, `ui/OpenCodeTheme.kt`, `ui/ThemeSharedKeys.kt` | done | `AppTheme` (iOS raw values, `@Serializable`), `AppearanceColorScheme`, `ThemeRGBA` (WCAG, OKLab/OKLCH, gamut mapping, `highContrastForeground`), `ThemeVariant`/`ThemeDefinition`, `ThemePalette.system` + `definition()`. Every dynamic provider (`canvas`, `groupedCanvas`, `groupedCard`, `codeBand`, `userBubble`, `inlineCodeFill`, text tiers, `bodyText(tone:)`, `border`, `accent`, Send button, `link`, syntax, diff) → `OpenCodeColors.resolve` with the same Increase Contrast and System-theme branches (System uses the UIKit values: `label` alpha code band, `tertiarySystemFill`, label/background Send button, systemGreen/Red diff fills). Material `onPrimary`/`onTertiary`/`onError` are white for the System theme (UIKit labels tint-filled and destructive controls white) and `highContrastForeground` for theme palettes; destructive primary buttons use white. Increase Contrast = system contrast ≥ medium (`UiModeManager.getContrast`). Keys `appearance-theme` / `appearance-color-scheme` with `.system` defaults. `applyAppAppearance()` → `OpenCodeAppTheme {}`; its window `overrideUserInterfaceStyle` (which restyles the status bar) → `OpenCodeAppTheme` sets the activity window's light/dark status and navigation bar content from the effective appearance, not the system night mode. `SettingsThemeSurface` → `OpenCodeColors.resolve(theme, isDark, highContrast)` (same values). Android divergence: the System theme follows the wallpaper (Material You dynamic colour, `ui/DynamicSystemTheme.kt`): the `ColorScheme` is the dynamic one and the iOS tokens are mapped from its roles (syntax and diff colours keep the System values); the Appearance swatches and previews read it through `rememberThemeDefinition`. The curated themes keep their fixed palettes. Not ported: UIKit trait plumbing (`AppThemeTrait`, `applyToWindows`; Compose recomposes), DEBUG `-lab-theme`/`-lab-appearance` overrides, legacy key clean-up (key never existed on Android), the 0.22 s window cross-fade on theme change (constant kept as `ThemePalette.THEME_CHANGE_CROSSFADE_SECONDS`) | +| `OpenCode/Core/Theme/Theme.swift` | 792 | `ui/AppTheme.kt`, `ui/OpenCodeColors.kt`, `ui/OpenCodeTheme.kt`, `ui/ThemeSharedKeys.kt` | done | `AppTheme` (iOS raw values, `@Serializable`), `AppearanceColorScheme`, `ThemeRGBA` (WCAG, OKLab/OKLCH, gamut mapping, `highContrastForeground`), `ThemeVariant`/`ThemeDefinition`, `ThemePalette.system` + `definition()`. Every dynamic provider (`canvas`, `groupedCanvas`, `groupedCard`, `codeBand`, `userBubble`, `inlineCodeFill`, text tiers, `bodyText(tone:)`, `border`, `accent`, Send button, `link`, syntax, diff) → `OpenCodeColors.resolve` with the same Increase Contrast and System-theme branches (System uses the UIKit values: `label` alpha code band, `tertiarySystemFill`, label/background Send button, systemGreen/Red diff fills). Material `onPrimary`/`onTertiary`/`onError` are white for the System theme (UIKit labels tint-filled and destructive controls white) and `highContrastForeground` for theme palettes; destructive primary buttons use white. Increase Contrast = system contrast ≥ medium (`UiModeManager.getContrast`). Keys `appearance-theme` / `appearance-color-scheme`; Android divergence: `appearance-theme` defaults to `oc-2` (the desktop palette, `BrandPalette`) instead of `.system`. `applyAppAppearance()` → `OpenCodeAppTheme {}`; its window `overrideUserInterfaceStyle` (which restyles the status bar) → `OpenCodeAppTheme` sets the activity window's light/dark status and navigation bar content from the effective appearance, not the system night mode. `SettingsThemeSurface` → `OpenCodeColors.resolve(theme, isDark, highContrast)` (same values). Android divergence: the System theme follows the wallpaper (Material You dynamic colour, `ui/DynamicSystemTheme.kt`): the `ColorScheme` is the dynamic one and the iOS tokens are mapped from its roles (syntax and diff colours keep the System values); the Appearance swatches and previews read it through `rememberThemeDefinition`. The curated themes keep their fixed palettes. Not ported: UIKit trait plumbing (`AppThemeTrait`, `applyToWindows`; Compose recomposes), DEBUG `-lab-theme`/`-lab-appearance` overrides, legacy key clean-up (key never existed on Android), the 0.22 s window cross-fade on theme change (constant kept as `ThemePalette.THEME_CHANGE_CROSSFADE_SECONDS`) | | `OpenCode/Core/Theme/ThemePalette+Generated.swift` | 397 | `ui/ThemePaletteGenerated.kt` (generated by `scripts/generate-themes-android.py`) | done | Every value copied from the generated Swift (6 themes × light/dark × 28 tokens); rerun the script when iOS regenerates | | `OpenCode/Core/Motion/MotionConstants.swift` | 130 | `motion/MotionConstants.kt`, `motion/OpenCodeMotionScheme.kt` | done | All 9 springs (`MotionSpring(duration, bounce)` → exact `spring(ζ, ω²)`), fades, delays, stagger, handover ratio, blur radii, rises; `animation(reduceMotion:delay:)`, `easeOut`/`easeInOut` with SwiftUI's curves; Reduce Motion → 0.2 s ease-in-out (`rememberReduceMotion()` = Remove animations). Android divergence: the M3 `MotionScheme` (`OpenCodeMotionScheme`) is Material 3 Expressive's own (`MotionScheme.expressive()`), so Material components move like the rest of Android; Reduce Motion still turns every spec into the 0.2 s fade. Android divergence: transition blurs (SwiftUI `.blur(radius:)` in a transition, `MotionBlurReveal`, `MorphReveal`, the text focus sweep, caption words) are off through `motion/TransitionBlur.kt` (`transitionBlur`, `transitionBlurEffect`, `TransitionBlur.enabled`); the blur maths and their ported tests stay. Backdrop blurs are unchanged. Android-only `motion/PageTransitions.kt`: Material shared axis X (forward, backward, predictive back) and fade through, for page changes (Settings). Every value is a live `Tunable` (`MotionTunables`, iOS keys/labels/defaults/ranges, `core/.../tuning/`), read through `Motion.*` getters; springs and tweens follow Developer Mode slow motion (`AnimationTimeScale`: ω × s, durations ÷ s); `MotionTunables.register()` = iOS `Motion.register(in:)` | | `OpenCode/Core/Motion/SpringSolver.swift` | 222 | `motion/SpringSolver.kt` | done | Same closed-form critically/under/over-damped solutions, epsilons, `retarget`, `step`, `parameters`; `(duration, bounce)` init is `SpringSolver.of(...)` or `SpringSolver(MotionSpring)` (JVM overload clash) | @@ -20,18 +84,20 @@ Paths below are relative to `core/src/main/kotlin/ai/opencode/core/`. | `OpenCode/Core/Motion/MotionDisplayLink.swift` | 90 | `motion/MotionFrameLoop.kt` | done | `motionFrameLoop {}` on Compose's frame clock (`withFrameNanos`, display rate up to 120 Hz), `dt = min(delta, maxFrames × frame) × scale`, first frame one frame long, `Continue`/`Stop`; `rememberFrameDurationSeconds()`. No explicit 80–120 Hz range request (Android picks the rate per window; Compose drives at the display rate). the scale is read every frame from `AnimationTimeScale.shared.scale` unless `timeScale` pins it (Developer Mode slow motion, `core/.../tuning/AnimationTimeScale.kt`) Android perf: `rememberReduceMotion()` reads one app-wide observer of the animator scale instead of registering one per caller (rows paid a settings-service round trip each as they scrolled in). | | `OpenCode/Core/RollingNumber/RollingNumber.swift` | 928 | `ui/RollingNumberModel.kt`, `ui/RollingNumber.kt` | done | Model ported line for line (keys, parse with locale separators over Swift `Character`s = grapheme clusters, unwrap and settle with Swift's half-away-from-zero rounding, stagger, 240 Hz semi-implicit springs stepped on `AnimationTimeScale`, hold/rise/blur envelopes, alignment, settle). Rendering: Compose `Canvas` + `TextMeasurer`, tabular digits, edge fade mask, clipped to its line like iOS's Canvas (callers don't clip), baseline alignment, plain-text cross-fade fallback (Reduce Motion, RTL, not resumed, too narrow, unrollable; one line, wrapping only at accessibility font scales as iOS's `fixedSize`). Smear drawn from a 0.45 band radius (shader's cut-off) and arrival/exit blur above 0.3, as iOS. Presets `Native/Snappy/Gentle/Lively`; `RollingNumberTunables` (`ui/RollingNumberTunables.kt`: `numbers.*` keys, `numbers.presets` feels, `register`, `style()`) is the default `motion`. Arrival/exit blur drawn as the same vertical smear (iOS: isotropic per-glyph blur). `isRollingNumberSizingOnly` environment not needed (Compose measures without drawing) Android perf: glyph metrics are shared per style (`SharedRollingMetrics`, the 8 most recent styles, colour not in the key), so a row scrolling in doesn't measure its digits again. Formats and parses in `appFormattingLocale()` (`ui/AppFormattingLocale.kt`: English in the configuration's region, iOS `Locale.current` in an English-only bundle) | | `OpenCode/Core/RollingNumber/RollingNumberShaders.metal` | 33 | `ui/RollingNumber.kt` (`drawRollingFrame`) | done | Same intent without a shader: per-band vertical Gaussian (`exp(-2.5t²)`, radius from reel speed) as a 9-tap additive offscreen composite (`BlendMode.Plus`) | -| `OpenCode/Core/Glass.swift` | 30 | `ui/OpenCodeButtons.kt`, `ui/OpenCodeShapes.kt` | done | `openCodePrimaryButton()` → `OpenCodePrimaryButton` (M3 filled, accent; red only for `Destructive`); `openCodeSecondaryButton()` → `OpenCodeSecondaryButton` (M3 tonal, neutral `secondaryContainer`); shared 52 dp height for peers. `GlassGeometry.radius` → `OpenCodeShapeGeometry.radius` (iOS removed the unused `GlassShape.clamped` wrapper in 18771799; `OpenCodeShapeGeometry.clamped` went with it). `openCodeGlass(in:interactive:tint:)`: n/a, Liquid Glass maps to Material tonal surfaces (`Surface(color = surfaceContainer*)`), never blur; iOS 27 availability gates: n/a | -| `OpenCode/Core/TapTarget.swift` | 53 | `ui/TapTarget.kt` | done | `Modifier.openCodeTapTarget(minSize = 48.dp, accessibility = true)`: centred ≥48 dp rectangle, one merged TalkBack node (Android's 48 dp ≙ iOS 44 pt). `openCodeGlassCircle(_:tint:)` → `OpenCodeIconButton(style = Circle, size, tint)` (M3 filled tonal icon button, circle); `Standard` style for bare toolbar glyphs Sync ae029f85 (86ca6803, 6a173ff1): `openCodeTapTarget(lowered:)` and `openCodeAccessibilityTarget(lowered:)` aren't added: their only callers are the composer's pickers, which lower themselves with an offset pair (`targetDrop`, see composer.md) since Compose moves touch and semantics bounds together. | +| `OpenCode/Core/Glass.swift` | 30 | `ui/OpenCodeButtons.kt`, `ui/OpenCodeShapes.kt` | done | `openCodePrimaryButton()` → `OpenCodePrimaryButton` (M3 filled, accent; red only for `Destructive`); `openCodeSecondaryButton()` → `OpenCodeSecondaryButton` (base surface with a hairline: the desktop's neutral button); shared 48 dp height for peers, 8 dp corners. `GlassGeometry.radius` → `OpenCodeShapeGeometry.radius` (iOS removed the unused `GlassShape.clamped` wrapper in 18771799; `OpenCodeShapeGeometry.clamped` went with it). `openCodeGlass(in:interactive:tint:)`: n/a, Liquid Glass maps to the desktop's flat floating surfaces (`OpenCodeSurfaces`: fill + hairline + small shadow), never blur; iOS 27 availability gates: n/a | +| `OpenCode/Core/TapTarget.swift` | 53 | `ui/TapTarget.kt` | done | `Modifier.openCodeTapTarget(minSize = 48.dp, accessibility = true)`: centred ≥48 dp rectangle, one merged TalkBack node (Android's 48 dp ≙ iOS 44 pt). `openCodeGlassCircle(_:tint:)` → `OpenCodeIconButton(style = Circle, size, tint)` (desktop neutral icon button: 10 dp rounded square, hairline; filled when tinted); `Standard` style for bare toolbar glyphs Sync ae029f85 (86ca6803, 6a173ff1): `openCodeTapTarget(lowered:)` and `openCodeAccessibilityTarget(lowered:)` aren't added: their only callers are the composer's pickers, which lower themselves with an offset pair (`targetDrop`, see composer.md) since Compose moves touch and semantics bounds together. | | `OpenCode/Core/BackSwipe.swift` | 390 | `ui/BackSwipeRules.kt` | done | `edgeWidth` 28, hold 0.45 s, decision distance 8, handle reach 24, `decision(...)`, `yieldsToHold`, release rule `goesBack` (250/s flick, else halfway) for the in-app drawer pan. n/a: `BackPanGestureRecognizer`, `SystemBackSwipeGate`, scroller/control/selection hit tests (system back and predictive back are Android's; nested scrolling and text selection already arbitrate). `BackSwipeSpring` → `SpringSolver(Motion.drawerSlide)` + `motionFrameLoop` in the drawer feature Sync ae029f85 (665f985d): comment-only (`selectionHandleReach` now also names the reply selection's handles; Android `TranscriptReplySelection.HANDLE_REACH` is 24 dp). | | `OpenCode/Core/Motion/RenderServerLoop.swift` | 80 | — | n/a: a Core Animation loop re-added after suspension or cell reuse; Compose's infinite transitions run on the frame clock and restart with a reused composition, so the drawer ring and Server Flow sweep can't be dropped | Sync ae029f85 (a599a6a4, 76dd31fd). | ## Design-system API (for area agents) - Theme: wrap each window's root in `OpenCodeAppTheme { }` (reads the persisted choice); previews use `OpenCodeTheme(theme, appearance) { }`. Colours: `OpenCodeTheme.colors.` (e.g. `groupedCard`, `secondaryText`, `bodyText(0.92)`, `syntaxKeyword`); Material roles: `MaterialTheme.colorScheme` (mapping table in `OpenCodeColors.kt`). -- Type: `MaterialTheme.typography.*` (role mapping in `OpenCodeTypography.kt`) or the iOS names in `OpenCodeTextStyles` (`footnote`, `subheadline`, …). `OpenCodeFonts.berkeleyMono` only for onboarding brand marks. -- Shapes and spacing: `OpenCodeShape.capsule/circle/card/panel/sheet`, `OpenCodeRadius.*`, `OpenCodeSpacing.*`. +- Type: `MaterialTheme.typography.*` (role mapping in `OpenCodeTypography.kt`) or the iOS names in `OpenCodeTextStyles` (`footnote`, `subheadline`, …), Inter at desktop sizes; code in `OpenCodeFonts.monospace` (IBM Plex Mono). `OpenCodeFonts.berkeleyMono` only for the wordmark. +- Shapes and spacing: `OpenCodeShape.control` for controls, `capsule/circle` for true capsules, `card/panel/sheet`, `OpenCodeRadius.*`, `OpenCodeSpacing.*`. +- Surfaces: `OpenCodeSurfaces.color/border/dialogShape/popoverShape/raisedShadow/popoverShadow`, `Modifier.openCodeHairline(shape)`, `OpenCodeAlertDialog` instead of `AlertDialog`; Material `Button`s take `shape = OpenCodeShape.control`. - Motion: `Motion..spec()` / `.animation(reduceMotion)`, `Motion.easeOut(Motion.fadeStandard, …)`, `rememberReduceMotion()`, `SpringSolver` + `motionFrameLoop {}` for custom drivers, `PresenceGate`, `Modifier.motionBlurReveal`. -- Controls: `OpenCodePrimaryButton` / `OpenCodeSecondaryButton` (`role = Destructive` for red), `OpenCodeIconButton(SFSymbol.X, "Label", onClick)`, `Modifier.openCodeTapTarget()` after `clickable`. +- Title bars: `OpenCodeTopBar(title = { Text(...) }, navigation = { OpenCodeTopBarBackButton(onBack) }, actions = { ... }, centerTitle, scrollBehavior)` or `OpenCodeLargeTopBar("Title", TopAppBarDefaults.exitUntilCollapsedScrollBehavior())` instead of Material `TopAppBar`s; put the behaviour's `nestedScrollConnection` on the `Scaffold`. +- Controls: `OpenCodePrimaryButton` / `OpenCodeSecondaryButton` (`role = Destructive` for red), `OpenCodeIconButton(SFSymbol.X, "Label", onClick)`, `Modifier.openCodeTapTarget()` after `clickable`; `OpenCodeSwitch(checked, onCheckedChange)` instead of Material's `Switch` (pass `null` when the row is the toggleable); sheets take `dragHandle = { OpenCodeSheetHandle() }` and `shape = OpenCodeSheetDefaults.shape` (both the default in `OpenCodeBottomSheet`); `OpenCodeTextField(value, onValueChange, label = "…", placeholder = "…")` and `OpenCodeSearchField` instead of Material's `OutlinedTextField` / `TextField`. - Icons: `OpenCodeIcon(SFSymbol.ArrowUpCircleFill, contentDescription)` or `OpenCodeIcon("arrow.up", …)` / `sfSymbol(name)` for names held as strings. New icon: add a line to `scripts/material-symbols.txt`, run `python3 scripts/fetch-material-symbols.py`, add the `SFSymbol` entry and a row below. - TalkBack focus (`ui/AccessibilityFocus.kt`, moved down from `:feature:composer`'s `AttachmentMenu.kt`; one helper where VoiceOver moves by itself): `Modifier.accessibilityFocusRequest(request)` moves TalkBack's focus onto the element once per `AccessibilityFocusRequest` (after a window on top hands focus back); a request is spent by its move, so a recomposition, a remount or a session moved into Catch Up's stack never replays it (QA W-05); `rememberAccessibilityFocusRequest(event)` makes a new one for each new non-null `event`; `LocalAccessibilityFocusMoves` false (Catch Up's inert preview card) turns every move off; a move refused because the element isn't in the accessibility tree yet (fading in) tries again each frame for up to 1 s (QA AF-02: Catch Up's Leave was always refused and only TalkBack's own pick landed there); `Modifier.accessibilityFocusTarget(target)` + `AccessibilityFocusTarget.focus()` move it when the caller decides. Both mark their semantics node (ahead of any `clearAndSetSemantics`), find it in the view's tree and perform `ACTION_ACCESSIBILITY_FOCUS` through the view's accessibility node provider. Compose has no public accessibility-focus API and no public node → id mapping (`requireSemanticsInfo` is internal), so the tree comes from `RootForTest` in this one file. - Gallery: `DesignSystemGallery()` (`ui/DesignSystemGallery.kt`). diff --git a/docs/parity/session.md b/docs/parity/session.md index 1562ad0e9..4d98af952 100644 --- a/docs/parity/session.md +++ b/docs/parity/session.md @@ -15,7 +15,7 @@ Status values: `todo`, `partial: `, `done`, `n/a: