dokar3 / sheets

Another feature-rich bottom sheet for Compose Multiplatform.
https://dokar3.github.io/sheets/
Apache License 2.0
198 stars 9 forks source link

[Feature Request] Support to Hide SystemBar (StatusBar + NavigationBar) #171

Open qiushui95 opened 1 month ago

qiushui95 commented 1 month ago

First, thank you for your amazing work on the Sheets library. It has been incredibly useful for my project.

I would like to request a feature to hide the SystemBar (both the StatusBar and NavigationBar) when the application is in full-screen mode. This would enhance the user experience by providing a more immersive interface.

Currently, when using Sheets in full-screen mode, the SystemBar remains visible, which can be distracting for users. Having an option to automatically hide these bars would be a great addition.

Thank you for considering this feature request. Your efforts and contributions are greatly appreciated.

Thanks

dokar3 commented 1 month ago

Thank you for your kind words!

For the request, I would suggest using CoreBottomSheetLayout and controlling the system bars manually. Because there seems to be no easy way to get a fullscreen dialog when enabling the immersive mode, the space of the status bar still remains.

If you know how to get rid of the status bar space, this snippet might also help:

BottomSheet(
    state = state,
    behaviors = DialogSheetBehaviors(
        extendsIntoStatusBar = true,
        extendsIntoNavigationBar = true,
    ),
) {
    val view = LocalView.current
    val window = (view.parent as DialogWindowProvider).window
    LaunchedEffect(view, window) {
        val insetsController = WindowCompat.getInsetsController(window, view)
        insetsController.systemBarsBehavior =
            WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
        insetsController.hide(WindowInsetsCompat.Type.systemBars())
    }

    // Content
}