Last active
July 15, 2022 20:01
-
-
Save AlShevelev/5c31be308ebf9e6c473e514a468cbbd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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