Created
March 4, 2023 23:15
-
-
Save fvilarino/92930260c4ab6999d95ff946f1e5e432 to your computer and use it in GitHub Desktop.
Ticker - Top Half
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 | |
private fun TopHalf( | |
modifier: Modifier = Modifier, | |
content: @Composable () -> Unit, | |
) { | |
// 1 | |
Layout( | |
// 2 | |
modifier = modifier.clipToBounds(), | |
content = content, | |
) { measurables, constraints -> | |
require(measurables.size == 1) { "This composable expects a single child" } | |
// 3 | |
val placeable = measurables.first().measure(constraints) | |
// 4 | |
val height = placeable.height / 2 | |
// 5 | |
layout( | |
width = placeable.width, | |
height = height, | |
) { | |
// 6 | |
placeable.placeRelative( | |
x = 0, | |
y = 0, | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment