Colton Idle
03/09/2021, 1:11 AM@Composable
fun PadMyContentWithTitle(
modifier: Modifier = Modifier,
header: String = "",
content: @Composable ColumnScope.() -> Unit
) {
Column(modifier) {
Text(text = header)
content(modifier.padding(horizontal = 16.dp))
}
}
I want to have a composable with that essentially takes in another compasable (slot) but pads it on the left and right and adds a Text on top of it. This is what I came up with but I can't actually call content(modifier.padding(horizontal = 16.dp))
. Is the way around this just to nest the context in a Box/Column and apply padding to that?Timo Drick
03/09/2021, 2:14 AMcontent: @Composable ColumnScope.(PaddingValues) -> Unit
Scaffold do it this way. But it depends on what you want.Colton Idle
03/09/2021, 3:05 AMcontent(ColumnScope, PaddingValues(horizontal = 16.dp))
I did look into the Scaffold source but I am admittedly a little bit lost.Colton Idle
03/09/2021, 3:08 AMIan Lake
03/09/2021, 3:34 AMTimo Drick
03/09/2021, 8:44 AM@Composable
fun PadMyContentWithTitle(
modifier: Modifier = Modifier,
header: String = "",
content: @Composable ColumnScope.() -> Unit
) {
Column(modifier) {
Text(text = header)
Column(modifier.padding(horizontal = 16.dp)) {
content()
}
}
}
Colton Idle
03/09/2021, 3:59 PM