Steffen Funke
11/09/2021, 9:19 PMBottomSheetDialogFragment
(can’t change that to Compose unfortunately), which contains a LazyColumn
.
I am kind of stuck figuring out, why the scrolling does not work as expected, e.g. why the BottomSheetDialogFragment
intercepts the LazyColumn
scrolling.
Is there any flag / setting / modifier for LazyColumn
regarding nested scrolling, that I am missing?
Expected behaviour would be that I can drag the Sheet down as soon as I have scrolled up completely, but not before. Cannot convert it to a Column
though, since the items need to be lazy loaded.
👉 Video attached in 🧵.
Any ideas welcomed. Thank you!Steffen Funke
11/09/2021, 9:19 PMSteffen Funke
11/09/2021, 10:20 PMWill Shelor
11/10/2021, 3:33 AMWill Shelor
11/10/2021, 3:34 AMWill Shelor
11/10/2021, 3:37 AMclass ComposeBottomSheetDialogFragment(
val sheetContent: @Composable ColumnScope.() -> Unit
) : DialogFragment() {
private var onDismissListener: (() -> Unit)? = null
@OptIn(ExperimentalMaterialApi::class)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View {
super.onCreateView(inflater, container, savedInstanceState)
setStyle(STYLE_NO_FRAME, R.style.FullScreenDialog)
dialog?.let {
val width = ViewGroup.LayoutParams.MATCH_PARENT
val height = ViewGroup.LayoutParams.MATCH_PARENT
it.window?.setLayout(width, height)
it.window?.setBackgroundDrawable(ColorDrawable(resources.getColor(R.color.transparent)))
}
return inflater.inflate(R.layout.fragment_checkout_landing_screen, container, false).apply {
this.findViewById<ComposeView>(R.id.compose_view).apply {
setContent {
// your content
}
}
}
}
override fun getTheme() = R.style.FullScreenDialog
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
onDismissListener?.invoke()
}
fun setOnDismissListener(function: () -> Unit) {
this.onDismissListener = function
}
}
Will Shelor
11/10/2021, 3:38 AM<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="FullScreenDialog" parent="Theme.AppCompat.Light.Dialog">
<item name="android:backgroundDimEnabled">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:padding">0dp</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
</resources>
Will Shelor
11/10/2021, 3:38 AMSteffen Funke
11/10/2021, 5:18 AMisCancelable
in the BottomSheetDialogFragment…. But swipe to dismiss is nice and I would like it to keep, if I can.Steffen Funke
11/10/2021, 5:19 AMIt was one of my first experiences with Compose.Yeah feels like learning something new everyday again 😆
Will Shelor
11/10/2021, 5:20 AMSteffen Funke
11/10/2021, 5:22 AMLazyColumn
denies scrolling… But I feel I might have to dig deeper there, “halfway there”:
val lazyListState = rememberLazyListState()
val disallow = RequestDisallowInterceptTouchEvent()
LazyColumn(
modifier = Modifier
.pointerInteropFilter(requestDisallowInterceptTouchEvent = disallow, onTouchEvent = {
when(it.action) {
MotionEvent.ACTION_DOWN -> {
disallow(true)
return@pointerInteropFilter true
}
MotionEvent.ACTION_UP -> {
disallow(false)
return@pointerInteropFilter false
}
}
true
})
.fillMaxWidth(),
state = lazyListState
) {
.... items content
Steffen Funke
11/10/2021, 5:24 AMWe made a custom bottom sheet for just this reason. We copied the base idea of the accompanist bottom sheet scaffold and made our own with some custom behavior.So it keeps being swipe to dismissable? Mind to share some insights in how you tackled the nested scrolling part in the custom behavior? Probably would make a good stackoverlfow answer as well 😄
Will Shelor
11/10/2021, 5:26 AMSteffen Funke
11/10/2021, 5:36 AMThere is a method on View called isNestedScrollingEnabled(), and Compose always returns false,Mind if I ask where you found that call, and that compose returns false? Maybe subclassing
ComposeView
(like with those old ViewPager hacks to allow nested scrolling) would be worth looking into 🤔.Steffen Funke
11/10/2021, 5:37 AMSteffen Funke
11/10/2021, 5:39 AMRequestDisallowInterceptTouchEvent
could be a lead, but no luck for now. I feel I’ll have to read myself back in touch event internals.Will Shelor
11/10/2021, 7:02 AM