Skip to content

Commit

Permalink
## 2.0.0-dev
Browse files Browse the repository at this point in the history
* Fix Null check operator used on a null value
  • Loading branch information
zmtzawqlp committed Dec 4, 2020
1 parent 9650bbd commit 24a8a20
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 36 deletions.
65 changes: 34 additions & 31 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
## [2.0.0]
## 2.0.0-dev

* Fix Null check operator used on a null value
## 2.0.0

* Breaking change: add clipBehavior and restorationId
* Merge flutter/issues/29264(SliverAppBar's flexibleSpace glitch on iOS when NestedScrollView's body is a ScrollView)

## [1.0.1]
## 1.0.1

* Merge flutter/flutter#59187(Support floating the header slivers of a NestedScrollView)

## [1.0.0]
## 1.0.0

* Merge code from 1.17.0
* Fix analysis_options

## [0.4.1]
## 0.4.1

* add demo to show how to change pinned header height dynamically.

## [0.4.0]
## 0.4.0

* web support

## [0.3.8]
## 0.3.8

* add NestedScrollViewState key to get currentInnerPosition/innerScrollPositions instead of ScrollController
* due to we can't set ScrollController for list in NestedScrollView's body(it will breaking behaviours of InnerScrollController in NestedScrollView), provide demos('PullToRefresh','LoadMore' and 'ScrollToTop') to show how to do it without ScrollController

## [0.3.6]
## 0.3.6

* fix api error base on Flutter SDK v1.7.8+hotfix.2

## [0.3.5]
## 0.3.5

* New ExtendedNestedScrollView still has some issues in special layout, make it as obsolete for now till find a better solution

## [0.3.3]
## 0.3.3

* fix issue that Caught error: type 'Future<void>' is not a subtype of type 'Future<Null>'
for old extended_nested_scroll_view

## [0.2.9]
## 0.2.9

* fix issue [0.2.5] for old extended_nested_scroll_view
* fix issue 0.2.5 for old extended_nested_scroll_view

## [0.2.7]
## 0.2.7

* fix issue for quick change page
* handle unavailable page change(no actived nested positions in it)

## [0.2.5]
## 0.2.5

* fix issue that ut postion is not overscroll actually,it get minimal value
and will scroll inner positions
Expand All @@ -60,58 +63,58 @@
}
}

## [0.2.0]
## 0.2.0

* update new extended_nested_scroll_view demo

## [0.1.9]
## 0.1.9

* set keepOnlyOneInnerNestedScrollPositionActive default value: false

## [0.1.8]
## 0.1.8

* update new ExtendedNestedScrollView readme

## [0.1.7]
## 0.1.7

* add assert for keepOnlyOneInnerNestedScrollPositionActive
///when ExtendedNestedScrollView body has [TabBarView]/[PageView] and children have
///when ExtendedNestedScrollView body has TabBarView/PageView and children have
///AutomaticKeepAliveClientMixin or PageStorageKey,
///[_innerController.nestedPositions] will have more one,
///_innerController.nestedPositions will have more one,
///when you scroll, it will scroll all of nestedPositions
///set [keepOnlyOneInnerNestedScrollPositionActive] true to avoid it.
///notice: only for Axis.horizontal [TabBarView]/[PageView] and
///[scrollDirection] must be Axis.vertical.
///set keepOnlyOneInnerNestedScrollPositionActive true to avoid it.
///notice: only for Axis.horizontal TabBarView/PageView and
///scrollDirection must be Axis.vertical.
assert(!(widget.keepOnlyOneInnerNestedScrollPositionActive && widget.scrollDirection == Axis.horizontal));

## [0.1.6]
## 0.1.6

* fix issue: Actived [_NestedScrollPosition] is not right for multiple
* fix issue: Actived _NestedScrollPosition is not right for multiple

## [0.1.5]
## 0.1.5

* add new ExtendedNestedScrollView to slove issue more smartly.

## [0.1.4]
## 0.1.4

* Update readme.

## [0.1.3]
## 0.1.3

* Update demo.

## [0.1.2]
## 0.1.2

* Remove unused method.

## [0.1.1]
## 0.1.1

* Update demo.

## [0.1.0]
## 0.1.0

* Upgrade Some Commments.

## [0.0.1]
## 0.0.1

* Initial Open Source release.
93 changes: 90 additions & 3 deletions lib/src/old_extended_nested_scroll_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ class _NestedScrollCoordinator

bool get hasScrolledBody {
for (final _NestedScrollPosition position in _currentInnerPositions) {
assert(position.minScrollExtent != null && position.pixels != null);
assert(position.hasContentDimensions && position.hasPixels);
if (position.pixels > position.minScrollExtent) {
return true;
}
Expand Down Expand Up @@ -899,6 +899,64 @@ class _NestedScrollCoordinator
goBallistic(0.0);
}

void pointerScroll(double delta) {
assert(delta != 0.0);

goIdle();
updateUserScrollDirection(
delta < 0.0 ? ScrollDirection.forward : ScrollDirection.reverse);

if (_innerPositions.isEmpty) {
// Does not enter overscroll.
_outerPosition.applyClampedPointerSignalUpdate(delta);
} else if (delta > 0.0) {
// Dragging "up" - delta is positive
// Prioritize getting rid of any inner overscroll, and then the outer
// view, so that the app bar will scroll out of the way asap.
double outerDelta = delta;
for (final _NestedScrollPosition position in _currentInnerPositions) {
if (position.pixels < 0.0) {
// This inner position is in overscroll.
final double potentialOuterDelta =
position.applyClampedPointerSignalUpdate(delta);
// In case there are multiple positions in varying states of
// overscroll, the first to 'reach' the outer view above takes
// precedence.
outerDelta = math.max(outerDelta, potentialOuterDelta);
}
}
if (outerDelta != 0.0) {
final double innerDelta =
_outerPosition.applyClampedPointerSignalUpdate(outerDelta);
if (innerDelta != 0.0) {
for (final _NestedScrollPosition position in _currentInnerPositions)
position.applyClampedPointerSignalUpdate(innerDelta);
}
}
} else {
// Dragging "down" - delta is negative
double innerDelta = delta;
// Apply delta to the outer header first if it is configured to float.
if (_floatHeaderSlivers)
innerDelta = _outerPosition.applyClampedPointerSignalUpdate(delta);

if (innerDelta != 0.0) {
// Apply the innerDelta, if we have not floated in the outer scrollable,
// any leftover delta after this will be passed on to the outer
// scrollable by the outerDelta.
double outerDelta = 0.0; // it will go negative if it changes
for (final _NestedScrollPosition position in _currentInnerPositions) {
final double overscroll =
position.applyClampedPointerSignalUpdate(innerDelta);
outerDelta = math.min(outerDelta, overscroll);
}
if (outerDelta != 0.0)
_outerPosition.applyClampedPointerSignalUpdate(outerDelta);
}
}
goBallistic(0.0);
}

@override
double setPixels(double newPixels) {
assert(false);
Expand Down Expand Up @@ -947,7 +1005,7 @@ class _NestedScrollCoordinator
// Prioritize getting rid of any inner overscroll, and then the outer
// view, so that the app bar will scroll out of the way asap.
double outerDelta = delta;
for (final _NestedScrollPosition position in _innerPositions) {
for (final _NestedScrollPosition position in _currentInnerPositions) {
if (position.pixels < 0.0) {
// This inner position is in overscroll.
final double potentialOuterDelta =
Expand Down Expand Up @@ -1183,7 +1241,7 @@ class _NestedScrollPosition extends ScrollPosition
oldPosition: oldPosition,
debugLabel: debugLabel,
) {
if (pixels == null && initialPixels != null) {
if (!hasPixels && initialPixels != null) {
correctPixels(initialPixels);
}
if (activity == null) {
Expand Down Expand Up @@ -1333,6 +1391,30 @@ class _NestedScrollPosition extends ScrollPosition
return 0.0;
}

// Returns the amount of delta that was not used.
//
// Negative delta represents a forward ScrollDirection, while the positive
// would be a reverse ScrollDirection.
//
// The method doesn't take into account the effects of [ScrollPhysics].
double applyClampedPointerSignalUpdate(double delta) {
assert(delta != 0.0);

final double min =
delta > 0.0 ? -double.infinity : math.min(minScrollExtent, pixels);
// The logic for max is equivalent but on the other side.
final double max =
delta < 0.0 ? double.infinity : math.max(maxScrollExtent, pixels);
final double newPixels = (pixels + delta).clamp(min, max) as double;
final double clampedDelta = newPixels - pixels;
if (clampedDelta == 0.0) {
return delta;
}
forcePixels(newPixels);
didUpdateScrollPositionBy(clampedDelta);
return delta - clampedDelta;
}

@override
ScrollDirection get userScrollDirection => coordinator.userScrollDirection;

Expand Down Expand Up @@ -1412,6 +1494,11 @@ class _NestedScrollPosition extends ScrollPosition
return coordinator.jumpTo(coordinator.unnestOffset(value, this));
}

@override
void pointerScroll(double delta) {
return coordinator.pointerScroll(delta);
}

@override
void jumpToWithoutSettling(double value) {
assert(false);
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: extended_nested_scroll_view
description: extended nested scroll view to fix pinned header and inner scrollables sync issues.
version: 2.0.0
version: 2.0.0-dev
homepage: https://github.com/fluttercandies/extended_nested_scroll_view

environment:
sdk: ">=2.6.0 <3.0.0"
flutter: ">=1.22.0-2.0"
flutter: ">1.22.4"

dependencies:
flutter:
Expand Down

0 comments on commit 24a8a20

Please sign in to comment.