I have a `BottomSheetScaffold` with the following ...
# compose
l
I have a
BottomSheetScaffold
with the following `scaffoldState`:
Copy code
val scaffoldState = rememberBottomSheetScaffoldState(
    bottomSheetState = rememberStandardBottomSheetState(
        initialValue = Hidden,
        skipHiddenState = false,
        confirmValueChange = { newValue ->
            println("new value: $newValue")
            if (newValue == Hidden) viewModel.onCodeBottomSheetClosed()
            true
        }
    )
)
However the behavior of the state in
confirmValueChange
is quite weird (see 🧵).
Opening bottom sheet with `scaffoldState.bottomSheetState.expand()`:
Copy code
new value: Expanded
new value: PartiallyExpanded
new value: PartiallyExpanded
Closing bottom sheet by swipe:
Copy code
sheet new value: PartiallyExpanded
sheet new value: PartiallyExpanded
sheet new value: Expanded
Closing bottom sheet by explicitly calling `scaffoldState.bottomSheetState.hide()`:
Copy code
new value: Hidden
new value: PartiallyExpanded
Why does it always default to
PartiallyExpanded
? Why doesn't it go to
Hidden
state when just swiped, but does so when explicitly calling
hide()
?
It doesn't seem to respect the
initialValue = Hidden
as well.
As to what my viewModel does in
onCodeBottomSheetClicked()
, it just sets the
sheetContent
to an empty lambda.
Ok, it looks like the solution is to use
Copy code
bottomSheetState = rememberModalBottomSheetState(
    skipPartiallyExpanded = true,
    confirmValueChange = { newValue ->
        if (newValue == Hidden) viewModel.onCodeBottomSheetClosed()
        true
    }
)
instead of
rememberStandardBottomSheetState()
.
c
It’s by definition that the standard bottom sheets are not totally hidden. https://m3.material.io/components/bottom-sheets/guidelines
l
Yes, although when I overwrite the initial state to
Hidden
I would expect it.
Also when I swipe it down I expect it to hide.
Also I set
skipHiddenState
to
false
c
No, it’s always peeking up.
l
Why then these parameters?
🤷🏻‍♂️ 1
👀 1