Fixes messages FAB's position when open
This commit is contained in:
+13
-3
@@ -20,16 +20,19 @@
|
|||||||
*/
|
*/
|
||||||
package com.vitorpamplona.amethyst.ui.layouts
|
package com.vitorpamplona.amethyst.ui.layouts
|
||||||
|
|
||||||
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.BoxScope
|
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.BottomAppBarScrollBehavior
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.ui.layout.layout
|
import androidx.compose.ui.layout.layout
|
||||||
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@@ -42,10 +45,17 @@ fun DisappearingFloatingButton(
|
|||||||
// 1.0 = fully visible, 0.0 = fully hidden
|
// 1.0 = fully visible, 0.0 = fully hidden
|
||||||
val progress = (1f - scrollBehavior.state.collapsedFraction).coerceAtLeast(0.001f)
|
val progress = (1f - scrollBehavior.state.collapsedFraction).coerceAtLeast(0.001f)
|
||||||
|
|
||||||
|
val border =
|
||||||
|
with(LocalDensity.current) {
|
||||||
|
20.dp.toPx()
|
||||||
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.size(75.dp)
|
.border(1.dp, Color.Green)
|
||||||
|
.padding(20.dp)
|
||||||
|
.border(1.dp, Color.Red)
|
||||||
.layout { measurable, constraints ->
|
.layout { measurable, constraints ->
|
||||||
val placeable = measurable.measure(constraints)
|
val placeable = measurable.measure(constraints)
|
||||||
// Adjust the height of the layout so the FAB doesn't leave a "hole"
|
// Adjust the height of the layout so the FAB doesn't leave a "hole"
|
||||||
@@ -54,7 +64,7 @@ fun DisappearingFloatingButton(
|
|||||||
placeable.placeRelative(0, 0)
|
placeable.placeRelative(0, 0)
|
||||||
}
|
}
|
||||||
}.graphicsLayer {
|
}.graphicsLayer {
|
||||||
this.translationY = this.size.height / 3.5f
|
this.translationY = border
|
||||||
this.scaleX = progress
|
this.scaleX = progress
|
||||||
this.scaleY = progress
|
this.scaleY = progress
|
||||||
this.alpha = progress
|
this.alpha = progress
|
||||||
|
|||||||
Reference in New Issue
Block a user