From ce84c614de5492bb53c490e89965eb8cfb541986 Mon Sep 17 00:00:00 2001 From: meyou <2636699780@qq.com> Date: Mon, 25 May 2026 23:06:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=81=A2=E5=A4=8D=20AnimatedGif=20?= =?UTF-8?q?=E5=BC=B9=E8=B7=B3=E5=8A=A8=E7=94=BB=E5=92=8C=20YearGridView=20?= =?UTF-8?q?=E5=85=A8=E9=87=8F=20sharedElement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - AnimatedGif: 恢复原始 scale 弹跳入场动画,仅保留 repeatCount 限制 - YearGridView: 恢复所有 12 个月的 sharedElement,保证点击任意 月份都有正确的共享元素转场动画 - CalendarPager: beyondViewportPageCount 1→0 保留(无视觉影响) --- .../kotlin/plus/rua/project/ui/AnimatedGif.kt | 18 +++++++++++---- .../plus/rua/project/ui/YearGridView.kt | 23 +++++++------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/core/src/main/kotlin/plus/rua/project/ui/AnimatedGif.kt b/core/src/main/kotlin/plus/rua/project/ui/AnimatedGif.kt index 7f4fbb1..e102446 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/AnimatedGif.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/AnimatedGif.kt @@ -2,6 +2,8 @@ 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 @@ -38,13 +40,17 @@ fun AnimatedGif( ) { val webpFile = remember(seed) { WEBP_FILES.random() } val uri = remember(webpFile) { getWebpUri(webpFile) } - val alpha = remember { Animatable(0f) } + val scale = remember { Animatable(0f) } LaunchedEffect(seed) { - alpha.snapTo(0f) - alpha.animateTo( + scale.snapTo(0f) + scale.animateTo( + targetValue = 1.1f, + animationSpec = tween(250, easing = FastOutSlowInEasing), + ) + scale.animateTo( targetValue = 1f, - animationSpec = tween(150, easing = FastOutSlowInEasing), + animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy), ) } @@ -57,7 +63,9 @@ fun AnimatedGif( contentDescription = contentDescription, state = state, modifier = modifier.graphicsLayer { - this.alpha = alpha.value + scaleX = scale.value + scaleY = scale.value + alpha = scale.value.coerceIn(0f, 1f) }, ) } diff --git a/core/src/main/kotlin/plus/rua/project/ui/YearGridView.kt b/core/src/main/kotlin/plus/rua/project/ui/YearGridView.kt index 6abbcd8..a20a451 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/YearGridView.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/YearGridView.kt @@ -167,12 +167,11 @@ fun YearGridView( ) { (0 until 3).forEach { col -> val month = row * 3 + col + 1 - val isSelectedMonth = month == selectedMonth with(sharedTransitionScope) { MiniMonth( year = year, month = month, - isSelected = isSelectedMonth, + isSelected = month == selectedMonth, today = today, days = monthDays[month - 1], colors = colors, @@ -182,19 +181,13 @@ fun YearGridView( onClick = { onMonthClick(month) }, modifier = Modifier .weight(1f) - .then( - if (isSelectedMonth) { - Modifier.sharedElement( - sharedContentState = rememberSharedContentState( - key = "month_grid_${year}_$month" - ), - animatedVisibilityScope = animatedVisibilityScope, - boundsTransform = { _, _ -> - tween(400, easing = FastOutSlowInEasing) - } - ) - } else { - Modifier + .sharedElement( + sharedContentState = rememberSharedContentState( + key = "month_grid_${year}_$month" + ), + animatedVisibilityScope = animatedVisibilityScope, + boundsTransform = { _, _ -> + tween(400, easing = FastOutSlowInEasing) } ) )