Cotton code
72 lines · 3.2 KB · KotlinRaw
package com.cottondb.android.ui.settingsimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.layout.Arrangementimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.fillMaxSizeimport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.paddingimport androidx.compose.foundation.layout.safeDrawingPaddingimport androidx.compose.foundation.rememberScrollStateimport androidx.compose.foundation.verticalScrollimport androidx.compose.material3.Buttonimport androidx.compose.material3.Switchimport androidx.compose.material3.Textimport androidx.compose.runtime.Composableimport androidx.compose.ui.Modifierimport androidx.compose.ui.semantics.contentDescriptionimport androidx.compose.ui.semantics.semanticsimport androidx.compose.ui.unit.dpimport com.cottondb.android.design.CottonMetricsimport com.cottondb.android.design.CottonTextStylesimport com.cottondb.android.generated.CottonPalette/** Controlled Android keyboard setup and consent surface. The host owns platform settings and persistence. */@Composablefun KeyboardSettingsScreen(    typedCapture: Boolean,    problem: String?,    onBack: () -> Unit,    onTypedCaptureChange: (Boolean) -> Unit,    onEnableKeyboard: () -> Unit,    onSelectKeyboard: () -> Unit,    enabled: Boolean = true,    modifier: Modifier = Modifier,) {    Column(        modifier            .fillMaxSize()            .background(CottonPalette.groundMuted)            .safeDrawingPadding()            .verticalScroll(rememberScrollState())            .padding(horizontal = CottonMetrics.settingsMargin, vertical = 20.dp),        verticalArrangement = Arrangement.spacedBy(12.dp),    ) {        Button(onClick = onBack, modifier = Modifier.semantics { contentDescription = "Back" }) { Text("Back") }        Text("Keyboard", style = CottonTextStyles.pageTitle, color = CottonPalette.ink)        Text(            "Turn it on once: open Android keyboard settings, enable Cotton, then select it from the keyboard switcher.",            style = CottonTextStyles.caption,            color = CottonPalette.inkSecondary,        )        Button(onClick = onEnableKeyboard, modifier = Modifier.semantics { contentDescription = "Enable Cotton keyboard" }) {            Text("Enable Cotton keyboard")        }        Button(onClick = onSelectKeyboard, modifier = Modifier.semantics { contentDescription = "Select Cotton keyboard" }) {            Text("Select Cotton keyboard")        }        Text("Keep what I type", style = CottonTextStyles.body, color = CottonPalette.ink)        Text(            "Cotton can keep words you type on this keyboard. Password fields and editors that request private typing are excluded.",            style = CottonTextStyles.caption,            color = CottonPalette.inkSecondary,        )        Switch(            checked = typedCapture,            onCheckedChange = { next -> if (enabled) onTypedCaptureChange(next) },            enabled = enabled,            modifier = Modifier.semantics { contentDescription = "Keep what I type" },        )        problem?.let { Text(it, style = CottonTextStyles.caption, color = CottonPalette.statusWarning) }    }}