Skip to content

Instantly share code, notes, and snippets.

@pauloaapereira
Created March 16, 2021 19:03
Show Gist options
  • Save pauloaapereira/df1a72aba4632adf376e6932544bd5cb to your computer and use it in GitHub Desktop.
Save pauloaapereira/df1a72aba4632adf376e6932544bd5cb to your computer and use it in GitHub Desktop.
Jetpack Compose — Drawer Pushing Content - 1
@Composable
fun MyBasicColumn(
modifier: Modifier = Modifier,
content: @Composable() () -> Unit
) {
Layout(
modifier = modifier,
content = content
) { measurables, constraints ->
// List of measured children
val placeables = measurables.map { measurable ->
// Measure each children
measurable.measure(constraints.copy(minHeight = 0))
}
// Set the size of the layout as big as it can
layout(constraints.maxWidth, constraints.maxHeight) {
// Track the y co-ord we have placed children up to
var yPosition = 0
// Place children in the parent layout
placeables.forEach { placeable ->
// Position item on the screen
placeable.place(x = 0, y = yPosition)
// Record the y co-ord placed up to
yPosition += placeable.height
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment