https://kotlinlang.org logo
Title
c

Colton Idle

11/10/2021, 2:53 AM
Simplifying a question I asked earlier: I need a modal bottom sheet that is only ever HIDDEN or EXPANDED. I never want it to be in a half-expanded state. Is that possible when using
ModalBottomSheetLayout
?
t

Tin Tran

11/10/2021, 4:14 AM
I think you can use
confirmStateChange
and reject if the status change to
HalfExpanded
. Once you do that the user have to swipe longer distance to close the bottom sheet. Another way is to extend the
ModalBottomSheetState
and set is
isHalfExpandedEnabled
to false
c

Colton Idle

11/10/2021, 5:32 AM
This might be a dumb question... but by "extend" ModalBottomSheetState, how would you do that?
I tried this too for your first suggestion, but not really sure how to use that api.
val bottomSheetState =
    rememberModalBottomSheetState(initialValue = ModalBottomSheetValue.Hidden, 
        confirmStateChange = {modalBottomSheetValue: ModalBottomSheetValue ->
        false
    })
Going to look up more docs/source now
Ah sweet. This worked
rememberModalBottomSheetState(ModalBottomSheetValue.Hidden, confirmStateChange = {
    it != ModalBottomSheetValue.HalfExpanded
})
Thanks @Tin Tran
🙌 1
t

Tin Tran

11/10/2021, 5:51 AM
Cool! You're welcome