package com.cottondb.android.ui.settings import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.safeDrawingPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.Switch import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics import androidx.compose.ui.unit.dp import com.cottondb.android.design.CottonMetrics import com.cottondb.android.design.CottonTextStyles import com.cottondb.android.generated.CottonPalette /** Controlled Android keyboard setup and consent surface. The host owns platform settings and persistence. */ @Composable fun 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) } } }