From b79460113484d22a194016b5f649cf993d11ea15 Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 15 May 2026 10:18:52 +0800 Subject: [PATCH] Fix style issues in MonthHeader and CalendarMonthView Replace hardcoded padding values with constants, use Spacer instead of space character for spacing, remove fontSize override on bodySmall, and fix WeekdayHeader modifier order (padding before onSizeChanged). Co-Authored-By: Claude Opus 4.7 --- .../kotlin/plus/rua/project/ui/CalendarMonthView.kt | 11 ++++++----- .../kotlin/plus/rua/project/ui/MonthHeader.kt | 9 +++++---- 2 files changed, 11 insertions(+), 9 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 986f352..ff8adfd 100644 --- a/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthView.kt +++ b/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthView.kt @@ -32,6 +32,7 @@ import plus.rua.project.CalendarViewModel private const val START_PAGE = Int.MAX_VALUE / 2 private const val ROW_PADDING_DP = 4 +private const val HORIZONTAL_PADDING_DP = 16 /** * 日历主界面,包含月/周视图切换和折叠动画。 @@ -89,8 +90,8 @@ fun CalendarMonthView( // 预估行高:DayCell aspectRatio=1,宽度 = (screenWidth - horizontalPadding) / 7 // 加上 Row 的 vertical padding (4dp × 2) val estimatedRowHeightPx = if (screenWidthPx > 0) { - val cellWidth = (screenWidthPx - with(density) { 32.dp.toPx() }) / 7 - val rowPadding = with(density) { 8.dp.toPx() } + val cellWidth = (screenWidthPx - with(density) { (HORIZONTAL_PADDING_DP * 2).dp.toPx() }) / 7 + val rowPadding = with(density) { (ROW_PADDING_DP * 2).dp.toPx() } (cellWidth + rowPadding).toInt() } else 0 @@ -130,7 +131,7 @@ fun CalendarMonthView( screenHeightPx = size.height } ) { - Column(modifier = Modifier.padding(horizontal = 16.dp)) { + Column(modifier = Modifier.padding(horizontal = HORIZONTAL_PADDING_DP.dp)) { MonthHeader( year = currentYear, month = currentMonth, @@ -140,9 +141,9 @@ fun CalendarMonthView( } ) WeekdayHeader( - modifier = Modifier.fillMaxWidth().onSizeChanged { size -> + modifier = Modifier.fillMaxWidth().padding(bottom = ROW_PADDING_DP.dp).onSizeChanged { size -> weekdayHeaderHeightPx = size.height - }.padding(bottom = ROW_PADDING_DP.dp) + } ) // 完全折叠且无动画时显示 WeekPager,否则显示 CalendarPager(含下拉恢复过程) if (viewModel.isCollapsed && viewModel.collapseProgress >= 1f) { diff --git a/shared/src/commonMain/kotlin/plus/rua/project/ui/MonthHeader.kt b/shared/src/commonMain/kotlin/plus/rua/project/ui/MonthHeader.kt index 9efe528..dbe78bd 100644 --- a/shared/src/commonMain/kotlin/plus/rua/project/ui/MonthHeader.kt +++ b/shared/src/commonMain/kotlin/plus/rua/project/ui/MonthHeader.kt @@ -1,15 +1,16 @@ package plus.rua.project.ui import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp /** * 月份标题栏,显示"年月"文字和 ISO 周号。 @@ -36,10 +37,10 @@ fun MonthHeader( text = "${year}年${month}月", style = MaterialTheme.typography.titleLarge ) + Spacer(modifier = Modifier.width(6.dp)) Text( - text = " 第${weekNumber}周", - style = MaterialTheme.typography.bodySmall, - fontSize = 13.sp + text = "第${weekNumber}周", + style = MaterialTheme.typography.bodySmall ) } }