回退 gridHeightPx/calendarAreaHeightPx/cardHeightPx 的 derivedStateOf
derivedStateOf 导致快照时序问题:cardHeightPx 计算时 gridHeightPx 尚未更新(仍为 0),calendarAreaHeightPx 极小,cardHeightPx 占 96% 屏幕, BottomCard 遮挡整个日历。改回直接计算确保同一帧内值一致。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
0962d13216
commit
b2284c3986
@ -61,6 +61,7 @@ import kotlinx.datetime.todayIn
|
||||
import plus.rua.project.CalendarViewModel
|
||||
import kotlin.math.abs
|
||||
import kotlin.time.Clock
|
||||
import android.util.Log
|
||||
|
||||
/**
|
||||
* 日历主界面,包含月/周视图切换、折叠动画和年视图缩放转场。
|
||||
@ -168,38 +169,35 @@ fun CalendarMonthView(
|
||||
val cellWidth = (screenWidthPx - horizontalPaddingPx) / 7
|
||||
(cellWidth + rowPadding2Px).toInt()
|
||||
} else 0
|
||||
Log.d("CalLayout", "estimatedRow=$estimatedRowHeightPx screenW=$screenWidthPx screenH=$screenHeightPx")
|
||||
|
||||
val effectiveRowHeightPx = if (rowHeightPx > 0) rowHeightPx else estimatedRowHeightPx
|
||||
val effectiveWeeks = interpolatedWeeks
|
||||
|
||||
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
|
||||
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()
|
||||
}
|
||||
}
|
||||
} else 0
|
||||
Log.d("CalLayout", "gridHeightPx=$gridHeightPx rowH=$effectiveRowHeightPx weeks=$effectiveWeeks collapse=$collapseProgress")
|
||||
|
||||
val calendarAreaHeightPx by remember {
|
||||
derivedStateOf { headerHeightPx + gridHeightPx + rowPaddingPx + cardGapPx }
|
||||
}
|
||||
val calendarAreaHeightPx = headerHeightPx + gridHeightPx + rowPaddingPx + cardGapPx
|
||||
Log.d("CalLayout", "calendarArea=$calendarAreaHeightPx header=$headerHeightPx grid=$gridHeightPx rowPad=$rowPaddingPx cardGap=$cardGapPx")
|
||||
|
||||
val cardHeightPx by remember {
|
||||
derivedStateOf {
|
||||
if (screenHeightPx > 0 && calendarAreaHeightPx > 0) screenHeightPx - calendarAreaHeightPx else 0
|
||||
}
|
||||
}
|
||||
val cardHeightPx =
|
||||
if (screenHeightPx > 0 && calendarAreaHeightPx > 0) screenHeightPx - calendarAreaHeightPx else 0
|
||||
Log.d("CalLayout", "cardHeight=$cardHeightPx screenH=$screenHeightPx calArea=$calendarAreaHeightPx")
|
||||
|
||||
val pagerModifier = if (rowHeightPx > 0 && gridHeightPx > 0) {
|
||||
Log.d("CalLayout", "pagerModifier: height=${with(density) { gridHeightPx.toDp() }} rowH=$rowHeightPx gridH=$gridHeightPx")
|
||||
Modifier
|
||||
.height(with(density) { gridHeightPx.toDp() })
|
||||
.clipToBounds()
|
||||
} else {
|
||||
Log.d("CalLayout", "pagerModifier: EMPTY rowH=$rowHeightPx gridH=$gridHeightPx")
|
||||
Modifier
|
||||
}
|
||||
|
||||
@ -320,6 +318,7 @@ fun CalendarMonthView(
|
||||
}
|
||||
|
||||
if (cardHeightPx > 0) {
|
||||
Log.d("CalLayout", "BottomCard: height=${with(density) { cardHeightPx.toDp() }} cardH=$cardHeightPx isCollapsed=${viewModel.isCollapsed}")
|
||||
BottomCard(
|
||||
viewModel = viewModel,
|
||||
dragRangePx = dragRangePx,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user