compose-navigation-reimagined icon indicating copy to clipboard operation
compose-navigation-reimagined copied to clipboard

BottomSheet support

Open hrach opened this issue 1 year ago • 5 comments

Hello, I cannot find any mention of bottomsheet. How does it work with this library? Is it expected to use DialogNavigator to show those bottomsheet? I expect that bottomsheet is a bit more complicated as some swiping down should skip further animation (the swipe already animated the destination removal or it should continue animating). Thank you

hrach avatar Aug 20 '22 14:08 hrach

@hrach Hi, there is no current integration with ModalBottomSheetLayout and BottomSheetScaffold. And yes, it is actually not that trivial to implement. I'm planning to give it a go in the future, but not yet.

For now, I can suggest using DialogNavHost with BottomSheetDialog from this library: https://github.com/holixfactory/bottomsheetdialog-compose

I've tested it and it works great. ~~Just be aware of this small issue: https://github.com/holixfactory/bottomsheetdialog-compose/issues/1~~

~~Until developers fix the issue, it can be handled in this way (see how dismissCalled prevents the second accidental pop):~~ Use at least version 1.0.2 of the specified library:

val navController = rememberNavController<DialogNavHostDestination>(
    initialBackstack = emptyList()
)

DialogNavHost(navController) { destination ->
    BottomSheetDialog(onDismissRequest = {
        navController.pop()
    }) {
        when (destination) {
            DialogNavHostDestination.First -> FirstDialogLayout(
                toSecondDialogButtonClick = { navController.navigate(DialogNavHostDestination.Second) }
            )
            DialogNavHostDestination.Second -> SecondDialogLayout()
        }
    }
}

olshevski avatar Aug 21 '22 17:08 olshevski

Thank you for the response. What's the motivation not to use the material bottom sheet?

hrach avatar Aug 21 '22 17:08 hrach

I'm not sure what you mean by "material bottom sheet". They are all material 🙂

If you mean the default ModalBottomSheetLayout and BottomSheetScaffold, I haven't said I'm against them, they just require a special treatment. It would probably be a separate type of NavHost that wraps around ModalBottomSheetLayout and BottomSheetScaffold.

olshevski avatar Aug 21 '22 17:08 olshevski

Yes, I mean the Compose Material implementation. Bringing the View system or even the View's bottomsheet behavior seems quite non-optimal to me and we will always lack the latest features for Compose.

hrach avatar Aug 22 '22 08:08 hrach

But it is the same as using composable Dialogs. It is just a separate window with a compose layout inside. I've used this library in a separate project and find it so much more convenient for simple cases rather than ModalBottomSheetLayout and BottomSheetScaffold.

But again, I'm not strictly against Compose's implementations, just give me the time, I have ideas on how it could be done better. But not at these exact moment. Sorry for inconvenience.

olshevski avatar Aug 22 '22 08:08 olshevski

BottomSheetNavHost is finally implemented as part of reimagined-material artifact in version 1.3.0.

olshevski avatar Nov 01 '22 19:11 olshevski