I am starting to doubt whether Jetpack Compose is ...
# compose
s
I am starting to doubt whether Jetpack Compose is a step forward or backwards. It is really starting to get on my nerves , i was excited as building the UI is handsdown simple and quick but man the navigation is a mess specially with the bottomsheet. I mean now i have to worry about back handling too.
Can anyone explain me how to dismiss the ModalBottomSheet when user presses system back instead of exiting the whole screen? I am using Accompanist AnimatedNavigation as well as ModalBottomSheet
a
There are multiple solutions to handle navigation. Doesn't have to be the one from androidx
☝️ 2
s
@andylamax i don't know how your vague suggestion is supposed to help me in any way. Would appreciate if i can see code for real
👎 2
c
you're right. compose is a huge step backwards. just use xml. problem solved
☝️ 4
😂 2
s
Sorry for above harsh comments but its been a long day and i am really looking for some solutions. @Colton Idle do you know how we can disable BottomSheet to be dragged or close on outside touch? I used sheetGesturesEnabled = false but did not work . Also currently i am using ModalBottomSheetLayout and i can't find a way to disable half expansion state ?
c
There's a bunch of different questions asked here from you in this thread and it's not really clear which one you're talking about. It'll probably be better if you ask each one individually if I missed one below. First
navigation is a mess specially with the bottomsheet. I mean now i have to worry about back handling too.
You're probably better off using a bottom sheet as a navigation destination as it'll be added to the backstack. Therefore it'll react to back button. I believe you can only do that using the accompanist library on github? If you don't want to do that, you can just catch the back button and check if the bottom sheet is open. If it's open, then close it... Something like this
Copy code
BackHandler(enabled = !sheetIsShowing) { onBack() }
do you know how we can disable BottomSheet to be dragged
there should be an arg for it. If that doesn't work, id file a bug
or close on outside touch?
I thought this was handled automatically? idk. Could have sworn it closes automatically for me.
ModalBottomSheetLayout and i can't find a way to disable half expansion state
I think I opened up a bug about this, but there is a workaround I think
Copy code
val myBottomSheetState =
    rememberModalBottomSheetState(
        ModalBottomSheetValue.Hidden,
        confirmStateChange = { it != ModalBottomSheetValue.HalfExpanded })
Anyway. My answers aren't all that great I guess. But you should really ask them one at a time. showing what you tried. etc.
s
Yes @Colton Idle i tried Accompanist Library and it is quite easy as it can handle back navigation for us automatically , also bottomsheet can be navigated as a destination but there is a problem with it. And the problem is bottomsheet half expands at first launch and switches to half expanded form on swipe down. So i switched to Normal Navigation without bottomsheet and handled bottomsheet navigation manually . This way i don't get half expanded state. But i also want the bottomsheet to be non canceleable meaning swiping down should do nothing or ven touch outside should not close the bottomsheet . I used sheetGesturesEnabled = false flag but it does nothing in my case.
c
Someone had a comment about that same thing yesterday. Sounds like that argument isn't working. I'd file a bug.
s
I read an issue or request in accompanist github to support halfExpandSupport flag to enable or disable it as per needed. I also commented along with that if we get option to disable drag gesture in Accompanist ModalBottomSheet that would be really helpful
👍 1
344 Views