Bottom Sheet's scroll behavior is triggered instead of the Column's scroll behavior

102 Views Asked by At

I have a BottomSheetDialogFragment. In the OnCreateView, I return a ComposeView. Inside the ComposeView, I have a Column with a Vertical Scroll since the column has quite a few items.

When I swipe up the bottom sheet, the bottom sheet fills the screen and the entire column is scrolling up, which is the expected nested scroll behaviour. But when I swipe down or scroll down, the bottom sheet's scroll behaviour is triggered instead of the column's scroll behaviour.

The expected behaviour is that the column's scroll behaviour should complete, i.e., it should scroll down until the column's first item is visible, and when the column could no longer scroll down, the bottom sheet's scroll behaviour should then kick in.

Is there any way to fix this scroll discrepancy?

@AndroidEntryPoint
class DemoBottomSheetDialogFragment : BottomSheetDialogFragment() {

 override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
 ): View {
    
    return ComposeView(requireContext()).apply {

        setContent {

            val scrollState = rememberScrollState()
            val connection = remember {
            object : NestedScrollConnection {

              }
            }

            Box(
                    Modifier
                    .fillMaxSize()
                    .nestedScroll(connection)
             ) {
                 Column(
                       Modifier
                        .verticalScroll(scrollState)
                        .nestedScroll(connection)
                  ) {
                     //Column content
                    }
                }
             }
          }
      }
  }
0

There are 0 best solutions below