Merge branch 'cfh763551832-master'

This commit is contained in:
sanfan.hx
2019-09-24 14:13:35 +08:00
11 changed files with 454 additions and 2 deletions

View File

@ -1 +1 @@
[{"name":"RangeSlider","screenShot":"","author":"RangeSlider","email":"hanxu317@qq.com","desc":"RangeSlider widget demo","id":"e5f958bc_52ae_4241_9c8a_5c9e1f92b096"},{"name":"demoName","screenShot":"","author":"yourName","email":"yourEmail","desc":"这是一个测试的标准demo","id":"1a29aa8e_32ae_4241_9c8a_5c9e1f92b096"},{"name":"local","screenShot":"","author":"ab","email":"email","desc":"ags","id":"2c1d57d0_42ae_4241_9c8a_5c9e1f92b096"}]
[{"name":"PullToRefresh","screenShot":"","author":"chenfeihu","email":"763551832@qq.com","desc":"刷新组件","id":"5553db80_52ae_4241_9c8a_5c9e1f92b096"},{"name":"RangeSlider","screenShot":"","author":"RangeSlider","email":"hanxu317@qq.com","desc":"RangeSlider widget demo","id":"e5f958bc_52ae_4241_9c8a_5c9e1f92b096"},{"name":"demoName","screenShot":"","author":"yourName","email":"yourEmail","desc":"这是一个测试的标准demo","id":"1a29aa8e_32ae_4241_9c8a_5c9e1f92b096"},{"name":"local","screenShot":"","author":"ab","email":"email","desc":"ags","id":"2c1d57d0_42ae_4241_9c8a_5c9e1f92b096"}]

View File

@ -0,0 +1,9 @@
{
"name": "PullToRefresh",
"screenShot": "",
"author":"chenfeihu",
"email": "763551832@qq.com",
"desc": "刷新组件",
"id": "5553db80_52ae_4241_9c8a_5c9e1f92b096"
}

View File

@ -0,0 +1,15 @@
//
// Created with flutter go cli
// User: chenfeihu
// Time: 2019-09-24 12:11:14.085126
// email: 763551832@qq.com
// desc: 刷新组件
//
import 'src/index.dart';
var demoWidgets = [
new Demo()
];

View File

@ -0,0 +1,241 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
class Demo extends StatefulWidget {
@override
_State createState() => _State();
}
class _State extends State<Demo> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(5.0),
width: double.infinity,
height: 600.0,
child: Pulltorefresh(),
);
}
}
class Pulltorefresh extends StatefulWidget {
@override
_PulltorefreshState createState() => _PulltorefreshState();
}
class _PulltorefreshState extends State<Pulltorefresh> {
List<Widget> datas=ListData.getList();
RefreshController _controller=RefreshController(initialRefresh: false);
void _onRefresh() async{
await Future.delayed(Duration(milliseconds: 1000));
_controller.refreshCompleted();
}
void _onLoading() async{
await Future.delayed(Duration(milliseconds: 1500));
ItemModel model=ItemModel(getRandomColor(), Icons.airplanemode_active, "军事新闻", "俄军大秀战略",
"酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 5000);
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
if(mounted)
setState(() {
});
_controller.loadComplete();
}
@override
Widget build(BuildContext context) {
Widget _itemBuilder(BuildContext context, int position) {
return Card(child: this.datas[position]);
}
return Scaffold(
appBar: AppBar(
title: Text("Pulltorefresh"),
),
body: SmartRefresher(
enablePullDown: true,
enablePullUp: true,
header: WaterDropHeader(),
footer: ClassicFooter(
loadStyle: LoadStyle.ShowAlways,
completeDuration: Duration(microseconds: 50),
),
onRefresh: _onRefresh,
onLoading: _onLoading,
controller: _controller,
child: ListView.builder(itemBuilder: _itemBuilder,itemCount: this.datas.length),
),
);
}
Color getRandomColor(){
List<Color> colors=[Colors.deepOrange,Colors.amber,Colors.cyan,Colors.green,Colors.red,Colors.yellow];
int randomValue=Random().nextInt(colors.length);
if(randomValue==colors.length){
randomValue=colors.length-1;
}
return colors[randomValue];
}
}
class Item extends StatelessWidget {
Color color;
IconData icon;
String mainTitle;
String subTitle;
String des;
int readCount;
Item(this.color, this.icon, this.mainTitle, this.subTitle, this.des,
this.readCount);
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.fromLTRB(10.0, 5.0, 10.0, 5.0),
height: 90.0,
child: Row(
children: <Widget>[
Container(
width: 90.0,
color: color,
alignment: Alignment.center,
child: Icon(icon, color: Colors.white),
),
SizedBox(width: 10),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text(mainTitle,
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 18.0))),
Expanded(child: Text(subTitle, style: TextStyle(fontSize: 14.0))),
Expanded(
child: Text(
des,
style: TextStyle(fontSize: 13.0),
overflow: TextOverflow.ellipsis,
)),
Expanded(
child: Text("阅读量:${readCount.toString()}",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.0,
color: Colors.redAccent))),
],
))
],
),
);
}
}
class ItemModel{
Color _color;
IconData _icon;
String _mainTitle;
String _subTitle;
String _des;
int _readCount;
ItemModel(this._color, this._icon, this._mainTitle, this._subTitle, this._des,
this._readCount);
int get readCount => _readCount;
set readCount(int value) {
_readCount = value;
}
String get des => _des;
set des(String value) {
_des = value;
}
String get subTitle => _subTitle;
set subTitle(String value) {
_subTitle = value;
}
String get mainTitle => _mainTitle;
set mainTitle(String value) {
_mainTitle = value;
}
IconData get icon => _icon;
set icon(IconData value) {
_icon = value;
}
Color get color => _color;
set color(Color value) {
_color = value;
}
}
class ListData{
static List<Widget> getList(){
List<Widget> models=[];
ItemModel model1= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "俄军大秀战略",
"酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 2999);
ItemModel model2= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "俄“中部”演习",
"俄罗斯卫星网报道称,俄罗斯国防部长绍伊古表示,“中央-2019”战略演习是", 4588);
ItemModel model3= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "中国2.7万吨坞登舰",
"据印度新德里电视台16日报道印度海军发现7艘中国军舰在印度洋", 7777);
ItemModel model4= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "针对中国?",
"美国空军着力打造军用5G网络5G+VR飞行员无需上天就能操控战机美军濒海", 8888);
ItemModel model5= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "“凯旋”防空导弹系统",
"俄罗斯卫星通讯社报道俄罗斯北方舰队Russian Northern Fleet新闻处", 9999);
ItemModel model6= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "火箭军还有骑兵连",
"迅速对禁区“敌特分子”活动区域进行侦察定位,战斗小分队", 104754);
ItemModel model7= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "侦察兵跨越冰川",
"在海拔5000多米的雪域高原第77集团军某合成旅的侦察兵们正在进行野外驻训", 47545);
ItemModel model8= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "香港被护商船",
"新京报快讯 据北海舰队官微消息:“感谢海军!”“祖国万岁!”,当地时", 124574);
models.add(Item(model1.color, model1.icon, model1.mainTitle, model1.subTitle, model1.des, model1.readCount));
models.add(Item(model2.color, model2.icon, model2.mainTitle, model2.subTitle, model2.des, model2.readCount));
models.add(Item(model3.color, model3.icon, model3.mainTitle, model3.subTitle, model3.des, model3.readCount));
models.add(Item(model4.color, model4.icon, model4.mainTitle, model4.subTitle, model4.des, model4.readCount));
models.add(Item(model5.color, model5.icon, model5.mainTitle, model5.subTitle, model5.des, model5.readCount));
models.add(Item(model6.color, model6.icon, model6.mainTitle, model6.subTitle, model6.des, model6.readCount));
models.add(Item(model7.color, model7.icon, model7.mainTitle, model7.subTitle, model7.des, model7.readCount));
models.add(Item(model8.color, model8.icon, model8.mainTitle, model8.subTitle, model8.des, model8.readCount));
return models;
}
}

View File

@ -1,7 +1,9 @@
import 'PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096;
import 'RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096;
import 'demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096;
import 'local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096;
var demoObjects = {
'5553db80_52ae_4241_9c8a_5c9e1f92b096': StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096.demoWidgets,
'e5f958bc_52ae_4241_9c8a_5c9e1f92b096': StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096.demoWidgets,
'1a29aa8e_32ae_4241_9c8a_5c9e1f92b096': StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096.demoWidgets,
'2c1d57d0_42ae_4241_9c8a_5c9e1f92b096': StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096.demoWidgets

View File

@ -1 +1 @@
[{"name":"local","screenShot":"","author":"hnaxu","title":"本地","email":"hanxu@qq.com","desc":"desc","id":"5d7178d0_42ae_4241_9c8a_5c9e1f92b096"},{"name":"test","screenShot":"","author":"abc","title":"ya","email":"adsf.com","desc":"desc","id":"84f38e00_42ae_4241_9c8a_5c9e1f92b096"},{"name":"standard","screenShot":"","author":"sanfan","title":"介绍页","email":"hanxu317@qq.com","desc":"desc","id":"ee4feb8e_32ae_4241_9c8a_5c9e1f92b096"},{"name":"standard_for_slider","screenShot":"","author":"sanfan","title":"slider组件","email":"hanxu@qq.com","desc":"slider, new Slider","id":"8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096"},{"name":"RangeSlider","screenShot":"","author":"hanxu","title":"RangeSlider","email":"hanxu317@qq.com","desc":"RangeSlider widget","id":"cbffbf7c_52ae_4241_9c8a_5c9e1f92b096"}]
[{"name":"PullToRefresh","screenShot":"","author":"chenfeihu","title":"PullToRefresh","email":"763551832@qq.com","desc":"Refresh conponent","id":"cd9b8b80_52ae_4241_9c8a_5c9e1f92b096"},{"name":"local","screenShot":"","author":"hnaxu","title":"本地","email":"hanxu@qq.com","desc":"desc","id":"5d7178d0_42ae_4241_9c8a_5c9e1f92b096"},{"name":"test","screenShot":"","author":"abc","title":"ya","email":"adsf.com","desc":"desc","id":"84f38e00_42ae_4241_9c8a_5c9e1f92b096"},{"name":"standard","screenShot":"","author":"sanfan","title":"介绍页","email":"hanxu317@qq.com","desc":"desc","id":"ee4feb8e_32ae_4241_9c8a_5c9e1f92b096"},{"name":"standard_for_slider","screenShot":"","author":"sanfan","title":"slider组件","email":"hanxu@qq.com","desc":"slider, new Slider","id":"8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096"},{"name":"RangeSlider","screenShot":"","author":"hanxu","title":"RangeSlider","email":"hanxu317@qq.com","desc":"RangeSlider widget","id":"cbffbf7c_52ae_4241_9c8a_5c9e1f92b096"}]

View File

@ -0,0 +1,10 @@
{
"name": "PullToRefresh",
"screenShot": "",
"author":"chenfeihu",
"title":"PullToRefresh",
"email": "763551832@qq.com",
"desc": "Refresh conponent",
"id": "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096"
}

View File

@ -0,0 +1,87 @@
String getMd() {
return """
# PullToRefresh
> 下拉刷新 上拉加载
PullToRefresh 是一个刷新列表组件借助于pull_to_refresh库实现感觉这是目前最好的一款三方刷新库它的可定制性比较好刷新样式多样化已经满足大部分的开发需求。
### **基本用法**
* 添加依赖 pull_to_refresh: ^1.5.6
* ListView包裹一层SmartRefresher
### **SmartRefresher常用属性说明**
* **enablePullDown** 允许下拉刷新
* **enablePullUp** 允许上拉加载
* **header** 下拉刷新头部样式
* **footer** 上拉加载底部样式
* **onRefresh** 下拉刷新的回调
* **onLoading** 上拉加载的回调
* **controller** 刷新控件的控制器,用来处理回调状态等
### **国际化显示**
```
需要添加语言本地化SDK不然刷新库头部与底部显示加载提示内容为英文
添加依赖 flutter_localizations:
sdk: flutter
main.dart中MateriaApp里面添加以下内容
localizationsDelegates: [
// 这行是关键
RefreshLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalMaterialLocalizations.delegate
],
supportedLocales: [
const Locale('en'),
const Locale('zh'),
],
localeResolutionCallback:
(Locale locale, Iterable<Locale> supportedLocales) {
//print("change language");
return locale;
},
```
### **全局配置**
全局配置RefreshConfiguration,配置子树下的所有SmartRefresher表现,一般存放于MaterialApp的根部
```
RefreshConfiguration(
headerBuilder: () => WaterDropHeader(), // 配置默认头部指示器,假如你每个页面的头部指示器都一样的话,你需要设置这个
footerBuilder: () => ClassicFooter(), // 配置默认底部指示器
headerTriggerDistance: 80.0, // 头部触发刷新的越界距离
springDescription:SpringDescription(stiffness: 170, damping: 16, mass: 1.9), // 自定义回弹动画,三个属性值意义请查询flutter api
maxOverScrollExtent :100, //头部最大可以拖动的范围,如果发生冲出视图范围区域,请设置这个属性
maxUnderScrollExtent:0, // 底部最大可以拖动的范围
enableScrollWhenRefreshCompleted: true, //这个属性不兼容PageView和TabBarView,如果你特别需要TabBarView左右滑动,你需要把它设置为true
enableLoadingWhenFailed : true, //在加载失败的状态下,用户仍然可以通过手势上拉来触发加载更多
hideFooterWhenNotFull: false, // Viewport不满一屏时,禁用上拉加载更多功能
enableBallisticLoad: true, // 可以通过惯性滑动触发加载更多
child: MaterialApp(
........
)
);
```
### 实例展示
[demo:5553db80_52ae_4241_9c8a_5c9e1f92b096]
""";
}

View File

@ -0,0 +1,82 @@
# PullToRefresh
> 下拉刷新 上拉加载
PullToRefresh 是一个刷新列表组件借助于pull_to_refresh库实现感觉这是目前最好的一款三方刷新库它的可定制性比较好刷新样式多样化已经满足大部分的开发需求。
### **基本用法**
* 添加依赖 pull_to_refresh: ^1.5.6
* ListView包裹一层SmartRefresher
### **SmartRefresher常用属性说明**
* **enablePullDown** 允许下拉刷新
* **enablePullUp** 允许上拉加载
* **header** 下拉刷新头部样式
* **footer** 上拉加载底部样式
* **onRefresh** 下拉刷新的回调
* **onLoading** 上拉加载的回调
* **controller** 刷新控件的控制器,用来处理回调状态等
### **国际化显示**
```
需要添加语言本地化SDK不然刷新库头部与底部显示加载提示内容为英文
添加依赖 flutter_localizations:
sdk: flutter
main.dart中MateriaApp里面添加以下内容
localizationsDelegates: [
// 这行是关键
RefreshLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalMaterialLocalizations.delegate
],
supportedLocales: [
const Locale('en'),
const Locale('zh'),
],
localeResolutionCallback:
(Locale locale, Iterable<Locale> supportedLocales) {
//print("change language");
return locale;
},
```
### **全局配置**
全局配置RefreshConfiguration,配置子树下的所有SmartRefresher表现,一般存放于MaterialApp的根部
```
RefreshConfiguration(
headerBuilder: () => WaterDropHeader(), // 配置默认头部指示器,假如你每个页面的头部指示器都一样的话,你需要设置这个
footerBuilder: () => ClassicFooter(), // 配置默认底部指示器
headerTriggerDistance: 80.0, // 头部触发刷新的越界距离
springDescription:SpringDescription(stiffness: 170, damping: 16, mass: 1.9), // 自定义回弹动画,三个属性值意义请查询flutter api
maxOverScrollExtent :100, //头部最大可以拖动的范围,如果发生冲出视图范围区域,请设置这个属性
maxUnderScrollExtent:0, // 底部最大可以拖动的范围
enableScrollWhenRefreshCompleted: true, //这个属性不兼容PageView和TabBarView,如果你特别需要TabBarView左右滑动,你需要把它设置为true
enableLoadingWhenFailed : true, //在加载失败的状态下,用户仍然可以通过手势上拉来触发加载更多
hideFooterWhenNotFull: false, // Viewport不满一屏时,禁用上拉加载更多功能
enableBallisticLoad: true, // 可以通过惯性滑动触发加载更多
child: MaterialApp(
........
)
);
```
### 实例展示
[demo:5553db80_52ae_4241_9c8a_5c9e1f92b096]

View File

@ -1,4 +1,5 @@
import 'PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096;
import 'local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096;
import 'test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096;
import 'standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096;
@ -9,6 +10,8 @@ class StandardPages {
Map<String, String> getPages() {
return {
"0": "0" ,
"cd9b8b80_52ae_4241_9c8a_5c9e1f92b096" : StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096.getMd()
,
"5d7178d0_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096.getMd()
,
"84f38e00_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096.getMd()
@ -23,6 +26,8 @@ class StandardPages {
List<Map<String, String>> getLocalList() {
return [
{},
{ "id": "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096", "name": "PullToRefresh", "email": "763551832@qq.com", "author": "chenfeihu"}
,
{ "id": "5d7178d0_42ae_4241_9c8a_5c9e1f92b096", "name": "local", "email": "hanxu@qq.com", "author": "hnaxu"}
,
{ "id": "84f38e00_42ae_4241_9c8a_5c9e1f92b096", "name": "test", "email": "adsf.com", "author": "abc"}

View File

@ -53,6 +53,7 @@ dependencies:
flutter_jpush: ^0.0.4
zefyr:
path: ./zefyr
pull_to_refresh: ^1.5.6
dev_dependencies: