From 1cf2766e84c9f05ea2ea976504a5d3d28e6ae391 Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 14 May 2026 17:32:08 +0800 Subject: [PATCH] Increase row padding to 4dp and auto-select date on page change Select the Monday of the week when WeekPager changes, and the 1st of the month when CalendarPager changes, so the selected date always matches the visible page. Co-Authored-By: Claude Opus 4.7 --- .../kotlin/plus/rua/project/ui/CalendarMonthPage.kt | 2 +- .../kotlin/plus/rua/project/ui/CalendarMonthView.kt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthPage.kt b/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthPage.kt index c106eeb..2a3ae58 100644 --- a/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthPage.kt +++ b/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthPage.kt @@ -121,7 +121,7 @@ fun CalendarMonthPage( rowHeightPx = size.height } } - .padding(vertical = 2.dp) + .padding(vertical = 4.dp) ) { week.forEach { dayData -> DayCell( 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 e1f2011..4ed16d9 100644 --- a/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthView.kt +++ b/shared/src/commonMain/kotlin/plus/rua/project/ui/CalendarMonthView.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.draw.clipToBounds import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.dp +import kotlinx.datetime.LocalDate import kotlinx.datetime.TimeZone import kotlinx.datetime.todayIn import kotlin.time.Clock @@ -64,7 +65,7 @@ fun CalendarMonthView( expandedGridHeightPx } else 0 - val rowPaddingPx = with(density) { 2.dp.toPx() }.toInt() + val rowPaddingPx = with(density) { 4.dp.toPx() }.toInt() val cardTopPx = headerHeightPx + gridHeightPx + rowPaddingPx val cardHeightPx = screenHeightPx - cardTopPx @@ -106,7 +107,7 @@ fun CalendarMonthView( WeekdayHeader( modifier = Modifier.fillMaxWidth().onSizeChanged { size -> weekdayHeaderHeightPx = size.height - }.padding(bottom = 2.dp) + }.padding(bottom = 4.dp) ) // 完全折叠且无动画时显示 WeekPager,否则显示 CalendarPager(含下拉恢复过程) if (viewModel.isCollapsed && viewModel.collapseProgress >= 1f) { @@ -115,6 +116,7 @@ fun CalendarMonthView( today = today, onDateClick = { date -> viewModel.selectDate(date) }, onWeekChanged = { weekMonday -> + viewModel.selectDate(weekMonday) currentYear = weekMonday.year @Suppress("DEPRECATION") // monthNumber 无替代 API,kotlinx-datetime 尚未提供新接口 currentMonth = weekMonday.monthNumber @@ -126,6 +128,7 @@ fun CalendarMonthView( today = today, onDateClick = { date -> viewModel.selectDate(date) }, onMonthChanged = { year, month -> + viewModel.selectDate(LocalDate(year, month, 1)) currentYear = year currentMonth = month },