Skip to content

Commit

Permalink
Make triggerDistance be equally valid for pullup loading
Browse files Browse the repository at this point in the history
  • Loading branch information
peng8350 committed May 21, 2018
1 parent bff22ca commit 2a0fa1a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
43 changes: 21 additions & 22 deletions lib/src/internals/indicator_wrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ class RefreshWrapper extends Wrapper {
this.onOffsetChange,
this.completeDuration: default_completeDuration,
double triggerDistance,
this.visibleRange:default_VisibleRange,
this.visibleRange: default_VisibleRange,
bool up: true,
}) : assert(up != null),
super(
up: up,
key: key,
modeListener: modeLis,
builder: builder,
triggerDistance: triggerDistance,
);
up: up,
key: key,
modeListener: modeLis,
builder: builder,
triggerDistance: triggerDistance,
);

@override
State<StatefulWidget> createState() {
Expand Down Expand Up @@ -200,13 +200,13 @@ class RefreshWrapperState extends State<RefreshWrapper>
sizeFactor: _sizeController,
child: new Container(height: widget.visibleRange),
),
widget.builder(context,widget.mode)
widget.builder(context, widget.mode)
],
);
}
return new Column(
children: <Widget>[
widget.builder(context,widget.mode),
widget.builder(context, widget.mode),
new SizeTransition(
sizeFactor: _sizeController,
child: new Container(height: widget.visibleRange),
Expand All @@ -226,8 +226,7 @@ class LoadWrapper extends Wrapper {
@required ValueNotifier<int> modeListener,
double triggerDistance,
this.autoLoad,
IndicatorBuilder
builder})
IndicatorBuilder builder})
: assert(up != null, modeListener != null),
super(
key: key,
Expand All @@ -248,17 +247,15 @@ class LoadWrapperState extends State<LoadWrapper> implements GestureProcessor {
@override
Widget build(BuildContext context) {
// TODO: implement build
return widget.builder(context,widget.mode);
return widget.builder(context, widget.mode);
}

@override
void initState() {
// TODO: implement initState
super.initState();
widget.modeListener.addListener((){
setState(() {

});
widget.modeListener.addListener(() {
setState(() {});
});
}

Expand All @@ -270,13 +267,15 @@ class LoadWrapperState extends State<LoadWrapper> implements GestureProcessor {
@override
void onDragMove(ScrollUpdateNotification notification) {
// TODO: implement onDragMove
if (!widget._isScrollToOutSide(notification)) {
return;
}
// if (!widget._isScrollToOutSide(notification)) {
// return;
// }
if (widget._isRefreshing || widget._isComplete) return;

if (notification.metrics.outOfRange && widget.autoLoad) {
widget.mode = RefreshStatus.refreshing;
if (widget.autoLoad) {
if (widget.up && notification.metrics.extentBefore <= widget.triggerDistance)
widget.mode = RefreshStatus.refreshing;
if (!widget.up && notification.metrics.extentAfter <= widget.triggerDistance)
widget.mode = RefreshStatus.refreshing;
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/smart_refresher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ class _SmartRefresherState extends State<SmartRefresher> {

//check user is pulling up
bool _isPullUp(ScrollNotification noti) {
return noti.metrics.extentAfter == 0;
return noti.metrics.pixels < 0;
}

//check user is pulling down
bool _isPullDown(ScrollNotification noti) {
return noti.metrics.extentBefore == 0;
return noti.metrics.pixels > 0;
}

double _measure(ScrollNotification notification) {
Expand Down

0 comments on commit 2a0fa1a

Please sign in to comment.