gridHeightPx/calendarAreaHeightPx/cardHeightPx 包裹 derivedStateOf
将依赖 collapseProgress 的中间计算移入 derivedStateOf, 确保只在被读取时才计算,避免不必要的中间对象创建。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
d5b7d2cd8a
commit
0962d13216
@ -172,18 +172,28 @@ fun CalendarMonthView(
|
||||
val effectiveRowHeightPx = if (rowHeightPx > 0) rowHeightPx else estimatedRowHeightPx
|
||||
val effectiveWeeks = interpolatedWeeks
|
||||
|
||||
val gridHeightPx = if (effectiveRowHeightPx > 0) {
|
||||
val rowH = effectiveRowHeightPx.toFloat()
|
||||
if (collapseProgress > OFFSET_FRACTION_THRESHOLD) {
|
||||
(rowH * (1 + (effectiveWeeks - 1) * (1f - collapseProgress))).toInt()
|
||||
} else {
|
||||
(rowH * effectiveWeeks).toInt()
|
||||
val gridHeightPx by remember {
|
||||
derivedStateOf {
|
||||
if (effectiveRowHeightPx > 0) {
|
||||
val rowH = effectiveRowHeightPx.toFloat()
|
||||
if (collapseProgress > OFFSET_FRACTION_THRESHOLD) {
|
||||
(rowH * (1 + (effectiveWeeks - 1) * (1f - collapseProgress))).toInt()
|
||||
} else {
|
||||
(rowH * effectiveWeeks).toInt()
|
||||
}
|
||||
} else 0
|
||||
}
|
||||
} else 0
|
||||
}
|
||||
|
||||
val calendarAreaHeightPx = headerHeightPx + gridHeightPx + rowPaddingPx + cardGapPx
|
||||
val cardHeightPx =
|
||||
if (screenHeightPx > 0 && calendarAreaHeightPx > 0) screenHeightPx - calendarAreaHeightPx else 0
|
||||
val calendarAreaHeightPx by remember {
|
||||
derivedStateOf { headerHeightPx + gridHeightPx + rowPaddingPx + cardGapPx }
|
||||
}
|
||||
|
||||
val cardHeightPx by remember {
|
||||
derivedStateOf {
|
||||
if (screenHeightPx > 0 && calendarAreaHeightPx > 0) screenHeightPx - calendarAreaHeightPx else 0
|
||||
}
|
||||
}
|
||||
|
||||
val pagerModifier = if (rowHeightPx > 0 && gridHeightPx > 0) {
|
||||
Modifier
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user