How to control status bar and nav bar colors when ...
# compose
e
How to control status bar and nav bar colors when ModalBottomSheet is displayed? The app uses Material3 only with darkColors and in activity
enableEdgeToEdge
is configured as
Copy code
enableEdgeToEdge(
    statusBarStyle = SystemBarStyle.dark(Color.TRANSPARENT),
    navigationBarStyle = SystemBarStyle.dark(Color.argb(0x80, 0x1b, 0x1b, 0x1b))
)
Overall, everything works well, but when the ModalBottomSheet is displayed, the colors of the status bar and navigation bar change depending on the device's dark theme
a
@Erlan Amanatov the
enableEdgeToEdge()
changes the colors of the window of your activity. modals (such as the modalbottomsheet) have their own separate window, so you need to do changes on that. I am not aware how to hold access to it. Worst case scenario, you can always use the Compose Unstyled ModalBottomSheet which gives you access to the
LocalModalWindow
which you can style as you like (code example).
👍 1
s
Looking at their implementation, they seem to be calling
Copy code
WindowCompat.getInsetsController(window, window.decorView).apply {
 isAppearanceLightStatusBars = properties.isAppearanceLightStatusBars
 isAppearanceLightNavigationBars = properties.isAppearanceLightNavigationBars
}
right here: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]odalBottomSheet.android.kt;l=550-553?q=ModalBottomSheetDialog Going up the call stack, there seems to take in a
properties
parameter, where you can give your own values https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]se/material3/ModalBottomSheet.kt;l=136-140?q=ModalBottomSheet so you can decide if it's dark or not. Looks very straightforward to me, give it a shot and lmk if it works or not
☝🏼 1
e
@Stylianos Gakis Yes, first of all, I looked at all the parameters of the
ModalBottomSheet
function, thinking that there might be configuration parameters, but there aren't any. I am using version 1.3.0 of the dependency
androidx.compose.material3:material3
, and
ModalBottomSheetProperties
looks different there:
Copy code
actual class ModalBottomSheetProperties(
    val securePolicy: SecureFlagPolicy = SecureFlagPolicy.Inherit,
    actual val shouldDismissOnBackPress: Boolean = true,
)
@Alex Styl Yes, I was aware of the existence of your project composeunstyled.com and had considered that opiton, thank you
👌 1
@Stylianos Gakis It seems that the changes in your link will only be available in version 1.4.0-alpha03, which hasn't been released yet
@huthefa didn't understand your message, could you rephrase it?
s
I see, then you either wait for the alpha release or look for any of the alternatives. It's your choice 😊
e
yea, looks like I will wait for the next stable release