Fixes messages FAB's position when open

This commit is contained in:
Vitor Pamplona
2026-04-14 10:31:13 -04:00
parent d23f6f8ec1
commit 080be06a2f
@@ -20,16 +20,19 @@
*/
package com.vitorpamplona.amethyst.ui.layouts
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.BottomAppBarScrollBehavior
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.layout
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
@OptIn(ExperimentalMaterial3Api::class)
@@ -42,10 +45,17 @@ fun DisappearingFloatingButton(
// 1.0 = fully visible, 0.0 = fully hidden
val progress = (1f - scrollBehavior.state.collapsedFraction).coerceAtLeast(0.001f)
val border =
with(LocalDensity.current) {
20.dp.toPx()
}
Box(
modifier =
Modifier
.size(75.dp)
.border(1.dp, Color.Green)
.padding(20.dp)
.border(1.dp, Color.Red)
.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
// Adjust the height of the layout so the FAB doesn't leave a "hole"
@@ -54,7 +64,7 @@ fun DisappearingFloatingButton(
placeable.placeRelative(0, 0)
}
}.graphicsLayer {
this.translationY = this.size.height / 3.5f
this.translationY = border
this.scaleX = progress
this.scaleY = progress
this.alpha = progress