mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-04-20 11:08:03 +08:00
@@ -7,6 +7,8 @@ import 'dart:io' show Platform;
|
||||
|
||||
import 'package:PiliPlus/common/widgets/scroll_behavior.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'
|
||||
show RefreshScrollPhysics;
|
||||
import 'package:flutter/foundation.dart' show clampDouble;
|
||||
import 'package:flutter/material.dart' hide RefreshIndicator;
|
||||
|
||||
@@ -593,30 +595,3 @@ class RefreshScrollBehavior extends CustomScrollBehavior {
|
||||
return scrollPhysics;
|
||||
}
|
||||
}
|
||||
|
||||
typedef OnDrag = bool Function(double offset, double viewportDimension);
|
||||
|
||||
class RefreshScrollPhysics extends ClampingScrollPhysics {
|
||||
const RefreshScrollPhysics({
|
||||
super.parent,
|
||||
required this.onDrag,
|
||||
});
|
||||
|
||||
final OnDrag onDrag;
|
||||
|
||||
@override
|
||||
RefreshScrollPhysics applyTo(ScrollPhysics? ancestor) {
|
||||
return RefreshScrollPhysics(
|
||||
parent: buildParent(ancestor),
|
||||
onDrag: onDrag,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
double applyPhysicsToUserOffset(ScrollMetrics position, double offset) {
|
||||
if (offset < 0.0 && onDrag(offset, position.viewportDimension)) {
|
||||
return 0.0;
|
||||
}
|
||||
return parent?.applyPhysicsToUserOffset(position, offset) ?? offset;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user