dm-padding message-12

This commit is contained in:
eric 2026-07-09 16:04:27 +08:00
parent 24f600a40b
commit d5911ebde1

View file

@ -102,19 +102,31 @@ fun BottomBarAnimated(
height: Dp, height: Dp,
content: @Composable BoxScope.() -> Unit content: @Composable BoxScope.() -> Unit
) { ) {
// 位移與透明度動畫 // 🎯 核心修正:讓實體高度也參與動畫
// 當 visible 為 false 時,這塊 Box 的高度會縮減到 0,從而讓 Scaffold 重新計算 innerPadding
val animatedHeight by animateDpAsState(targetValue = if (visible) height else 0.dp)
// 位移與透明度動畫保持不變
val offsetY by animateDpAsState(targetValue = if (visible) 0.dp else height) val offsetY by animateDpAsState(targetValue = if (visible) 0.dp else height)
val alpha by animateFloatAsState(targetValue = if (visible) 1f else 0f) val alpha by animateFloatAsState(targetValue = if (visible) 1f else 0f)
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(height) .height(animatedHeight) // 關鍵:動態高度決定了內容區域下方的留白
.offset(y = offsetY)
.graphicsLayer { this.alpha = alpha } .graphicsLayer { this.alpha = alpha }
.background(Color.Transparent), .background(Color.Transparent)
content = content ) {
) // 內部的內容容器則維持原高度,並配合 offset 達成滑出效果
Box(
modifier = Modifier
.fillMaxWidth()
.height(height)
.offset(y = offsetY)
) {
content()
}
}
} }
@Composable @Composable