opt handle scroll

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-02-18 18:10:09 +08:00
parent 9b93ce84ab
commit 651e79ce26
3 changed files with 21 additions and 14 deletions

View File

@@ -22,7 +22,7 @@ abstract class CommonPageState<
Widget onBuild(Widget child) {
if (_barOffset != null) {
return NotificationListener<ScrollUpdateNotification>(
return NotificationListener<ScrollNotification>(
onNotification: onNotification,
child: child,
);
@@ -30,22 +30,29 @@ abstract class CommonPageState<
return child;
}
bool onNotification(ScrollUpdateNotification notification) {
if (!_mainController.useBottomNav) return false;
final metrics = notification.metrics;
if (metrics.axis == .horizontal ||
metrics.pixels < 0 ||
notification.dragDetails == null) {
return false;
}
final scrollDelta = notification.scrollDelta ?? 0.0;
void _updateOffset(double scrollDelta) {
_barOffset!.value = clampDouble(
_barOffset!.value + scrollDelta,
0.0,
StyleString.topBarHeight,
);
}
bool onNotification(ScrollNotification notification) {
if (!_mainController.useBottomNav) return false;
if (notification.metrics.axis == .horizontal) return false;
if (notification is ScrollUpdateNotification) {
if (notification.dragDetails == null) return false;
_updateOffset(notification.scrollDelta ?? 0.0);
return false;
}
if (notification is OverscrollNotification) {
_updateOffset(notification.overscroll);
return false;
}
return false;
}