修复月视图首帧行堆叠:rowHeightPx 未就绪时 alpha=0

draw 阶段已读到更新后的 rowHeightPx,但 layout 仍用旧值时会出现行堆叠。
增加 layoutReady 守卫,首帧 rowHeightPx==0 时直接隐藏月视图。
This commit is contained in:
meyou 2026-05-18 22:06:58 +08:00
parent 780a5e70dd
commit a478ecb1bd
No known key found for this signature in database
2 changed files with 4 additions and 2 deletions

View File

@ -233,6 +233,9 @@ fun CalendarMonthView(
}
val monthProgress = 1f - viewModel.yearViewProgress
// 组合阶段计算lambda 捕获快照值,避免 draw 阶段读到已更新的 rowHeightPx
// 但 layout 仍用旧值导致行堆叠
val layoutReady = rowHeightPx > 0
Box(
modifier = Modifier
.fillMaxSize()
@ -240,7 +243,7 @@ fun CalendarMonthView(
val scale = lerp(0.3f, 1f, monthProgress)
scaleX = scale
scaleY = scale
alpha = monthProgress.coerceIn(0f, 1f)
alpha = if (layoutReady) monthProgress.coerceIn(0f, 1f) else 0f
transformOrigin = TransformOrigin(anchorPivotX, anchorPivotY)
}
) {

View File

@ -18,7 +18,6 @@ class CalendarViewModelTest {
private val fixedInstant = Instant.parse("2026-05-15T00:00:00Z")
private val testClock = FixedClock(fixedInstant)
private fun createViewModel(): CalendarViewModel {
val scope = CoroutineScope(Dispatchers.Unconfined)
return CalendarViewModel(coroutineScope = scope, clock = testClock)