From be023a00a97b375833faa4763115d12f62cec009 Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 1 Jun 2026 13:47:36 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E5=B9=B4?= =?UTF-8?q?=E4=BB=BD=E8=A7=86=E5=9B=BE=E5=88=87=E6=8D=A2=E5=8A=A8=E7=94=BB?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8=20Animatable=20=E7=B2=BE=E7=A1=AE?= =?UTF-8?q?=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 用 Animatable + LaunchedEffect 替换 animateFloatAsState 实现滑出/滑入分阶段动画序列(先滑出再滑入) - 统一缩放/淡入淡出动画时长为 350ms - 底部卡片滑出偏移从 200.dp 增加到 300.dp Co-Authored-By: Claude Opus 4.7 (1M context) --- .../plus/rua/project/ui/CalendarMonthView.kt | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt b/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt index a30242a..c57536a 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt @@ -6,6 +6,7 @@ import androidx.compose.animation.EnterTransition import androidx.compose.animation.ExitTransition import androidx.compose.animation.core.FastOutSlowInEasing import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.Animatable import androidx.compose.animation.core.animateFloatAsState import androidx.compose.animation.core.spring import androidx.compose.animation.core.tween @@ -194,11 +195,11 @@ fun CalendarMonthView( val enter = scaleIn( initialScale = 0.85f, animationSpec = tween(350, easing = FastOutSlowInEasing) - ) + fadeIn(tween(250, easing = FastOutSlowInEasing)) + ) + fadeIn(tween(350, easing = FastOutSlowInEasing)) val exit = scaleOut( targetScale = 0.85f, - animationSpec = tween(250, easing = FastOutSlowInEasing) - ) + fadeOut(tween(200, easing = FastOutSlowInEasing)) + animationSpec = tween(350, easing = FastOutSlowInEasing) + ) + fadeOut(tween(350, easing = FastOutSlowInEasing)) enter togetherWith exit }, modifier = Modifier.fillMaxSize() @@ -582,11 +583,17 @@ private fun BottomCardArea( dragRangeMinPx } - val slideProgress by animateFloatAsState( - targetValue = if (isYearView) 1f else 0f, - animationSpec = tween(350, delayMillis = 100, easing = FastOutSlowInEasing), - label = "bottomCardSlide" - ) + val slideAnim = remember { Animatable(if (isYearView) 1f else 0f) } + LaunchedEffect(isYearView) { + if (isYearView) { + slideAnim.animateTo(1f, tween(200)) + } else { + slideAnim.snapTo(1f) + delay(200) + slideAnim.animateTo(0f, tween(150)) + } + } + val slideProgress = slideAnim.value var lastLoggedSlide by remember { mutableStateOf(-1f) } SideEffect { if (kotlin.math.abs(lastLoggedSlide - slideProgress) > 0.001f) { @@ -620,7 +627,7 @@ private fun BottomCardArea( onExpandDragEnd = { viewModel.onExpandDragEnd() }, dragRangePx = dragRangePx, modifier = modifier - .offset(y = with(density) { (slideProgress * 200).dp }) + .offset(y = with(density) { (slideProgress * 300).dp }) .alpha(1f - slideProgress) ) }