mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-08-29 07:16:08 +00:00
Restore Wear chat content space
This commit is contained in:
parent
45915fab8f
commit
34f94882f5
@ -190,7 +190,7 @@ private fun ChatBody(
|
||||
val palette = LocalBitchatPalette.current
|
||||
val context = LocalContext.current
|
||||
val transformationSpec = rememberTransformationSpec()
|
||||
val headerBackdropHeight = if (LocalConfiguration.current.isScreenRound) 35.dp else 37.dp
|
||||
val headerBackdropHeight = if (LocalConfiguration.current.isScreenRound) 49.dp else 37.dp
|
||||
|
||||
// Slide-to-cancel: while recording, the finger's position is tracked globally; the
|
||||
// overlay's mic button reports its bounds and becomes the cancel target when the
|
||||
@ -276,8 +276,10 @@ private fun ChatBody(
|
||||
// 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)
|
||||
// Wear Material already supplies a responsive 5.2% horizontal inset. Keep it,
|
||||
// but omit the scaffold's vertical inset because the viewport itself reserves
|
||||
// the header and action-bar space. Stacking both made chat narrow and too high.
|
||||
contentPadding = scaffoldPadding.horizontalOnly(layoutDirection)
|
||||
) {
|
||||
if (messages.isEmpty()) {
|
||||
item {
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
package com.bitchat.watch.ui
|
||||
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlin.math.ceil
|
||||
|
||||
/**
|
||||
* Preserve the responsive, shape-aware padding supplied by Wear Material while allowing a
|
||||
@ -33,24 +30,21 @@ internal fun PaddingValues.withAdditionalPadding(
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun PaddingValues.withRoundScreenPadding(
|
||||
/**
|
||||
* Keep the responsive horizontal inset supplied by Wear Material without also reserving its
|
||||
* vertical list padding. Chat owns its fixed header and action-bar clearances, so stacking the
|
||||
* scaffold's vertical padding on top would unnecessarily shorten the message viewport.
|
||||
*/
|
||||
internal fun PaddingValues.horizontalOnly(
|
||||
layoutDirection: LayoutDirection
|
||||
): PaddingValues = withAdditionalPadding(
|
||||
layoutDirection = layoutDirection,
|
||||
horizontal = additionalRoundScreenPadding(
|
||||
screenWidthDp = LocalConfiguration.current.screenWidthDp,
|
||||
isScreenRound = LocalConfiguration.current.isScreenRound
|
||||
)
|
||||
)
|
||||
|
||||
internal fun additionalRoundScreenPadding(
|
||||
screenWidthDp: Int,
|
||||
isScreenRound: Boolean
|
||||
): Dp = if (isScreenRound) {
|
||||
ceil(screenWidthDp * ROUND_SCREEN_ADDITIONAL_PADDING_FRACTION).toInt().dp
|
||||
} else {
|
||||
0.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, end = end)
|
||||
}
|
||||
|
||||
private const val ROUND_SCREEN_ADDITIONAL_PADDING_FRACTION = 0.10f
|
||||
|
||||
@ -24,9 +24,13 @@ class WearContentPaddingTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `round screens receive an additional ten percent inset`() {
|
||||
assertEquals(20.dp, additionalRoundScreenPadding(192, isScreenRound = true))
|
||||
assertEquals(22.dp, additionalRoundScreenPadding(220, isScreenRound = true))
|
||||
assertEquals(0.dp, additionalRoundScreenPadding(192, isScreenRound = false))
|
||||
fun `horizontal only padding preserves width inset and restores vertical space`() {
|
||||
val resolved = PaddingValues(start = 10.dp, top = 20.dp, end = 12.dp, bottom = 20.dp)
|
||||
.horizontalOnly(LayoutDirection.Ltr)
|
||||
|
||||
assertEquals(10.dp, resolved.calculateLeftPadding(LayoutDirection.Ltr))
|
||||
assertEquals(12.dp, resolved.calculateRightPadding(LayoutDirection.Ltr))
|
||||
assertEquals(0.dp, resolved.calculateTopPadding())
|
||||
assertEquals(0.dp, resolved.calculateBottomPadding())
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user