https://kotlinlang.org logo
Title
c

Chris Fillmore

12/09/2021, 5:53 PM
I am using
ModalBottomSheetLayout
and
BottomSheetNavigator
and I’d like my bottom sheets to open into
Expanded
state. The
HalfExpanded
state doesn’t really suit my use case as there is often a lot of content in the sheet, and/or the keyboard is up. But, curiously,
ModalBottomSheetState.expand()
is
internal
and it’s not obvious to me how I could manipulate
SwipeableState.anchors
. Any advice? Thanks!
I’m wondering if I might be better served by using
BottomSheetScaffold
j

jossiwolf

12/09/2021, 7:34 PM
This is because whether the sheet should be half-expanded or expanded is just an implementation detail right now; the only intention you can express is to show the sheet. Right now it's not really possible to do this but it will be possible to configure your
ModalBottomSheetLayout
soon (CL: https://android-review.googlesource.com/c/platform/frameworks/support/+/1891098, just need to update a small thing). RE:
BottomSheetNavigator
- you shouldn't be using a
ModalBottomSheetState
explicitly if you are using Accompanist Nav Material, prefer using
rememberBottomSheetNavigator
which sets this up for you. By holding a
ModalBottomSheetState
on your own, you are risking
BottomSheetNavigator
getting out of sync if you control it manually - the
BottomSheetNavigator
constructor that takes the sheet state will be made internal soon too to avoid this. Once we merge the CL upstream in Material, I'll add an API for this asap in Accompanist. (Hopefully something like end of next week or the week after)
fwiw if you are in fact in control of the state, you can use
animateTo(ModalBottomSheetValue.Expanded
instead of
expand()
c

Chris Fillmore

12/09/2021, 7:46 PM
Thanks Jossi. I'll keep an eye out for your updates. Thanks for the work on bottom sheets!