Skip to content

Commit

Permalink
release 1.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
peng8350 committed May 24, 2019
1 parent 8a187ee commit cdae722
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 98 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,11 @@ Notice: This version of the code changes much, Api too
* decrease default triggerDistance from 100.0 to 80.0
* improve dragging scrolling speed of Front Style
* Add offset attr in Front Style

## 1.3.7
* Adding an asSlivers constructor can be inserted into slivers as a Sliver
* Fix FrontStyle cannot support dynamic change enablePullDown
* Fix FrontStyle cannot enter refresh state when init
* Optimize indicator internal code to avoid locking widgets
* Fix iOS click status cannot roll back without ScrollController in child
* Fix one ignored situation after finish refresh -> completed(not in visual range)
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ If you are Chinese,click here([中文文档](https://github.com/peng8350/flutter


## How to use?

the first way,use SmartRefresher and RefreshController
```
dependencies:
pull_to_refresh: ^1.3.6
pull_to_refresh: ^1.3.7
```

Expand Down Expand Up @@ -103,6 +103,54 @@ void dispose(){
```

Second Way(1.3.7 new),Considering that sometimes Sliver doesn't have to be placed in the first

```
/*
1. Request refresh operation
For FrontStyle header, animateTo (0.0), for other refresh styles, animateTo (- trigger Distance) is the default trigger distance of 80.
Of course, not all indicators have a trigger distance of 80, such as WaterDropHeader, which has an internal trigger distance of 100.0.
_scrollController.animateTo(-80.0);
2.Request loading operation
_scrollController
.animateTo(scrollController.position.maxScrollExtent);
3.Sometimes, if you have to operate on the status of an internal indicator, you can use GlobalKey, which exposes getters and setters.
GlobalKey<LoadIndicatorState> key = GlobalKey();
key.currentState.mode = LoadStatus.idle;
*/
/*
for physics:
1.for header: Follow,UnFollow,Behind Style
return RefreshBouncePhysics()
2.header is Front Style
Return RefreshClampPhysics (springBackDistance: 100.0) when displayed, and 100.0 corresponds to the header's height
Return to Clamping ScrollPhysics when hidden
*/
CustomScrollView(
controller: _scrollController,
physics: RefreshBouncePhysics(), //don't forget,necessary
slivers: [
.....
_enablePullDown?ClassicHeader.asSliver(onRefresh: () async {
await Future.delayed(Duration(milliseconds: 1000));
// return true,it mean refreshCompleted,return false it mean refreshFailed
return true;
}):null,
.....
_enablePullUp?ClassicFooter.asSliver(onLoading: () async {
await Future.delayed(Duration(milliseconds: 1000));
//return true it mean set the footerStatus to idle,else set to NoData state
return true;
}):null
].where((child) => child!=null).toList(),
);
```


## More
- [SmartRefresher,RefreshController](refresher_controller_en.md)
Expand Down
53 changes: 50 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@
```
dependencies:
pull_to_refresh: ^1.3.6
pull_to_refresh: ^1.3.7
```



第一种使用方法,使用SmartRefresh和RefreshController
```
RefreshController _refreshController;
Expand Down Expand Up @@ -97,6 +96,54 @@ void dispose(){
```

第二种使用方法(1.3.7新增),考虑到有的时候Sliver不一定要放在头部

```
/*
1.请求刷新操作
对于header为FrontStyle来说,animateTo(0.0),对于其他刷新风格来说,应animateTo(-triggerDistance),这个触发距离大部分默认为80,
当然不是所有指示器的触发距离都是80,比如WaterDropHeader,它内部触发距离为100.0
_scrollController.animateTo(-80.0);
2.请求加载更多的操作。
_scrollController
.animateTo(scrollController.position.maxScrollExtent);
3.有时,假如不得不操作内部指示器的状态,可以使用GlobalKey,内部已经暴露好getter和setter
GlobalKey<LoadIndicatorState> key = GlobalKey();
key.currentState.mode = LoadStatus.idle;
*/
/*
for physics:
1.header为Follow,UnFollow,Behind风格
返回RefreshBouncePhysics()即可
2.header为Front
当显示时需要返回RefreshClampPhysics(springBackDistance: 100.0),100.0对应header的高度
当隐藏时返回ClampingScrollPhysics即可
*/
CustomScrollView(
controller: _scrollController,
physics: RefreshBouncePhysics(), //don't forget,necessary
slivers: [
....,
_enablePullDown?ClassicHeader.asSliver(onRefresh: () async {
await Future.delayed(Duration(milliseconds: 1000));
// return true,it mean refreshCompleted,return false it mean refreshFailed
return true;
}):null,
....,
_enablePullUp?ClassicFooter.asSliver(onLoading: () async {
await Future.delayed(Duration(milliseconds: 1000));
//return true it mean set the footerStatus to idle,else set to NoData state
return true;
}):null
].where((child) => child!=null).toList(),
);
```

## 更多
- [SmartRefresher,RefreshController](refresher_controller.md)
- [自定义指示器](custom_indicator.md)
Expand Down
2 changes: 0 additions & 2 deletions example/lib/ui/indicator/base/IndicatorActivity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ class _IndicatorActivityState extends State<IndicatorActivity> {
onLoading: _onLoading,
header: widget.header,
footer: widget.footer,

enablePullDown: true,
enableOverScroll: widget.enableOverScroll,
isNestWrapped: widget.isNest,
enablePullUp: totalHeight > lIstHeight,
controller: _refreshController);
Expand Down
75 changes: 53 additions & 22 deletions example/lib/ui/sample/Appbar_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:flutter_sticky_header/flutter_sticky_header.dart';

class AppBarHeader extends StatefulWidget {
@override
Expand All @@ -14,6 +15,7 @@ class AppBarHeader extends StatefulWidget {
class _AppBarHeaderState extends State<AppBarHeader> {
List<Widget> data = [];
RefreshController _refreshController;

void _getDatas() {
for (int i = 0; i < 18; i++) {
data.add(Container(
Expand All @@ -32,10 +34,10 @@ class _AppBarHeaderState extends State<AppBarHeader> {
super.initState();
}

List<Widget> buildList(){
List<Widget> buildList() {
List<Widget> items = [];

for(int i = 0 ;i<100;i++){
for (int i = 0; i < 100; i++) {
items.add(Text('样例数据'));
}
return items;
Expand All @@ -54,28 +56,57 @@ class _AppBarHeaderState extends State<AppBarHeader> {
return Container(
color: Colors.white,
child: SmartRefresher(
child: CustomScrollView(
slivers: [
// This is necessary,if not SliverAppbar will follow headerIndicator
SliverToBoxAdapter(
child: Container(),
child: CustomScrollView(
slivers: [
// This is necessary,if not SliverAppbar will follow headerIndicator
SliverStickyHeader(
header: new Container(
height: 60.0,
color: Colors.lightBlue,
padding: EdgeInsets.symmetric(horizontal: 16.0),
alignment: Alignment.centerLeft,
child: new Text(
'Header #0',
style: const TextStyle(color: Colors.white),
),
),
SliverAppBar(
backgroundColor: Colors.greenAccent,
expandedHeight: 200.0,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
background: Image.network(
"https://images.unsplash.com/photo-1541701494587-cb58502866ab?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=0c21b1ac3066ae4d354a3b2e0064c8be&auto=format&fit=crop&w=500&q=60",
fit: BoxFit.cover,
)),
sliver: new SliverList(
delegate: new SliverChildBuilderDelegate(
(context, i) => new ListTile(
leading: new CircleAvatar(
child: new Text('0'),
),
title: new Text('List tile #$i'),
),
childCount: 4,
),
),
SliverList(
delegate: SliverChildListDelegate(buildList()))
],
),
controller: _refreshController,header: ClassicHeader(refreshStyle: RefreshStyle.Follow,),),
),
SliverToBoxAdapter(
child: Container(),
),

SliverAppBar(
backgroundColor: Colors.greenAccent,
expandedHeight: 200.0,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
background: Image.network(
"https://images.unsplash.com/photo-1541701494587-cb58502866ab?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=0c21b1ac3066ae4d354a3b2e0064c8be&auto=format&fit=crop&w=500&q=60",
fit: BoxFit.cover,
)),
),
SliverList(delegate: SliverChildListDelegate(buildList()))
],
),
controller: _refreshController,
onRefresh: (){
_refreshController.refreshCompleted();
},
header: MaterialClassicHeader(
),
),
);
}
}
32 changes: 16 additions & 16 deletions example/lib/ui/test/Example3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,22 @@ class Example3State extends State<Example3> with TickerProviderStateMixin {
// TODO: implement initState

// for test #68 true-> false ->true
Future.delayed(Duration(milliseconds: 3000),(){
_enablePullDown = false;
_enablePullUp = false;
if(mounted)
setState(() {

});
});
Future.delayed(Duration(milliseconds: 6000),(){
_enablePullDown = true;
_enablePullUp = true;
if(mounted)
setState(() {

});
});
// Future.delayed(Duration(milliseconds: 3000),(){
// _enablePullDown = false;
// _enablePullUp = false;
// if(mounted)
// setState(() {
//
// });
// });
// Future.delayed(Duration(milliseconds: 6000),(){
// _enablePullDown = true;
// _enablePullUp = true;
// if(mounted)
// setState(() {
//
// });
// });

// // for test #68 false-> true ->false
// Future.delayed(Duration(milliseconds: 3000),(){
Expand Down
Loading

0 comments on commit cdae722

Please sign in to comment.