fix: 恢复 AnimatedGif 弹跳动画和 YearGridView 全量 sharedElement
- AnimatedGif: 恢复原始 scale 弹跳入场动画,仅保留 repeatCount 限制 - YearGridView: 恢复所有 12 个月的 sharedElement,保证点击任意 月份都有正确的共享元素转场动画 - CalendarPager: beyondViewportPageCount 1→0 保留(无视觉影响)
This commit is contained in:
parent
5158b99800
commit
ce84c614de
@ -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)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user