Stylianos Gakis
07/17/2021, 10:21 PMStylianos Gakis
07/17/2021, 10:21 PMStylianos Gakis
07/17/2021, 10:21 PM@Composable
fun MapAndIcon(
modifier: Modifier = Modifier,
map: @Composable () -> Unit,
icon: @Composable () -> Unit,
) {
Layout(
modifier = modifier,
content = {
map()
icon()
}
) { measurables: List<Measurable>, constraints: Constraints ->
val mapPlaceable = measurables[0].measure(constraints)
val iconPlaceable = measurables[1].measure(constraints)
layout(
width = constraints.maxWidth,
height = mapPlaceable.height + (iconPlaceable.height / 2)
) {
mapPlaceable.placeRelative(x = 0, y = 0)
iconPlaceable.placeRelative(
x = (constraints.maxWidth / 2) - (iconPlaceable.width / 2),
y = (mapPlaceable.height) - (iconPlaceable.height / 2),
)
}
}
}
This looks quite involved and feels like there might be a better approach?
And if not, I am not entirely happy with using measurables[x] to access my two composables, is there a better approach to that too?Stylianos Gakis
07/17/2021, 10:23 PMNabeel
07/18/2021, 5:38 AMStylianos Gakis
07/18/2021, 7:07 AM