https://kotlinlang.org logo
j

Jan Skrasek

07/18/2023, 2:19 PM
I'm running emulator Pixel 4 with SDK 33 and Pixel 7 with SDK 33 and I see different insets handling. Am I crazy, or is emulator able to differentiate - have different OSes for those different phones? What's more, I see the same bug on physical Pixel 5, I can understand that (Pixel 6 is first one to be ok). But I'm really puzzled where the insets handling differentiates when there is the same OS version. The navigation bar padding is empty for Pixel 4 (second screenshot). Code in thread.
Copy code
MaterialTheme {
    var shown by remember { mutableStateOf(false) }
    OutlinedButton(onClick = { shown = true }, Modifier.statusBarsPadding()) { Text("Show") }
    Text(
        Build.MANUFACTURER + Build.DEVICE + Build.BRAND + Build.MODEL,
        modifier = Modifier.padding(top = 80.dp)
    )
    if (shown) {
        ModalBottomSheet(
            onDismissRequest = { shown = false },
            sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true),
            windowInsets = WindowInsets(0),
        ) {
            Box(
                Modifier
                    .navigationBarsPadding()
                    .background(Color.Red)
                    .height(400.dp)
                    .width(150.dp)
            )
        }
    }
}
I'm puzzled mostly by the fact that on emulator it is reproducible with the same SDK API 🤔
o

Oleksandr Balan

07/18/2023, 6:12 PM
Could you try to resolve navigationBar padding outside the ModalBottomSheet and then apply it as a padding instead of .navigationBarsPadding() modifier and see if it changes something?
j

Jan Skrasek

07/18/2023, 6:26 PM
Yes I can. I do so for API < 30 where it is always needed but I'm totally lost why it doesn't work on Pixel 5 with A13.