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
|
modifier
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCollapsed && collapseProgress >= 1f) {
|
CalendarPager(
|
||||||
WeekPager(
|
selectedDate = selectedDate,
|
||||||
selectedDate = selectedDate,
|
today = today,
|
||||||
today = today,
|
onDateClick = onDateClick,
|
||||||
onDateClick = onDateClick,
|
onMonthChanged = onMonthChanged,
|
||||||
onWeekChanged = { weekMonday ->
|
collapseProgress = collapseProgress,
|
||||||
val weekSunday = weekMonday.plus(DatePeriod(days = 6))
|
rowHeightPx = rowHeightPx,
|
||||||
val date = when {
|
effectiveWeeks = effectiveWeeks,
|
||||||
today in weekMonday..weekSunday -> today
|
shiftKindAt = shiftKindAt,
|
||||||
weekMonday.month != weekSunday.month -> {
|
showLegalHoliday = showLegalHoliday,
|
||||||
if (weekMonday < selectedDate) {
|
onRowHeightMeasured = onRowHeightMeasured,
|
||||||
@Suppress("DEPRECATION") // monthNumber 无替代 API
|
pagerState = pagerState,
|
||||||
LocalDate(weekSunday.year, weekSunday.month.number, 1)
|
modifier = pagerModifier
|
||||||
} 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
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
package plus.rua.project.ui
|
package plus.rua.project.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.foundation.pager.HorizontalPager
|
import androidx.compose.foundation.pager.HorizontalPager
|
||||||
import androidx.compose.foundation.pager.PagerDefaults
|
import androidx.compose.foundation.pager.PagerDefaults
|
||||||
import androidx.compose.foundation.pager.rememberPagerState
|
import androidx.compose.foundation.pager.rememberPagerState
|
||||||
@ -89,6 +91,7 @@ fun WeekPager(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.alpha(alpha)
|
.alpha(alpha)
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
.background(MaterialTheme.colorScheme.surface)
|
||||||
.padding(vertical = ROW_PADDING_DP.dp)
|
.padding(vertical = ROW_PADDING_DP.dp)
|
||||||
) {
|
) {
|
||||||
(0 until 7).forEach { dayOffset ->
|
(0 until 7).forEach { dayOffset ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user