https://kotlinlang.org logo
#compose
Title
# compose
l

Lukasz Kalnik

08/04/2022, 2:51 PM
What is the purpose of the
content
in
ModalBottomSheetLayout
when
sheetContent
takes all the contents of the bottom sheet? What if I want to display this modal bottom sheet over different screens, should I just then leave
content
empty?
c

curioustechizen

08/04/2022, 2:57 PM
I had the same confusion. I then realized that
ModalBottomSheetLayout
is not meant for displaying a bottom sheet. It is meant for displaying a screen along with a bottom sheet. The
sheetContent
by itself does not exist in isolation, it is always shown over
content
. If you want to show the sheet over different screens then you have 2 choices: 1. Include the
ModalBottomSheetLayout
itself high enough in the tree such that it is a common parent of all screens where you want to show the bottom sheet 2. Make every screen that you want to have bottom sheet to use
ModalBottomSheetLayout
for its layout. I went for option 2 because I only have a handful of screens where I need this. You could make this less repetitive by creating your own wrapper around
ModalBottomSheetLayout
and just exposing
content
as a slot for consumers.
y

Yves Kalume

08/04/2022, 2:57 PM
content
contains de main content of the page, and
sheetContent
contains the bottom sheet content
l

Lukasz Kalnik

08/04/2022, 3:22 PM
Ok, thank you for the explanations! That helps a lot! 🙏
8 Views