119af76eaf79

polish: EntryDetailScreen TOTP band + copy animation — accent-tinted band w/ 38sp Cormorant code, mono countdown, hot-state breach pulse; two-effect copy button (sheen sweep + 1.4s drain) per spec §4.4 (v2.1.15)

time
2026-06-08 19:56 UTC · 5 months ago
machine
koh2
agent
claude-opus-4-8
session
vault visual parity v2
parent
3490c7ec9351
1 file app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+113 −10
app/src/main/java/com/peachpasswords/ui/vault/EntryDetailScreen.kt+113 −10
@@ -1,7 +1,15 @@11 package com.peachpasswords.ui.vault22 33 import android.view.WindowManager4+import androidx.compose.animation.core.LinearEasing5+import androidx.compose.animation.core.RepeatMode6+import androidx.compose.animation.core.animateFloat7+import androidx.compose.animation.core.animateFloatAsState8+import androidx.compose.animation.core.infiniteRepeatable9+import androidx.compose.animation.core.rememberInfiniteTransition10+import androidx.compose.animation.core.tween411 import androidx.compose.foundation.background12+import androidx.compose.foundation.border513 import androidx.compose.foundation.clickable614 import androidx.compose.foundation.layout.Arrangement715 import androidx.compose.foundation.layout.Box@@ -19,6 +27,8 @@1927 import androidx.compose.foundation.rememberScrollState2028 import androidx.compose.foundation.shape.CircleShape2129 import androidx.compose.foundation.shape.RoundedCornerShape30+import androidx.compose.material.icons.rounded.Check31+import androidx.compose.material.icons.rounded.ContentCopy2232 import androidx.compose.foundation.verticalScroll2333 import androidx.compose.material.icons.Icons2434 import androidx.compose.material.icons.automirrored.rounded.ArrowBack@@ -38,6 +48,9 @@3848 import androidx.compose.ui.draw.drawBehind3949 import androidx.compose.ui.geometry.Offset4050 import androidx.compose.ui.geometry.Size51+import androidx.compose.ui.graphics.Brush52+import androidx.compose.ui.graphics.Color53+import androidx.compose.ui.graphics.graphicsLayer4154 import androidx.compose.ui.platform.LocalContext4255 import androidx.compose.ui.text.TextStyle4356 import androidx.compose.ui.unit.dp@@ -52,6 +65,7 @@5265 import com.peachpasswords.ui.components.TOTPRing5366 import com.peachpasswords.ui.lock.Biometrics5467 import com.peachpasswords.ui.theme.LocalPeachAccent68+import com.peachpasswords.ui.theme.LocalReduceMotion5569 import com.peachpasswords.ui.theme.PeachColors5670 import com.peachpasswords.ui.theme.PeachType5771 import com.peachpasswords.ui.theme.ShellBackground@@ -183,7 +197,8 @@183197                     )184198                 }185199                 if (e.hasTOTP()) {186-                    TotpCard(totpField = e.totp!!, copied = copiedField == "totp", onCopy = vm::copyTotp)200+                    Spacer(Modifier.height(4.dp))201+                    TotpBand(totpField = e.totp!!, copied = copiedField == "totp", onCopy = vm::copyTotp)187202                 }188203                 e.notes?.takeIf { it.isNotBlank() }?.let {189204                     FieldRow("notes", it, copiedField == "notes", mono = false) { vm.copy("notes", it) }@@ -259,30 +274,118 @@259274     }260275 }261276 277+/** Accent-tinted TOTP band (spec §5.4): large Cormorant code, mono countdown, sweep ring. */262278 @Composable263-private fun TotpCard(totpField: String, copied: Boolean, onCopy: () -> Unit) {279+private fun TotpBand(totpField: String, copied: Boolean, onCopy: () -> Unit) {280+    val accent = LocalPeachAccent.current281+    val reduceMotion = LocalReduceMotion.current264282     val code by produceState(TOTPGenerator.generateCode(totpField) ?: "------") {265283         while (true) {266284             value = TOTPGenerator.generateCode(totpField) ?: "------"267285             kotlinx.coroutines.delay(1000)268286         }269287     }270-    FieldShell("one-time code") {271-        val spaced = if (code.length == 6) "${code.substring(0, 3)} ${code.substring(3)}" else code272-        Text(spaced, color = PeachColors.T0, style = PeachType.bodyMono, modifier = Modifier.weight(1f))273-        TOTPRing(size = 26.dp)274-        Spacer(Modifier.width(8.dp))275-        CopyButton(copied, onCopy)288+    val remaining by produceState(TOTPGenerator.remainingSeconds()) {289+        while (true) { value = TOTPGenerator.remainingSeconds(); kotlinx.coroutines.delay(500) }276290     }291+    val isHot = remaining <= 5292+    // Gentle pulse for the final 5s; the transition always runs but only applies when hot.293+    val pulse = rememberInfiniteTransition(label = "totp-pulse")294+    val pulseAlpha by pulse.animateFloat(295+        initialValue = 0.55f, targetValue = 1f,296+        animationSpec = infiniteRepeatable(tween(600), RepeatMode.Reverse), label = "totp-pulse-alpha",297+    )298+    val codeAlpha = if (isHot && !reduceMotion) pulseAlpha else 1f299+300+    Box(301+        Modifier302+            .fillMaxWidth()303+            .padding(vertical = 10.dp)304+            .clip(RoundedCornerShape(8.dp))305+            .background(accent.copy(alpha = 0.08f))306+            .border(1.dp, accent.copy(alpha = 0.20f), RoundedCornerShape(8.dp))307+            .padding(horizontal = 14.dp, vertical = 10.dp),308+    ) {309+        Row(verticalAlignment = Alignment.CenterVertically) {310+            Column(Modifier.weight(1f)) {311+                Text(312+                    "ONE-TIME CODE",313+                    color = accent.copy(alpha = 0.70f),314+                    style = PeachType.labelMono.copy(letterSpacing = 0.08.em),315+                )316+                val spaced = if (code.length == 6) "${code.substring(0, 3)} ${code.substring(3)}" else code317+                Text(318+                    spaced,319+                    color = if (isHot) PeachColors.Breach else accent,320+                    style = PeachType.totpCode,321+                    modifier = Modifier.graphicsLayer { alpha = codeAlpha },322+                )323+            }324+            Text("${remaining}s", color = PeachColors.T2, style = PeachType.totpCountdown)325+            Spacer(Modifier.width(12.dp))326+            TOTPRing(size = 28.dp)327+            Spacer(Modifier.width(8.dp))328+            CopyButton(copied, onCopy)329+        }330+    }277331 }278332 333+/**334+ * Copy button with the two-effect copy feedback (spec §4.4): a diagonal sheen335+ * sweeps once over ~600ms and an accent drain bar fills 0→100% over 1.4s. Both336+ * collapse instantly when the copied latch clears, and are skipped under337+ * reduce-motion.338+ */279339 @Composable280340 private fun CopyButton(copied: Boolean, onCopy: () -> Unit) {341+    val accent = LocalPeachAccent.current342+    val reduceMotion = LocalReduceMotion.current343+    val animate = copied && !reduceMotion344+    val drain by animateFloatAsState(345+        targetValue = if (copied) 1f else 0f,346+        animationSpec = if (animate) tween(1400, easing = LinearEasing) else tween(0),347+        label = "copy-drain",348+    )349+    val sheen by animateFloatAsState(350+        targetValue = if (copied) 1f else 0f,351+        animationSpec = if (animate) tween(600, easing = LinearEasing) else tween(0),352+        label = "copy-sheen",353+    )281354     Box(282-        Modifier.size(36.dp).clip(RoundedCornerShape(8.dp)).clickable(onClick = onCopy),355+        Modifier356+            .size(36.dp)357+            .clip(RoundedCornerShape(6.dp))358+            .background(PeachColors.S2)359+            .clickable(onClick = onCopy)360+            .drawBehind {361+                if (animate && sheen < 1f) {362+                    val sweepX = (sheen * 2f - 0.5f) * size.width363+                    val band = size.width * 0.5f364+                    drawRect(365+                        brush = Brush.linearGradient(366+                            colors = listOf(Color.Transparent, accent.copy(alpha = 0.35f), Color.Transparent),367+                            start = Offset(sweepX - band, 0f),368+                            end = Offset(sweepX + band, size.height),369+                        ),370+                    )371+                }372+                if (drain > 0f) {373+                    val h = 2.dp.toPx()374+                    drawRect(375+                        color = accent,376+                        topLeft = Offset(0f, size.height - h),377+                        size = Size(size.width * drain, h),378+                    )379+                }380+            },283381         contentAlignment = Alignment.Center,284382     ) {285-        Text(if (copied) "✓" else "⧉", color = if (copied) PeachColors.SyncOk else PeachColors.T1, fontSize = 15.sp)383+        Icon(384+            if (copied) Icons.Rounded.Check else Icons.Rounded.ContentCopy,385+            contentDescription = "copy",386+            tint = if (copied) accent else PeachColors.T1,387+            modifier = Modifier.size(15.dp),388+        )286389     }287390 }288391 

view file