Is it possible to add a modifier or wrap all child...
# compose
m
Is it possible to add a modifier or wrap all child composeables in for example a Column. What I want to achieve right now is to be able to add padding around each component but the question is a bit broader.
z
You can pass a custom Arrangement to Column to implement padding between its children.
💡 2
m
but wrapping, as like decorating them is not possible? this does not seems to work;
Copy code
Column {
    listOf(
            Text("Line1"),
            Text("Line2")
    ).map { Box(modifier = Modifier.padding(12.dp)) { it } }
}
z
That exact example does not work, because most UI widget composables, like
Text
, do not return anything. However, some other options are: - You could make your list contain composable functions (eg
{ Text() }
, and then call those functions from your wrapper. - You can write a custom
Layout
that modifies the measurement/placement of all its children. This is a more general version of the
Column
-specific arrangement one.
m
I need to get my head around exactly how it composes things 🙂 Thanks for the hints
z
Leland has given a few talks and written a few articles on this that are really helpful.
m
youtube / medium or other places?
z
Google "leland richardson compose", there's a bunch