Clip Wear messages below the chat header

This commit is contained in:
callebtc 2026-08-24 20:01:46 +02:00
parent 7788328917
commit 5d66b69129

View File

@ -6,10 +6,12 @@ import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
@ -20,6 +22,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.runtime.snapshotFlow
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clipToBounds
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.graphicsLayer
@ -35,6 +38,7 @@ import androidx.wear.compose.foundation.lazy.TransformingLazyColumnState
import androidx.wear.compose.foundation.lazy.items
import androidx.wear.compose.foundation.lazy.rememberTransformingLazyColumnState
import androidx.wear.compose.material3.ScreenScaffold
import androidx.wear.compose.material3.MaterialTheme
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.lazy.rememberTransformationSpec
import androidx.wear.compose.material3.lazy.transformedHeight
@ -262,7 +266,8 @@ private fun ChatBody(
state = columnState,
modifier = Modifier
.fillMaxSize()
.padding(top = 30.dp, bottom = 64.dp),
.padding(top = 30.dp, bottom = 64.dp)
.clipToBounds(),
// Arrangement.Bottom anchors short content to the bottom: the first message
// starts just above the action bar and new messages push history upward.
// The viewport itself stays between the floating header and action bar, so
@ -304,7 +309,14 @@ private fun ChatBody(
// The header stays put and shrinks to its dense form instead of disappearing;
// as an overlay its size animation never touches the list's scroll geometry.
Box(modifier = Modifier.align(Alignment.TopCenter)) {
Box(
modifier = Modifier
.align(Alignment.TopCenter)
.fillMaxWidth()
.height(30.dp)
.background(MaterialTheme.colorScheme.background),
contentAlignment = Alignment.TopCenter
) {
header(controlsVisible)
}