Search code examples
androidkotlinandroid-jetpack-compose

Jetpack Compose Immersive mode Dialog


I have an Immersive application that's hiding the system bar using the Compose accompanist library in system navigation

val systemUiController: SystemUiController = rememberSystemUiController()

systemUiController.isStatusBarVisible = false // Status bar
systemUiController.isNavigationBarVisible = false // Navigation bar
systemUiController.isSystemBarsVisible = false // Status & Navigation bars
systemUiController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

This works fine but when I open a new alertDialog the system navigations show up again. Looking for a compose way of preventing the system bar to appear when AlertDialog or DropdownMenu is opened.

My code is basically a scaffold with a variable that controls showing/hiding the AlertDialog from the ViewModel.

Here is a gif to make it more clear. You can see the system navigation are hidden normally but when I clicked on DropDownMenu and when the AlertDialog they appear. enter image description here


Solution

  • Want to answer my own question in case anyone else is looking for a solution. Please follow the Github conversation