ProCelebration.kt

4.2 KB · raw

1package com.peachpasswords.ui.settings23import androidx.compose.animation.core.LinearEasing4import androidx.compose.animation.core.animateFloat5import androidx.compose.animation.core.rememberInfiniteTransition6import androidx.compose.animation.core.infiniteRepeatable7import androidx.compose.animation.core.tween8import androidx.compose.foundation.background9import androidx.compose.foundation.clickable10import androidx.compose.foundation.layout.Box11import androidx.compose.foundation.layout.Column12import androidx.compose.foundation.layout.fillMaxSize13import androidx.compose.foundation.layout.padding14import androidx.compose.foundation.Canvas15import androidx.compose.material3.Text16import androidx.compose.runtime.Composable17import androidx.compose.runtime.LaunchedEffect18import androidx.compose.runtime.getValue19import androidx.compose.ui.Alignment20import androidx.compose.ui.Modifier21import androidx.compose.ui.geometry.Offset22import androidx.compose.ui.graphics.Color23import androidx.compose.ui.text.TextStyle24import androidx.compose.ui.text.font.FontStyle25import androidx.compose.ui.text.style.TextAlign26import androidx.compose.ui.unit.dp27import androidx.compose.ui.unit.sp28import com.peachpasswords.ui.components.PeachMark29import com.peachpasswords.ui.theme.LocalPeachAccent30import com.peachpasswords.ui.theme.LocalReduceMotion31import com.peachpasswords.ui.theme.peachColors32import com.peachpasswords.ui.theme.PeachType33import kotlinx.coroutines.delay34import kotlin.math.cos35import kotlin.math.sin3637/**38 * Full-screen Pro activation celebration. Auto-dismisses after ~1800ms (calls [onDone]);39 * a tap dismisses early. Accent bloom + PeachMark + a ring of staggered sparkle dots.40 */41@Composable42fun ProCelebration(onDone: () -> Unit) {43    val accent = LocalPeachAccent.current44    val reduceMotion = LocalReduceMotion.current4546    LaunchedEffect(Unit) {47        delay(1800)48        onDone()49    }5051    val phase by if (reduceMotion) {52        rememberInfiniteTransition(label = "spark").animateFloat(53            0f, 0f, infiniteRepeatable(tween(1)), label = "sparkStatic",54        )55    } else {56        rememberInfiniteTransition(label = "spark").animateFloat(57            initialValue = 0f, targetValue = 1f,58            animationSpec = infiniteRepeatable(tween(1800, easing = LinearEasing)),59            label = "sparkPhase",60        )61    }6263    Box(64        modifier = Modifier65            .fillMaxSize()66            .background(peachColors.Bg)67            .clickable(onClick = onDone),68        contentAlignment = Alignment.Center,69    ) {70        // Accent bloom (higher opacity than the shell).71        Canvas(Modifier.fillMaxSize()) {72            drawCircle(73                color = accent.copy(alpha = 0.18f),74                radius = size.minDimension * 0.55f,75                center = Offset(size.width / 2f, size.height * 0.42f),76            )77            // 12 sparkle dots radiating from centre, staggered fade.78            val cx = size.width / 2f79            val cy = size.height * 0.42f80            val ringR = size.minDimension * 0.34f81            for (i in 0 until 12) {82                val ang = (i / 12f) * 2f * Math.PI.toFloat()83                val local = ((phase + i / 12f) % 1f)84                val a = (1f - kotlin.math.abs(local - 0.5f) * 2f).coerceIn(0f, 1f)85                drawCircle(86                    color = accent.copy(alpha = 0.7f * a),87                    radius = 4f,88                    center = Offset(cx + cos(ang) * ringR, cy + sin(ang) * ringR),89                )90            }91        }92        Column(horizontalAlignment = Alignment.CenterHorizontally) {93            PeachMark(size = 80.dp)94            Text(95                "peach pro",96                color = accent,97                style = TextStyle(fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 44.sp),98                textAlign = TextAlign.Center,99                modifier = Modifier.padding(top = 18.dp),100            )101            Text(102                "thank you.",103                color = peachColors.T1,104                style = TextStyle(fontFamily = PeachType.Display, fontStyle = FontStyle.Italic, fontSize = 26.sp),105                textAlign = TextAlign.Center,106                modifier = Modifier.padding(top = 6.dp),107            )108        }109    }110}