https://kotlinlang.org logo
#compose-android
Title
# compose-android
a

Atul Gupta

11/26/2023, 7:20 PM
Inside a parent nested scroll container like bottom sheet, I want one child lazy list to not part in nested scrolling(i.e., it should not ask parent prescroll and consume all the scroll event). Is this possible to do in compose?
I was able to do it in view world using the code below
Copy code
class BottomSheetExcludedNestedScrollViewIds<T : View> @JvmOverloads constructor(
    context: Context,
    attrib: AttributeSet? = null,
) : BottomSheetBehavior<T>(context, attrib)
{
    override fun onStartNestedScroll(
        coordinatorLayout: CoordinatorLayout,
        child: T,
        directTargetChild: View,
        target: View,
        axes: Int,
        type: Int,
    ): Boolean
    {
        return if (target.id in listOfExcludedNestedScrollViewIds)
        {
            // excluding the nested scroll for few ids present in `listOfExcludedNestedScrollViewIds`
            false
        }
        else
        {
            super.onStartNestedScroll(
                coordinatorLayout,
                child,
                directTargetChild,
                target,
                axes,
                type
            )
        }
    }

    /**
     * List of ids for which nested scroll will be ignored
     */
    val listOfExcludedNestedScrollViewIds = arrayListOf<Int>()
}
Or is this currently not possible?
m

MR3Y

11/29/2023, 6:22 PM
Just saw this https://github.com/skydoves/FlexibleBottomSheet specifically, "Nested Scrolling" section which might be what you want here?
a

Atul Gupta

11/29/2023, 6:31 PM
Thanks a lot 🤩 This is what I am looking for
👌 1
Tried it seems to work but this lib is 0.1.0 version and also uses private window api using reflection 😭
🙀 1
m

MR3Y

11/30/2023, 11:16 AM
Haven't dived into its internals yet (as the library is still very new indeed), but yeah I guess this is basically the tradeoff here as apparently there is no public API or an easy way to do this.
🥲 1