package com.peachpasswords.ui.components import androidx.compose.animation.animateColorAsState import androidx.compose.foundation.layout.Row import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Shadow import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.unit.sp import com.peachpasswords.ui.theme.LocalPeachAccent import com.peachpasswords.ui.theme.LocalReduceMotion import com.peachpasswords.ui.theme.peachColors import com.peachpasswords.ui.theme.PeachType import kotlinx.coroutines.delay import androidx.compose.runtime.LaunchedEffect import kotlin.random.Random private const val RUNE_COUNT = 9 /** * A faint row of PeachScript runes (Private Use Area glyphs). Mirrors the * browser LockRuneCanvas: ~13sp, text at 12% opacity, and one rune periodically * picks up the accent color with a soft glow before fading back. */ @Composable fun LockRuneString(modifier: Modifier = Modifier) { val accent = LocalPeachAccent.current val reduceMotion = LocalReduceMotion.current val runes = remember { (0 until RUNE_COUNT).map { (0xE000 + Random.nextInt(256)).toChar().toString() } } var glowIdx by remember { mutableIntStateOf(-1) } if (!reduceMotion) { LaunchedEffect(Unit) { while (true) { delay(1500L + Random.nextLong(3000)) glowIdx = Random.nextInt(RUNE_COUNT) delay(2000L + Random.nextLong(1500)) glowIdx = -1 } } } Row(modifier = modifier) { runes.forEachIndexed { idx, ch -> val glowing = idx == glowIdx val color by animateColorAsState( targetValue = if (glowing) accent else peachColors.T0.copy(alpha = 0.12f), label = "rune-glow", ) Text( text = ch, color = color, style = TextStyle( fontFamily = PeachType.Script, fontStyle = FontStyle.Normal, fontSize = 13.sp, shadow = if (glowing) Shadow(color = accent, blurRadius = 12f) else null, ), ) } } }