John O'Reilly
11/24/2024, 5:49 PMignoresSafeArea
on iOS) where there's nested Scaffolds (outer one contains bottomBar
and inner one the topBar
)?John O'Reilly
11/24/2024, 5:49 PMtopBar
in this scenarioJohn O'Reilly
11/24/2024, 5:51 PMScaffold
but still not sure why
Modifier.consumeWindowInsets(WindowInsets.systemBars)
John O'Reilly
11/24/2024, 5:51 PMJohn O'Reilly
11/24/2024, 5:54 PMAndrei Salavei
11/25/2024, 9:51 AMJohn O'Reilly
11/25/2024, 9:52 AMJohn O'Reilly
11/25/2024, 6:25 PMJohn O'Reilly
11/25/2024, 6:26 PMfun App() {
MaterialTheme {
Scaffold(
// have bottom bar here for example but same behaviour
// regardless
) {
// this padding here seems to cause the issue
Column(Modifier.padding(it)) {
// "nested" Scaffold with top app bar
// (normally in some nexted composable)
Scaffold(
topBar = { TopAppBar(title = { Text("Some title") }) }
) {
Column(Modifier.padding(it)) {
Text("Hi")
Text("there")
}
}
}
}
}
}
John O'Reilly
11/25/2024, 6:29 PMJohn O'Reilly
11/25/2024, 8:02 PMColumn(Modifier.padding(it))
for thatAndrei Salavei
11/27/2024, 8:12 AMenableEdgeToEdge()
on Android. If you enable it, you will see that material3.Scaffold behaves identically on both platforms. There are many ways to fix it. For example, using modifier = Modifier.consumeWindowInsets(innerPadding)
.John O'Reilly
11/27/2024, 8:20 AMedgeToEdge()
on Android.....I don't think you see same padding at top in this case?Andrei Salavei
11/27/2024, 8:40 AMAndrei Salavei
11/27/2024, 8:41 AMJohn O'Reilly
11/27/2024, 8:57 AMJohn O'Reilly
11/27/2024, 8:58 AMconsumeWindowInsets
should be called to fix this?John O'Reilly
11/27/2024, 9:06 AMJohn O'Reilly
11/27/2024, 9:15 AMfun App() {
MaterialTheme {
Scaffold(
topBar = { CenterAlignedTopAppBar(
title = { Text("Some title") },
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(
containerColor = MaterialTheme.colorScheme.primaryContainer,
)
)},
bottomBar = { BottomBar() }
) {
Column(Modifier.padding(it)) {
LazyColumn {
items(50) { index ->
Text(text = "Item: ${index+1}")
}
}
}
}
}
}
Andrei Salavei
11/27/2024, 9:57 AMJohn O'Reilly
11/27/2024, 9:58 AMAndrei Salavei
11/27/2024, 10:30 AMJohn O'Reilly
11/27/2024, 10:32 AMI sill don't see issues with top bar behavior as they are identical on both platforms.are you not seeing same as following there for that case....or is suggestion that this is expected still? You also mentioned about using
consumeWindowInsets
...where would that be used?Andrei Salavei
11/27/2024, 12:43 PMor is suggestion that this is expected still?Yes, the top bar behaviour that I see is the expected one. I have to mention that we're didn't change the Scaffold behavior on iOS - basically it shares the same code with Android. If you think there is a bug, you can file an issue in Google Issue Tracker.
You also mentioned about usingThat was from the Scaffold documentation, but it seems it does not work for inner Scaffold. After some tries I found the fix:...where would that be used?consumeWindowInsets
Scaffold {
Column(Modifier.padding(it)) {
Scaffold(
topBar = { TopAppBar(title = { Text("Some title") }, windowInsets = WindowInsets(0.dp)) },
bottomBar = { BottomAppBar(windowInsets = WindowInsets(0.dp)) { } }
) {
...
}
}
}
John O'Reilly
11/27/2024, 12:57 PMJohn O'Reilly
11/27/2024, 12:58 PMJohn O'Reilly
11/27/2024, 12:59 PMconsumeWindowInsets
as workaround but that seemed to remove too much padding on AndroidJohn O'Reilly
11/27/2024, 1:01 PMWindowInsets
approach as well