I'm trying to create a modifier to "layout stuff v...
# compose
d
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)
Copy code
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:
Copy code
java.lang.IllegalArgumentException: Can't represent a size of 2147483515 in Constraints
I can provide the full stack trace if needed
r
Isn’t this what
Column
does?
d
I'm not sure I understand what you mean
r
I mean laying out items vertically is supposed to be a job for a
Column
. I could be missing the motive behind your question though.
d
oh, that's not what the modifier does... It rotate 90 degree whatever composable you apply it to. But if you just use rotate it will take space as if you didn't rotate, this fixes that and compute the space it actually takes after rotating