Keep Wear chat rows clear of controls

This commit is contained in:
callebtc 2026-08-24 19:58:03 +02:00
parent 2e41dabd07
commit 7788328917
3 changed files with 6 additions and 44 deletions

View File

@ -260,19 +260,17 @@ private fun ChatBody(
val layoutDirection = LocalLayoutDirection.current
TransformingLazyColumn(
state = columnState,
modifier = Modifier.fillMaxSize(),
modifier = Modifier
.fillMaxSize()
.padding(top = 30.dp, bottom = 64.dp),
// Arrangement.Bottom anchors short content to the bottom: the first message
// starts just above the action bar and new messages push history upward.
// The padding reserves permanent room for the floating header and action
// bar; being constant, it never disturbs an in-flight scroll gesture.
// The viewport itself stays between the floating header and action bar, so
// rows cannot scroll underneath either control. Its geometry is constant,
// so showing or hiding the overlays never disturbs an in-flight gesture.
verticalArrangement = Arrangement.Bottom,
contentPadding = scaffoldPadding
.withRoundScreenPadding(layoutDirection)
.withMinimumVerticalPadding(
layoutDirection = layoutDirection,
top = 30.dp,
bottom = 64.dp
)
) {
if (messages.isEmpty()) {
item {

View File

@ -33,27 +33,6 @@ internal fun PaddingValues.withAdditionalPadding(
)
}
internal fun PaddingValues.withMinimumVerticalPadding(
layoutDirection: LayoutDirection,
top: Dp,
bottom: Dp
): PaddingValues {
val start = when (layoutDirection) {
LayoutDirection.Ltr -> calculateLeftPadding(layoutDirection)
LayoutDirection.Rtl -> calculateRightPadding(layoutDirection)
}
val end = when (layoutDirection) {
LayoutDirection.Ltr -> calculateRightPadding(layoutDirection)
LayoutDirection.Rtl -> calculateLeftPadding(layoutDirection)
}
return PaddingValues(
start = start,
top = maxOf(calculateTopPadding(), top),
end = end,
bottom = maxOf(calculateBottomPadding(), bottom)
)
}
@Composable
internal fun PaddingValues.withRoundScreenPadding(
layoutDirection: LayoutDirection

View File

@ -23,21 +23,6 @@ class WearContentPaddingTest {
assertEquals(28.dp, resolved.calculateBottomPadding())
}
@Test
fun `chat padding keeps responsive sides and overlay clearances`() {
val resolved = PaddingValues(start = 10.dp, top = 18.dp, end = 12.dp, bottom = 20.dp)
.withMinimumVerticalPadding(
layoutDirection = LayoutDirection.Ltr,
top = 30.dp,
bottom = 64.dp
)
assertEquals(10.dp, resolved.calculateLeftPadding(LayoutDirection.Ltr))
assertEquals(12.dp, resolved.calculateRightPadding(LayoutDirection.Ltr))
assertEquals(30.dp, resolved.calculateTopPadding())
assertEquals(64.dp, resolved.calculateBottomPadding())
}
@Test
fun `round screens receive an additional ten percent inset`() {
assertEquals(20.dp, additionalRoundScreenPadding(192, isScreenRound = true))