Joel Denke
01/22/2024, 5:10 PMMofe Ejegi
01/22/2024, 5:29 PMWindowCompat.setDecorFitsSystemWindows(window, false)
iOS in ContentView.swift:
ComposeView().ignoresSafeArea(.all)
This lets you draw from edge-to-edge on both platforms.
Then you can use Compose's systemBarsPadding()
if you want to still respect the paddingsMofe Ejegi
01/22/2024, 5:31 PMJoel Denke
01/22/2024, 5:47 PMMofe Ejegi
01/22/2024, 5:57 PMsystemBarsPadding()
modifier applied to the content to avoid the edge to edge drawing. You can also apply _statusBarsPadding_()
or _navigationBarsPadding_()
independently if you want. On the screen you want to draw from edge to edge, don't apply this padding modifier. Take a look at this my slack post on the #compose channel. You can see that the background is drawn from edge to edge but the logo uses the system padding.
The second approach, which I believe could work in theory is to create an expect/actual function that uses a SideEffect
to dynamically update the edge to edge drawing requirements for the MainActivity and the Root SwiftUI ComposeView. I'm not sure if this would work, and personally, it's not worth the hassle for me.Joel Denke
01/22/2024, 5:59 PMMofe Ejegi
01/22/2024, 6:07 PM@Composable
fun MyScreen(
viewState: MyViewState,
eventProcessor: (MyViewEvent) -> Unit,
) {
Box(modifier = Modifier.fillMaxSize().systemBarsPadding().imePadding()) {
// Your content here...
}
}
I added imePadding()
in case you've got a text field in there.Mofe Ejegi
01/22/2024, 6:12 PMsystemBarsPadding()
.
Compose MP is cool, it respects the different values of system paddings based on the platform.Joel Denke
01/23/2024, 8:26 AMWindowCompat.setDecorFitsSystemWindows(window, false)
enableEdgeToEdge(SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT))
super.onCreate(savedInstanceState)
setContent {
....
}
Now just need to learn how to make all Material 3 components like topbar understand these system bar paddings 😄Stylianos Gakis
02/06/2024, 8:44 AMenableEdgeToEdge
calls WindowCompat.setDecorFitsSystemWindows(window, false)
internally too, so you can avoid calling that alltogetherJoel Denke
02/06/2024, 9:35 AM