Thread
#compose
    Mikael Alfredsson

    Mikael Alfredsson

    2 years ago
    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.
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    You can pass a custom Arrangement to Column to implement padding between its children.
    Mikael Alfredsson

    Mikael Alfredsson

    2 years ago
    but wrapping, as like decorating them is not possible? this does not seems to work;
    Column {
        listOf(
                Text("Line1"),
                Text("Line2")
        ).map { Box(modifier = Modifier.padding(12.dp)) { it } }
    }
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    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.
    Mikael Alfredsson

    Mikael Alfredsson

    2 years ago
    I need to get my head around exactly how it composes things 🙂 Thanks for the hints
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    Leland has given a few talks and written a few articles on this that are really helpful.
    Mikael Alfredsson

    Mikael Alfredsson

    2 years ago
    youtube / medium or other places?
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    Google "leland richardson compose", there's a bunch