11package com.pira.ccloud.screens
22
3- import android.view.animation.OvershootInterpolator
4- import androidx.compose.animation.core.Animatable
5- import androidx.compose.animation.core.tween
6- import androidx.compose.foundation.Image
73import androidx.compose.foundation.background
84import androidx.compose.foundation.layout.Arrangement
95import androidx.compose.foundation.layout.Column
@@ -15,50 +11,26 @@ import androidx.compose.material3.MaterialTheme
1511import androidx.compose.material3.Text
1612import androidx.compose.runtime.Composable
1713import androidx.compose.runtime.LaunchedEffect
18- import androidx.compose.runtime.remember
1914import androidx.compose.ui.Alignment
2015import androidx.compose.ui.Modifier
21- import androidx.compose.ui.draw.alpha
22- import androidx.compose.ui.draw.scale
2316import androidx.compose.ui.graphics.Color
24- import androidx.compose.ui.layout.ContentScale
25- import androidx.compose.ui.res.painterResource
17+ import androidx.compose.ui.platform.LocalContext
2618import androidx.compose.ui.text.font.FontWeight
2719import androidx.compose.ui.text.style.TextAlign
2820import androidx.compose.ui.unit.dp
2921import androidx.compose.ui.unit.sp
30- import com.pira.ccloud.BuildConfig // This might not be available immediately
22+ import com.pira.ccloud.BuildConfig
3123import com.pira.ccloud.R
24+ import coil.compose.AsyncImage
25+ import coil.request.ImageRequest
3226import kotlinx.coroutines.delay
3327
3428@Composable
3529fun SplashScreen (
3630 onTimeout : () -> Unit ,
3731 backgroundColor : Color
3832) {
39- val scale = remember { Animatable (0f ) }
40- val alpha = remember { Animatable (0f ) }
41-
4233 LaunchedEffect (Unit ) {
43- // Animate the logo scale
44- scale.animateTo(
45- targetValue = 1f ,
46- animationSpec = tween(
47- durationMillis = 1000 ,
48- easing = {
49- OvershootInterpolator (2f ).getInterpolation(it)
50- }
51- )
52- )
53-
54- // Animate the alpha for text
55- alpha.animateTo(
56- targetValue = 1f ,
57- animationSpec = tween(
58- durationMillis = 800
59- )
60- )
61-
6234 // Wait for some time before navigating
6335 delay(2000 )
6436 onTimeout()
@@ -71,13 +43,14 @@ fun SplashScreen(
7143 horizontalAlignment = Alignment .CenterHorizontally ,
7244 verticalArrangement = Arrangement .Center
7345 ) {
74- Image (
75- painter = painterResource(id = R .drawable.splash_logo),
46+ // App Logo
47+ AsyncImage (
48+ model = ImageRequest .Builder (LocalContext .current)
49+ .data(R .drawable.splash_logo)
50+ .crossfade(true )
51+ .build(),
7652 contentDescription = " App Logo" ,
77- modifier = Modifier
78- .size(120 .dp)
79- .scale(scale.value),
80- contentScale = ContentScale .Fit
53+ modifier = Modifier .size(120 .dp)
8154 )
8255
8356 Spacer (modifier = Modifier .height(32 .dp))
@@ -94,7 +67,7 @@ fun SplashScreen(
9467 Spacer (modifier = Modifier .height(8 .dp))
9568
9669 Text (
97- text = " Version ${BuildConfig .VERSION_NAME ? : " 1.0" } " , // Add fallback
70+ text = " Version ${BuildConfig .VERSION_NAME ? : " 1.0" } " ,
9871 style = MaterialTheme .typography.bodyMedium,
9972 color = MaterialTheme .colorScheme.onBackground.copy(alpha = 0.7f ),
10073 textAlign = TextAlign .Center
0 commit comments