I'm trying to create a modifier to "layout stuff vertically"
EDIT: what I mean is: rotated 90 degree. But the composable take the space actually used (if you just rotate it takes the space as if you did not rotate it)
fun Modifier.layoutVertically() =
rotate(-90f).layout { measurable, constraints ->
val swappedConstraints = constraints.copy(
minWidth = constraints.minHeight,
maxWidth = constraints.maxHeight,
minHeight = constraints.minWidth,
maxHeight = constraints.maxWidth,
)
val placeable = measurable.measure(swappedConstraints)
layout(placeable.height, placeable.width) {
placeable.place(
x = -(placeable.width / 2 - placeable.height / 2),
y = -(placeable.height / 2 - placeable.width / 2)
)
}
}
If I have a layout with this modifier inside I can't use Intrinsic sizing, I get this error:
java.lang.IllegalArgumentException: Can't represent a size of 2147483515 in Constraints