From 3a3e6014d8fa18458438fcab80071bed319e2ed4 Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 18 May 2026 17:37:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B9=B4=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E7=BC=A9=E6=94=BE=E5=8A=A8=E7=94=BB=E4=B8=A2=E5=A4=B1=EF=BC=9A?= =?UTF-8?q?progress=20=E6=8F=90=E5=89=8D=E5=88=B0=E9=87=8D=E7=BB=84?= =?UTF-8?q?=E9=98=B6=E6=AE=B5=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit graphicsLayer { } lambda 在 draw 阶段执行,内部直接读取 viewModel.yearViewProgress 不会被 Compose 标记为可观察状态,导致 Animatable 每帧 value 变化不触发重绘, 动画只在 isYearView 翻转时重组一次然后卡到动画完成。 修复:在 if (isYearView) / if (!isYearView) 块内先读取 progress 为局部变量, graphicsLayer lambda 通过捕获使用,让 Animatable 变化能驱动重组进而触发重绘。 --- .../plus/rua/project/ui/CalendarMonthView.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthView.kt b/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthView.kt index 93974eb..3147918 100644 --- a/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthView.kt +++ b/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthView.kt @@ -233,14 +233,15 @@ fun CalendarMonthView( dragRangeMinPx } + val monthProgress = 1f - viewModel.yearViewProgress Box( modifier = Modifier .fillMaxSize() .graphicsLayer { - val progress = if (viewModel.isYearView) viewModel.yearViewProgress else 1f - viewModel.yearViewProgress - scaleX = lerp(0.3f, 1f, progress) - scaleY = lerp(0.3f, 1f, progress) - alpha = progress.coerceIn(0f, 1f) + val scale = lerp(0.3f, 1f, monthProgress) + scaleX = scale + scaleY = scale + alpha = monthProgress.coerceIn(0f, 1f) transformOrigin = TransformOrigin(anchorPivotX, anchorPivotY) } ) { @@ -335,16 +336,16 @@ fun CalendarMonthView( // 年视图层:标题固定,HorizontalPager 只包裹网格。 if (viewModel.isYearView) { + val yearProgress = viewModel.yearViewProgress composeTraceBeginSection("YearView:Compose") Column( modifier = Modifier .fillMaxSize() .graphicsLayer { - val progress = if (viewModel.isYearView) viewModel.yearViewProgress else 1f - viewModel.yearViewProgress - val scale = lerp(3.3f, 1f, progress) + val scale = lerp(3.3f, 1f, yearProgress) scaleX = scale scaleY = scale - alpha = progress.coerceIn(0f, 1f) + alpha = yearProgress.coerceIn(0f, 1f) transformOrigin = TransformOrigin(anchorPivotX, anchorPivotY) } .padding(horizontal = HORIZONTAL_PADDING_DP.dp)