Commit b082b93a authored by Adam Barth's avatar Adam Barth Committed by GitHub

Simplify AbsoluteScrollPosition class structure (#7785)

Instead of using mixins and subclasses, we now use a `ScrollPhysics` delegate
to customize the scrolling phyics for Android and iOS. This change will make it
easier to customize the scroll position for paging.
parent 84de5e81
...@@ -209,14 +209,6 @@ abstract class ScrollPosition extends ViewportOffset { ...@@ -209,14 +209,6 @@ abstract class ScrollPosition extends ViewportOffset {
return null; return null;
} }
/// Used by [AbsoluteDragScrollActivity] and other user-driven activities to
/// convert an offset in logical pixels as provided by the [DragUpdateDetails]
/// into a delta to apply using [setPixels].
///
/// This is used by some [ScrollPosition] subclasses to apply friction during
/// overscroll situations.
double applyPhysicsToUserOffset(double offset) => offset;
// /// // ///
// /// The velocity should be in logical pixels per second. // /// The velocity should be in logical pixels per second.
void beginBallisticActivity(double velocity) { void beginBallisticActivity(double velocity) {
......
...@@ -45,6 +45,7 @@ class TestBehavior extends ScrollBehavior2 { ...@@ -45,6 +45,7 @@ class TestBehavior extends ScrollBehavior2 {
state, state,
new Tolerance(velocity: 20.0, distance: 1.0), new Tolerance(velocity: 20.0, distance: 1.0),
oldPosition, oldPosition,
const ClampingScrollPhysics(),
); );
} }
...@@ -52,13 +53,13 @@ class TestBehavior extends ScrollBehavior2 { ...@@ -52,13 +53,13 @@ class TestBehavior extends ScrollBehavior2 {
bool shouldNotify(TestBehavior oldDelegate) => false; bool shouldNotify(TestBehavior oldDelegate) => false;
} }
class TestViewportScrollPosition extends AbsoluteScrollPosition class TestViewportScrollPosition extends AbsoluteScrollPosition {
with ClampingAbsoluteScrollPositionMixIn {
TestViewportScrollPosition( TestViewportScrollPosition(
Scrollable2State state, Scrollable2State state,
Tolerance scrollTolerances, Tolerance scrollTolerances,
ScrollPosition oldPosition, ScrollPosition oldPosition,
) : super(state, scrollTolerances, oldPosition); ScrollPhysics physics,
) : super(state, scrollTolerances, oldPosition, physics);
@override @override
bool applyContentDimensions(double minScrollExtent, double maxScrollExtent) { bool applyContentDimensions(double minScrollExtent, double maxScrollExtent) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment