From 297a7a54d4b0d02d3eb878df8cd187adf91602e0 Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 25 May 2026 16:50:02 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=B9=B4=E8=A7=86=E5=9B=BE/BottomCard?= =?UTF-8?q?=20alpha+offset=20=E2=86=92=20graphicsLayer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - YearGridView crossFadeAlpha: alpha() → graphicsLayer(年视图翻页淡入淡出) - BottomCard slideProgress: offset()+alpha() → graphicsLayer(年视图切换滑出) Co-Authored-By: Claude Opus 4.7 (1M context) --- .../kotlin/plus/rua/project/ui/CalendarMonthView.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 2c6bbc2..bc6ef43 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt @@ -19,6 +19,7 @@ import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideOutVertically import androidx.compose.animation.togetherWith import androidx.compose.ui.graphics.TransformOrigin +import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.foundation.Canvas import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -309,7 +310,7 @@ fun CalendarMonthView( }, sharedTransitionScope = sharedScope, animatedVisibilityScope = this@AnimatedContent, - modifier = Modifier.alpha(crossFadeAlpha) + modifier = Modifier.graphicsLayer { this.alpha = crossFadeAlpha } ) } } @@ -570,6 +571,7 @@ private fun BottomCardArea( animationSpec = tween(350, delayMillis = 100, easing = FastOutSlowInEasing), label = "bottomCardSlide" ) + val slideOffsetY = with(density) { (slideProgress * 200).dp.toPx() } // 延迟一帧显示 BottomCard,避免 AnimatedGif 和 lunar 计算阻塞首帧 var hasLoaded by remember { mutableStateOf(false) } @@ -594,8 +596,10 @@ private fun BottomCardArea( onExpandDragEnd = { viewModel.onExpandDragEnd() }, dragRangePx = dragRangePx, modifier = modifier - .offset(y = with(density) { (slideProgress * 200).dp }) - .alpha(1f - slideProgress) + .graphicsLayer { + translationY = slideOffsetY + this.alpha = 1f - slideProgress + } ) } }