From b784ab5aa5ac155b14ed2bd5639d28203a111cc2 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sat, 21 May 2022 19:02:33 +0200 Subject: [PATCH] Fix scrolling with notification gesture --- .../launcher2/ui/launcher/PagerScaffold.kt | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ui/src/main/java/de/mm20/launcher2/ui/launcher/PagerScaffold.kt b/ui/src/main/java/de/mm20/launcher2/ui/launcher/PagerScaffold.kt index f2f2dd1f..bc0bd81d 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/launcher/PagerScaffold.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/launcher/PagerScaffold.kt @@ -150,22 +150,19 @@ fun PagerScaffold( object: NestedScrollConnection { private var pullDownTotalY: Float? = 0f override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset { - if (widgetsScrollState.value == 0 && source == NestedScrollSource.Drag) { - val diff = widgetsScrollState.value - available.y - var totalY = pullDownTotalY - if (totalY != null) { - totalY += diff - if (totalY < -notificationDragThreshold) { - notificationShadeController.expandNotifications() - pullDownTotalY = null - } else { - pullDownTotalY = totalY - } - return Offset(0f, -diff) - } else { - return available - } + val diff = widgetsScrollState.value - available.y + var totalY = pullDownTotalY ?: return available + if (diff >= 0) return super.onPreScroll(available, source) + + totalY += diff + + if (totalY < -notificationDragThreshold) { + notificationShadeController.expandNotifications() + pullDownTotalY = null + return available } + pullDownTotalY = totalY + return super.onPreScroll(available, source) }