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
793 stars 36 forks source link

Initial state not working and not able to be set. #25

Open jasoneggleton-benevity opened 7 months ago

jasoneggleton-benevity commented 7 months ago

Initial state not working or not able to be set.

Tracing the library code, calling rememberFlexibleBottomSheetState calls a private function rememberFlexibleSheetState which has a default parameter of initialValue: FlexibleSheetValue = FlexibleSheetValue.Hidden. The public method does not take that parameter, however, the initial state should evaluate to hidden regardless.

In my most basic implementation, the sheet always starts off a not hidden, intermediately expanded.

 val sheetState = rememberFlexibleBottomSheetState(
      isModal = false
 )

FlexibleBottomSheet(
        windowInsets = WindowInsets(0, 0, 0, 0),
        onDismissRequest = { },
        sheetState = sheetState,
      ) {
        CircularProgressIndicator()
      }
}

It's not clear how to set the initial state, or if it's supported. Am I missing something obvious?

Wrapping the entire FlexibleBottomSheet in an if statement and check some state before showing works, but then it gets awkward to have a nice animation to hide it when that state changes, it would just abruptly disappear.

Expected Behaviour:

cacato86 commented 6 months ago

I had the same problem, any idea how to solve this @skydoves ?

Checking the code seems relative easy to fix, just adding the initialValue to the public fun rememberFlexibleBottomSheetState would work.

Thanks for your time!

zokirjonkodirov commented 2 months ago

Any updates on this issue?