Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
},
Expand All @@ -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.placeRelative(x, 0)
}
}
.size(40.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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),
)
Expand Down
Loading