Anyone else had an issue if you have a BottomSheet...
# compose
n
Anyone else had an issue if you have a BottomSheetDialogFragment with a ComposeView in the onCreateView that has a column with vertical scroll, that you cant scroll the content up without first doing a motion to scroll it down? (it drags the dialog down instead of scrolling the content up). I would assume that the scrollview would intercept the drag and scroll and not pass it to the parent dialog for dragging?
if anyone is curious I found a hack around it, that blocks dragging in the BottomSheetDialog if scrollState.value > 0
j
cc @levima
🙏 1
l
I think it really depends on how things are wired up? If nested scroll interop is activated in the bottom sheet?
a
If you are using Compose 1.2.0, apply
Modifier.nestedScroll(rememberNestedScrollInteropConnection())
to the list. If you are using an older version, you can copy the source from here.
🙏 1
⬆️ 1
n
Thanks @Albert Chang seems to work pretty well, I have one small issue thou, in below code my BottomSheetDialogFragment is only draggable when I drag the area in ScrollableComposeContent. Do I need to do something in my ComposeHeader to make drags in its area make the dialog dragged?
Copy code
Column(
                        Modifier
                            .padding(top = 0.dp, start = 8.dp, end = 8.dp)
                            .fillMaxWidth()
                            .nestedScroll(rememberNestedScrollInteropConnection())
                    ) {
                        ComposeHeader(Modifier)
                        ScrollableComposeContent(Modifier.verticalScroll(rememberScrollState()))
                    }
l
Hey @nlindberg I think your use case is pretty similar to the one in comment 49 here https://issuetracker.google.com/issues/174348612#comment49. Maybe the solution proposed there might make sense for you?
n
thx @levima, ye following the solution proposed by wrapping the header in a scrollable box seems to work. Not the most readable code 😛 since the header is never scrollable but just have this modifier to propegate drag ?
Copy code
Box(Modifier.verticalScroll(rememberScrollState())) {
    ComposeHeader(Modifier)
}
l
Not sure about your complete use case, but this might also work:
Copy code
Column(
                        Modifier
                            .padding(top = 0.dp, start = 8.dp, end = 8.dp)
                            .fillMaxWidth()
                            .nestedScroll(rememberNestedScrollInteropConnection())
                            .verticalScroll(rememberScrollState())
                    ) {
                        ComposeHeader(Modifier)
                        ScrollableComposeContent()
                    }
🙏 1
234 Views