1+ package com.cavin.material3expressivecatalog
2+
3+ import androidx.compose.animation.core.*
4+ import androidx.compose.foundation.Canvas
5+ import androidx.compose.foundation.background
6+ import androidx.compose.foundation.layout.*
7+ import androidx.compose.foundation.Image
8+ import androidx.compose.runtime.*
9+ import androidx.compose.ui.Alignment
10+ import androidx.compose.ui.Modifier
11+ import androidx.compose.ui.graphics.Color
12+ import androidx.compose.ui.graphics.graphicsLayer
13+ import androidx.compose.ui.res.painterResource
14+ import androidx.compose.ui.unit.dp
15+ import kotlinx.coroutines.delay
16+ import kotlin.random.Random
17+
18+ @Composable
19+ fun PremiumSplashScreen (onSplashFinished : () -> Unit ) {
20+ val scale = remember { Animatable (0f ) }
21+
22+ // Infinite transitions for logo animation
23+ val infiniteTransition = rememberInfiniteTransition()
24+ val rotation by infiniteTransition.animateFloat(
25+ initialValue = - 10f ,
26+ targetValue = 10f ,
27+ animationSpec = infiniteRepeatable(
28+ tween(1000 , easing = FastOutSlowInEasing ),
29+ repeatMode = RepeatMode .Reverse
30+ )
31+ )
32+ val pulse by infiniteTransition.animateFloat(
33+ initialValue = 1f ,
34+ targetValue = 1.1f ,
35+ animationSpec = infiniteRepeatable(
36+ tween(800 , easing = FastOutSlowInEasing ),
37+ repeatMode = RepeatMode .Reverse
38+ )
39+ )
40+ val bounce by infiniteTransition.animateFloat(
41+ initialValue = 0f ,
42+ targetValue = - 20f ,
43+ animationSpec = infiniteRepeatable(
44+ tween(600 , easing = FastOutSlowInEasing ),
45+ repeatMode = RepeatMode .Reverse
46+ )
47+ )
48+
49+
50+ val particleCount = 27
51+ val particles = remember {
52+ List (particleCount) {
53+ Particle (
54+ x = Random .nextFloat() * 800f ,
55+ y = Random .nextFloat() * 1600f ,
56+ radius = Random .nextFloat() * 4f + 2f ,
57+ alpha = Random .nextFloat() * 0.5f + 0.3f
58+ )
59+ }
60+ }
61+
62+ // Animate logo scale in
63+ LaunchedEffect (Unit ) {
64+ scale.animateTo(1f , tween(1000 , easing = FastOutSlowInEasing ))
65+ delay(2000 ) // splash duration
66+ onSplashFinished()
67+ }
68+
69+ Box (
70+ modifier = Modifier
71+ .fillMaxSize()
72+ .background(Color .Black ),
73+ contentAlignment = Alignment .Center
74+ ) {
75+ // Draw floating particles
76+ Canvas (modifier = Modifier .fillMaxSize()) {
77+ particles.forEach { p ->
78+ drawCircle(
79+ color = Color .White .copy(alpha = p.alpha),
80+ radius = p.radius,
81+ center = androidx.compose.ui.geometry.Offset (p.x, p.y)
82+ )
83+ }
84+ }
85+
86+ // Logo animation
87+ Image (
88+ painter = painterResource(id = R .drawable.logo),
89+ contentDescription = " App Logo" ,
90+ modifier = Modifier
91+ .size(200 .dp)
92+ .graphicsLayer {
93+ scaleX = scale.value * pulse
94+ scaleY = scale.value * pulse
95+ translationY = bounce
96+ rotationZ = rotation
97+ shadowElevation = 20f
98+ }
99+ )
100+ }
101+ }
102+
103+ data class Particle (
104+ var x : Float ,
105+ var y : Float ,
106+ var radius : Float ,
107+ var alpha : Float
108+ )
0 commit comments