Skip to content

Commit

Permalink
add DraggableScrollableSheet+Loadmore example
Browse files Browse the repository at this point in the history
  • Loading branch information
peng8350 committed Jul 3, 2019
1 parent e2b495e commit f1692c9
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ finally,[here](https://github.com/peng8350/flutter_pulltorefresh/tree/master/exa
|:---:|:---:|:---:|
|art| ![](arts/example5.gif) | ![](arts/example6.gif) |

|Style| [ simple custom header(使用SpinKit)](example/lib/ui/example/useStage/custom_header.dart)|
|Style| [ simple custom header(使用SpinKit)](example/lib/ui/example/useStage/custom_header.dart)| [dragableScrollSheet+LoadMore](example/lib/ui/example/otherwidget/draggable_bottomsheet_loadmore.dart)|
|:---:|:---:|
|art| ![](arts/example7.gif) |
|art| ![](arts/example7.gif) | ![](arts/example8.gif) |


### Indicator
Expand Down
6 changes: 3 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ header和footer的重复性的工作,在RefreshConfiguration子树下的SmartRef
|:---:|:---:|:---:|
|art| ![](arts/example5.gif) | ![](arts/example6.gif) |

|Style| [简单自定义刷新指示器(使用SpinKit)](example/lib/ui/example/useStage/custom_header.dart)|
|:---:|:---:|
|art| ![](arts/example7.gif) |
|Style| [简单自定义刷新指示器(使用SpinKit)](example/lib/ui/example/useStage/custom_header.dart)| [dragableScrollSheet+LoadMore](example/lib/ui/example/otherwidget/draggable_bottomsheet_loadmore.dart)|
|:---:|:---:|:---:|
|art| ![](arts/example7.gif) | ![](arts/example8.gif) |

### 各种指示器

Expand Down
Binary file modified arts/example2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arts/example8.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions example/lib/ui/example/ExamplePage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import 'package:example/ui/example/otherwidget/refresh_pageView_example.dart';
import 'package:example/ui/example/useStage/link_header_example.dart';
import 'package:example/ui/example/useStage/twolevel_refresh.dart';
import 'otherwidget/refresh_recordable_listview_example.dart';
import 'otherwidget/draggable_bottomsheet_loadmore.dart';

class ExamplePage extends StatefulWidget {
@override
Expand Down Expand Up @@ -167,6 +168,16 @@ class _ExamplePageState extends State<ExamplePage>
);
}));
}),
ExampleItem(
title: "loadmore+draggablesheet",
onClick: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return Scaffold(
appBar: AppBar(),
body: DraggableLoadingBottomSheet(),
);
}));
}),
ExampleItem(
title: "pageView共用SmartRefresher",
onClick: () {
Expand Down
100 changes: 100 additions & 0 deletions example/lib/ui/example/otherwidget/draggable_bottomsheet_loadmore.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Author: Jpeng
* Email: [email protected]
* Time: 2019-07-03 17:24
*/

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../Item.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

/*
notice that,If your combine with DraggableScrollSheet with SmartRefresher,
It not support enablePullDown,only support enablePullUp = true.
the second, the example has StatefulBuilder,just not setState(),it will never rebuild scrollSheet
*/
class DraggableLoadingBottomSheet extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return _DraggableLoadingBottomSheetState();
}
}

class _DraggableLoadingBottomSheetState
extends State<DraggableLoadingBottomSheet> {
RefreshController _controller = RefreshController();

List<String> items = [];

@override
void initState() {
// TODO: implement initState
super.initState();
for (int i = 0; i < 15; i++) items.add("数据");
}

@override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(
title: const Text('DraggableScrollableSheet'),
),
body: Container(
child: RaisedButton(
onPressed: () {
showModalBottomSheet(
backgroundColor: Colors.transparent,
context: context,
builder: (c) {
return DraggableScrollableSheet(
initialChildSize: 1.0,
maxChildSize: 1.0,
minChildSize: 0.5,
builder: (BuildContext context,
ScrollController scrollController) {
return Container(
color: Colors.blue[100],
child: StatefulBuilder(
builder: (BuildContext context2, setter) {
return SmartRefresher(
child: ListView.separated(
controller: scrollController,
separatorBuilder: (c, i) => Divider(),
itemBuilder: (_, e) => Container(
child:
Center(child: Text("菜单" + e.toString())),
height: 40.0,
),
physics: ClampingScrollPhysics(),
itemCount: items.length,
),
controller: _controller,
onLoading: () async {
await Future.delayed(
Duration(milliseconds: 1000));
_controller.loadComplete();
for (int i = 0; i < 15; i++) {
items.add("1");
}

setter(() {});
},
enablePullUp: true,
enablePullDown: false,
);
},
),
);
},
);
});
},
child: Text("点击打开滑动BottomSheet"),
),
),
);
}
}
2 changes: 1 addition & 1 deletion lib/src/internals/refresh_physics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class RefreshPhysics extends ScrollPhysics {
spring: spring,
position: position.pixels,
// -1.0 avoid stop springing back ,and release gesture
velocity: velocity,
velocity: -1.0,
// TODO(abarth): We should move this constant closer to the drag end.
leadingExtent: position.minScrollExtent,
trailingExtent: headerMode.value == RefreshStatus.twoLeveling
Expand Down

0 comments on commit f1692c9

Please sign in to comment.