package com.peachpasswords.ui.settings import androidx.compose.animation.core.LinearEasing import androidx.compose.animation.core.animateFloat import androidx.compose.animation.core.rememberInfiniteTransition import androidx.compose.animation.core.infiniteRepeatable import androidx.compose.animation.core.tween import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.Canvas import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.peachpasswords.ui.components.PeachMark 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 kotlin.math.cos import kotlin.math.sin /** * Full-screen Pro activation celebration. Auto-dismisses after ~1800ms (calls [onDone]); * a tap dismisses early. Accent bloom + PeachMark + a ring of staggered sparkle dots. */ @Composable fun ProCelebration(onDone: () -> Unit) { val accent = LocalPeachAccent.current val reduceMotion = LocalReduceMotion.current LaunchedEffect(Unit) { delay(1800) onDone() } val phase by if (reduceMotion) { rememberInfiniteTransition(label = "spark").animateFloat( 0f, 0f, infiniteRepeatable(tween(1)), label = "sparkStatic", ) } else { rememberInfiniteTransition(label = "spark").animateFloat( initialValue = 0f, targetValue = 1f, animationSpec = infiniteRepeatable(tween(1800, easing = LinearEasing)), label = "sparkPhase", ) } Box( modifier = Modifier .fillMaxSize() .background(peachColors.Bg) .clickable(onClick = onDone), contentAlignment = Alignment.Center, ) { // Accent bloom (higher opacity than the shell). Canvas(Modifier.fillMaxSize()) { drawCircle( color = accent.copy(alpha = 0.18f), radius = size.minDimension * 0.55f, center = Offset(size.width / 2f, size.height * 0.42f), ) // 12 sparkle dots radiating from centre, staggered fade. val cx = size.width / 2f val cy = size.height * 0.42f val ringR = size.minDimension * 0.34f for (i in 0 until 12) { val ang = (i / 12f) * 2f * Math.PI.toFloat() val local = ((phase + i / 12f) % 1f) val a = (1f - kotlin.math.abs(local - 0.5f) * 2f).coerceIn(0f, 1f) drawCircle( color = accent.copy(alpha = 0.7f * a), radius = 4f, center = Offset(cx + cos(ang) * ringR, cy + sin(ang) * ringR), ) } } Column(horizontalAlignment = Alignment.CenterHorizontally) { PeachMark(size = 80.dp) Text( "peach pro", color = accent, style = TextStyle(fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 44.sp), textAlign = TextAlign.Center, modifier = Modifier.padding(top = 18.dp), ) Text( "thank you.", color = peachColors.T1, style = TextStyle(fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 26.sp), textAlign = TextAlign.Center, modifier = Modifier.padding(top = 6.dp), ) } } }