修复折叠态跨月周选中上个月日期的问题
跨月周(如5月第一周周一是4月27日)改为选中下个月的1号, 避免月份标题和展开内容不一致。
This commit is contained in:
parent
e403c683f6
commit
104c5e5baa
@ -179,9 +179,16 @@ fun CalendarMonthView(
|
|||||||
today = today,
|
today = today,
|
||||||
onDateClick = { date -> viewModel.selectDate(date) },
|
onDateClick = { date -> viewModel.selectDate(date) },
|
||||||
onWeekChanged = { weekMonday ->
|
onWeekChanged = { weekMonday ->
|
||||||
// 优先选中当周内的今天,否则选中该周周一
|
|
||||||
val weekSunday = weekMonday.plus(DatePeriod(days = 6))
|
val weekSunday = weekMonday.plus(DatePeriod(days = 6))
|
||||||
val date = if (today in weekMonday..weekSunday) today else weekMonday
|
val date = when {
|
||||||
|
today in weekMonday..weekSunday -> today
|
||||||
|
weekMonday.month != weekSunday.month -> {
|
||||||
|
// 跨月周:选中下个月的1号
|
||||||
|
@Suppress("DEPRECATION") // monthNumber 无替代 API
|
||||||
|
LocalDate(weekSunday.year, weekSunday.month.number, 1)
|
||||||
|
}
|
||||||
|
else -> weekMonday
|
||||||
|
}
|
||||||
viewModel.selectDate(date)
|
viewModel.selectDate(date)
|
||||||
},
|
},
|
||||||
modifier = pagerModifier
|
modifier = pagerModifier
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user