From 1395e9666f5777391433df91bb8353d1223213ae Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 19 May 2026 16:17:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20GIF=20=E5=88=87=E6=8D=A2=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E5=9C=BA=E7=BC=A9=E6=94=BE=E5=BC=B9=E6=80=A7?= =?UTF-8?q?=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 (1M context) --- .../kotlin/plus/rua/project/ui/AnimatedGif.kt | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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) + }, ) }