From 62d3bbabeab605b97fa850dc26829ceee8e9d7e6 Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 8 Jun 2026 13:20:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=A6=96=E9=A1=B5=20FAB=20?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=9B=BE=E6=A0=87=E6=9B=BF=E6=8D=A2=E4=B8=BA?= =?UTF-8?q?=20Material=20Icons=EF=BC=8C=E5=B1=95=E5=BC=80=E6=97=B6?= =?UTF-8?q?=E5=88=87=E6=8D=A2=20Close=20=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=BF=87=E6=B8=A1=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plus/rua/project/ui/CalendarMonthView.kt | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 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 54bcd6b..153f5fc 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt @@ -18,7 +18,6 @@ import androidx.compose.animation.scaleOut 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 import androidx.compose.foundation.gestures.detectTapGestures @@ -38,10 +37,14 @@ import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.Close +import androidx.compose.material.icons.filled.Menu import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.FloatingActionButton import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -63,8 +66,6 @@ import androidx.compose.ui.platform.testTag import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.testTagsAsResourceId import androidx.compose.ui.draw.clipToBounds -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalDensity @@ -368,8 +369,18 @@ fun CalendarMonthView( containerColor = MaterialTheme.colorScheme.primaryContainer, contentColor = MaterialTheme.colorScheme.onPrimaryContainer ) { - val iconColor = MaterialTheme.colorScheme.onPrimaryContainer - MenuIcon(color = iconColor) + AnimatedContent( + targetState = isMenuExpanded, + transitionSpec = { + fadeIn(tween(200)) togetherWith fadeOut(tween(200)) + }, + label = "fab_icon" + ) { expanded -> + Icon( + imageVector = if (expanded) Icons.Filled.Close else Icons.Filled.Menu, + contentDescription = if (expanded) "关闭菜单" else "打开菜单" + ) + } } // Scrim:全透明,仅拦截点击关闭菜单,无动画 @@ -466,24 +477,6 @@ fun CalendarMonthView( } } -@Composable -private fun MenuIcon(color: Color, modifier: Modifier = Modifier) { - Canvas(modifier = modifier.size(24.dp)) { - val strokeWidth = 2.dp.toPx() - val lineSpacing = 4.dp.toPx() - val totalHeight = strokeWidth * 3 + lineSpacing * 2 - val startY = (size.height - totalHeight) / 2 - repeat(3) { i -> - drawLine( - color = color, - start = Offset(0f, startY + i * (strokeWidth + lineSpacing)), - end = Offset(size.width, startY + i * (strokeWidth + lineSpacing)), - strokeWidth = strokeWidth - ) - } - } -} - @Composable private fun CalendarPagerArea( selectedDate: LocalDate,