diff --git a/shared/src/commonMain/kotlin/plus/rua/project/ui/AnimatedGif.kt b/shared/src/commonMain/kotlin/plus/rua/project/ui/AnimatedGif.kt index 269d420..5c4c2ae 100644 --- a/shared/src/commonMain/kotlin/plus/rua/project/ui/AnimatedGif.kt +++ b/shared/src/commonMain/kotlin/plus/rua/project/ui/AnimatedGif.kt @@ -1,8 +1,15 @@ package plus.rua.project.ui +import androidx.compose.animation.core.Animatable +import androidx.compose.animation.core.FastOutSlowInEasing +import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.spring +import androidx.compose.animation.core.tween import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.graphicsLayer import com.github.panpf.sketch.AsyncImage import plus.rua.project.getGifUri @@ -26,9 +33,28 @@ fun AnimatedGif( ) { val gifFile = remember(seed) { GIF_FILES.random() } val uri = remember(gifFile) { getGifUri(gifFile) } + val scale = remember { Animatable(0f) } + + LaunchedEffect(seed) { + scale.snapTo(0f) + scale.animateTo( + targetValue = 1.1f, + animationSpec = tween(250, easing = FastOutSlowInEasing), + ) + scale.animateTo( + targetValue = 1f, + animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy), + ) + } + AsyncImage( uri = uri, contentDescription = contentDescription, - modifier = modifier, + modifier = modifier + .graphicsLayer { + scaleX = scale.value + scaleY = scale.value + alpha = scale.value.coerceIn(0f, 1f) + }, ) }