From 05d376cffb39f94a5420fdb0b5bd986911d08680 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 4 Jul 2022 11:58:52 +0200 Subject: [PATCH] fix(core): allow scroll notification bubbling in lazy load scroll view --- .../lib/src/lazy_load_scroll_view.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/stream_chat_flutter_core/lib/src/lazy_load_scroll_view.dart b/packages/stream_chat_flutter_core/lib/src/lazy_load_scroll_view.dart index e086ab55..5c6ad9c0 100644 --- a/packages/stream_chat_flutter_core/lib/src/lazy_load_scroll_view.dart +++ b/packages/stream_chat_flutter_core/lib/src/lazy_load_scroll_view.dart @@ -17,6 +17,7 @@ class LazyLoadScrollView extends StatefulWidget { this.onPageScrollEnd, this.onInBetweenOfPage, this.scrollOffset = 100, + this.allowNotificationBubbling = false, }); /// The [Widget] that this widget watches for changes on @@ -40,6 +41,9 @@ class LazyLoadScrollView extends StatefulWidget { /// The offset to take into account when triggering [onEndOfPage]/[onStartOfPage] in pixels final double scrollOffset; + /// If true the notifications will keep bubbling up the tree + final bool allowNotificationBubbling; + @override State createState() => _LazyLoadScrollViewState(); } @@ -59,13 +63,13 @@ class _LazyLoadScrollViewState extends State { if (notification is ScrollStartNotification) { if (widget.onPageScrollStart != null) { widget.onPageScrollStart!(); - return true; + return widget.allowNotificationBubbling; } } if (notification is ScrollEndNotification) { if (widget.onPageScrollEnd != null) { widget.onPageScrollEnd!(); - return true; + return widget.allowNotificationBubbling; } } if (notification is ScrollUpdateNotification) { @@ -78,7 +82,7 @@ class _LazyLoadScrollViewState extends State { pixels < (maxScrollExtent - scrollOffset)) { if (widget.onInBetweenOfPage != null) { widget.onInBetweenOfPage!(); - return true; + return widget.allowNotificationBubbling; } } @@ -90,12 +94,12 @@ class _LazyLoadScrollViewState extends State { if (scrollingDown) { if (extentAfter <= scrollOffset) { _onEndOfPage(); - return true; + return widget.allowNotificationBubbling; } } else { if (extentBefore <= scrollOffset) { _onStartOfPage(); - return true; + return widget.allowNotificationBubbling; } } } @@ -106,9 +110,9 @@ class _LazyLoadScrollViewState extends State { if (notification.overscroll < 0) { _onStartOfPage(); } - return true; + return widget.allowNotificationBubbling; } - return false; + return widget.allowNotificationBubbling; } void _onEndOfPage() {