Simple question, what's difference between ModalBottomSheetLayout and BottomSheetScaffold in compose?
if they both do the same things so what's the difference ?
there are several differences.
- ModalBottomSheetLayout is a modal window that does not allow you to interact with the rest of the screen. It will collapse if you touch the dimmed part of the screen. BottomSheetScaffold allows you to interact with the rest of the screen. BottomSheetScaffold allows you to keep the bottomSheet on the screen all the time. You can even disable gestures and don't allow users to close it. And you can add a peekHeight to make the bottomSheet visible even in collapsed state.
- ModalBottomSheetLayout creates a shadow above the rest of the screen, but it leaves a status bar unchanged (unlike BottomSheetDialogFragment which dims the status bar with the rest of the screen). BottomSheetScaffold does not dim the screen.
- As people already said BottomSheetScaffold provides the Slot API, it is a container. You can add a TopAppBar, a DrawerContent, a SheetContent, a Floating Action Button and a Snackbar. ModalBottomSheet contains only bottomSheet content and the rest of the screen.
So these components have different use cases.
ModalBottomSheetLayout is a modal window that can be used to ask user for a one-time action that requires immediate attention
and BottomSheetScaffold is a container that allows you to create a bottomSheet that makes continuous interaction with the content possible, for example you can add a textField to enter messages or a voice input button
Hope somebody will find my definitions useful :)