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.ui.PeachNav56import com.peachpasswords.ui.sync.SyncViewModel57import com.peachpasswords.ui.theme.ACCENT_COLORS58import com.peachpasswords.ui.theme.PeachType59import androidx.hilt.navigation.compose.hiltViewModel60import com.peachpasswords.vault.VaultSettings61import com.peachpasswords.vault.VaultSnapshot62import kotlinx.coroutines.launch63import kotlinx.coroutines.delay64import java.text.SimpleDateFormat65import java.util.Date66import java.util.Locale6768private const val PRO_URL = "https://buy.polar.sh/polar_cl_IXSFIPojx67rcOTksn8LkH5mnU3osPHtYqBIl1eyuIz"697071727374757677@Composable78fun CardBody(79 id: CardId,80 fg: Color,81 vm: SettingsViewModel,82 settings: VaultSettings,83 entriesCount: Int,84 onNavigate: (PeachNav) -> Unit,85) {86 when (id) {87 CardId.Appearance -> AppearanceBody(fg, vm, settings)88 CardId.Protection -> ProtectionBody(fg, vm, settings, onNavigate)89 CardId.Vault -> VaultBody(fg, vm, settings, entriesCount, onNavigate)90 CardId.Sync -> SyncBody(fg, onNavigate)91 CardId.Shortcuts -> ShortcutsBody(fg)92 CardId.Pro -> ProBody(fg, vm)93 CardId.Feedback -> FeedbackBody(fg, vm)94 }95}96979899@Composable100private fun SubLabel(text: String, fg: Color, top: Dp = 14.dp) {101 Text(102 text,103 modifier = Modifier.padding(top = top, bottom = 4.dp),104 color = fg.copy(alpha = 0.58f),105 fontFamily = PeachType.Mono,106 fontSize = 8.sp,107 letterSpacing = 0.22.em,108 )109}110111@Composable112private fun RowLine(fg: Color, modifier: Modifier = Modifier, content: @Composable RowScope.() -> Unit) {113 Row(114 Modifier.fillMaxWidth().then(modifier).padding(vertical = 9.dp),115 verticalAlignment = Alignment.CenterVertically,116 horizontalArrangement = Arrangement.SpaceBetween,117 content = content,118 )119 Box(Modifier.fillMaxWidth().height(1.dp).background(fg.copy(alpha = 0.12f)))120}121122@Composable123private fun RowScope.Name(text: String, fg: Color) {124 Text(text, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp, modifier = Modifier.weight(1f))125}126127@Composable128private fun ValueText(text: String, fg: Color) {129 Text(text, color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Mono, fontSize = 11.sp)130}131132@Composable133private fun SubtleButton(label: String, fg: Color, onClick: () -> Unit) {134 Box(135 Modifier.clip(RoundedCornerShape(8.dp))136 .border(1.dp, fg.copy(alpha = 0.28f), RoundedCornerShape(8.dp))137 .background(fg.copy(alpha = 0.08f))138 .clickable(onClick = onClick)139 .padding(horizontal = 12.dp, vertical = 6.dp),140 ) {141 Text(label, color = fg, fontFamily = PeachType.Mono, fontSize = 11.sp)142 }143}144145@Composable146private fun Toggle(on: Boolean, fg: Color, onToggle: (Boolean) -> Unit) {147 val knob by animateDpAsState(if (on) 16.dp else 2.dp, label = "knob")148 Box(149 Modifier.size(width = 34.dp, height = 20.dp).clip(RoundedCornerShape(999.dp))150 .background(if (on) fg.copy(alpha = 0.28f) else fg.copy(alpha = 0.08f))151 .border(1.dp, fg.copy(alpha = if (on) 0.5f else 0.32f), RoundedCornerShape(999.dp))152 .clickable { onToggle(!on) },153 ) {154 Box(155 Modifier.padding(top = 2.dp).width(16.dp).fillMaxWidth().height(16.dp)156 .padding(start = knob - 2.dp)157 .size(14.dp).clip(CircleShape)158 .background(if (on) fg else fg.copy(alpha = 0.58f)),159 )160 }161}162163@Composable164private fun Pill(label: String, active: Boolean, fg: Color, onClick: () -> Unit) {165 Box(166 Modifier.clip(RoundedCornerShape(999.dp))167 .border(1.dp, fg.copy(alpha = if (active) 0.55f else 0.32f), RoundedCornerShape(999.dp))168 .background(if (active) fg.copy(alpha = 0.18f) else Color.Transparent)169 .clickable(onClick = onClick)170 .padding(horizontal = 12.dp, vertical = 5.dp),171 ) {172 Text(label, color = fg, fontFamily = PeachType.Mono, fontSize = 10.sp)173 }174}175176@Composable177private fun ProBadge(fg: Color) {178 Box(179 Modifier.padding(start = 6.dp).clip(RoundedCornerShape(4.dp))180 .background(fg.copy(alpha = 0.16f)).padding(horizontal = 5.dp, vertical = 1.dp),181 ) {182 Text("Pro", color = fg.copy(alpha = 0.85f), fontFamily = PeachType.Mono, fontSize = 8.sp)183 }184}185186@Composable187private fun Hint(text: String, fg: Color) {188 Text(189 text,190 modifier = Modifier.padding(top = 6.dp),191 color = fg.copy(alpha = 0.6f),192 fontFamily = PeachType.Display,193 fontStyle = FontStyle.Italic,194 fontSize = 11.5.sp,195 lineHeight = 16.sp,196 )197}198199200201@OptIn(ExperimentalLayoutApi::class)202@Composable203private fun AppearanceBody(fg: Color, vm: SettingsViewModel, s: VaultSettings) {204 SubLabel("THEME", fg, top = 0.dp)205 RowLine(fg) {206 Name("Theme", fg)207 val (label, next) = when (s.theme) {208 "dark" -> "Switch to light" to "light"209 else -> "Switch to dark" to "dark"210 }211 SubtleButton(label, fg) { vm.setTheme(next) }212 }213 SubLabel("ACCENT", fg)214 FlowRow(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {215 ACCENT_COLORS.forEach { (name, color) ->216 Box(217 Modifier.size(22.dp).clip(CircleShape).background(color)218 .border(219 if (s.accentColor == name) 2.dp else 1.dp,220 if (s.accentColor == name) fg else fg.copy(alpha = 0.2f),221 CircleShape,222 )223 .clickable { vm.setAccent(name) },224 )225 }226 }227 SubLabel("TEXT SIZE", fg)228 RowLine(fg) {229 Name("Size", fg)230 Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {231 Pill("Default", s.textSize == "medium", fg) { vm.setTextSize("medium") }232 Pill("Large", s.textSize == "large", fg) { vm.setTextSize("large") }233 }234 }235 SubLabel("MOTION", fg)236 RowLine(fg) {237 Name("Reduce motion", fg)238 SubtleButton(if (s.reduceMotion) "On" else "Off", fg) { vm.setReduceMotion(!s.reduceMotion) }239 }240}241242243244@Composable245private fun ProtectionBody(fg: Color, vm: SettingsViewModel, s: VaultSettings, onNavigate: (PeachNav) -> Unit) {246 val lockOptions = listOf(1 to "1 minute", 5 to "5 minutes", 15 to "15 minutes", 30 to "30 minutes", 0 to "Never")247 val current = s.autoLockMinutes ?: 0248249 SubLabel("LOCKING", fg, top = 0.dp)250 RowLine(fg) {251 Name("Auto-lock after", fg)252 val idx = lockOptions.indexOfFirst { it.first == current }.coerceAtLeast(0)253 SubtleButton(lockOptions[idx].second, fg) {254 val next = lockOptions[(idx + 1) % lockOptions.size].first255 vm.setAutoLockMinutes(if (next == 0) 0 else next)256 }257 }258 SubLabel("BIOMETRICS", fg)259 val bioActivity = LocalContext.current as? androidx.fragment.app.FragmentActivity260 RowLine(fg) {261 Name("Unlock with biometrics", fg)262 Toggle(s.biometricsEnabled, fg) { on ->263 if (on && bioActivity != null) vm.enableBiometrics(bioActivity) else vm.disableBiometrics()264 }265 }266 val bioError = com.peachpasswords.ui.lock.Biometrics.statusMessage(LocalContext.current)267 if (bioError != null) {268 Text(269 bioError,270 color = com.peachpasswords.ui.theme.peachColors.Breach,271 fontFamily = PeachType.Mono, fontSize = 10.sp,272 modifier = Modifier.padding(start = 2.dp, top = 2.dp, bottom = 4.dp),273 )274 }275 SubLabel("PASSKEYS", fg)276 RowLine(fg) {277 Column(Modifier.weight(1f)) {278 Text("Credential provider", color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)279 Text(280 "Peach can handle passkey sign-in and creation through Android Credential Manager.",281 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,282 modifier = Modifier.padding(top = 2.dp),283 )284 }285 Toggle(s.passkeyProviderEnabled, fg) { vm.setPasskeyProviderEnabled(it) }286 }287 RowLine(fg) {288 Name("Status", fg)289 ValueText(if (s.passkeyProviderEnabled) "enabled" else "off", fg)290 }291 SubLabel("RECOVERY", fg)292 RowLine(fg) {293 Name("View recovery words", fg)294 SubtleButton("view", fg) { onNavigate(PeachNav.RecoveryView) }295 }296 SubLabel("BREACH PROTECTION", fg)297 val checkingBreaches by vm.checkingBreaches.collectAsState()298 val breachResult by vm.breachResult.collectAsState()299 RowLine(fg) {300 Name("Breach monitoring", fg)301 Toggle(s.breachMonitoring, fg) { vm.setBreachMonitoring(it) }302 }303 RowLine(fg) {304 Name("Check all passwords", fg)305 SubtleButton(if (checkingBreaches) "checking..." else "run", fg) { vm.checkAllBreaches() }306 }307 breachResult?.let { result ->308 RowLine(fg) {309 Name("Last check", fg)310 ValueText(result, fg)311 }312 }313314 SubLabel("MASTER PASSWORD", fg)315 ChangePasswordRow(fg, vm)316317 SubLabel("DURESS PASSWORD", fg)318 val duressIsPro by vm.isPro.collectAsState()319 if (!duressIsPro) {320 RowLine(fg) {321 Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) {322 Name("Duress password", fg); ProBadge(fg)323 }324 ValueText("off", fg)325 }326 Hint("If entered under coercion, a decoy empty vault opens; your real vault stays hidden. Pro feature.", fg)327 } else {328 DuressSection(fg, vm)329 }330}331332@Composable333private fun ChangePasswordRow(fg: Color, vm: SettingsViewModel) {334 var open by remember { mutableStateOf(false) }335 var current by remember { mutableStateOf("") }336 var next by remember { mutableStateOf("") }337 var confirm by remember { mutableStateOf("") }338 var error by remember { mutableStateOf<String?>(null) }339 var done by remember { mutableStateOf(false) }340 val scope = rememberCoroutineScope()341342 RowLine(fg) {343 Name("Master password", fg)344 SubtleButton(if (open) "cancel" else "change", fg) { open = !open; error = null; done = false }345 }346 AnimatedVisibility(open) {347 Column(Modifier.fillMaxWidth().padding(top = 8.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {348 PwField("current password", current, fg) { current = it }349 PwField("new password (min 12 chars)", next, fg) { next = it }350 PwField("confirm new password", confirm, fg) { confirm = it }351 error?.let { Text(it, color = Color(0xFFE5805C), fontFamily = PeachType.Mono, fontSize = 10.sp) }352 if (done) Text("password changed ✓", color = fg, fontFamily = PeachType.Mono, fontSize = 10.sp)353 SubtleButton("save new password", fg) {354 error = when {355 current.isBlank() -> "enter your current password"356 next.length < 12 -> "new password must be at least 12 characters"357 next != confirm -> "new passwords do not match"358 next == current -> "new password must differ from current"359 else -> null360 }361 if (error == null) scope.launch {362 if (vm.changePassword(current, next)) {363 current = ""; next = ""; confirm = ""; open = false; done = true364 } else error = "incorrect current password"365 }366 }367 }368 }369}370371@Composable372private fun PwField(placeholder: String, value: String, fg: Color, onChange: (String) -> Unit) {373 Box(374 Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp))375 .background(Color(0x2E000000))376 .border(1.dp, fg.copy(alpha = 0.22f), RoundedCornerShape(8.dp))377 .padding(horizontal = 10.dp, vertical = 10.dp),378 ) {379 if (value.isEmpty()) {380 Text(placeholder, color = fg.copy(alpha = 0.42f), fontFamily = PeachType.Mono, fontSize = 12.sp)381 }382 BasicTextField(383 value = value,384 onValueChange = onChange,385 singleLine = true,386 textStyle = TextStyle(color = fg, fontFamily = PeachType.Mono, fontSize = 12.sp),387 cursorBrush = SolidColor(fg),388 visualTransformation = PasswordVisualTransformation(),389 modifier = Modifier.fillMaxWidth(),390 )391 }392}393394395396@Composable397private fun VaultBody(398 fg: Color,399 vm: SettingsViewModel,400 s: VaultSettings,401 entriesCount: Int,402 onNavigate: (PeachNav) -> Unit,403) {404 val trashOptions = listOf(7 to "7 days", 30 to "30 days", 90 to "90 days", 0 to "Never")405 val current = s.trashRetentionDays ?: 0406 val isPro by vm.isPro.collectAsState()407 val dedupCount by vm.dedupCount.collectAsState()408 val dedupRunning by vm.dedupRunning.collectAsState()409 val dedupDone by vm.dedupDone.collectAsState()410 val history by vm.vaultHistory.collectAsState()411 val restoringSnapshotId by vm.restoringSnapshotId.collectAsState()412413 SubLabel("ENTRIES", fg, top = 0.dp)414 RowLine(fg) { Name("Entries", fg); ValueText("$entriesCount", fg) }415 RowLine(fg) {416 Name("Duplicates", fg)417 val done = dedupDone418 if (done != null) {419 ValueText(if (done == 0) "already clean" else "removed $done", com.peachpasswords.ui.theme.peachColors.SyncOk)420 } else {421 val count = dedupCount422 val label = when {423 dedupRunning -> "scanning..."424 count == null -> "scan"425 count == 0 -> "none found"426 else -> "$count found"427 }428 SubtleButton(label, fg) {429 if (count == null || count == 0) vm.scanDuplicates()430 }431 }432 }433 if ((dedupCount ?: 0) > 0 && dedupDone == null) {434 Column(435 Modifier.fillMaxWidth()436 .padding(top = 2.dp, bottom = 8.dp)437 .clip(RoundedCornerShape(8.dp))438 .background(fg.copy(alpha = 0.08f))439 .border(1.dp, fg.copy(alpha = 0.18f), RoundedCornerShape(8.dp))440 .padding(10.dp),441 verticalArrangement = Arrangement.spacedBy(8.dp),442 ) {443 val count = dedupCount ?: 0444 Text(445 "$count duplicate ${if (count == 1) "entry" else "entries"} found. The newest copy of each will be kept; older duplicates will be moved to trash.",446 color = fg.copy(alpha = 0.82f),447 fontFamily = PeachType.Body,448 fontSize = 11.sp,449 lineHeight = 16.sp,450 )451 Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {452 SubtleButton("cancel", fg) { vm.cancelDuplicateRemoval() }453 SubtleButton(if (dedupRunning) "removing..." else "remove duplicates", fg) { vm.removeDuplicates() }454 }455 }456 }457458 SubLabel("MAINTENANCE", fg)459 RowLine(fg) {460 Name("Trash auto-delete", fg)461 val idx = trashOptions.indexOfFirst { it.first == current }.coerceAtLeast(0)462 SubtleButton(trashOptions[idx].second, fg) {463 vm.setTrashRetentionDays(trashOptions[(idx + 1) % trashOptions.size].first)464 }465 }466 RowLine(fg) { Name("Advanced Vault Health", fg); SubtleButton("open", fg) { onNavigate(PeachNav.Health) } }467 RowLine(fg) { Name("Trash", fg); SubtleButton("open", fg) { onNavigate(PeachNav.Trash) } }468469 SubLabel("DATA", fg)470 RowLine(fg) { Name("Import passwords", fg); SubtleButton("open", fg) { onNavigate(PeachNav.Import) } }471 RowLine(fg) { Name("Export backup", fg); SubtleButton("open", fg) { onNavigate(PeachNav.Export) } }472 RowLine(fg) {473 Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) { Name("Peach Codex", fg); if (!isPro) ProBadge(fg) }474 SubtleButton(if (isPro) "open" else "Pro", fg) { if (isPro) onNavigate(PeachNav.CodexGenerate) }475 }476 RowLine(fg) { Name("Restore from Codex", fg); SubtleButton("open", fg) { onNavigate(PeachNav.CodexRestore) } }477478 var historyShowAll by remember { mutableStateOf(false) }479 SubLabel("VAULT HISTORY", fg)480 if (history.isEmpty()) {481 Text(482 "No snapshots yet. Peach saves automatically before every change — saves, syncs, and imports.",483 color = fg.copy(alpha = 0.68f),484 fontFamily = PeachType.Body,485 fontSize = 11.sp,486 lineHeight = 16.sp,487 modifier = Modifier.padding(bottom = 6.dp),488 )489 } else {490 Text(491 "Restoring locks your vault. Unlock with the password that encrypted that snapshot to confirm.",492 color = fg.copy(alpha = 0.68f),493 fontFamily = PeachType.Body,494 fontSize = 11.sp,495 lineHeight = 16.sp,496 modifier = Modifier.padding(bottom = 4.dp),497 )498 history.take(if (historyShowAll) history.size else 3).forEach { snap ->499 RowLine(fg) {500 Column(Modifier.weight(1f)) {501 Text(snapshotTimeLabel(snap.savedAt), color = fg, fontFamily = PeachType.Body, fontSize = 12.sp)502 Text(snapshotSubLabel(snap), color = fg.copy(alpha = 0.62f), fontFamily = PeachType.Mono, fontSize = 10.sp)503 }504 SubtleButton(if (restoringSnapshotId == snap.id) "..." else "restore", fg) {505 vm.restoreVaultSnapshot(snap.id)506 }507 }508 }509 if (history.size > 3) {510 RowLine(fg) {511 Name(if (historyShowAll) "show less" else "${history.size - 3} older", fg)512 SubtleButton(if (historyShowAll) "hide" else "show", fg) { historyShowAll = !historyShowAll }513 }514 }515 Text(516 "${history.size} of 5 snapshots",517 color = fg.copy(alpha = 0.58f),518 fontFamily = PeachType.Mono,519 fontSize = 10.sp,520 modifier = Modifier.padding(top = 2.dp, bottom = 6.dp),521 )522 }523524 var advancedOpen by remember { mutableStateOf(false) }525 SubLabel("ADVANCED", fg)526 RowLine(fg) {527 Name("Advanced", fg)528 SubtleButton(if (advancedOpen) "hide" else "show", fg) { advancedOpen = !advancedOpen }529 }530 if (advancedOpen) {531 RowLine(fg) {532 Name("Replace vault from backup", com.peachpasswords.ui.theme.peachColors.SyncBusy)533 SubtleButton("open", com.peachpasswords.ui.theme.peachColors.SyncBusy) { onNavigate(PeachNav.Import) }534 }535 RowLine(fg) {536 Name("Destroy vault", com.peachpasswords.ui.theme.peachColors.Breach)537 SubtleButton("destroy", com.peachpasswords.ui.theme.peachColors.Breach) { onNavigate(PeachNav.Panic) }538 }539 }540}541542private fun snapshotSubLabel(snapshot: VaultSnapshot): String {543 val count = snapshot.entryCount?.let { "up to $it ${if (it == 1) "entry" else "entries"}" }544 return listOfNotNull(count, snapshotReasonLabel(snapshot.reason)).joinToString(" · ")545}546547private fun snapshotReasonLabel(reason: String): String = when (reason) {548 "local_save" -> "saved"549 "sync_received" -> "synced"550 "import" -> "imported"551 "restore" -> "restored"552 else -> reason553}554555private fun snapshotTimeLabel(savedAt: Long): String {556 val diff = System.currentTimeMillis() - savedAt557 if (diff < 60_000) return "Just now"558 if (diff < 3_600_000) return "${diff / 60_000}m ago"559 val date = Date(savedAt)560 val today = SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(Date())561 val thenDay = SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(date)562 val time = SimpleDateFormat("h:mm a", Locale.getDefault()).format(date)563 if (today == thenDay) return "Today $time"564 val yesterday = SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(Date(System.currentTimeMillis() - 86_400_000))565 if (yesterday == thenDay) return "Yesterday $time"566 return SimpleDateFormat("MMM d h:mm a", Locale.getDefault()).format(date)567}568569570571@Composable572private fun SyncBody(fg: Color, onNavigate: (PeachNav) -> Unit) {573 val syncVm: SyncViewModel = hiltViewModel()574 val pairedDevices by syncVm.pairedDevices.collectAsState()575 val pendingVouched by syncVm.pendingVouched.collectAsState()576 val syncStatus by syncVm.status.collectAsState()577 val scope = rememberCoroutineScope()578 var confirmUnpair by remember { mutableStateOf<String?>(null) }579 var rotateConfirmOpen by remember { mutableStateOf(false) }580 var rotating by remember { mutableStateOf(false) }581 var rotateError by remember { mutableStateOf<String?>(null) }582583 SubLabel("PAIRING", fg, top = 0.dp)584 RowLine(fg) {585 Column(Modifier.weight(1f)) {586 Row(verticalAlignment = Alignment.CenterVertically) {587 Text("Peach Sync", color = fg, fontFamily = PeachType.Body, fontSize = 13.sp); ProBadge(fg)588 }589 Text(590 "Pair nearby devices by chirp and keep encrypted vault blobs in step without a central account.",591 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,592 modifier = Modifier.padding(top = 2.dp),593 )594 }595 }596 597 598 RowLine(fg, Modifier.clickable { onNavigate(PeachNav.ChirpPair) }) {599 Name("Sync hub", fg)600 Text("›", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 15.sp)601 }602 RowLine(fg) {603 Column(Modifier.weight(1f)) {604 Text("Pair new device", color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)605 Text(606 "Add a phone, another browser, or your desktop sync helper.",607 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,608 modifier = Modifier.padding(top = 2.dp),609 )610 }611 SubtleButton("pair", fg) { onNavigate(PeachNav.ChirpPair) }612 }613614 SubLabel("PAIRED DEVICES", fg)615 if (pairedDevices.isEmpty()) {616 Text(617 "No paired devices yet.",618 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 12.sp,619 modifier = Modifier.padding(top = 2.dp),620 )621 } else {622 pairedDevices.forEach { d ->623 RowLine(fg) {624 Column(Modifier.weight(1f)) {625 Text(d.deviceName ?: d.deviceId, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)626 Text(627 "${deviceTypeLabel(d.deviceType)} · ${syncTimeLabel(d.lastSyncedAt)}${if (isSyncStale(d.lastSyncedAt)) " · not seen recently" else ""}",628 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,629 modifier = Modifier.padding(top = 2.dp),630 )631 }632 if (confirmUnpair == d.deviceId) {633 Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {634 SubtleButton("cancel", fg) { confirmUnpair = null }635 SubtleButton("remove", peachColors.Breach) { syncVm.unpairDevice(d.deviceId); confirmUnpair = null }636 }637 } else {638 SubtleButton("remove", fg) { confirmUnpair = d.deviceId }639 }640 }641 }642 RowLine(fg) {643 ValueText(syncFlashLabel(syncStatus), fg)644 SubtleButton(if (syncStatus == SyncStatus.Syncing) "syncing..." else "sync now", fg) {645 if (syncStatus != SyncStatus.Syncing) syncVm.syncNow()646 }647 }648 }649650 if (pendingVouched.isNotEmpty()) {651 SubLabel("PENDING DEVICES", fg)652 pendingVouched.forEach { dev ->653 RowLine(fg) {654 Column(Modifier.weight(1f)) {655 Text(dev.deviceName, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)656 Text(657 "Was added by another of your devices. Allow it to sync with this vault?",658 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,659 modifier = Modifier.padding(top = 2.dp),660 )661 }662 Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {663 SubtleButton("Allow", fg) { syncVm.confirmVouchedDevice(dev.deviceId) }664 SubtleButton("Reject", fg) { syncVm.rejectVouchedDevice(dev.deviceId) }665 }666 }667 }668 }669670 SubLabel("RECOVERY", fg)671 if (rotateConfirmOpen) {672 Hint("This will disconnect all paired devices and your 12 recovery words will change. You'll be shown the new words next.", peachColors.Breach)673 rotateError?.let {674 Text(it, color = peachColors.Breach, fontFamily = PeachType.Body, fontSize = 11.sp, modifier = Modifier.padding(top = 6.dp))675 }676 Row(Modifier.padding(top = 10.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) {677 SubtleButton("cancel", fg) { if (!rotating) rotateConfirmOpen = false }678 SubtleButton(if (rotating) "rotating..." else "Rotate sync identity", peachColors.Breach) {679 if (rotating) return@SubtleButton680 rotating = true681 rotateError = null682 scope.launch {683 val ok = syncVm.rotateSyncIdentity()684 rotating = false685 if (ok) {686 rotateConfirmOpen = false687 onNavigate(PeachNav.RecoverySetup)688 } else {689 rotateError = "Rotation failed. Unlock your real vault and try again."690 }691 }692 }693 }694 } else {695 RowLine(fg) {696 Column(Modifier.weight(1f)) {697 Text("Rotate sync identity", color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)698 Text(699 "Use this if a paired device was lost or stolen. Re-keys the vault so the old device's key is useless.",700 color = fg.copy(alpha = 0.7f), fontFamily = PeachType.Body, fontSize = 11.sp, lineHeight = 16.sp,701 modifier = Modifier.padding(top = 2.dp),702 )703 }704 SubtleButton("rotate", peachColors.Breach) { rotateError = null; rotateConfirmOpen = true }705 }706 }707708 Hint("Sync uses the same zero-knowledge vault format as backup and restore; pairing authorizes a device, not a cloud account.", fg)709}710711private fun deviceTypeLabel(type: String?): String = when (type) {712 "android" -> "Android"713 "phone" -> "Phone"714 "tablet" -> "Tablet"715 "desktop" -> "Desktop"716 "browser" -> "Browser"717 else -> "Device"718}719720private fun syncTimeLabel(lastSyncedAt: Long?): String {721 if (lastSyncedAt == null) return "never synced"722 val diff = System.currentTimeMillis() - lastSyncedAt723 if (diff < 60_000) return "just now"724 if (diff < 3_600_000) return "${diff / 60_000}m ago"725 if (diff < 86_400_000) return "${diff / 3_600_000}h ago"726 return "${diff / 86_400_000}d ago"727}728729private fun isSyncStale(lastSyncedAt: Long?): Boolean =730 lastSyncedAt != null && System.currentTimeMillis() - lastSyncedAt > 7L * 24L * 60L * 60L * 1000L731732private fun syncFlashLabel(status: SyncStatus): String = when (status) {733 SyncStatus.Idle -> ""734 SyncStatus.Syncing -> "syncing..."735 SyncStatus.Offline -> "offline"736 is SyncStatus.Error -> status.message737 is SyncStatus.LastSynced -> "synced ${syncTimeLabel(status.timestamp)}"738}739740741742@Composable743private fun ShortcutsBody(fg: Color) {744 val bindings = listOf(745 "Copy password" to "⌘C", "Copy username" to "⌘⇧C", "Open entry" to "↵",746 "Edit entry" to "E", "New entry" to "⌘N", "Search" to "/",747 )748 SubLabel("KEYBINDINGS", fg, top = 0.dp)749 Hint("Shortcuts apply when a hardware keyboard is attached. Defaults shown below.", fg)750 Spacer(Modifier.height(8.dp))751 bindings.forEach { (label, key) ->752 RowLine(fg) {753 Name(label, fg)754 Box(755 Modifier.clip(RoundedCornerShape(4.dp)).background(fg.copy(alpha = 0.06f))756 .border(1.dp, fg.copy(alpha = 0.32f), RoundedCornerShape(4.dp))757 .padding(horizontal = 7.dp, vertical = 2.dp),758 ) { Text(key, color = fg, fontFamily = PeachType.Mono, fontSize = 10.sp) }759 }760 }761}762763764765@Composable766private fun ProBody(fg: Color, vm: SettingsViewModel) {767 val ctx = LocalContext.current768 val isPro by vm.isPro.collectAsState()769 if (isPro) {770 ProActiveBody(fg, vm)771 return772 }773 val features = listOf(774 "Peach Sync" to "Encrypted · peer-to-peer",775 "Peach Codex" to "Restore from paper",776 "Passkeys" to "Zero-knowledge WebAuthn",777 "Advanced Vault Health" to "Reuse · age · exposure",778 "Canary entries" to "Detects vault compromise",779 "Duress vault" to "Decoy under coercion",780 )781 Text("PEACH PRO · ONE-TIME", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 8.sp, letterSpacing = 0.22.em)782 Text(783 "Everything, everywhere.",784 modifier = Modifier.padding(top = 8.dp),785 color = fg, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 24.sp,786 )787 Text(788 "One key unlocks every Pro feature — for the lifetime of the app.",789 modifier = Modifier.padding(top = 6.dp),790 color = fg.copy(alpha = 0.72f), fontFamily = PeachType.Body, fontSize = 12.sp, lineHeight = 17.sp,791 )792 Spacer(Modifier.height(12.dp))793 features.forEachIndexed { i, (name, desc) ->794 RowLine(fg) {795 Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) {796 Text("%02d".format(i + 1), color = fg.copy(alpha = 0.5f), fontFamily = PeachType.Mono, fontSize = 10.sp, modifier = Modifier.padding(end = 10.dp))797 Text(name, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)798 }799 Text(desc, color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 11.sp)800 }801 }802 Spacer(Modifier.height(14.dp))803 Text(804 "$39",805 color = fg, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 28.sp,806 )807 Text("once · yours forever", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 9.sp, letterSpacing = 0.18.em)808 Spacer(Modifier.height(10.dp))809 Box(810 Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp))811 .background(fg.copy(alpha = 0.16f))812 .border(1.dp, fg.copy(alpha = 0.4f), RoundedCornerShape(10.dp))813 .clickable {814 runCatching { ctx.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(PRO_URL))) }815 }816 .padding(vertical = 12.dp),817 contentAlignment = Alignment.Center,818 ) { Text("Get Peach Pro", color = fg, fontFamily = PeachType.Mono, fontSize = 12.sp) }819820 Spacer(Modifier.height(16.dp))821 Text("LICENSE KEY", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 8.sp, letterSpacing = 0.22.em)822 var key by remember { mutableStateOf("") }823 val activating by vm.activating.collectAsState()824 val activationError by vm.activationError.collectAsState()825 Box(826 Modifier.fillMaxWidth().padding(top = 6.dp)827 .border(1.dp, fg.copy(alpha = 0.3f), RoundedCornerShape(8.dp))828 .padding(horizontal = 12.dp, vertical = 10.dp),829 ) {830 BasicTextField(831 value = key,832 onValueChange = { key = it.uppercase(); vm.clearActivationError() },833 singleLine = true,834 textStyle = TextStyle(fontFamily = PeachType.Mono, fontSize = 13.sp, letterSpacing = 0.12.em, color = fg),835 cursorBrush = SolidColor(fg),836 modifier = Modifier.fillMaxWidth(),837 decorationBox = { inner ->838 if (key.isEmpty()) Text("PPK-XXXX-XXXX-XXXX", color = fg.copy(alpha = 0.3f), fontFamily = PeachType.Mono, fontSize = 13.sp, letterSpacing = 0.12.em)839 inner()840 },841 )842 }843 if (activationError != null) {844 Text(activationError!!, color = com.peachpasswords.ui.theme.peachColors.Breach, fontFamily = PeachType.Mono, fontSize = 10.sp, modifier = Modifier.padding(top = 6.dp))845 }846 Spacer(Modifier.height(8.dp))847 Box(848 Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp))849 .background(fg.copy(alpha = if (activating || key.isBlank()) 0.08f else 0.16f))850 .border(1.dp, fg.copy(alpha = 0.4f), RoundedCornerShape(10.dp))851 .clickable(enabled = !activating && key.isNotBlank()) { vm.activateLicense(key) }852 .padding(vertical = 12.dp),853 contentAlignment = Alignment.Center,854 ) { Text(if (activating) "Activating…" else "Activate", color = fg, fontFamily = PeachType.Mono, fontSize = 12.sp) }855}856857@Composable858private fun ProActiveBody(fg: Color, vm: SettingsViewModel) {859 val ctx = LocalContext.current860 val features = listOf("Peach Sync", "Peach Codex", "Passkeys", "Advanced Vault Health", "Canary entries", "Duress vault")861 val licenseKey by vm.licenseKey.collectAsState()862 val issuedAt by vm.licenseIssuedAt.collectAsState()863 var showKey by remember { mutableStateOf(false) }864 var copied by remember { mutableStateOf(false) }865 val scope = rememberCoroutineScope()866 Box(Modifier.fillMaxWidth().padding(vertical = 8.dp), contentAlignment = Alignment.Center) {867 com.peachpasswords.ui.components.PeachMark(size = 60.dp)868 }869 Text(870 "Peach Pro",871 modifier = Modifier.fillMaxWidth(),872 color = fg, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 26.sp,873 textAlign = androidx.compose.ui.text.style.TextAlign.Center,874 )875 Text(876 formatLicenseActiveSince(issuedAt),877 modifier = Modifier.fillMaxWidth().padding(top = 4.dp),878 color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 9.sp, letterSpacing = 0.18.em,879 textAlign = androidx.compose.ui.text.style.TextAlign.Center,880 )881 licenseKey?.let { key ->882 Spacer(Modifier.height(12.dp))883 Text("LICENSE KEY", color = fg.copy(alpha = 0.6f), fontFamily = PeachType.Mono, fontSize = 8.sp, letterSpacing = 0.22.em)884 RowLine(fg) {885 Text(886 if (showKey) key else "************************",887 color = fg.copy(alpha = if (showKey) 0.82f else 0.58f),888 fontFamily = PeachType.Mono,889 fontSize = 10.sp,890 modifier = Modifier.weight(1f),891 )892 Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {893 SubtleButton(if (copied) "copied" else "copy", fg) {894 PeachClipboard.copy(ctx, "peach license", key)895 copied = true896 scope.launch {897 delay(1_500)898 copied = false899 }900 }901 SubtleButton(if (showKey) "hide" else "reveal", fg) { showKey = !showKey }902 }903 }904 }905 Spacer(Modifier.height(12.dp))906 features.forEachIndexed { i, name ->907 RowLine(fg) {908 Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) {909 Text("%02d".format(i + 1), color = fg.copy(alpha = 0.5f), fontFamily = PeachType.Mono, fontSize = 10.sp, modifier = Modifier.padding(end = 10.dp))910 Text(name, color = fg, fontFamily = PeachType.Body, fontSize = 13.sp)911 }912 Text("unlocked", color = com.peachpasswords.ui.theme.peachColors.HealthOk, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 11.sp)913 }914 }915 Spacer(Modifier.height(12.dp))916 Box(917 Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp))918 .border(1.dp, com.peachpasswords.ui.theme.peachColors.Breach.copy(alpha = 0.4f), RoundedCornerShape(10.dp))919 .clickable { vm.deactivate() }920 .padding(vertical = 12.dp),921 contentAlignment = Alignment.Center,922 ) { Text("Deactivate", color = com.peachpasswords.ui.theme.peachColors.Breach, fontFamily = PeachType.Mono, fontSize = 12.sp) }923}924925private fun formatLicenseActiveSince(issuedAt: Long?): String {926 if (issuedAt == null) return "Active"927 val monthYear = SimpleDateFormat("MMMM yyyy", Locale.getDefault()).format(Date(issuedAt))928 return "Active since $monthYear"929}930931932933@OptIn(ExperimentalLayoutApi::class)934@Composable935private fun FeedbackBody(fg: Color, vm: SettingsViewModel) {936 val categories = listOf("Bug report", "Feature request", "Question", "Other")937 var category by remember { mutableStateOf(categories[0]) }938 var message by remember { mutableStateOf("") }939 val state by vm.feedbackState.collectAsState()940941 942 DisposableEffect(Unit) { onDispose { vm.resetFeedback() } }943944 if (state is FeedbackState.Sent) {945 Box(946 Modifier.fillMaxWidth().clip(RoundedCornerShape(10.dp)).background(fg.copy(alpha = 0.08f))947 .border(1.dp, fg.copy(alpha = 0.32f), RoundedCornerShape(10.dp)).padding(16.dp),948 ) {949 Column {950 Text("Thank you", color = fg, fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 18.sp)951 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))952 }953 }954 return955 }956957 val sending = state is FeedbackState.Sending958959 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)960 SubLabel("TYPE", fg)961 FlowRow(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {962 categories.forEach { cat -> Pill(cat, category == cat, fg) { if (!sending) category = cat } }963 }964 SubLabel("MESSAGE", fg)965 Box(966 Modifier.fillMaxWidth().height(110.dp).clip(RoundedCornerShape(8.dp))967 .background(Color(0x2E000000)).border(1.dp, fg.copy(alpha = 0.22f), RoundedCornerShape(8.dp))968 .padding(10.dp),969 ) {970 if (message.isEmpty()) Text("Describe the issue or idea...", color = fg.copy(alpha = 0.42f), fontFamily = PeachType.Body, fontSize = 12.sp)971 BasicTextField(972 value = message, onValueChange = { message = it },973 enabled = !sending,974 textStyle = TextStyle(color = fg, fontFamily = PeachType.Body, fontSize = 12.sp),975 cursorBrush = SolidColor(fg), modifier = Modifier.fillMaxWidth(),976 )977 }978 Spacer(Modifier.height(8.dp))979980 Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {981 val canSend = !sending && message.isNotBlank()982 Box(983 Modifier.clip(RoundedCornerShape(8.dp))984 .border(1.dp, fg.copy(alpha = if (canSend) 0.28f else 0.14f), RoundedCornerShape(8.dp))985 .background(fg.copy(alpha = if (canSend) 0.08f else 0.04f))986 .clickable(enabled = canSend) { vm.sendFeedback(category, message) }987 .padding(horizontal = 12.dp, vertical = 6.dp),988 ) {989 Text(990 if (state is FeedbackState.Error) "Retry" else "Send",991 color = fg.copy(alpha = if (canSend) 1f else 0.4f),992 fontFamily = PeachType.Mono, fontSize = 11.sp,993 )994 }995 if (sending) {996 CircularProgressIndicator(997 color = LocalPeachAccent.current,998 strokeWidth = 2.dp,999 modifier = Modifier.size(16.dp),1000 )1001 }1002 }10031004 (state as? FeedbackState.Error)?.let { err ->1005 Text(1006 err.message,1007 modifier = Modifier.padding(top = 8.dp),1008 color = peachColors.Breach,1009 fontFamily = PeachType.Mono,1010 fontSize = 11.sp,1011 lineHeight = 15.sp,1012 )1013 }10141015 Hint("Sent anonymously · no account required", fg)1016}1017101810191020@Composable1021internal fun DuressSection(fg: Color, vm: SettingsViewModel) {1022 val configured by vm.duressConfigured.collectAsState()1023 if (configured) DuressActiveState(fg, vm) else DuressForm(fg, vm)1024}10251026@Composable1027private fun DuressActiveState(fg: Color, vm: SettingsViewModel) {1028 Text(1029 "Duress password is active",1030 color = peachColors.HealthOk,1031 fontFamily = PeachType.Mono,1032 fontSize = 11.sp,1033 modifier = Modifier.padding(top = 6.dp),1034 )1035 Spacer(Modifier.height(8.dp))1036 DuressDangerGhostButton("Disable duress password", fg) { vm.disableDuress() }1037 Hint("Entering your duress password instead of your real one triggers the action you chose.", fg)1038}10391040@Composable1041private fun DuressForm(fg: Color, vm: SettingsViewModel) {1042 var enabled by remember { mutableStateOf(false) }1043 var password by remember { mutableStateOf("") }1044 var confirm by remember { mutableStateOf("") }1045 var action by remember { mutableStateOf(DuressAction.DECOY) }1046 var error by remember { mutableStateOf<String?>(null) }1047 val scope = rememberCoroutineScope()10481049 RowLine(fg) {1050 Name("Duress password", fg)1051 Toggle(enabled, fg) { on ->1052 enabled = on1053 if (!on) { password = ""; confirm = ""; error = null }1054 }1055 }1056 Text(1057 "Entering your duress password instead of your real one opens a decoy vault or wipes the real one.",1058 color = fg.copy(alpha = 0.7f),1059 fontFamily = PeachType.Mono,1060 fontSize = 10.sp,1061 modifier = Modifier.padding(top = 6.dp),1062 )10631064 AnimatedVisibility(enabled) {1065 Column(Modifier.fillMaxWidth().padding(top = 10.dp), verticalArrangement = Arrangement.spacedBy(6.dp)) {1066 PwField("DURESS PASSPHRASE", password, fg) { password = it; error = null }1067 PwField("CONFIRM DURESS PASSPHRASE", confirm, fg) { confirm = it; error = null }10681069 Text(1070 "When your duress password is entered at the lock screen, Peach will:",1071 color = fg.copy(alpha = 0.7f),1072 fontFamily = PeachType.Mono,1073 fontSize = 10.sp,1074 modifier = Modifier.padding(top = 4.dp),1075 )10761077 DuressRadioOption("Show a decoy vault", action == DuressAction.DECOY, fg) { action = DuressAction.DECOY }1078 DuressRadioOption("Destroy the real vault", action == DuressAction.DESTROY, fg) { action = DuressAction.DESTROY }10791080 error?.let { Text(it, color = peachColors.Breach, fontFamily = PeachType.Mono, fontSize = 10.sp) }10811082 val canSave = password.isNotBlank() && confirm.isNotBlank()1083 DuressSaveButton("Save duress password", fg, canSave) {1084 error = when {1085 password.isBlank() || confirm.isBlank() -> "Enter and confirm a duress password"1086 password != confirm -> "Passwords do not match"1087 else -> null1088 }1089 if (error == null) scope.launch {1090 if (vm.saveDuress(password, action)) {1091 password = ""; confirm = ""; enabled = false1092 } else {1093 error = "Couldn't save — the duress passphrase must differ from your real password"1094 }1095 }1096 }1097 }1098 }1099}11001101@Composable1102private fun DuressRadioOption(label: String, selected: Boolean, fg: Color, onClick: () -> Unit) {1103 val accent = LocalPeachAccent.current1104 Row(1105 Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp)).clickable(onClick = onClick).padding(vertical = 7.dp),1106 verticalAlignment = Alignment.CenterVertically,1107 horizontalArrangement = Arrangement.spacedBy(10.dp),1108 ) {1109 Box(1110 Modifier.size(16.dp).clip(CircleShape)1111 .border(1.dp, if (selected) accent else fg.copy(alpha = 0.4f), CircleShape),1112 contentAlignment = Alignment.Center,1113 ) {1114 if (selected) Box(Modifier.size(8.dp).clip(CircleShape).background(accent))1115 }1116 Text(label, color = if (selected) accent else fg, fontFamily = PeachType.Mono, fontSize = 11.sp)1117 }1118}11191120@Composable1121private fun DuressSaveButton(label: String, fg: Color, enabled: Boolean, onClick: () -> Unit) {1122 val accent = LocalPeachAccent.current1123 val tint = if (enabled) accent else fg.copy(alpha = 0.3f)1124 Box(1125 Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp))1126 .border(1.dp, tint.copy(alpha = if (enabled) 0.6f else 0.3f), RoundedCornerShape(8.dp))1127 .background(tint.copy(alpha = if (enabled) 0.16f else 0.06f))1128 .let { if (enabled) it.clickable(onClick = onClick) else it }1129 .padding(vertical = 11.dp),1130 contentAlignment = Alignment.Center,1131 ) {1132 Text(label, color = if (enabled) accent else fg.copy(alpha = 0.4f), fontFamily = PeachType.Mono, fontSize = 11.sp)1133 }1134}11351136@Composable1137private fun DuressDangerGhostButton(label: String, fg: Color, onClick: () -> Unit) {1138 Box(1139 Modifier.fillMaxWidth().clip(RoundedCornerShape(8.dp))1140 .border(1.dp, peachColors.Breach.copy(alpha = 0.5f), RoundedCornerShape(8.dp))1141 .clickable(onClick = onClick)1142 .padding(vertical = 11.dp),1143 contentAlignment = Alignment.Center,1144 ) {1145 Text(label, color = peachColors.Breach, fontFamily = PeachType.Mono, fontSize = 11.sp)1146 }1147}