Skip to content

Commit

Permalink
Remove autoLoad in RefreshConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
peng8350 committed May 7, 2021
1 parent 22a700f commit bd5b264
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 59 deletions.
7 changes: 0 additions & 7 deletions lib/src/internals/indicator_wrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,6 @@ abstract class LoadIndicatorState<T extends LoadIndicator> extends State<T>
configuration!.footerTriggerDistance &&
_position!.extentBefore > 2.0 &&
_enableLoading) {
if (!configuration!.autoLoad && mode == LoadStatus.idle) {
return false;
}
if (!configuration!.enableLoadingWhenFailed &&
mode == LoadStatus.failed) {
return false;
Expand Down Expand Up @@ -558,10 +555,6 @@ abstract class LoadIndicatorState<T extends LoadIndicator> extends State<T>
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if ((mode == LoadStatus.idle && !configuration!.autoLoad) ||
(_mode!.value == LoadStatus.failed)) {
enterLoading();
}
if (widget.onClick != null) {
widget.onClick!();
}
Expand Down
8 changes: 1 addition & 7 deletions lib/src/smart_refresher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,6 @@ class RefreshConfiguration extends InheritedWidget {
/// when listView data small(not enough one page) , it should be hide
final bool hideFooterWhenNotFull;

/// whether footer can trigger load by reaching footerDistance when idle
final bool autoLoad;

/// whether user can drag viewport when twoLeveling
final bool enableScrollWhenTwoLevel;

Expand Down Expand Up @@ -932,7 +929,6 @@ class RefreshConfiguration extends InheritedWidget {
this.twiceTriggerDistance: 150.0,
this.closeTwoLevelDistance: 80.0,
this.skipCanRefresh: false,
this.autoLoad: true,
this.maxOverScrollExtent,
this.enableBallisticLoad: true,
this.maxUnderScrollExtent,
Expand Down Expand Up @@ -971,7 +967,6 @@ class RefreshConfiguration extends InheritedWidget {
double? twiceTriggerDistance,
double? closeTwoLevelDistance,
bool? skipCanRefresh,
bool? autoLoad,
double? maxOverScrollExtent,
double? maxUnderScrollExtent,
double? topHitBoundary,
Expand All @@ -983,7 +978,6 @@ class RefreshConfiguration extends InheritedWidget {
bool? hideFooterWhenNotFull,
}) : assert(RefreshConfiguration.of(context) != null,
"search RefreshConfiguration anscestor return null,please Make sure that RefreshConfiguration is the ancestor of that element"),
autoLoad = autoLoad ?? RefreshConfiguration.of(context)!.autoLoad,
headerBuilder =
headerBuilder ?? RefreshConfiguration.of(context)!.headerBuilder,
footerBuilder =
Expand Down Expand Up @@ -1038,7 +1032,7 @@ class RefreshConfiguration extends InheritedWidget {

@override
bool updateShouldNotify(RefreshConfiguration oldWidget) {
return autoLoad != oldWidget.autoLoad ||
return
skipCanRefresh != oldWidget.skipCanRefresh ||
hideFooterWhenNotFull != oldWidget.hideFooterWhenNotFull ||
dragSpeedRatio != oldWidget.dragSpeedRatio ||
Expand Down
47 changes: 3 additions & 44 deletions test/loadmore_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -458,51 +458,10 @@ void main() {
});
});

testWidgets("when autoLoad = false or enableLoadingWhenFailed = true",
testWidgets("when enableLoadingWhenFailed = true",
(tester) async {
final RefreshController _refreshController = RefreshController();
await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: RefreshConfiguration(
child: SmartRefresher(
header: TestHeader(),
footer: TestFooter(),
enablePullUp: true,
enablePullDown: true,
child: ListView.builder(
itemBuilder: (c, i) => Center(
child: Text(data[i]),
),
itemCount: 20,
itemExtent: 100,
),
controller: _refreshController,
),
autoLoad: false,
enableLoadingWhenFailed: false,
),
));

_refreshController.position!
.jumpTo(_refreshController.position!.maxScrollExtent);
await tester.drag(find.byType(Scrollable), const Offset(0, -150.0));
expect(_refreshController.footerStatus, LoadStatus.idle);
await tester.pumpAndSettle(Duration(milliseconds: 500));
expect(_refreshController.footerStatus, LoadStatus.idle);

_refreshController.footerMode!.value = LoadStatus.failed;
_refreshController.position!
.jumpTo(_refreshController.position!.maxScrollExtent - 30.0);
expect(_refreshController.position!.pixels,
_refreshController.position!.maxScrollExtent - 30.0);
expect(_refreshController.footerStatus, LoadStatus.failed);
await tester.pump();
await tester.drag(find.byType(Scrollable), const Offset(0, -100.0));
await tester.pump();
expect(_refreshController.footerStatus, LoadStatus.failed);
await tester.pumpAndSettle(Duration(milliseconds: 200));
expect(_refreshController.footerStatus, LoadStatus.failed);

RefreshController _refreshController = RefreshController();
await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: RefreshConfiguration(
Expand All @@ -520,7 +479,7 @@ void main() {
),
controller: _refreshController,
),
autoLoad: true,

enableLoadingWhenFailed: true,
),
));
Expand Down
1 change: 0 additions & 1 deletion test/smart_refresher_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ void main() {
dragSpeedRatio: 0.8,
closeTwoLevelDistance: 100,
footerTriggerDistance: 150,
autoLoad: false,
enableScrollWhenRefreshCompleted: true,
child: Builder(
builder: (c1) {
Expand Down

0 comments on commit bd5b264

Please sign in to comment.