1package com.peachpasswords.ui.settings23import android.content.Intent4import android.net.Uri5import androidx.compose.animation.AnimatedVisibility6import androidx.compose.animation.core.animateDpAsState7import androidx.compose.foundation.background8import androidx.compose.foundation.border9import androidx.compose.foundation.clickable10import androidx.compose.foundation.layout.Arrangement11import androidx.compose.foundation.layout.Box12import androidx.compose.foundation.layout.Column13import androidx.compose.foundation.layout.FlowRow14import androidx.compose.foundation.layout.ExperimentalLayoutApi15import androidx.compose.foundation.layout.Row16import androidx.compose.foundation.layout.RowScope17import androidx.compose.foundation.layout.Spacer18import androidx.compose.foundation.layout.fillMaxWidth19import androidx.compose.foundation.layout.height20import androidx.compose.foundation.layout.padding21import androidx.compose.foundation.layout.size22import androidx.compose.foundation.layout.width23import androidx.compose.foundation.shape.CircleShape24import androidx.compose.foundation.shape.RoundedCornerShape25import androidx.compose.foundation.text.BasicTextField26import androidx.compose.runtime.Composable27import androidx.compose.material3.CircularProgressIndicator28import androidx.compose.runtime.DisposableEffect29import androidx.compose.runtime.collectAsState30import androidx.compose.runtime.getValue31import com.peachpasswords.feedback.FeedbackState32import com.peachpasswords.shared.PeachClipboard33import com.peachpasswords.sync.SyncStatus34import com.peachpasswords.ui.theme.LocalPeachAccent35import com.peachpasswords.vault.DuressAction36import com.peachpasswords.ui.theme.peachColors37import androidx.compose.runtime.mutableStateOf38import androidx.compose.runtime.remember39import androidx.compose.runtime.rememberCoroutineScope40import androidx.compose.runtime.setValue41import androidx.compose.ui.Alignment42import androidx.compose.ui.Modifier43import androidx.compose.ui.draw.clip44import androidx.compose.ui.graphics.Color45import androidx.compose.ui.graphics.SolidColor46import androidx.compose.ui.platform.LocalContext47import androidx.compose.ui.text.TextStyle48import androidx.compose.ui.text.font.FontStyle49import androidx.compose.ui.text.input.PasswordVisualTransformation50import androidx.compose.ui.unit.Dp51import androidx.compose.ui.unit.dp52import androidx.compose.ui.unit.em53import androidx.compose.ui.unit.sp54import androidx.compose.material3.Text55import com.peachpasswords.BuildConfig56import com.peachpasswords.ui.PeachNav57import com.peachpasswords.ui.components.PeachEmptyOrEndState58import com.peachpasswords.ui.components.PeachField59import com.peachpasswords.ui.sync.SyncViewModel60import com.peachpasswords.ui.theme.ACCENT_COLORS61import com.peachpasswords.ui.theme.PeachSpacing62import com.peachpasswords.ui.theme.PeachType63import androidx.hilt.navigation.compose.hiltViewModel64import com.peachpasswords.vault.VaultSettings65import com.peachpasswords.vault.VaultSnapshot66import kotlinx.coroutines.launch67import kotlinx.coroutines.delay68import java.text.SimpleDateFormat69import java.util.Date70import java.util.Locale7172private const val PRO_URL = "https://buy.polar.sh/polar_cl_IXSFIPojx67rcOTksn8LkH5mnU3osPHtYqBIl1eyuIz"737475767778798081@Composable82fun CardBody(83 id: CardId,84 fg: Color,85 vm: SettingsViewModel,86 settings: VaultSettings,87 entriesCount: Int,88 onNavigate: (PeachNav) -> Unit,89) {90 when (id) {91 CardId.Appearance -> AppearanceBody(fg, vm, settings)92 CardId.Protection -> ProtectionBody(fg, vm, settings, onNavigate)93 CardId.Vault -> VaultBody(fg, vm, settings, entriesCount, onNavigate)94 CardId.Sync -> SyncBody(fg, onNavigate)95 CardId.Shortcuts -> ShortcutsBody(fg)96 CardId.Pro -> ProBody(fg, vm)97 CardId.Feedback -> FeedbackBody(fg, vm)98 }99}100101102103@Composable104private fun SubLabel(text: String, fg: Color, top: Dp = 14.dp) {105 Text(106 text,107 modifier = Modifier.padding(top = top, bottom = 4.dp),108 color = fg.copy(alpha = 0.58f),109 fontFamily = PeachType.Mono,110 fontSize = 8.sp,111 letterSpacing = 0.22.em,112 )113}114115@Composable116private fun RowLine(fg: Color, modifier: Modifier = Modifier, content: @Composable RowScope.() -> Unit) {117 Row(118 Modifier.fillMaxWidth().then(modifier).padding(vertical = 9.dp),119 verticalAlignment = Alignment.CenterVertically,120 horizontalArrangement = Arrangement.SpaceBetween,121 content = content,122 )123 Box(Modifier.fillMaxWidth().height(1.dp).background(fg.copy(alpha = 0.12f)))124}125126@Composable127private fun RowScope.Name(text: String, fg: Color) {128 Text(text, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp, modifier = Modifier.weight(1f))129}130131@Composable132private fun ValueText(text: String, fg: Color) {133 Text(text, color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Mono, fontSize = 11.sp)134}135136@Composable137private fun SubtleButton(label: String, fg: Color, onClick: () -> Unit) {138 Box(139 Modifier.clip(RoundedCornerShape(8.dp))140 .border(1.dp, fg.copy(alpha = 0.28f), RoundedCornerShape(8.dp))141 .background(fg.copy(alpha = 0.08f))142 .clickable(onClick = onClick)143 .padding(horizontal = 12.dp, vertical = 6.dp),144 ) {145 Text(label, color = fg, fontFamily = PeachType.Mono, fontSize = 11.sp)146 }147}148149@Composable150private fun Toggle(on: Boolean, fg: Color, onToggle: (Boolean) -> Unit) {151 val knob by animateDpAsState(if (on) 16.dp else 2.dp, label = "knob")152 Box(153 Modifier.size(width = 34.dp, height = 20.dp).clip(RoundedCornerShape(999.dp))154 .background(if (on) fg.copy(alpha = 0.28f) else fg.copy(alpha = 0.08f))155 .border(1.dp, fg.copy(alpha = if (on) 0.5f else 0.32f), RoundedCornerShape(999.dp))156 .clickable { onToggle(!on) },157 ) {158 Box(159 Modifier.padding(top = 2.dp).width(16.dp).fillMaxWidth().height(16.dp)160 .padding(start = knob - 2.dp)161 .size(14.dp).clip(CircleShape)162 .background(if (on) fg else fg.copy(alpha = 0.58f)),163 )164 }165}166167@Composable168private fun Pill(label: String, active: Boolean, fg: Color, onClick: () -> Unit) {169 Box(170 Modifier.clip(RoundedCornerShape(999.dp))171 .border(1.dp, fg.copy(alpha = if (active) 0.55f else 0.32f), RoundedCornerShape(999.dp))172 .background(if (active) fg.copy(alpha = 0.18f) else Color.Transparent)173 .clickable(onClick = onClick)174 .padding(horizontal = 12.dp, vertical = 5.dp),175 ) {176 Text(label, color = fg, fontFamily = PeachType.Mono, fontSize = 10.sp)177 }178}179180@Composable181private fun ProBadge(fg: Color) {182 Box(183 Modifier.padding(start = 6.dp).clip(RoundedCornerShape(4.dp))184 .background(fg.copy(alpha = 0.16f)).padding(horizontal = 5.dp, vertical = 1.dp),185 ) {186 Text("Pro", color = fg.copy(alpha = 0.85f), fontFamily = PeachType.Mono, fontSize = 8.sp)187 }188}189190@Composable191private fun Hint(text: String, fg: Color) {192 Text(193 text,194 modifier = Modifier.padding(top = 6.dp),195 color = fg.copy(alpha = 0.6f),196 fontFamily = PeachType.Display,197 fontStyle = FontStyle.Italic,198 fontSize = 11.5.sp,199 lineHeight = 16.sp,200 )201}202203204205@OptIn(ExperimentalLayoutApi::class)206@Composable207private fun AppearanceBody(fg: Color, vm: SettingsViewModel, s: VaultSettings) {208 SubLabel("THEME", fg, top = 0.dp)209 RowLine(fg) {210 Name("Theme", fg)211 val (label, next) = when (s.theme) {212 "dark" -> "Switch to light" to "light"213 else -> "Switch to dark" to "dark"214 }215 SubtleButton(label, fg) { vm.setTheme(next) }216 }217 SubLabel("ACCENT", fg)218 FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {219 ACCENT_COLORS.forEach { (name, color) ->220 Box(221 Modifier.size(22.dp).clip(CircleShape).background(color)222 .border(223 if (s.accentColor == name) 2.dp else 1.dp,224 if (s.accentColor == name) fg else fg.copy(alpha = 0.2f),225 CircleShape,226 )227 .clickable { vm.setAccent(name) },228 )229 }230 }231 SubLabel("TEXT SIZE", fg)232 RowLine(fg) {233 Name("Size", fg)234 Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {235 Pill("Default", s.textSize == "medium", fg) { vm.setTextSize("medium") }236 Pill("Large", s.textSize == "large", fg) { vm.setTextSize("large") }237 }238 }239 SubLabel("MOTION", fg)240 RowLine(fg) {241 Name("Reduce motion", fg)242 SubtleButton(if (s.reduceMotion) "On" else "Off", fg) { vm.setReduceMotion(!s.reduceMotion) }243 }244}245246247248@Composable249private fun ProtectionBody(fg: Color, vm: SettingsViewModel, s: VaultSettings, onNavigate: (PeachNav) -> Unit) {250 val lockOptions = listOf(1 to "1 minute", 5 to "5 minutes", 15 to "15 minutes", 30 to "30 minutes", 0 to "Never")251 val current = s.autoLockMinutes ?: 0252253 SubLabel("LOCKING", fg, top = 0.dp)254 RowLine(fg) {255 Name("Auto-lock after", fg)256 val idx = lockOptions.indexOfFirst { it.first == current }.coerceAtLeast(0)257 SubtleButton(lockOptions[idx].second, fg) {258 val next = lockOptions[(idx + 1) % lockOptions.size].first259 vm.setAutoLockMinutes(if (next == 0) 0 else next)260 }261 }262 SubLabel("BIOMETRICS", fg)263 val bioActivity = LocalContext.current as? androidx.fragment.app.FragmentActivity264 RowLine(fg) {265 Name("Unlock with biometrics", fg)266 Toggle(s.biometricsEnabled, fg) { on ->267 if (on && bioActivity != null) vm.enableBiometrics(bioActivity) else vm.disableBiometrics()268 }269 }270 val bioError = com.peachpasswords.ui.lock.Biometrics.statusMessage(LocalContext.current)271 if (bioError != null) {272 Text(273 bioError,274 color = com.peachpasswords.ui.theme.peachColors.Breach,275 fontFamily = PeachType.Mono, fontSize = 10.sp,276 modifier = Modifier.padding(start = 2.dp, top = 2.dp, bottom = 4.dp),277 )278 }279 SubLabel("PASSKEYS", fg)280 RowLine(fg) {281 Column(Modifier.weight(1f)) {282 Text("Credential provider", color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)283 Text(284 "Peach can handle passkey sign-in and creation through Android Credential Manager.",285 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,286 modifier = Modifier.padding(top = 2.dp),287 )288 }289 Toggle(s.passkeyProviderEnabled, fg) { vm.setPasskeyProviderEnabled(it) }290 }291 RowLine(fg) {292 Name("Status", fg)293 ValueText(if (s.passkeyProviderEnabled) "enabled" else "off", fg)294 }295 SubLabel("RECOVERY", fg)296 RowLine(fg) {297 Column(Modifier.weight(1f)) {298 Text("View recovery words", color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)299 Text(300 "Keep the paper copy current before rotating sync identity or replacing devices.",301 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,302 modifier = Modifier.padding(top = 2.dp),303 )304 }305 SubtleButton("view", fg) { onNavigate(PeachNav.RecoveryView) }306 }307 SubLabel("BREACH PROTECTION", fg)308 val checkingBreaches by vm.checkingBreaches.collectAsState()309 val breachResult by vm.breachResult.collectAsState()310 RowLine(fg) {311 Name("Breach monitoring", fg)312 Toggle(s.breachMonitoring, fg) { vm.setBreachMonitoring(it) }313 }314 RowLine(fg) {315 Name("Check all passwords", fg)316 SubtleButton(if (checkingBreaches) "checking..." else "run", fg) { vm.checkAllBreaches() }317 }318 breachResult?.let { result ->319 RowLine(fg) {320 Name("Last check", fg)321 ValueText(result, fg)322 }323 }324325 SubLabel("MASTER PASSWORD", fg)326 ChangePasswordRow(fg, vm)327328 SubLabel("DURESS PASSWORD", fg)329 val duressIsPro by vm.isPro.collectAsState()330 if (!duressIsPro) {331 RowLine(fg) {332 Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) {333 Name("Duress password", fg); ProBadge(fg)334 }335 ValueText("off", fg)336 }337 Hint("If entered under coercion, a decoy empty vault opens; your real vault stays hidden. Pro feature.", fg)338 } else {339 DuressSection(fg, vm)340 }341}342343@Composable344private fun ChangePasswordRow(fg: Color, vm: SettingsViewModel) {345 var open by remember { mutableStateOf(false) }346 var current by remember { mutableStateOf("") }347 var next by remember { mutableStateOf("") }348 var confirm by remember { mutableStateOf("") }349 var error by remember { mutableStateOf<String?>(null) }350 var done by remember { mutableStateOf(false) }351 val scope = rememberCoroutineScope()352353 RowLine(fg) {354 Name("Master password", fg)355 SubtleButton(if (open) "cancel" else "change", fg) { open = !open; error = null; done = false }356 }357 AnimatedVisibility(open) {358 Column(Modifier.fillMaxWidth().padding(top = PeachSpacing.sm), verticalArrangement = Arrangement.spacedBy(PeachSpacing.sm)) {359 PwField("current password", current, fg) { current = it }360 PwField("new password (min 12 chars)", next, fg) { next = it }361 PwField("confirm new password", confirm, fg) { confirm = it }362 error?.let { Text(it, color = Color(0xFFE5805C), fontFamily = PeachType.Mono, fontSize = 10.sp) }363 if (done) Text("password changed ✓", color = fg, fontFamily = PeachType.Mono, fontSize = 10.sp)364 SubtleButton("save new password", fg) {365 error = when {366 current.isBlank() -> "enter your current password"367 next.length < 12 -> "new password must be at least 12 characters"368 next != confirm -> "new passwords do not match"369 next == current -> "new password must differ from current"370 else -> null371 }372 if (error == null) scope.launch {373 if (vm.changePassword(current, next)) {374 current = ""; next = ""; confirm = ""; open = false; done = true375 } else error = "incorrect current password"376 }377 }378 }379 }380}381382@Composable383private fun PwField(placeholder: String, value: String, @Suppress("UNUSED_PARAMETER") fg: Color, onChange: (String) -> Unit) {384 PeachField(385 label = placeholder,386 value = value,387 onValueChange = onChange,388 keyboardType = androidx.compose.ui.text.input.KeyboardType.Password,389 visualTransformation = PasswordVisualTransformation(),390 )391}392393394395@Composable396private fun VaultBody(397 fg: Color,398 vm: SettingsViewModel,399 s: VaultSettings,400 entriesCount: Int,401 onNavigate: (PeachNav) -> Unit,402) {403 val trashOptions = listOf(7 to "7 days", 30 to "30 days", 90 to "90 days", 0 to "Never")404 val current = s.trashRetentionDays ?: 0405 val isPro by vm.isPro.collectAsState()406 val dedupCount by vm.dedupCount.collectAsState()407 val dedupRunning by vm.dedupRunning.collectAsState()408 val dedupDone by vm.dedupDone.collectAsState()409 val history by vm.vaultHistory.collectAsState()410 val restoringSnapshotId by vm.restoringSnapshotId.collectAsState()411412 SubLabel("ENTRIES", fg, top = 0.dp)413 RowLine(fg) { Name("Entries", fg); ValueText("$entriesCount", fg) }414 RowLine(fg) {415 Name("Duplicates", fg)416 val done = dedupDone417 if (done != null) {418 ValueText(if (done == 0) "already clean" else "removed $done", com.peachpasswords.ui.theme.peachColors.SyncOk)419 } else {420 val count = dedupCount421 val label = when {422 dedupRunning -> "scanning..."423 count == null -> "scan"424 count == 0 -> "none found"425 else -> "$count found"426 }427 SubtleButton(label, fg) {428 if (count == null || count == 0) vm.scanDuplicates()429 }430 }431 }432 if ((dedupCount ?: 0) > 0 && dedupDone == null) {433 Column(434 Modifier.fillMaxWidth()435 .padding(top = 2.dp, bottom = 8.dp)436 .clip(RoundedCornerShape(8.dp))437 .background(fg.copy(alpha = 0.08f))438 .border(1.dp, fg.copy(alpha = 0.18f), RoundedCornerShape(8.dp))439 .padding(10.dp),440 verticalArrangement = Arrangement.spacedBy(8.dp),441 ) {442 val count = dedupCount ?: 0443 Text(444 "$count duplicate ${if (count == 1) "entry" else "entries"} found. The newest copy of each will be kept; older duplicates will be moved to trash.",445 color = fg.copy(alpha = 0.82f),446 fontFamily = PeachType.Body,447 fontSize = 11.sp,448 lineHeight = 16.sp,449 )450 Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {451 SubtleButton("cancel", fg) { vm.cancelDuplicateRemoval() }452 SubtleButton(if (dedupRunning) "removing..." else "remove duplicates", fg) { vm.removeDuplicates() }453 }454 }455 }456457 SubLabel("MAINTENANCE", fg)458 RowLine(fg) {459 Name("Trash auto-delete", fg)460 val idx = trashOptions.indexOfFirst { it.first == current }.coerceAtLeast(0)461 SubtleButton(trashOptions[idx].second, fg) {462 vm.setTrashRetentionDays(trashOptions[(idx + 1) % trashOptions.size].first)463 }464 }465 RowLine(fg) { Name("Advanced Vault Health", fg); SubtleButton("open", fg) { onNavigate(PeachNav.Health) } }466 RowLine(fg) { Name("Trash", fg); SubtleButton("open", fg) { onNavigate(PeachNav.Trash) } }467468 SubLabel("DATA", fg)469 RowLine(fg) { Name("Import passwords", fg); SubtleButton("open", fg) { onNavigate(PeachNav.Import) } }470 RowLine(fg) { Name("Export backup", fg); SubtleButton("open", fg) { onNavigate(PeachNav.Export) } }471 RowLine(fg) {472 Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) { Name("Peach Codex", fg); if (!isPro) ProBadge(fg) }473 SubtleButton(if (isPro) "open" else "Pro", fg) { if (isPro) onNavigate(PeachNav.CodexGenerate) }474 }475 RowLine(fg) { Name("Restore from Codex", fg); SubtleButton("open", fg) { onNavigate(PeachNav.CodexRestore) } }476477 var historyShowAll by remember { mutableStateOf(false) }478 SubLabel("VAULT HISTORY", fg)479 if (history.isEmpty()) {480 Text(481 "No snapshots yet. Peach saves automatically before every change — saves, syncs, and imports.",482 color = fg.copy(alpha = 0.68f),483 fontFamily = PeachType.Body,484 fontSize = 11.sp,485 lineHeight = 16.sp,486 modifier = Modifier.padding(bottom = 6.dp),487 )488 } else {489 Text(490 "Restoring locks your vault. Unlock with the password that encrypted that snapshot to confirm.",491 color = fg.copy(alpha = 0.68f),492 fontFamily = PeachType.Body,493 fontSize = 11.sp,494 lineHeight = 16.sp,495 modifier = Modifier.padding(bottom = 4.dp),496 )497 history.take(if (historyShowAll) history.size else 3).forEach { snap ->498 RowLine(fg) {499 Column(Modifier.weight(1f)) {500 Text(snapshotTimeLabel(snap.savedAt), color = fg, fontFamily = PeachType.Body, fontSize = 12.sp)501 Text(snapshotSubLabel(snap), color = fg.copy(alpha = 0.62f), fontFamily = PeachType.Mono, fontSize = 10.sp)502 }503 SubtleButton(if (restoringSnapshotId == snap.id) "..." else "restore", fg) {504 vm.restoreVaultSnapshot(snap.id)505 }506 }507 }508 if (history.size > 3) {509 RowLine(fg) {510 Name(if (historyShowAll) "show less" else "${history.size - 3} older", fg)511 SubtleButton(if (historyShowAll) "hide" else "show", fg) { historyShowAll = !historyShowAll }512 }513 }514 Text(515 "${history.size} of 5 snapshots",516 color = fg.copy(alpha = 0.58f),517 fontFamily = PeachType.Mono,518 fontSize = 10.sp,519 modifier = Modifier.padding(top = 2.dp, bottom = 6.dp),520 )521 }522523 var advancedOpen by remember { mutableStateOf(false) }524 SubLabel("ADVANCED", fg)525 RowLine(fg) {526 Name("Advanced", fg)527 SubtleButton(if (advancedOpen) "hide" else "show", fg) { advancedOpen = !advancedOpen }528 }529 if (advancedOpen) {530 RowLine(fg) {531 Name("Replace vault from backup", com.peachpasswords.ui.theme.peachColors.SyncBusy)532 SubtleButton("open", com.peachpasswords.ui.theme.peachColors.SyncBusy) { onNavigate(PeachNav.Import) }533 }534 RowLine(fg) {535 Name("Destroy vault", com.peachpasswords.ui.theme.peachColors.Breach)536 SubtleButton("destroy", com.peachpasswords.ui.theme.peachColors.Breach) { onNavigate(PeachNav.Panic) }537 }538 }539}540541private fun snapshotSubLabel(snapshot: VaultSnapshot): String {542 val count = snapshot.entryCount?.let { "up to $it ${if (it == 1) "entry" else "entries"}" }543 return listOfNotNull(count, snapshotReasonLabel(snapshot.reason)).joinToString(" · ")544}545546private fun snapshotReasonLabel(reason: String): String = when (reason) {547 "local_save" -> "saved"548 "sync_received" -> "synced"549 "import" -> "imported"550 "restore" -> "restored"551 else -> reason552}553554private fun snapshotTimeLabel(savedAt: Long): String {555 val diff = System.currentTimeMillis() - savedAt556 if (diff < 60_000) return "Just now"557 if (diff < 3_600_000) return "${diff / 60_000}m ago"558 val date = Date(savedAt)559 val today = SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(Date())560 val thenDay = SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(date)561 val time = SimpleDateFormat("h:mm a", Locale.getDefault()).format(date)562 if (today == thenDay) return "Today $time"563 val yesterday = SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(Date(System.currentTimeMillis() - 86_400_000))564 if (yesterday == thenDay) return "Yesterday $time"565 return SimpleDateFormat("MMM d h:mm a", Locale.getDefault()).format(date)566}567568569570@Composable571private fun SyncBody(fg: Color, onNavigate: (PeachNav) -> Unit) {572 val syncVm: SyncViewModel = hiltViewModel()573 val pairedDevices by syncVm.pairedDevices.collectAsState()574 val pendingVouched by syncVm.pendingVouched.collectAsState()575 val syncStatus by syncVm.status.collectAsState()576 val scope = rememberCoroutineScope()577 var confirmUnpair by remember { mutableStateOf<String?>(null) }578 var rotateConfirmOpen by remember { mutableStateOf(false) }579 var rotating by remember { mutableStateOf(false) }580 var rotateError by remember { mutableStateOf<String?>(null) }581582 SubLabel("PAIRING", fg, top = 0.dp)583 RowLine(fg) {584 Column(Modifier.weight(1f)) {585 Row(verticalAlignment = Alignment.CenterVertically) {586 Text("Peach Sync", color = fg, fontFamily = PeachType.Body, fontSize = 13.sp); ProBadge(fg)587 }588 Text(589 "Pair nearby devices by chirp and keep encrypted vault blobs in step without a central account.",590 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,591 modifier = Modifier.padding(top = 2.dp),592 )593 }594 }595 596 597 RowLine(fg, Modifier.clickable { onNavigate(PeachNav.ChirpPair) }) {598 Name("Sync hub", fg)599 Text("›", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 15.sp)600 }601 RowLine(fg) {602 Column(Modifier.weight(1f)) {603 Text("Pair new device", color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)604 Text(605 "Add a phone, another browser, or your desktop sync helper.",606 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,607 modifier = Modifier.padding(top = 2.dp),608 )609 }610 SubtleButton("pair", fg) { onNavigate(PeachNav.ChirpPair) }611 }612613 SubLabel("PAIRED DEVICES", fg)614 if (pairedDevices.isEmpty()) {615 PeachEmptyOrEndState(616 message = "No paired devices yet.",617 detail = "Pair a nearby phone, browser, or desktop helper when you're ready to sync.",618 modifier = Modifier.padding(top = PeachSpacing.xs),619 )620 } else {621 pairedDevices.forEach { d ->622 RowLine(fg) {623 Column(Modifier.weight(1f)) {624 Text(d.deviceName ?: d.deviceId, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)625 Text(626 "${deviceTypeLabel(d.deviceType)} · ${syncTimeLabel(d.lastSyncedAt)}${if (isSyncStale(d.lastSyncedAt)) " · not seen recently" else ""}",627 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,628 modifier = Modifier.padding(top = 2.dp),629 )630 }631 if (confirmUnpair == d.deviceId) {632 Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {633 SubtleButton("cancel", fg) { confirmUnpair = null }634 SubtleButton("remove", peachColors.Breach) { syncVm.unpairDevice(d.deviceId); confirmUnpair = null }635 }636 } else {637 SubtleButton("remove", fg) { confirmUnpair = d.deviceId }638 }639 }640 }641 RowLine(fg) {642 ValueText(syncFlashLabel(syncStatus), fg)643 SubtleButton(if (syncStatus == SyncStatus.Syncing) "syncing..." else "sync now", fg) {644 if (syncStatus != SyncStatus.Syncing) syncVm.syncNow()645 }646 }647 }648649 if (pendingVouched.isNotEmpty()) {650 SubLabel("PENDING DEVICES", fg)651 pendingVouched.forEach { dev ->652 RowLine(fg) {653 Column(Modifier.weight(1f)) {654 Text(dev.deviceName, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)655 Text(656 "Was added by another of your devices. Allow it to sync with this vault?",657 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,658 modifier = Modifier.padding(top = 2.dp),659 )660 }661 Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {662 SubtleButton("Allow", fg) { syncVm.confirmVouchedDevice(dev.deviceId) }663 SubtleButton("Reject", fg) { syncVm.rejectVouchedDevice(dev.deviceId) }664 }665 }666 }667 }668669 SubLabel("RECOVERY", fg)670 if (rotateConfirmOpen) {671 Hint("This will disconnect all paired devices and your 12 recovery words will change. You'll be shown the new words next.", peachColors.Breach)672 rotateError?.let {673 Text(it, color = peachColors.Breach, fontFamily = PeachType.Body, fontSize = 11.sp, modifier = Modifier.padding(top = 6.dp))674 }675 Row(Modifier.padding(top = 10.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {676 SubtleButton("cancel", fg) { if (!rotating) rotateConfirmOpen = false }677 SubtleButton(if (rotating) "rotating..." else "Rotate sync identity", peachColors.Breach) {678 if (rotating) return@SubtleButton679 rotating = true680 rotateError = null681 scope.launch {682 val ok = syncVm.rotateSyncIdentity()683 rotating = false684 if (ok) {685 rotateConfirmOpen = false686 onNavigate(PeachNav.RecoverySetup)687 } else {688 rotateError = "Rotation failed. Unlock your real vault and try again."689 }690 }691 }692 }693 } else {694 RowLine(fg) {695 Column(Modifier.weight(1f)) {696 Text("Rotate sync identity", color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)697 Text(698 "Use this if a paired device was lost or stolen. Re-keys the vault so the old device's key is useless.",699 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,700 modifier = Modifier.padding(top = 2.dp),701 )702 }703 SubtleButton("rotate", peachColors.Breach) { rotateError = null; rotateConfirmOpen = true }704 }705 }706707 Hint("Sync uses the same zero-knowledge vault format as backup and restore; pairing authorizes a device, not a cloud account.", fg)708}709710private fun deviceTypeLabel(type: String?): String = when (type) {711 "android" -> "Android"712 "phone" -> "Phone"713 "tablet" -> "Tablet"714 "desktop" -> "Desktop"715 "browser" -> "Browser"716 else -> "Device"717}718719private fun syncTimeLabel(lastSyncedAt: Long?): String {720 if (lastSyncedAt == null) return "never synced"721 val diff = System.currentTimeMillis() - lastSyncedAt722 if (diff < 60_000) return "just now"723 if (diff < 3_600_000) return "${diff / 60_000}m ago"724 if (diff < 86_400_000) return "${diff / 3_600_000}h ago"725 return "${diff / 86_400_000}d ago"726}727728private fun isSyncStale(lastSyncedAt: Long?): Boolean =729 lastSyncedAt != null && System.currentTimeMillis() - lastSyncedAt > 7L * 24L * 60L * 60L * 1000L730731private fun syncFlashLabel(status: SyncStatus): String = when (status) {732 SyncStatus.Idle -> ""733 SyncStatus.Syncing -> "syncing..."734 SyncStatus.Offline -> "offline"735 is SyncStatus.Error -> status.message736 is SyncStatus.LastSynced -> "synced ${syncTimeLabel(status.timestamp)}"737}738739740741@Composable742private fun ShortcutsBody(fg: Color) {743 val bindings = listOf(744 "Copy password" to "⌘C", "Copy username" to "⌘⇧C", "Open entry" to "↵",745 "Edit entry" to "E", "New entry" to "⌘N", "Search" to "/",746 )747 SubLabel("KEYBINDINGS", fg, top = 0.dp)748 Hint("Shortcuts apply when a hardware keyboard is attached. Defaults shown below.", fg)749 Spacer(Modifier.height(8.dp))750 bindings.forEach { (label, key) ->751 RowLine(fg) {752 Name(label, fg)753 Box(754 Modifier.clip(RoundedCornerShape(4.dp)).background(fg.copy(alpha = 0.06f))755 .border(1.dp, fg.copy(alpha = 0.32f), RoundedCornerShape(4.dp))756 .padding(horizontal = 7.dp, vertical = 2.dp),757 ) { Text(key, color = fg, fontFamily = PeachType.Mono, fontSize = 10.sp) }758 }759 }760}761762763764@Composable765private fun ProBody(fg: Color, vm: SettingsViewModel) {766 val ctx = LocalContext.current767 val isPro by vm.isPro.collectAsState()768 if (isPro) {769 ProActiveBody(fg, vm)770 return771 }772 val features = listOf(773 "Peach Sync" to "Encrypted · peer-to-peer",774 "Peach Codex" to "Restore from paper",775 "Passkeys" to "Zero-knowledge WebAuthn",776 "Advanced Vault Health" to "Reuse · age · exposure",777 "Canary entries" to "Detects vault compromise",778 "Duress vault" to "Decoy under coercion",779 )780 Text("PEACH PRO · ONE-TIME", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 8.sp, letterSpacing = 0.22.em)781 Text(782 "Everything, everywhere.",783 modifier = Modifier.padding(top = 8.dp),784 color = fg, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 24.sp,785 )786 Text(787 "One key unlocks every Pro feature — for the lifetime of the app.",788 modifier = Modifier.padding(top = 6.dp),789 color = fg.copy(alpha = 0.72f), fontFamily = PeachType.Body, fontSize = 12.sp, lineHeight = 17.sp,790 )791 Spacer(Modifier.height(12.dp))792 features.forEachIndexed { i, (name, desc) ->793 RowLine(fg) {794 Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) {795 Text("%02d".format(i + 1), color = fg.copy(alpha = 0.5f), fontFamily = PeachType.Mono, fontSize = 10.sp, modifier = Modifier.padding(end = 10.dp))796 Text(name, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)797 }798 Text(desc, color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 11.sp)799 }800 }801 Spacer(Modifier.height(14.dp))802 Text(803 "$39",804 color = fg, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 28.sp,805 )806 Text("once · yours forever", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 9.sp, letterSpacing = 0.18.em)807 Spacer(Modifier.height(10.dp))808 Box(809 Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp))810 .background(fg.copy(alpha = 0.16f))811 .border(1.dp, fg.copy(alpha = 0.4f), RoundedCornerShape(10.dp))812 .clickable {813 runCatching { ctx.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(PRO_URL))) }814 }815 .padding(vertical = 12.dp),816 contentAlignment = Alignment.Center,817 ) { Text("Get Peach Pro", color = fg, fontFamily = PeachType.Mono, fontSize = 12.sp) }818819 Spacer(Modifier.height(16.dp))820 Text("LICENSE KEY", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 8.sp, letterSpacing = 0.22.em)821 var key by remember { mutableStateOf("") }822 val activating by vm.activating.collectAsState()823 val activationError by vm.activationError.collectAsState()824 Box(825 Modifier.fillMaxWidth().padding(top = 6.dp)826 .border(1.dp, fg.copy(alpha = 0.3f), RoundedCornerShape(8.dp))827 .padding(horizontal = 12.dp, vertical = 10.dp),828 ) {829 BasicTextField(830 value = key,831 onValueChange = { key = it.uppercase(); vm.clearActivationError() },832 singleLine = true,833 textStyle = TextStyle(fontFamily = PeachType.Mono, fontSize = 13.sp, letterSpacing = 0.12.em, color = fg),834 cursorBrush = SolidColor(fg),835 modifier = Modifier.fillMaxWidth(),836 decorationBox = { inner ->837 if (key.isEmpty()) Text("PPK-XXXX-XXXX-XXXX", color = fg.copy(alpha = 0.3f), fontFamily = PeachType.Mono, fontSize = 13.sp, letterSpacing = 0.12.em)838 inner()839 },840 )841 }842 if (activationError != null) {843 Text(activationError!!, color = com.peachpasswords.ui.theme.peachColors.Breach, fontFamily = PeachType.Mono, fontSize = 10.sp, modifier = Modifier.padding(top = 6.dp))844 }845 Spacer(Modifier.height(8.dp))846 Box(847 Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp))848 .background(fg.copy(alpha = if (activating || key.isBlank()) 0.08f else 0.16f))849 .border(1.dp, fg.copy(alpha = 0.4f), RoundedCornerShape(10.dp))850 .clickable(enabled = !activating && key.isNotBlank()) { vm.activateLicense(key) }851 .padding(vertical = 12.dp),852 contentAlignment = Alignment.Center,853 ) { Text(if (activating) "Activating…" else "Activate", color = fg, fontFamily = PeachType.Mono, fontSize = 12.sp) }854}855856@Composable857private fun ProActiveBody(fg: Color, vm: SettingsViewModel) {858 val ctx = LocalContext.current859 val features = listOf("Peach Sync", "Peach Codex", "Passkeys", "Advanced Vault Health", "Canary entries", "Duress vault")860 val licenseKey by vm.licenseKey.collectAsState()861 val issuedAt by vm.licenseIssuedAt.collectAsState()862 var showKey by remember { mutableStateOf(false) }863 var copied by remember { mutableStateOf(false) }864 val scope = rememberCoroutineScope()865 Box(Modifier.fillMaxWidth().padding(vertical = 8.dp), contentAlignment = Alignment.Center) {866 com.peachpasswords.ui.components.PeachMark(size = 60.dp)867 }868 Text(869 "Peach Pro",870 modifier = Modifier.fillMaxWidth(),871 color = fg, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 26.sp,872 textAlign = androidx.compose.ui.text.style.TextAlign.Center,873 )874 Text(875 formatLicenseActiveSince(issuedAt),876 modifier = Modifier.fillMaxWidth().padding(top = 4.dp),877 color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 9.sp, letterSpacing = 0.18.em,878 textAlign = androidx.compose.ui.text.style.TextAlign.Center,879 )880 licenseKey?.let { key ->881 Spacer(Modifier.height(12.dp))882 Text("LICENSE KEY", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 8.sp, letterSpacing = 0.22.em)883 RowLine(fg) {884 Text(885 if (showKey) key else "************************",886 color = fg.copy(alpha = if (showKey) 0.82f else 0.58f),887 fontFamily = PeachType.Mono,888 fontSize = 10.sp,889 modifier = Modifier.weight(1f),890 )891 Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {892 SubtleButton(if (copied) "copied" else "copy", fg) {893 PeachClipboard.copy(ctx, "peach license", key)894 copied = true895 scope.launch {896 delay(1_500)897 copied = false898 }899 }900 SubtleButton(if (showKey) "hide" else "reveal", fg) { showKey = !showKey }901 }902 }903 }904 Spacer(Modifier.height(12.dp))905 features.forEachIndexed { i, name ->906 RowLine(fg) {907 Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) {908 Text("%02d".format(i + 1), color = fg.copy(alpha = 0.5f), fontFamily = PeachType.Mono, fontSize = 10.sp, modifier = Modifier.padding(end = 10.dp))909 Text(name, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)910 }911 Text("unlocked", color = com.peachpasswords.ui.theme.peachColors.HealthOk, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 11.sp)912 }913 }914 Spacer(Modifier.height(12.dp))915 Box(916 Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp))917 .border(1.dp, com.peachpasswords.ui.theme.peachColors.Breach.copy(alpha = 0.4f), RoundedCornerShape(10.dp))918 .clickable { vm.deactivate() }919 .padding(vertical = 12.dp),920 contentAlignment = Alignment.Center,921 ) { Text("Deactivate", color = com.peachpasswords.ui.theme.peachColors.Breach, fontFamily = PeachType.Mono, fontSize = 12.sp) }922}923924private fun formatLicenseActiveSince(issuedAt: Long?): String {925 if (issuedAt == null) return "Active"926 val monthYear = SimpleDateFormat("MMMM yyyy", Locale.getDefault()).format(Date(issuedAt))927 return "Active since $monthYear"928}929930931932@OptIn(ExperimentalLayoutApi::class)933@Composable934private fun FeedbackBody(fg: Color, vm: SettingsViewModel) {935 val categories = listOf("Bug report", "Feature request", "Question", "Other")936 var category by remember { mutableStateOf(categories[0]) }937 var message by remember { mutableStateOf("") }938 val state by vm.feedbackState.collectAsState()939940 941 DisposableEffect(Unit) { onDispose { vm.resetFeedback() } }942943 if (state is FeedbackState.Sent) {944 Box(945 Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp)).background(fg.copy(alpha = 0.08f))946 .border(1.dp, fg.copy(alpha = 0.32f), RoundedCornerShape(10.dp)).padding(16.dp),947 ) {948 Column {949 Text("Thank you", color = fg, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 18.sp)950 Text("Your note is in the queue. Someone will process it soon.", color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 12.sp, modifier = Modifier.padding(top = 4.dp))951 }952 }953 return954 }955956 val sending = state is FeedbackState.Sending957958 Text("Help us improve Peach. Every report goes directly to our inbox.", color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 12.sp, lineHeight = 17.sp)959 SubLabel("TYPE", fg)960 FlowRow(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {961 categories.forEach { cat -> Pill(cat, category == cat, fg) { if (!sending) category = cat } }962 }963 SubLabel("MESSAGE", fg)964 Box(965 Modifier.fillMaxWidth().height(110.dp).clip(RoundedCornerShape(8.dp))966 .background(Color(0x2E000000)).border(1.dp, fg.copy(alpha = 0.22f), RoundedCornerShape(8.dp))967 .padding(10.dp),968 ) {969 if (message.isEmpty()) Text("Describe the issue or idea...", color = fg.copy(alpha = 0.42f), fontFamily = PeachType.Body, fontSize = 12.sp)970 BasicTextField(971 value = message, onValueChange = { message = it.take(MAX_FEEDBACK_MESSAGE_LENGTH) },972 enabled = !sending,973 textStyle = TextStyle(color = fg, fontFamily = PeachType.Body, fontSize = 12.sp),974 cursorBrush = SolidColor(fg), modifier = Modifier.fillMaxWidth(),975 )976 }977 Text(978 "Version ${BuildConfig.VERSION_NAME} · will be included automatically",979 modifier = Modifier.padding(top = 6.dp),980 color = fg.copy(alpha = 0.52f),981 fontFamily = PeachType.Mono,982 fontSize = 10.sp,983 lineHeight = 14.sp,984 )985 Spacer(Modifier.height(8.dp))986987 Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {988 val canSend = !sending && sanitizeFeedbackMessage(message).isNotBlank()989 Box(990 Modifier.clip(RoundedCornerShape(8.dp))991 .border(1.dp, fg.copy(alpha = if (canSend) 0.28f else 0.14f), RoundedCornerShape(8.dp))992 .background(fg.copy(alpha = if (canSend) 0.08f else 0.04f))993 .clickable(enabled = canSend) { vm.sendFeedback(category, message) }994 .padding(horizontal = 12.dp, vertical = 6.dp),995 ) {996 Text(997 feedbackSubmitLabel(state),998 color = fg.copy(alpha = if (canSend) 1f else 0.4f),999 fontFamily = PeachType.Mono, fontSize = 11.sp,1000 )1001 }1002 if (sending) {1003 CircularProgressIndicator(1004 color = LocalPeachAccent.current,1005 strokeWidth = 2.dp,1006 modifier = Modifier.size(16.dp),1007 )1008 }1009 }10101011 (state as? FeedbackState.Error)?.let { err ->1012 Text(1013 err.message,1014 modifier = Modifier.padding(top = 8.dp),1015 color = peachColors.Breach,1016 fontFamily = PeachType.Mono,1017 fontSize = 11.sp,1018 lineHeight = 15.sp,1019 )1020 }10211022 Hint("Sent anonymously · no account required", fg)1023}1024102510261027@Composable1028internal fun DuressSection(fg: Color, vm: SettingsViewModel) {1029 val configured by vm.duressConfigured.collectAsState()1030 if (configured) DuressActiveState(fg, vm) else DuressForm(fg, vm)1031}10321033@Composable1034private fun DuressActiveState(fg: Color, vm: SettingsViewModel) {1035 Text(1036 "Duress password is active",1037 color = peachColors.HealthOk,1038 fontFamily = PeachType.Mono,1039 fontSize = 11.sp,1040 modifier = Modifier.padding(top = 6.dp),1041 )1042 Spacer(Modifier.height(8.dp))1043 DuressDangerGhostButton("Disable duress password", fg) { vm.disableDuress() }1044 Hint("Entering your duress password instead of your real one triggers the action you chose.", fg)1045}10461047@Composable1048private fun DuressForm(fg: Color, vm: SettingsViewModel) {1049 var enabled by remember { mutableStateOf(false) }1050 var password by remember { mutableStateOf("") }1051 var confirm by remember { mutableStateOf("") }1052 var action by remember { mutableStateOf(DuressAction.DECOY) }1053 var error by remember { mutableStateOf<String?>(null) }1054 val scope = rememberCoroutineScope()10551056 RowLine(fg) {1057 Name("Duress password", fg)1058 Toggle(enabled, fg) { on ->1059 enabled = on1060 if (!on) { password = ""; confirm = ""; error = null }1061 }1062 }1063 Text(1064 "Entering your duress password instead of your real one opens a decoy vault or wipes the real one.",1065 color = fg.copy(alpha = 0.7f),1066 fontFamily = PeachType.Mono,1067 fontSize = 10.sp,1068 modifier = Modifier.padding(top = 6.dp),1069 )10701071 AnimatedVisibility(enabled) {1072 Column(Modifier.fillMaxWidth().padding(top = 10.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {1073 PwField("DURESS PASSPHRASE", password, fg) { password = it; error = null }1074 PwField("CONFIRM DURESS PASSPHRASE", confirm, fg) { confirm = it; error = null }10751076 Text(1077 "When your duress password is entered at the lock screen, Peach will:",1078 color = fg.copy(alpha = 0.7f),1079 fontFamily = PeachType.Mono,1080 fontSize = 10.sp,1081 modifier = Modifier.padding(top = 4.dp),1082 )10831084 DuressRadioOption("Show a decoy vault", action == DuressAction.DECOY, fg) { action = DuressAction.DECOY }1085 DuressRadioOption("Destroy the real vault", action == DuressAction.DESTROY, fg) { action = DuressAction.DESTROY }10861087 error?.let { Text(it, color = peachColors.Breach, fontFamily = PeachType.Mono, fontSize = 10.sp) }10881089 val canSave = password.isNotBlank() && confirm.isNotBlank()1090 DuressSaveButton("Save duress password", fg, canSave) {1091 error = when {1092 password.isBlank() || confirm.isBlank() -> "Enter and confirm a duress password"1093 password != confirm -> "Passwords do not match"1094 else -> null1095 }1096 if (error == null) scope.launch {1097 if (vm.saveDuress(password, action)) {1098 password = ""; confirm = ""; enabled = false1099 } else {1100 error = "Couldn't save — the duress passphrase must differ from your real password"1101 }1102 }1103 }1104 }1105 }1106}11071108@Composable1109private fun DuressRadioOption(label: String, selected: Boolean, fg: Color, onClick: () -> Unit) {1110 val accent = LocalPeachAccent.current1111 Row(1112 Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).clickable(onClick = onClick).padding(vertical = 7.dp),1113 verticalAlignment = Alignment.CenterVertically,1114 horizontalArrangement = Arrangement.spacedBy(10.dp),1115 ) {1116 Box(1117 Modifier.size(16.dp).clip(CircleShape)1118 .border(1.dp, if (selected) accent else fg.copy(alpha = 0.4f), CircleShape),1119 contentAlignment = Alignment.Center,1120 ) {1121 if (selected) Box(Modifier.size(8.dp).clip(CircleShape).background(accent))1122 }1123 Text(label, color = if (selected) accent else fg, fontFamily = PeachType.Mono, fontSize = 11.sp)1124 }1125}11261127@Composable1128private fun DuressSaveButton(label: String, fg: Color, enabled: Boolean, onClick: () -> Unit) {1129 val accent = LocalPeachAccent.current1130 val tint = if (enabled) accent else fg.copy(alpha = 0.3f)1131 Box(1132 Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp))1133 .border(1.dp, tint.copy(alpha = if (enabled) 0.6f else 0.3f), RoundedCornerShape(8.dp))1134 .background(tint.copy(alpha = if (enabled) 0.16f else 0.06f))1135 .let { if (enabled) it.clickable(onClick = onClick) else it }1136 .padding(vertical = 11.dp),1137 contentAlignment = Alignment.Center,1138 ) {1139 Text(label, color = if (enabled) accent else fg.copy(alpha = 0.4f), fontFamily = PeachType.Mono, fontSize = 11.sp)1140 }1141}11421143@Composable1144private fun DuressDangerGhostButton(label: String, fg: Color, onClick: () -> Unit) {1145 Box(1146 Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp))1147 .border(1.dp, peachColors.Breach.copy(alpha = 0.5f), RoundedCornerShape(8.dp))1148 .clickable(onClick = onClick)1149 .padding(vertical = 11.dp),1150 contentAlignment = Alignment.Center,1151 ) {1152 Text(label, color = peachColors.Breach, fontFamily = PeachType.Mono, fontSize = 11.sp)1153 }1154}