在使用 ModalBottomSheetLayout 时,如何在 Jetpack compose 中使背景和状态栏透明

while using ModalBottomSheetLayout, how to make background and status bar transparent in Jetpack compose

我是 Jetpack 新手。我的应用程序在 MainScreen 中有 ModalBottomSheetLayout。现在,当我单击 MainScreen 的按钮时,它会显示 BottomSheet。 bottom sheet 打开时,背景透明,状态栏不透明。如何让它透明?

至此,可以使用accompanist library中的System UI Controller来控制statusBar Color和navigationBar color

implementation "com.google.accompanist:accompanist-systemuicontroller:0.18.0"
// Remember a SystemUiController
val systemUiController = rememberSystemUiController()
val useDarkIcons = MaterialTheme.colors.isLight

SideEffect {
    // Update all of the system bar colors to be transparent, and use
    // dark icons if we're in light theme
    systemUiController.setSystemBarsColor(
        color = Color.Transparent,
        darkIcons = useDarkIcons
    )

    // setStatusBarsColor() and setNavigationBarsColor() also exist
}