6d948bad730d
fix: Make the TOTP border the countdown ring (v2.14.64)
- time
- 2026-08-15 01:50 UTC · 2 months ago
- machine
- koh2
- parent
- 7b4f2abb8ae7
↓ peach-android-6d948bad.tar.gzatlas at this save
files changed2 files
VERSION+1 −1app/src/main/java/com/peachpasswords/ui/vault/TotpInlineEdit.kt+20 −44app/src/main/java/com/peachpasswords/ui/vault/TotpInlineEdit.kt+20 −44
@@ -27,7 +27,6 @@2727 import androidx.compose.animation.core.RepeatMode2828 import androidx.compose.animation.core.Animatable2929 import androidx.compose.animation.core.FastOutSlowInEasing30-import androidx.compose.animation.core.LinearEasing3130 import androidx.compose.animation.core.animateFloat3231 import androidx.compose.animation.core.infiniteRepeatable3332 import androidx.compose.animation.core.rememberInfiniteTransition@@ -63,9 +62,6 @@6362 import androidx.compose.ui.draw.drawBehind6463 import androidx.compose.ui.geometry.CornerRadius6564 import androidx.compose.ui.geometry.Offset66-import androidx.compose.ui.geometry.Rect67-import androidx.compose.ui.geometry.RoundRect68-import androidx.compose.ui.graphics.Path6965 import androidx.compose.ui.graphics.Brush7066 import androidx.compose.ui.graphics.Color7167 import androidx.compose.ui.graphics.SolidColor@@ -82,7 +78,6 @@8278 import com.peachpasswords.ui.theme.peachColors8379 import com.peachpasswords.ui.theme.PeachType8480 import com.peachpasswords.vault.TOTPGenerator85-import kotlinx.coroutines.coroutineScope8681 import kotlinx.coroutines.isActive8782 import kotlinx.coroutines.launch8883 @@ -119,40 +114,30 @@119114 val accent = LocalPeachAccent.current120115 val reduceMotion = LocalReduceMotion.current121116 val surfaceCard = peachColors.SurfaceCard122- val liquidFraction = remember(totpField) { Animatable(1f) }117+ val liquidFraction = remember(totpField) { androidx.compose.runtime.mutableFloatStateOf(1f) }123118 val edgeFlash = remember(totpField) { Animatable(0f) }124119 LaunchedEffect(totpField, reduceMotion) {125120 if (reduceMotion) {126- liquidFraction.snapTo(1f)121+ liquidFraction.floatValue = 1f127122 edgeFlash.snapTo(0f)128123 } else {129124 val periodMillis = TOTPGenerator.PERIOD_SECONDS * 1_000L125+ var previousElapsedMillis = -1L130126 while (isActive) {131- val elapsedMillis = System.currentTimeMillis() % periodMillis132- val remainingMillis = periodMillis - elapsedMillis133- liquidFraction.snapTo(remainingMillis.toFloat() / periodMillis)134- liquidFraction.animateTo(135- targetValue = 0f,136- animationSpec = tween(137- durationMillis = remainingMillis.toInt(),138- easing = LinearEasing,139- ),140- )141- edgeFlash.snapTo(1f)142- coroutineScope {127+ val elapsedMillis = Math.floorMod(System.currentTimeMillis(), periodMillis)128+ liquidFraction.floatValue =129+ ((periodMillis - elapsedMillis).toFloat() / periodMillis).coerceIn(0f, 1f)130+ if (previousElapsedMillis >= 0L && elapsedMillis < previousElapsedMillis) {143131 launch {144- liquidFraction.animateTo(145- targetValue = 1f,146- animationSpec = tween(700, easing = FastOutSlowInEasing),147- )148- }149- launch {132+ edgeFlash.snapTo(1f)150133 edgeFlash.animateTo(151134 targetValue = 0f,152135 animationSpec = tween(900, easing = FastOutSlowInEasing),153136 )154137 }155138 }139+ previousElapsedMillis = elapsedMillis140+ kotlinx.coroutines.delay(16L)156141 }157142 }158143 }@@ -168,10 +153,8 @@168153 .drawBehind {169154 val radius = 8.dp.toPx()170155 val baseStroke = 1.dp.toPx()171- val ringPath = Path().apply {172- addRoundRect(RoundRect(Rect(Offset.Zero, size), radius, radius))173- }174- val accentWidth = (size.width * liquidFraction.value).coerceAtLeast(1f)156+ val fraction = liquidFraction.floatValue157+ val accentWidth = (size.width * fraction).coerceAtLeast(1f)175158 drawRoundRect(176159 color = surfaceCard,177160 cornerRadius = CornerRadius(radius),@@ -182,29 +165,22 @@182165 style = Stroke(width = baseStroke),183166 )184167 drawRoundRect(185- color = accent.copy(alpha = 0.74f * liquidFraction.value + edgeFlash.value * 0.12f),186- cornerRadius = CornerRadius(radius),187- style = Stroke(width = 1.5.dp.toPx()),188- )189- drawPath(190- ringPath,191168 brush = Brush.horizontalGradient(192- colorStops = arrayOf(193- 0f to accent.copy(alpha = 0.74f + edgeFlash.value * 0.12f),194- 0.82f to accent.copy(alpha = 0.74f + edgeFlash.value * 0.12f),195- 1f to Color.Transparent,169+ colors = listOf(170+ accent.copy(alpha = 0.92f + edgeFlash.value * 0.08f),171+ accent.copy(alpha = 0.92f + edgeFlash.value * 0.08f),172+ Color.Transparent,196173 ),197174 startX = 0f,198175 endX = accentWidth,199176 ),200- style = Stroke(201- width = 1.5.dp.toPx(),202- ),177+ cornerRadius = CornerRadius(radius),178+ style = Stroke(width = 2.dp.toPx()),203179 )204180 if (edgeFlash.value > 0f) {205- drawPath(206- ringPath,181+ drawRoundRect(207182 color = accent.copy(alpha = edgeFlash.value * 0.16f),183+ cornerRadius = CornerRadius(radius),208184 style = Stroke(width = 4.dp.toPx()),209185 )210186 }