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

mertceyhan

05/20/2022, 5:22 PM
Hi all! I have full-screen BottomSheetScaffold content and I want to make it scrollable inside the bottom sheet. I’ve seen this custom implementation but is there any support from the framework itself?

https://miro.medium.com/max/794/1*pcqyKlenZjgZAI_J7kF7wQ.gif

s

ste

05/20/2022, 6:17 PM
Well, I don't know if it can be achieved with material's BottomSheet, however I created my own component which handles that (see video). Basically, you need to use a
NestedScrollConnection
object to detect when the top bound is reached: if so, the next drags will control the bottom sheet offset
For instance, this is the logic I use
m

mertceyhan

05/21/2022, 7:33 AM
I’ll try that, thank you 🙏
j

jossiwolf

05/21/2022, 4:01 PM
@mertceyhan So you want the sheet to behave like in Ste's video example?
l

lesincs

05/22/2022, 8:57 AM
I think you can achieve that just based on
BottomSheetScaffold
, just giving the root composable of
sheetContent
a
Modifier.verticalScroll()
should work
m

mertceyhan

05/22/2022, 3:00 PM
Hey @jossiwolf! That’s right. I need to scrollable layout inside of a
BottomSheetScaffold
’s content
Hey @lesincs! I think this is not that easy. BottomSheetScaffold itself scrollable too. If you add
verticalScroll()
to the content’s modifier, you will get a crash because of the nested scroll.
l

lesincs

05/23/2022, 5:40 AM
Did you try it? I have the same scenario in my project, and it works like a charm, not only does it not crash, but it also has good scroll propagation.
m

mertceyhan

05/23/2022, 2:08 PM
This works, but there is a crash on BottomSheetScaffold
Copy code
ModalBottomSheetLayout(
    modifier = Modifier.fillMaxSize(),
    sheetState = sheetState,
    sheetContent = {
        Column(modifier = Modifier
            .fillMaxSize()
            .verticalScroll(rememberScrollState())) {
        }
    })
l

lesincs

05/24/2022, 12:53 PM
I didn’t get crash, the version is 1.1.1🤣
345 Views