perf: WeekRow 改用 graphicsLayer 避免折叠动画重组

将 offset() + alpha() 替换为 graphicsLayer { translationY / alpha },
collapseProgress 变化时跳过 Composition/Layout,仅更新 Draw 阶段。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-25 16:38:04 +08:00
parent 6ab63eae53
commit e175bb07da

View File

@ -15,8 +15,7 @@ import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.draw.alpha
import androidx.compose.foundation.layout.offset
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
@ -209,8 +208,10 @@ private fun WeekRow(
if (isAnchor && phase1 >= 1f) Modifier.background(MaterialTheme.colorScheme.surface)
else Modifier
)
.offset(y = with(density) { yOffsetPx.toDp() })
.alpha(rowAlpha)
.graphicsLayer {
translationY = yOffsetPx
this.alpha = rowAlpha
}
.then(
if (weekIndex == 0 && rowHeightPx == 0) {
Modifier.onSizeChanged { size ->