From e1345cc0719469ceaf203a72b145413f938d9458 Mon Sep 17 00:00:00 2001 From: xfy Date: Wed, 20 May 2026 16:46:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B9=B4=E6=9C=88=E8=A7=86=E5=9B=BE?= =?UTF-8?q?=E8=BD=AC=E5=9C=BA=E6=B7=BB=E5=8A=A0=20BottomCard=20=E6=BB=91?= =?UTF-8?q?=E5=85=A5=E5=8A=A8=E7=94=BB=E5=92=8C=E6=B7=A1=E5=85=A5=E6=B7=A1?= =?UTF-8?q?=E5=87=BA=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CalendarMonthView: 为 BottomCard 添加滑入/淡出动效 - 优化 AnimatedContent 过渡:fade + slideInVertically/slideOutVertically - YearGridView: 提取 sharedKey 变量 Co-Authored-By: Claude Opus 4.7 (1M context) --- .../plus/rua/project/ui/CalendarMonthView.kt | 24 +++++++++++++++++-- .../plus/rua/project/ui/YearGridView.kt | 3 ++- 2 files changed, 24 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 1005895..0fb492f 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt @@ -12,7 +12,10 @@ import androidx.compose.animation.fadeOut import androidx.compose.animation.ExperimentalSharedTransitionApi import androidx.compose.animation.scaleIn import androidx.compose.animation.scaleOut +import androidx.compose.animation.slideInVertically +import androidx.compose.animation.slideOutVertically import androidx.compose.animation.togetherWith +import androidx.compose.animation.core.animateFloatAsState import androidx.compose.ui.graphics.TransformOrigin import androidx.compose.foundation.Canvas import androidx.compose.foundation.background @@ -23,6 +26,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBarsPadding @@ -94,6 +98,15 @@ fun CalendarMonthView( @Suppress("DEPRECATION") // monthNumber 无替代 API,kotlinx-datetime 尚未提供新接口 val currentMonth by remember { derivedStateOf { viewModel.selectedDate.month.number } } + val density = LocalDensity.current + + // BottomCard 滑入动画:1f=完全隐藏(在下方),0f=完全显示 + val bottomCardSlideProgress by animateFloatAsState( + targetValue = if (viewModel.isYearView) 1f else 0f, + animationSpec = tween(350, delayMillis = 100, easing = FastOutSlowInEasing), + label = "bottomCardSlide" + ) + LocalDensity.current var rowHeightPx by remember { mutableIntStateOf(0) } @@ -159,7 +172,11 @@ fun CalendarMonthView( targetState = viewModel.isYearView, label = "month_year_transition", transitionSpec = { - fadeIn(tween(0)) togetherWith fadeOut(tween(0)) + val enter = fadeIn(tween(300, easing = FastOutSlowInEasing)) + + slideInVertically(tween(300, easing = FastOutSlowInEasing)) { it / 6 } + val exit = fadeOut(tween(200, easing = FastOutSlowInEasing)) + + slideOutVertically(tween(200, easing = FastOutSlowInEasing)) { -it / 6 } + enter togetherWith exit }, modifier = Modifier.fillMaxSize() ) { isYearView -> @@ -215,7 +232,10 @@ fun CalendarMonthView( viewModel = viewModel, today = today, rowHeightPx = rowHeightPx, - modifier = Modifier.fillMaxWidth() + modifier = Modifier + .fillMaxWidth() + .offset(y = with(density) { (bottomCardSlideProgress * 200).dp }) + .alpha(1f - bottomCardSlideProgress) ) } } diff --git a/core/src/main/kotlin/plus/rua/project/ui/YearGridView.kt b/core/src/main/kotlin/plus/rua/project/ui/YearGridView.kt index f55d7d7..4023aca 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/YearGridView.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/YearGridView.kt @@ -165,6 +165,7 @@ fun YearGridView( ) { (0 until 3).forEach { col -> val month = row * 3 + col + 1 + val sharedKey = "month_grid_${year}_$month" with(sharedTransitionScope) { MiniMonth( month = month, @@ -180,7 +181,7 @@ fun YearGridView( .weight(1f) .sharedElement( sharedContentState = rememberSharedContentState( - key = "month_grid_${year}_$month" + key = sharedKey ), animatedVisibilityScope = animatedVisibilityScope, boundsTransform = { _, _ ->