Should a ComposeView inside bottom sheet (behavior...
# compose
b
Should a ComposeView inside bottom sheet (behavior) handle scroll events correctly? As an example from the compose documentation:
Copy code
Simple nested scrolling requires no action on your part. Gestures that initiate a scrolling action are propagated from children to parents automatically, such that when the child can't scroll any further, the gesture is handled by its parent element.
When I scroll up in the bottom sheet, the bottom sheet first resizes to fill the screen then properly scrolls to the bottom of the content, which is the expected behavior. However, when trying to scroll back to the top of the content (ie dragging down), the bottom sheet starts to collapse instead of scrolling the content down first.
My ComposeView:
Copy code
<androidx.compose.ui.platform.ComposeView
   android:id="@+id/bottom_sheet"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   app:behavior_hideable="true"
   app:behavior_peekHeight="200dp"
   app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" />
And my content in compose:
Copy code
Column(
   modifier = Modifier.verticalScroll(scrollState)
) { ... }
a
If all the scrollable containers are implemented in Compose UI, nested scroll will work out of the box. But this isn't the case if you are using scrollable containers in both traditional view and Compose UI, in which case you need some kind of bridge such as this.
­čĹŹ 1
b
I have a complex map view that sits outside of compose. Is it possible to pull the bottom sheet view from there to the composable? Can you have a bottom sheet in a composable if the entire activity view does not exist in that composable.
Thinking about this a different way, maybe letting the traditional view handle the scroll is a better option.
Copy code
<FrameLayout
    android:id="@+id/bottom_sheet"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:behavior_hideable="true"
    app:behavior_peekHeight="200dp"
    app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" >

    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <androidx.compose.ui.platform.ComposeView
            android:id="@+id/compose_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        </androidx.compose.ui.platform.ComposeView>

    </androidx.core.widget.NestedScrollView>

</FrameLayout>
And of course removing the Modifier.verticalScroll(scrollState) from the compose column.