From c569c7350d0dcf7b2cd3dda4f9df774935aa1f3d Mon Sep 17 00:00:00 2001 From: Flaringapp Date: Mon, 6 Apr 2026 16:06:20 +0300 Subject: [PATCH 1/3] Fix column moving element sample to account for rtl --- .../shared/ui/samples/column/ColumnMovingElementSample.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/column/ColumnMovingElementSample.kt b/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/column/ColumnMovingElementSample.kt index fb6eece..f5a48a3 100644 --- a/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/column/ColumnMovingElementSample.kt +++ b/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/column/ColumnMovingElementSample.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape @@ -38,6 +39,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.lerp import androidx.compose.ui.zIndex @@ -133,8 +135,9 @@ private fun CollapsingTopBarColumnScope.CollapsibleSlidingAction( Box( modifier = Modifier .size(40.dp) - .graphicsLayer { - translationX = lerp(56.dp, 0.dp, twiceAsFastCollapseProgress).toPx() + .offset { + val x = lerp(56.dp, 0.dp, twiceAsFastCollapseProgress).roundToPx() + IntOffset(x, 0) } .background(color = Color.Red, shape = CircleShape), ) From 484406b94d00c6b3f342aae5afa2e061a191671d Mon Sep 17 00:00:00 2001 From: Flaringapp Date: Mon, 6 Apr 2026 16:26:54 +0300 Subject: [PATCH 2/3] Cleanup alignment in floating element sample --- .../ui/samples/advanced/FloatingElementSample.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/advanced/FloatingElementSample.kt b/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/advanced/FloatingElementSample.kt index c2359e9..7e7d951 100644 --- a/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/advanced/FloatingElementSample.kt +++ b/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/advanced/FloatingElementSample.kt @@ -19,10 +19,12 @@ package com.flaringapp.compose.topbar.sample.shared.ui.samples.advanced import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.Surface 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.layout.layout @@ -83,7 +85,11 @@ private fun CollapsingContent( ) SlidingDot( - modifier = Modifier.floating(), + modifier = Modifier + .floating() + .align(Alignment.BottomStart) + .parallax(1f) + .padding(bottom = 16.dp, start = 16.dp, end = 16.dp), state = topBarState, ) }, @@ -105,12 +111,11 @@ private fun SlidingDot( layout(placeable.width, placeable.height) { val layoutInfo = state.layoutInfo val x = lerp( - start = constraints.maxWidth - placeable.width - 16.dp.roundToPx(), - stop = 16.dp.roundToPx(), + start = constraints.maxWidth - placeable.width, + stop = 0, fraction = layoutInfo.collapseProgress, ) - val y = layoutInfo.height.toInt() - placeable.height - 16.dp.roundToPx() - placeable.place(x, y) + placeable.place(x, 0) } } .size(40.dp) From db48e46017d4c6c6069e565c12207d100112ae91 Mon Sep 17 00:00:00 2001 From: Flaringapp Date: Mon, 6 Apr 2026 16:31:08 +0300 Subject: [PATCH 3/3] Fix floating element sample rtl --- .../sample/shared/ui/samples/advanced/FloatingElementSample.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/advanced/FloatingElementSample.kt b/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/advanced/FloatingElementSample.kt index 7e7d951..9b6f568 100644 --- a/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/advanced/FloatingElementSample.kt +++ b/sample/shared/src/commonMain/kotlin/com/flaringapp/compose/topbar/sample/shared/ui/samples/advanced/FloatingElementSample.kt @@ -115,7 +115,7 @@ private fun SlidingDot( stop = 0, fraction = layoutInfo.collapseProgress, ) - placeable.place(x, 0) + placeable.placeRelative(x, 0) } } .size(40.dp)