Skip to content

Instantly share code, notes, and snippets.

@AlShevelev
Last active July 15, 2022 20:01
Show Gist options
  • Save AlShevelev/5c31be308ebf9e6c473e514a468cbbd6 to your computer and use it in GitHub Desktop.
Save AlShevelev/5c31be308ebf9e6c473e514a468cbbd6 to your computer and use it in GitHub Desktop.
@Composable
internal fun TopBarCollapsing(
currentOffset: Float,
maxOffset: Float,
modifier: Modifier = Modifier,
onHeightCalculated: (Float) -> Unit
) {
val alpha = (abs(currentOffset) / maxOffset).pow(0.75f)
Column(
modifier = modifier
.offset { IntOffset(x = 0, y = currentOffset.roundToInt()) }
.background(Color.Blue)
.padding(start = 16.dp)
.onGloballyPositioned {
onHeightCalculated(it.size.height.toFloat())
}
) {
Text(
text = "Some text 1",
color = Color.White,
modifier = Modifier.alpha(1f - alpha).padding(top = 8.dp)
)
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment