Pablo
07/18/2024, 4:46 PM@Composable
fun SectionScreen(
section: Section,
modifier: Modifier = Modifier,
content: @Composable (modifier: Modifier) -> Unit,
) {
Scaffold(
modifier = modifier,
topBar = {
Text(text = "Top Section Header -> sectionID: ${section.sectionID}")
},
bottomBar = {
Text(text = "Top Section Footer -> sectionID: ${section.sectionID}")
}
) { innerPadding ->
content(Modifier.padding(innerPadding))
}
}
Children:
@Composable
fun InfoSectionScreen(section: Section, modifier: Modifier = Modifier) = SectionScreen(
section = section,
modifier = modifier,
) {
Column(
modifier = modifier
) {
Text(text = "Section Content -> sectionID: ${section.sectionID}")
}
}
As you can see, the issue is in this line:
content(Modifier.padding(innerPadding))
I need to pass the innerpAdding but I don't know how to receive it on InfoSectionScreenMitch Ware
07/18/2024, 6:48 PMcontent
apply the modifier itself?
Parent:
@Composable
fun SectionScreen(
section: Section,
modifier: Modifier = Modifier,
content: @Composable (padding: Dp) -> Unit,
) {
Scaffold(
modifier = modifier,
topBar = {
Text(text = "Top Section Header -> sectionID: ${section.sectionID}")
},
bottomBar = {
Text(text = "Top Section Footer -> sectionID: ${section.sectionID}")
}
) { innerPadding ->
content(innerPadding)
}
}
Child:
@Composable
fun InfoSectionScreen(section: Section, modifier: Modifier = Modifier) = SectionScreen(
section = section,
modifier = modifier,
) { paddingValue ->
Column(
modifier = modifier.padding(paddingValue)
) {
Text(text = "Section Content -> sectionID: ${section.sectionID}")
}
}
Mitch Ware
07/18/2024, 6:49 PMDp
is the right type for the padding param, but hopefully you get the idea)Pablo
07/18/2024, 6:49 PMPablo
07/18/2024, 6:49 PMPablo
07/18/2024, 6:50 PMcontent: @Composable (padding: Dp) -> Unit,
it should be content: @Composable (paddingValues: PaddingValues) -> Unit,
Pablo
07/18/2024, 6:50 PM