I'm trying to implement a `SubcomposeLayout` that ...
# compose
a
I'm trying to implement a
SubcomposeLayout
that functions as a hybrid between
BoxWithConstraints
and a
Column
. Specifically the signature looks like this:
Copy code
interface ColumnWithPlaceablesScope : ColumnScope {
    val constraints: Constraints
    val placeables: List<Placeable>
}

@Composable
fun ColumnWithPlaceables(
    modifier: Modifier = Modifier,
    verticalArrangement: Arrangement.Vertical = <http://Arrangement.Top|Arrangement.Top>,
    horizontalAlignment: Alignment.Horizontal = Alignment.Start,
    content: @Composable ColumnWithPlaceablesScope.() -> Unit
)
I want it to support everything in
ColumnScope
e.g.
Modifier.weight
, but because everything in
Column.kt
is internal, I'm having to recreate everything from scratch. Is there a simpler way to do this that I'm missing?
a
It might be helpful to know your use case more for what you’re trying to build - if you need all of the functionality combined into one place, it’s going to be complicated. I’ve found the most success with custom layouts that only manipulate 2 or 3 direct children (which themselves could be much more complicated layouts), where the custom part is only for doing the thing that I couldn’t do easily with other components
a
I'm trying to build a custom Scaffold for an app I'm making for e-ink devices: will take in a header and a footer component and then fill the rest of the screen with another Column (that holds the items), calculating pagination based on how big that main content is. The header and footer need to be able to display and control that pagination, though, so they're included inside the SubcomposeLayout, and I want to measure everything beforehand to know how much space is available for the main Column