skydoves / FlexibleBottomSheet

🐬 Advanced Compose Multiplatform bottom sheet for segmented sizing, non-modal type, and allows interaction behind the bottom sheet similar to Google Maps.
Apache License 2.0
687 stars 30 forks source link

Scrim doesn't contain statusbar #2

Closed chandroidx closed 6 months ago

chandroidx commented 7 months ago

Please complete the following information:

Describe the Bug: With only Horizontal sides' insets scrim doesn't contain status bar 🧐

windowInsets = BottomSheetDefaults.windowInsets.only(WindowInsetsSides.Horizontal)

Expected Behavior:

A clear description of what you expected to happen.

skydoves commented 6 months ago

Hey @chandroidx, my apologies for the delayed response. It's expected that this task falls under the responsibility of the user.

To address this issue, you can easily change the status bar color using the following method:

  1. Add the accompanist dependency below:

    implementation("com.google.accompanist:accompanist-systemuicontroller:0.32.0")
  2. Observe the flexible bottom sheet's target value changes and change the statusbar color when the state value is not hidden like the example below:

  var currentSheetTarget by remember { mutableStateOf(FlexibleSheetValue.IntermediatelyExpanded) }
  val systemUiController = rememberSystemUiController()

  val primaryColor = MaterialTheme.colors.primary
  val scrimColor = Color.Black.copy(alpha = 0.65f)

  LaunchedEffect(currentSheetTarget) {
    if (currentSheetTarget == FlexibleSheetValue.Hidden) {
      systemUiController.setStatusBarColor(
        color = primaryColor
      )
    } else {
      systemUiController.setStatusBarColor(
        color = scrimColor
      )
    }
  }

  FlexibleBottomSheet(
    onDismissRequest = onDismissRequest,
    sheetState = rememberFlexibleBottomSheetState(
      flexibleSheetSize = FlexibleSheetSize(),
      isModal = true,
      skipSlightlyExpanded = false,
    ),
    onTargetChanges = { sheetValue ->
      currentSheetTarget = sheetValue
    },
    containerColor = Color.Black,
    scrimColor = scrimColor
  ) {
     ..
    }

This is the result as you've expected:

Screenshot 2023-12-17 at 2 50 43 PM

skydoves commented 6 months ago

Hey @chandroidx, I'm closing this issue for now. If you still face the same problem while addressing it with my suggestion, please reopen and discuss this anytime!