7097e444900e
feat: E6 TOTP inline edit in EntryDetail — double-tap/pencil opens masked 2FA-secret editor with validation, persists via updateField; old TotpBand removed (v2.1.38)
- time
- 2026-06-09 04:37 UTC · 5 months ago
- machine
- koh2
- agent
- claude-opus-4-8
- session
- peach remaining gaps
- parent
- 88da4e941cc5
↓ peach-android-7097e444.tar.gzatlas at this save
files changed3 files
app/drafts/E6/TotpInlineEdit.kt+0 −297app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+6 −57app/src/main/java/com/peachpasswords/ui/vault/TotpInlineEdit.kt+300 −0app/drafts/E6/TotpInlineEdit.kt+0 −297
@@ -1,297 +0,0 @@1-package com.peachpasswords.ui.vault2-3-/*4- * E6 — TOTP double-tap to edit the 2FA secret, inline in EntryDetailScreen.5- *6- * Self-contained drop-in composable. D6 / D7 / E6 all touch EntryDetailScreen.kt,7- * so this stays isolated with merge anchors documented in INTEGRATION.md.8- *9- * Provides:10- * - TotpBandEditable : a TOTP band that double-taps (or taps a 14dp pencil) into11- * an inline 2FA-secret editor — masked BasicTextField with an12- * eye toggle and a ✓ save / ✗ cancel row (mirrors the D613- * inline-edit visual pattern). On save it calls back with the14- * new secret; live regeneration happens automatically because15- * the band reads the field flowing in from the VM/entry.16- *17- * It deliberately does NOT reuse the private FieldShell / CopyButton helpers in18- * EntryDetailScreen.kt by name in a way that would force them to change visibility —19- * the band has its own accent-tinted chrome (matching the existing TotpBand), and a20- * local copy button. The only EntryDetailScreen helper it depends on at merge time21- * is the existing `CopyButton`, which already lives in the same file; if the22- * orchestrator instead drops this into a separate file, make `CopyButton` `internal`23- * (see INTEGRATION.md). All private helpers here are E6-prefixed to avoid colliding24- * with D6's identically-shaped UnderlinedField / SaveCancelRow.25- */26-27-import androidx.compose.animation.core.RepeatMode28-import androidx.compose.animation.core.animateFloat29-import androidx.compose.animation.core.infiniteRepeatable30-import androidx.compose.animation.core.rememberInfiniteTransition31-import androidx.compose.animation.core.tween32-import androidx.compose.foundation.background33-import androidx.compose.foundation.border34-import androidx.compose.foundation.clickable35-import androidx.compose.foundation.gestures.detectTapGestures36-import androidx.compose.foundation.layout.Arrangement37-import androidx.compose.foundation.layout.Box38-import androidx.compose.foundation.layout.Column39-import androidx.compose.foundation.layout.Row40-import androidx.compose.foundation.layout.Spacer41-import androidx.compose.foundation.layout.fillMaxWidth42-import androidx.compose.foundation.layout.height43-import androidx.compose.foundation.layout.padding44-import androidx.compose.foundation.layout.size45-import androidx.compose.foundation.layout.width46-import androidx.compose.foundation.shape.RoundedCornerShape47-import androidx.compose.foundation.text.BasicTextField48-import androidx.compose.material.icons.Icons49-import androidx.compose.material.icons.outlined.Edit50-import androidx.compose.material3.Icon51-import androidx.compose.material3.Text52-import androidx.compose.runtime.Composable53-import androidx.compose.runtime.getValue54-import androidx.compose.runtime.mutableStateOf55-import androidx.compose.runtime.produceState56-import androidx.compose.runtime.remember57-import androidx.compose.runtime.setValue58-import androidx.compose.ui.Alignment59-import androidx.compose.ui.Modifier60-import androidx.compose.ui.draw.clip61-import androidx.compose.ui.draw.drawBehind62-import androidx.compose.ui.geometry.Offset63-import androidx.compose.ui.graphics.SolidColor64-import androidx.compose.ui.graphics.graphicsLayer65-import androidx.compose.ui.input.pointer.pointerInput66-import androidx.compose.ui.text.input.PasswordVisualTransformation67-import androidx.compose.ui.text.input.VisualTransformation68-import androidx.compose.ui.unit.dp69-import androidx.compose.ui.unit.em70-import com.peachpasswords.ui.components.TOTPRing71-import com.peachpasswords.ui.theme.LocalPeachAccent72-import com.peachpasswords.ui.theme.LocalReduceMotion73-import com.peachpasswords.ui.theme.PeachColors74-import com.peachpasswords.ui.theme.PeachType75-import com.peachpasswords.vault.TOTPGenerator76-77-/**78- * Accent-tinted TOTP band with double-tap-to-edit of the underlying 2FA secret.79- *80- * View mode is visually identical to the existing private `TotpBand`: large code,81- * mono countdown, sweep ring, copy button. A 14dp pencil sits beside the code, and82- * a double-tap anywhere on the code/band enters edit mode.83- *84- * Edit mode shows a masked [BasicTextField] (eye toggle to reveal) seeded with the85- * raw `totp` field (a base32 secret or an `otpauth://` URI), labelled "2FA SECRET",86- * over a ✓ save / ✗ cancel row. The draft is validated with87- * [TOTPGenerator.generateCode]; an empty / unparseable secret shows88- * "Invalid 2FA secret" in breach color and blocks save.89- *90- * On a valid save [onSaveSecret] is invoked with the trimmed new secret — the caller91- * persists via `vm.updateEntry(entry.copy(totp = newValue))`. Because [totpField]92- * flows back in from the entry StateFlow, the band regenerates live with no extra93- * wiring.94- *95- * @param totpField the current raw `totp` value (base32 secret or otpauth URI).96- * @param copied copy-latch for this entry's TOTP (drives the copy button feedback).97- * @param onCopy copies the live code (NOT the secret) — wire to `vm::copyTotp`.98- * @param onSaveSecret called with the trimmed, validated new secret on ✓ save.99- */100-@Composable101-fun TotpBandEditable(102- totpField: String,103- copied: Boolean,104- onCopy: () -> Unit,105- onSaveSecret: (String) -> Unit,106-) {107- val accent = LocalPeachAccent.current108- val reduceMotion = LocalReduceMotion.current109-110- var editing by remember(totpField) { mutableStateOf(false) }111-112- Box(113- Modifier114- .fillMaxWidth()115- .padding(vertical = 10.dp)116- .clip(RoundedCornerShape(8.dp))117- .background(accent.copy(alpha = 0.08f))118- .border(1.dp, accent.copy(alpha = 0.20f), RoundedCornerShape(8.dp))119- .padding(horizontal = 14.dp, vertical = 10.dp),120- ) {121- if (!editing) {122- TotpView(123- totpField = totpField,124- accent = accent,125- reduceMotion = reduceMotion,126- copied = copied,127- onCopy = onCopy,128- onEnterEdit = { editing = true },129- )130- } else {131- TotpSecretEditor(132- initial = totpField,133- onSave = { newSecret -> onSaveSecret(newSecret); editing = false },134- onCancel = { editing = false },135- )136- }137- }138-}139-140-/** Read-only band content: code, countdown, ring, pencil, copy — plus double-tap-to-edit. */141-@Composable142-private fun TotpView(143- totpField: String,144- accent: androidx.compose.ui.graphics.Color,145- reduceMotion: Boolean,146- copied: Boolean,147- onCopy: () -> Unit,148- onEnterEdit: () -> Unit,149-) {150- val code by produceState(TOTPGenerator.generateCode(totpField) ?: "------", totpField) {151- while (true) {152- value = TOTPGenerator.generateCode(totpField) ?: "------"153- kotlinx.coroutines.delay(1000)154- }155- }156- val remaining by produceState(TOTPGenerator.remainingSeconds()) {157- while (true) { value = TOTPGenerator.remainingSeconds(); kotlinx.coroutines.delay(500) }158- }159- val isHot = remaining <= 5160- val pulse = rememberInfiniteTransition(label = "totp-pulse")161- val pulseAlpha by pulse.animateFloat(162- initialValue = 0.55f, targetValue = 1f,163- animationSpec = infiniteRepeatable(tween(600), RepeatMode.Reverse), label = "totp-pulse-alpha",164- )165- val codeAlpha = if (isHot && !reduceMotion) pulseAlpha else 1f166-167- Row(verticalAlignment = Alignment.CenterVertically) {168- Column(169- Modifier170- .weight(1f)171- // Double-tap the code area to edit the 2FA secret (E6).172- .pointerInput(Unit) { detectTapGestures(onDoubleTap = { onEnterEdit() }) },173- ) {174- Row(verticalAlignment = Alignment.CenterVertically) {175- Text(176- "ONE-TIME CODE",177- color = accent.copy(alpha = 0.70f),178- style = PeachType.labelMono.copy(letterSpacing = 0.08.em),179- )180- Spacer(Modifier.width(6.dp))181- Icon(182- Icons.Outlined.Edit,183- contentDescription = "edit 2FA secret",184- tint = PeachColors.T2,185- modifier = Modifier186- .size(14.dp)187- .clip(RoundedCornerShape(4.dp))188- .clickable(onClick = onEnterEdit),189- )190- }191- val spaced = if (code.length == 6) "${code.substring(0, 3)} ${code.substring(3)}" else code192- Text(193- spaced,194- color = if (isHot) PeachColors.Breach else accent,195- style = PeachType.totpCode,196- modifier = Modifier.graphicsLayer { alpha = codeAlpha },197- )198- }199- Text("${remaining}s", color = PeachColors.T2, style = PeachType.totpCountdown)200- Spacer(Modifier.width(12.dp))201- TOTPRing(size = 28.dp)202- Spacer(Modifier.width(8.dp))203- CopyButton(copied, onCopy)204- }205-}206-207-/** Inline 2FA-secret editor: masked underlined field + eye toggle + ✓/✗, with validation. */208-@Composable209-private fun TotpSecretEditor(210- initial: String,211- onSave: (String) -> Unit,212- onCancel: () -> Unit,213-) {214- val accent = LocalPeachAccent.current215- var draft by remember { mutableStateOf(initial) }216- var show by remember { mutableStateOf(false) }217- var showError by remember { mutableStateOf(false) }218-219- val trimmed = draft.trim()220- val valid = TOTPGenerator.generateCode(trimmed) != null221-222- Column(Modifier.fillMaxWidth()) {223- Text(224- "2FA SECRET",225- color = accent.copy(alpha = 0.70f),226- style = PeachType.labelMono.copy(letterSpacing = 0.08.em),227- )228- Spacer(Modifier.height(8.dp))229- Row(verticalAlignment = Alignment.CenterVertically) {230- E6UnderlinedField(231- draft = draft,232- onDraftChange = { draft = it; showError = false },233- transformation = if (show) VisualTransformation.None else PasswordVisualTransformation(),234- modifier = Modifier.weight(1f),235- )236- Text(237- if (show) "hide" else "show", color = accent, style = PeachType.labelMono,238- modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable { show = !show }.padding(6.dp),239- )240- }241- if (showError) {242- Spacer(Modifier.height(6.dp))243- Text("Invalid 2FA secret", color = PeachColors.Breach, style = PeachType.labelMono)244- }245- Spacer(Modifier.height(8.dp))246- E6SaveCancelRow(247- onSave = {248- if (valid) onSave(trimmed) else showError = true249- },250- onCancel = { onCancel() },251- )252- }253-}254-255-/** BasicTextField with an accent underline (mirrors D6's inline-edit field). */256-@Composable257-private fun E6UnderlinedField(258- draft: String,259- onDraftChange: (String) -> Unit,260- transformation: VisualTransformation = VisualTransformation.None,261- modifier: Modifier = Modifier,262-) {263- val accent = LocalPeachAccent.current264- BasicTextField(265- value = draft,266- onValueChange = onDraftChange,267- singleLine = true,268- textStyle = PeachType.bodyMono.copy(color = PeachColors.T0),269- cursorBrush = SolidColor(accent),270- visualTransformation = transformation,271- modifier = modifier272- .padding(bottom = 4.dp)273- .drawBehind {274- drawLine(275- color = accent,276- start = Offset(0f, size.height),277- end = Offset(size.width, size.height),278- strokeWidth = 1.dp.toPx(),279- )280- },281- )282-}283-284-@Composable285-private fun E6SaveCancelRow(onSave: () -> Unit, onCancel: () -> Unit) {286- val accent = LocalPeachAccent.current287- Row(horizontalArrangement = Arrangement.spacedBy(16.dp), verticalAlignment = Alignment.CenterVertically) {288- Text(289- "✓ save", color = accent, style = PeachType.labelMono,290- modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable(onClick = onSave).padding(vertical = 4.dp),291- )292- Text(293- "✗", color = PeachColors.T2, style = PeachType.labelMono,294- modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable(onClick = onCancel).padding(horizontal = 6.dp, vertical = 4.dp),295- )296- }297-}app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+6 −57
@@ -278,7 +278,12 @@278278 }279279 if (e.hasTOTP()) {280280 Spacer(Modifier.height(4.dp))281- TotpBand(totpField = e.totp!!, copied = copiedField == "totp", onCopy = vm::copyTotp)281+ TotpBandEditable(282+ totpField = e.totp!!,283+ copied = copiedField == "totp",284+ onCopy = vm::copyTotp,285+ onSaveSecret = { newSecret -> vm.updateField("totp", newSecret) },286+ )282287 }283288 }284289 e.notes?.takeIf { it.isNotBlank() }?.let { v ->@@ -330,62 +335,6 @@330335 Text(label.uppercase(), color = PeachColors.T2, style = PeachType.labelMono.copy(letterSpacing = 0.08.em))331336 Spacer(Modifier.height(6.dp))332337 Row(verticalAlignment = Alignment.CenterVertically, content = content)333- }334-}335-336-/** Accent-tinted TOTP band (spec §5.4): large Cormorant code, mono countdown, sweep ring. */337-@Composable338-private fun TotpBand(totpField: String, copied: Boolean, onCopy: () -> Unit) {339- val accent = LocalPeachAccent.current340- val reduceMotion = LocalReduceMotion.current341- val code by produceState(TOTPGenerator.generateCode(totpField) ?: "------") {342- while (true) {343- value = TOTPGenerator.generateCode(totpField) ?: "------"344- kotlinx.coroutines.delay(1000)345- }346- }347- val remaining by produceState(TOTPGenerator.remainingSeconds()) {348- while (true) { value = TOTPGenerator.remainingSeconds(); kotlinx.coroutines.delay(500) }349- }350- val isHot = remaining <= 5351- // Gentle pulse for the final 5s; the transition always runs but only applies when hot.352- val pulse = rememberInfiniteTransition(label = "totp-pulse")353- val pulseAlpha by pulse.animateFloat(354- initialValue = 0.55f, targetValue = 1f,355- animationSpec = infiniteRepeatable(tween(600), RepeatMode.Reverse), label = "totp-pulse-alpha",356- )357- val codeAlpha = if (isHot && !reduceMotion) pulseAlpha else 1f358-359- Box(360- Modifier361- .fillMaxWidth()362- .padding(vertical = 10.dp)363- .clip(RoundedCornerShape(8.dp))364- .background(accent.copy(alpha = 0.08f))365- .border(1.dp, accent.copy(alpha = 0.20f), RoundedCornerShape(8.dp))366- .padding(horizontal = 14.dp, vertical = 10.dp),367- ) {368- Row(verticalAlignment = Alignment.CenterVertically) {369- Column(Modifier.weight(1f)) {370- Text(371- "ONE-TIME CODE",372- color = accent.copy(alpha = 0.70f),373- style = PeachType.labelMono.copy(letterSpacing = 0.08.em),374- )375- val spaced = if (code.length == 6) "${code.substring(0, 3)} ${code.substring(3)}" else code376- Text(377- spaced,378- color = if (isHot) PeachColors.Breach else accent,379- style = PeachType.totpCode,380- modifier = Modifier.graphicsLayer { alpha = codeAlpha },381- )382- }383- Text("${remaining}s", color = PeachColors.T2, style = PeachType.totpCountdown)384- Spacer(Modifier.width(12.dp))385- TOTPRing(size = 28.dp)386- Spacer(Modifier.width(8.dp))387- CopyButton(copied, onCopy)388- }389338 }390339 }391340 app/src/main/java/com/peachpasswords/ui/vault/TotpInlineEdit.kt+300 −0
@@ -0,0 +1,300 @@1+package com.peachpasswords.ui.vault2+3+/*4+ * E6 — TOTP double-tap to edit the 2FA secret, inline in EntryDetailScreen.5+ *6+ * Self-contained drop-in composable. D6 / D7 / E6 all touch EntryDetailScreen.kt,7+ * so this stays isolated with merge anchors documented in INTEGRATION.md.8+ *9+ * Provides:10+ * - TotpBandEditable : a TOTP band that double-taps (or taps a 14dp pencil) into11+ * an inline 2FA-secret editor — masked BasicTextField with an12+ * eye toggle and a ✓ save / ✗ cancel row (mirrors the D613+ * inline-edit visual pattern). On save it calls back with the14+ * new secret; live regeneration happens automatically because15+ * the band reads the field flowing in from the VM/entry.16+ *17+ * It deliberately does NOT reuse the private FieldShell / CopyButton helpers in18+ * EntryDetailScreen.kt by name in a way that would force them to change visibility —19+ * the band has its own accent-tinted chrome (matching the existing TotpBand), and a20+ * local copy button. The only EntryDetailScreen helper it depends on at merge time21+ * is the existing `CopyButton`, which already lives in the same file; if the22+ * orchestrator instead drops this into a separate file, make `CopyButton` `internal`23+ * (see INTEGRATION.md). All private helpers here are E6-prefixed to avoid colliding24+ * with D6's identically-shaped UnderlinedField / SaveCancelRow.25+ */26+27+import androidx.compose.animation.core.RepeatMode28+import androidx.compose.animation.core.animateFloat29+import androidx.compose.animation.core.infiniteRepeatable30+import androidx.compose.animation.core.rememberInfiniteTransition31+import androidx.compose.animation.core.tween32+import androidx.compose.foundation.background33+import androidx.compose.foundation.border34+import androidx.compose.foundation.clickable35+import androidx.compose.foundation.gestures.detectTapGestures36+import androidx.compose.foundation.layout.Arrangement37+import androidx.compose.foundation.layout.Box38+import androidx.compose.foundation.layout.Column39+import androidx.compose.foundation.layout.Row40+import androidx.compose.foundation.layout.Spacer41+import androidx.compose.foundation.layout.fillMaxWidth42+import androidx.compose.foundation.layout.height43+import androidx.compose.foundation.layout.padding44+import androidx.compose.foundation.layout.size45+import androidx.compose.foundation.layout.width46+import androidx.compose.foundation.shape.RoundedCornerShape47+import androidx.compose.foundation.text.BasicTextField48+import androidx.compose.material.icons.Icons49+import androidx.compose.material.icons.outlined.Edit50+import androidx.compose.material3.Icon51+import androidx.compose.material3.Text52+import androidx.compose.runtime.Composable53+import androidx.compose.runtime.getValue54+import androidx.compose.runtime.mutableStateOf55+import androidx.compose.runtime.produceState56+import androidx.compose.runtime.remember57+import androidx.compose.runtime.setValue58+import androidx.compose.ui.Alignment59+import androidx.compose.ui.Modifier60+import androidx.compose.ui.draw.clip61+import androidx.compose.ui.draw.drawBehind62+import androidx.compose.ui.geometry.Offset63+import androidx.compose.ui.graphics.SolidColor64+import androidx.compose.ui.graphics.graphicsLayer65+import androidx.compose.ui.input.pointer.pointerInput66+import androidx.compose.ui.text.input.PasswordVisualTransformation67+import androidx.compose.ui.text.input.VisualTransformation68+import androidx.compose.ui.unit.dp69+import androidx.compose.ui.unit.em70+import com.peachpasswords.ui.components.CopyButton71+import com.peachpasswords.ui.components.TOTPRing72+import com.peachpasswords.ui.theme.LocalPeachAccent73+import com.peachpasswords.ui.theme.LocalReduceMotion74+import com.peachpasswords.ui.theme.PeachColors75+import com.peachpasswords.ui.theme.PeachType76+import com.peachpasswords.vault.TOTPGenerator77+78+/**79+ * Accent-tinted TOTP band with double-tap-to-edit of the underlying 2FA secret.80+ *81+ * View mode is visually identical to the existing private `TotpBand`: large code,82+ * mono countdown, sweep ring, copy button. A 14dp pencil sits beside the code, and83+ * a double-tap anywhere on the code/band enters edit mode.84+ *85+ * Edit mode shows a masked [BasicTextField] (eye toggle to reveal) seeded with the86+ * raw `totp` field (a base32 secret or an `otpauth://` URI), labelled "2FA SECRET",87+ * over a ✓ save / ✗ cancel row. The draft is validated with88+ * [TOTPGenerator.generateCode]; an empty / unparseable secret shows89+ * "Invalid 2FA secret" in breach color and blocks save.90+ *91+ * On a valid save [onSaveSecret] is invoked with the trimmed new secret — the caller92+ * persists via `vm.updateEntry(entry.copy(totp = newValue))`. Because [totpField]93+ * flows back in from the entry StateFlow, the band regenerates live with no extra94+ * wiring.95+ *96+ * @param totpField the current raw `totp` value (base32 secret or otpauth URI).97+ * @param copied copy-latch for this entry's TOTP (drives the copy button feedback).98+ * @param onCopy copies the live code (NOT the secret) — wire to `vm::copyTotp`.99+ * @param onSaveSecret called with the trimmed, validated new secret on ✓ save.100+ */101+@Composable102+fun TotpBandEditable(103+ totpField: String,104+ copied: Boolean,105+ onCopy: () -> Unit,106+ onSaveSecret: (String) -> Unit,107+) {108+ val accent = LocalPeachAccent.current109+ val reduceMotion = LocalReduceMotion.current110+111+ var editing by remember(totpField) { mutableStateOf(false) }112+113+ Box(114+ Modifier115+ .fillMaxWidth()116+ .padding(vertical = 10.dp)117+ .clip(RoundedCornerShape(8.dp))118+ .background(accent.copy(alpha = 0.08f))119+ .border(1.dp, accent.copy(alpha = 0.20f), RoundedCornerShape(8.dp))120+ .padding(horizontal = 14.dp, vertical = 10.dp),121+ ) {122+ if (!editing) {123+ TotpView(124+ totpField = totpField,125+ accent = accent,126+ reduceMotion = reduceMotion,127+ copied = copied,128+ onCopy = onCopy,129+ onEnterEdit = { editing = true },130+ )131+ } else {132+ TotpSecretEditor(133+ initial = totpField,134+ onSave = { newSecret -> onSaveSecret(newSecret); editing = false },135+ onCancel = { editing = false },136+ )137+ }138+ }139+}140+141+/** Read-only band content: code, countdown, ring, pencil, copy — plus double-tap-to-edit. */142+// produceState assigns `value` inside a while(true) loop — lint can't trace it statically.143+@Suppress("ProduceStateDoesNotAssignValue")144+@Composable145+private fun TotpView(146+ totpField: String,147+ accent: androidx.compose.ui.graphics.Color,148+ reduceMotion: Boolean,149+ copied: Boolean,150+ onCopy: () -> Unit,151+ onEnterEdit: () -> Unit,152+) {153+ val code by produceState(TOTPGenerator.generateCode(totpField) ?: "------", totpField) {154+ while (true) {155+ value = TOTPGenerator.generateCode(totpField) ?: "------"156+ kotlinx.coroutines.delay(1000)157+ }158+ }159+ val remaining by produceState(TOTPGenerator.remainingSeconds()) {160+ while (true) { value = TOTPGenerator.remainingSeconds(); kotlinx.coroutines.delay(500) }161+ }162+ val isHot = remaining <= 5163+ val pulse = rememberInfiniteTransition(label = "totp-pulse")164+ val pulseAlpha by pulse.animateFloat(165+ initialValue = 0.55f, targetValue = 1f,166+ animationSpec = infiniteRepeatable(tween(600), RepeatMode.Reverse), label = "totp-pulse-alpha",167+ )168+ val codeAlpha = if (isHot && !reduceMotion) pulseAlpha else 1f169+170+ Row(verticalAlignment = Alignment.CenterVertically) {171+ Column(172+ Modifier173+ .weight(1f)174+ // Double-tap the code area to edit the 2FA secret (E6).175+ .pointerInput(Unit) { detectTapGestures(onDoubleTap = { onEnterEdit() }) },176+ ) {177+ Row(verticalAlignment = Alignment.CenterVertically) {178+ Text(179+ "ONE-TIME CODE",180+ color = accent.copy(alpha = 0.70f),181+ style = PeachType.labelMono.copy(letterSpacing = 0.08.em),182+ )183+ Spacer(Modifier.width(6.dp))184+ Icon(185+ Icons.Outlined.Edit,186+ contentDescription = "edit 2FA secret",187+ tint = PeachColors.T2,188+ modifier = Modifier189+ .size(14.dp)190+ .clip(RoundedCornerShape(4.dp))191+ .clickable(onClick = onEnterEdit),192+ )193+ }194+ val spaced = if (code.length == 6) "${code.substring(0, 3)} ${code.substring(3)}" else code195+ Text(196+ spaced,197+ color = if (isHot) PeachColors.Breach else accent,198+ style = PeachType.totpCode,199+ modifier = Modifier.graphicsLayer { alpha = codeAlpha },200+ )201+ }202+ Text("${remaining}s", color = PeachColors.T2, style = PeachType.totpCountdown)203+ Spacer(Modifier.width(12.dp))204+ TOTPRing(size = 28.dp)205+ Spacer(Modifier.width(8.dp))206+ CopyButton(copied, onCopy)207+ }208+}209+210+/** Inline 2FA-secret editor: masked underlined field + eye toggle + ✓/✗, with validation. */211+@Composable212+private fun TotpSecretEditor(213+ initial: String,214+ onSave: (String) -> Unit,215+ onCancel: () -> Unit,216+) {217+ val accent = LocalPeachAccent.current218+ var draft by remember { mutableStateOf(initial) }219+ var show by remember { mutableStateOf(false) }220+ var showError by remember { mutableStateOf(false) }221+222+ val trimmed = draft.trim()223+ val valid = TOTPGenerator.generateCode(trimmed) != null224+225+ Column(Modifier.fillMaxWidth()) {226+ Text(227+ "2FA SECRET",228+ color = accent.copy(alpha = 0.70f),229+ style = PeachType.labelMono.copy(letterSpacing = 0.08.em),230+ )231+ Spacer(Modifier.height(8.dp))232+ Row(verticalAlignment = Alignment.CenterVertically) {233+ E6UnderlinedField(234+ draft = draft,235+ onDraftChange = { draft = it; showError = false },236+ transformation = if (show) VisualTransformation.None else PasswordVisualTransformation(),237+ modifier = Modifier.weight(1f),238+ )239+ Text(240+ if (show) "hide" else "show", color = accent, style = PeachType.labelMono,241+ modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable { show = !show }.padding(6.dp),242+ )243+ }244+ if (showError) {245+ Spacer(Modifier.height(6.dp))246+ Text("Invalid 2FA secret", color = PeachColors.Breach, style = PeachType.labelMono)247+ }248+ Spacer(Modifier.height(8.dp))249+ E6SaveCancelRow(250+ onSave = {251+ if (valid) onSave(trimmed) else showError = true252+ },253+ onCancel = { onCancel() },254+ )255+ }256+}257+258+/** BasicTextField with an accent underline (mirrors D6's inline-edit field). */259+@Composable260+private fun E6UnderlinedField(261+ draft: String,262+ onDraftChange: (String) -> Unit,263+ transformation: VisualTransformation = VisualTransformation.None,264+ modifier: Modifier = Modifier,265+) {266+ val accent = LocalPeachAccent.current267+ BasicTextField(268+ value = draft,269+ onValueChange = onDraftChange,270+ singleLine = true,271+ textStyle = PeachType.bodyMono.copy(color = PeachColors.T0),272+ cursorBrush = SolidColor(accent),273+ visualTransformation = transformation,274+ modifier = modifier275+ .padding(bottom = 4.dp)276+ .drawBehind {277+ drawLine(278+ color = accent,279+ start = Offset(0f, size.height),280+ end = Offset(size.width, size.height),281+ strokeWidth = 1.dp.toPx(),282+ )283+ },284+ )285+}286+287+@Composable288+private fun E6SaveCancelRow(onSave: () -> Unit, onCancel: () -> Unit) {289+ val accent = LocalPeachAccent.current290+ Row(horizontalArrangement = Arrangement.spacedBy(16.dp), verticalAlignment = Alignment.CenterVertically) {291+ Text(292+ "✓ save", color = accent, style = PeachType.labelMono,293+ modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable(onClick = onSave).padding(vertical = 4.dp),294+ )295+ Text(296+ "✗", color = PeachColors.T2, style = PeachType.labelMono,297+ modifier = Modifier.clip(RoundedCornerShape(6.dp)).clickable(onClick = onCancel).padding(horizontal = 6.dp, vertical = 4.dp),298+ )299+ }300+}