fix: 去掉 CalendarPager ↔ WeekPager 切换,修复折叠闪烁
CalendarPager 在 collapseProgress=1.0 时只渲染 anchor 行, 效果和 WeekPager 相同,但避免了切换导致的视觉跳跃。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ea7558dec8
commit
4c53f234cf
@ -520,48 +520,20 @@ private fun CalendarPagerArea(
|
||||
modifier
|
||||
}
|
||||
|
||||
if (isCollapsed && collapseProgress >= 1f) {
|
||||
WeekPager(
|
||||
selectedDate = selectedDate,
|
||||
today = today,
|
||||
onDateClick = onDateClick,
|
||||
onWeekChanged = { weekMonday ->
|
||||
val weekSunday = weekMonday.plus(DatePeriod(days = 6))
|
||||
val date = when {
|
||||
today in weekMonday..weekSunday -> today
|
||||
weekMonday.month != weekSunday.month -> {
|
||||
if (weekMonday < selectedDate) {
|
||||
@Suppress("DEPRECATION") // monthNumber 无替代 API
|
||||
LocalDate(weekSunday.year, weekSunday.month.number, 1)
|
||||
} else {
|
||||
weekMonday
|
||||
}
|
||||
}
|
||||
|
||||
else -> weekMonday
|
||||
}
|
||||
onDateClick(date)
|
||||
},
|
||||
shiftKindAt = shiftKindAt,
|
||||
showLegalHoliday = showLegalHoliday,
|
||||
modifier = pagerModifier
|
||||
)
|
||||
} else {
|
||||
CalendarPager(
|
||||
selectedDate = selectedDate,
|
||||
today = today,
|
||||
onDateClick = onDateClick,
|
||||
onMonthChanged = onMonthChanged,
|
||||
collapseProgress = collapseProgress,
|
||||
rowHeightPx = rowHeightPx,
|
||||
effectiveWeeks = effectiveWeeks,
|
||||
shiftKindAt = shiftKindAt,
|
||||
showLegalHoliday = showLegalHoliday,
|
||||
onRowHeightMeasured = onRowHeightMeasured,
|
||||
pagerState = pagerState,
|
||||
modifier = pagerModifier
|
||||
)
|
||||
}
|
||||
CalendarPager(
|
||||
selectedDate = selectedDate,
|
||||
today = today,
|
||||
onDateClick = onDateClick,
|
||||
onMonthChanged = onMonthChanged,
|
||||
collapseProgress = collapseProgress,
|
||||
rowHeightPx = rowHeightPx,
|
||||
effectiveWeeks = effectiveWeeks,
|
||||
shiftKindAt = shiftKindAt,
|
||||
showLegalHoliday = showLegalHoliday,
|
||||
onRowHeightMeasured = onRowHeightMeasured,
|
||||
pagerState = pagerState,
|
||||
modifier = pagerModifier
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package plus.rua.project.ui
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.PagerDefaults
|
||||
import androidx.compose.foundation.pager.rememberPagerState
|
||||
@ -89,6 +91,7 @@ fun WeekPager(
|
||||
modifier = Modifier
|
||||
.alpha(alpha)
|
||||
.fillMaxWidth()
|
||||
.background(MaterialTheme.colorScheme.surface)
|
||||
.padding(vertical = ROW_PADDING_DP.dp)
|
||||
) {
|
||||
(0 until 7).forEach { dayOffset ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user