fix(core): allow scroll notification bubbling in lazy load scroll view
This commit is contained in:
@@ -17,6 +17,7 @@ class LazyLoadScrollView extends StatefulWidget {
|
|||||||
this.onPageScrollEnd,
|
this.onPageScrollEnd,
|
||||||
this.onInBetweenOfPage,
|
this.onInBetweenOfPage,
|
||||||
this.scrollOffset = 100,
|
this.scrollOffset = 100,
|
||||||
|
this.allowNotificationBubbling = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The [Widget] that this widget watches for changes on
|
/// 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
|
/// The offset to take into account when triggering [onEndOfPage]/[onStartOfPage] in pixels
|
||||||
final double scrollOffset;
|
final double scrollOffset;
|
||||||
|
|
||||||
|
/// If true the notifications will keep bubbling up the tree
|
||||||
|
final bool allowNotificationBubbling;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _LazyLoadScrollViewState();
|
State<StatefulWidget> createState() => _LazyLoadScrollViewState();
|
||||||
}
|
}
|
||||||
@@ -59,13 +63,13 @@ class _LazyLoadScrollViewState extends State<LazyLoadScrollView> {
|
|||||||
if (notification is ScrollStartNotification) {
|
if (notification is ScrollStartNotification) {
|
||||||
if (widget.onPageScrollStart != null) {
|
if (widget.onPageScrollStart != null) {
|
||||||
widget.onPageScrollStart!();
|
widget.onPageScrollStart!();
|
||||||
return true;
|
return widget.allowNotificationBubbling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notification is ScrollEndNotification) {
|
if (notification is ScrollEndNotification) {
|
||||||
if (widget.onPageScrollEnd != null) {
|
if (widget.onPageScrollEnd != null) {
|
||||||
widget.onPageScrollEnd!();
|
widget.onPageScrollEnd!();
|
||||||
return true;
|
return widget.allowNotificationBubbling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (notification is ScrollUpdateNotification) {
|
if (notification is ScrollUpdateNotification) {
|
||||||
@@ -78,7 +82,7 @@ class _LazyLoadScrollViewState extends State<LazyLoadScrollView> {
|
|||||||
pixels < (maxScrollExtent - scrollOffset)) {
|
pixels < (maxScrollExtent - scrollOffset)) {
|
||||||
if (widget.onInBetweenOfPage != null) {
|
if (widget.onInBetweenOfPage != null) {
|
||||||
widget.onInBetweenOfPage!();
|
widget.onInBetweenOfPage!();
|
||||||
return true;
|
return widget.allowNotificationBubbling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,12 +94,12 @@ class _LazyLoadScrollViewState extends State<LazyLoadScrollView> {
|
|||||||
if (scrollingDown) {
|
if (scrollingDown) {
|
||||||
if (extentAfter <= scrollOffset) {
|
if (extentAfter <= scrollOffset) {
|
||||||
_onEndOfPage();
|
_onEndOfPage();
|
||||||
return true;
|
return widget.allowNotificationBubbling;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (extentBefore <= scrollOffset) {
|
if (extentBefore <= scrollOffset) {
|
||||||
_onStartOfPage();
|
_onStartOfPage();
|
||||||
return true;
|
return widget.allowNotificationBubbling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,9 +110,9 @@ class _LazyLoadScrollViewState extends State<LazyLoadScrollView> {
|
|||||||
if (notification.overscroll < 0) {
|
if (notification.overscroll < 0) {
|
||||||
_onStartOfPage();
|
_onStartOfPage();
|
||||||
}
|
}
|
||||||
return true;
|
return widget.allowNotificationBubbling;
|
||||||
}
|
}
|
||||||
return false;
|
return widget.allowNotificationBubbling;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onEndOfPage() {
|
void _onEndOfPage() {
|
||||||
|
|||||||
Reference in New Issue
Block a user