fix: 恢复 AnimatedGif 弹跳动画和 YearGridView 全量 sharedElement

- AnimatedGif: 恢复原始 scale 弹跳入场动画,仅保留 repeatCount 限制
- YearGridView: 恢复所有 12 个月的 sharedElement,保证点击任意
  月份都有正确的共享元素转场动画
- CalendarPager: beyondViewportPageCount 1→0 保留(无视觉影响)
This commit is contained in:
meyou 2026-05-25 23:06:15 +08:00
parent 5158b99800
commit ce84c614de
No known key found for this signature in database
2 changed files with 21 additions and 20 deletions

View File

@ -2,6 +2,8 @@ package plus.rua.project.ui
import androidx.compose.animation.core.Animatable import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.FastOutSlowInEasing 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.animation.core.tween
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
@ -38,13 +40,17 @@ fun AnimatedGif(
) { ) {
val webpFile = remember(seed) { WEBP_FILES.random() } val webpFile = remember(seed) { WEBP_FILES.random() }
val uri = remember(webpFile) { getWebpUri(webpFile) } val uri = remember(webpFile) { getWebpUri(webpFile) }
val alpha = remember { Animatable(0f) } val scale = remember { Animatable(0f) }
LaunchedEffect(seed) { LaunchedEffect(seed) {
alpha.snapTo(0f) scale.snapTo(0f)
alpha.animateTo( scale.animateTo(
targetValue = 1.1f,
animationSpec = tween(250, easing = FastOutSlowInEasing),
)
scale.animateTo(
targetValue = 1f, targetValue = 1f,
animationSpec = tween(150, easing = FastOutSlowInEasing), animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy),
) )
} }
@ -57,7 +63,9 @@ fun AnimatedGif(
contentDescription = contentDescription, contentDescription = contentDescription,
state = state, state = state,
modifier = modifier.graphicsLayer { modifier = modifier.graphicsLayer {
this.alpha = alpha.value scaleX = scale.value
scaleY = scale.value
alpha = scale.value.coerceIn(0f, 1f)
}, },
) )
} }

View File

@ -167,12 +167,11 @@ fun YearGridView(
) { ) {
(0 until 3).forEach { col -> (0 until 3).forEach { col ->
val month = row * 3 + col + 1 val month = row * 3 + col + 1
val isSelectedMonth = month == selectedMonth
with(sharedTransitionScope) { with(sharedTransitionScope) {
MiniMonth( MiniMonth(
year = year, year = year,
month = month, month = month,
isSelected = isSelectedMonth, isSelected = month == selectedMonth,
today = today, today = today,
days = monthDays[month - 1], days = monthDays[month - 1],
colors = colors, colors = colors,
@ -182,19 +181,13 @@ fun YearGridView(
onClick = { onMonthClick(month) }, onClick = { onMonthClick(month) },
modifier = Modifier modifier = Modifier
.weight(1f) .weight(1f)
.then( .sharedElement(
if (isSelectedMonth) { sharedContentState = rememberSharedContentState(
Modifier.sharedElement( key = "month_grid_${year}_$month"
sharedContentState = rememberSharedContentState( ),
key = "month_grid_${year}_$month" animatedVisibilityScope = animatedVisibilityScope,
), boundsTransform = { _, _ ->
animatedVisibilityScope = animatedVisibilityScope, tween(400, easing = FastOutSlowInEasing)
boundsTransform = { _, _ ->
tween(400, easing = FastOutSlowInEasing)
}
)
} else {
Modifier
} }
) )
) )