From 7d6ed1428e9b48a414f8fd1f0052cad987a98f82 Mon Sep 17 00:00:00 2001 From: xfy Date: Mon, 15 Jun 2026 13:26:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=97=A5=E6=9C=9F=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E5=99=A8=20Canvas=20=E6=89=8B=E7=BB=98=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E6=9B=BF=E6=8D=A2=E4=B8=BA=20Material=20Icons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CalendarIcon/ArrowRightIcon 改用 Icons.Filled.DateRange 和 Icons.AutoMirrored.Filled.ArrowForward,统一图标风格并支持 RTL 自动镜像;删除冗余 Canvas 绘制代码及关联 import(Offset/ StrokeCap/Stroke)。 --- .../plus/rua/project/ui/DateCheckerScreen.kt | 80 ++++--------------- 1 file changed, 15 insertions(+), 65 deletions(-) diff --git a/core/src/main/kotlin/plus/rua/project/ui/DateCheckerScreen.kt b/core/src/main/kotlin/plus/rua/project/ui/DateCheckerScreen.kt index c57c137..b05776e 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/DateCheckerScreen.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/DateCheckerScreen.kt @@ -38,8 +38,10 @@ import androidx.compose.material3.SmallFloatingActionButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ChevronLeft +import androidx.compose.material.icons.automirrored.filled.ArrowForward import androidx.compose.material.icons.filled.Add +import androidx.compose.material.icons.filled.ChevronLeft +import androidx.compose.material.icons.filled.DateRange import androidx.compose.material.icons.filled.Refresh import androidx.compose.material3.Icon import androidx.compose.material3.Scaffold @@ -64,11 +66,8 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.geometry.Offset import androidx.compose.ui.graphics.Brush import androidx.compose.ui.graphics.Color -import androidx.compose.ui.graphics.StrokeCap -import androidx.compose.ui.graphics.drawscope.Stroke import androidx.compose.ui.res.painterResource import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.LocalContext @@ -542,8 +541,10 @@ private fun ProductionDateCard( ), contentAlignment = Alignment.Center ) { - CalendarIcon( - color = MaterialTheme.colorScheme.onPrimaryContainer, + Icon( + imageVector = Icons.Filled.DateRange, + contentDescription = null, + tint = MaterialTheme.colorScheme.onPrimaryContainer, modifier = Modifier.size(24.dp) ) } @@ -629,8 +630,10 @@ private fun ExpiryCard( Spacer(modifier = Modifier.width(8.dp)) - ArrowRightIcon( - color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f), + Icon( + imageVector = Icons.AutoMirrored.Filled.ArrowForward, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f), modifier = Modifier.size(20.dp) ) @@ -656,8 +659,10 @@ private fun ExpiryCard( onClick = onShowDatePicker, modifier = Modifier.size(32.dp) ) { - CalendarIcon( - color = MaterialTheme.colorScheme.onSurfaceVariant, + Icon( + imageVector = Icons.Filled.DateRange, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.size(18.dp) ) } @@ -708,61 +713,6 @@ private fun ExpiryCard( } } -// region Icons - -@Composable -private fun CalendarIcon(color: Color, modifier: Modifier = Modifier) { - androidx.compose.foundation.Canvas(modifier = modifier.size(24.dp)) { - val strokeWidth = 1.5f.dp.toPx() - val pad = 3.dp.toPx() - val topY = pad + 4.dp.toPx() - val bottomY = size.height - pad - val leftX = pad - val rightX = size.width - pad - - drawLine(color, Offset(leftX, topY), Offset(rightX, topY), strokeWidth) - drawLine(color, Offset(leftX, topY), Offset(leftX, bottomY), strokeWidth) - drawLine(color, Offset(rightX, topY), Offset(rightX, bottomY), strokeWidth) - drawLine(color, Offset(leftX, bottomY), Offset(rightX, bottomY), strokeWidth) - - val h1 = size.width * 0.3f - val h2 = size.width * 0.7f - drawLine(color, Offset(h1, pad), Offset(h1, topY), strokeWidth) - drawLine(color, Offset(h2, pad), Offset(h2, topY), strokeWidth) - } -} - -@Composable -private fun ArrowRightIcon(color: Color, modifier: Modifier = Modifier) { - androidx.compose.foundation.Canvas(modifier = modifier) { - val strokeWidth = 2.dp.toPx() - val y = size.height / 2 - drawLine( - color = color, - start = Offset(0f, y), - end = Offset(size.width * 0.65f, y), - strokeWidth = strokeWidth, - cap = StrokeCap.Round - ) - drawLine( - color = color, - start = Offset(size.width * 0.4f, y - size.height * 0.3f), - end = Offset(size.width * 0.65f, y), - strokeWidth = strokeWidth, - cap = StrokeCap.Round - ) - drawLine( - color = color, - start = Offset(size.width * 0.4f, y + size.height * 0.3f), - end = Offset(size.width * 0.65f, y), - strokeWidth = strokeWidth, - cap = StrokeCap.Round - ) - } -} - -// endregion - // region Helpers /**