Procházet zdrojové kódy

更新下拉刷新

tags/0.0.1
Weller před 4 roky
rodič
revize
b6364e7919
3 změnil soubory, kde provedl 44 přidání a 16 odebrání
  1. +2
    -2
      .dart_tool/package_config.json
  2. +22
    -10
      lib/pages/main_page/main_page.dart
  3. +20
    -4
      lib/widgets/refresh/refresh_header/refresh_header.dart

+ 2
- 2
.dart_tool/package_config.json Zobrazit soubor

@@ -141,7 +141,7 @@
},
{
"name": "flutter_alibc",
"rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/flutter_alibc-0.0.15",
"rootUri": "file:///Users/fnuser/.pub-cache/git/zhiying_flutter_alibc-6e02aaf22b9798f4b01554a9153d2c66591da8c1/",
"packageUri": "lib/",
"languageVersion": "2.1"
},
@@ -620,7 +620,7 @@
"languageVersion": "2.1"
}
],
"generated": "2020-10-14T08:31:49.974712Z",
"generated": "2020-10-14T08:58:23.460236Z",
"generator": "pub",
"generatorVersion": "2.8.2"
}

+ 22
- 10
lib/pages/main_page/main_page.dart Zobrazit soubor

@@ -1,3 +1,5 @@
import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@@ -18,8 +20,7 @@ import 'package:zhiying_comm/zhiying_comm.dart';
class MainPage extends StatefulWidget {
final Map<String, dynamic> data;

MainPage(
this.data, {
MainPage(this.data, {
Key key,
}) : super(key: key);

@@ -58,7 +59,7 @@ class _MainPageContainerState extends State<_MainPageContainer>
ScrollController _controller = ScrollController();
MainPageBloc _bloc;
RefreshController _refreshController =
RefreshController(initialRefresh: false);
RefreshController(initialRefresh: false);

Widget _floatWidget;

@@ -69,8 +70,12 @@ class _MainPageContainerState extends State<_MainPageContainer>
}

void _onRefresh() async {
await Duration(microseconds: 3);
_refreshController.refreshCompleted();
// await Future.delayed(Duration(milliseconds: 3000));
// _refreshController.refreshCompleted();

if (widget.data.containsKey('skip_identifier')) {
_bloc.loadData(widget.data['skip_identifier']);
}
}

@override
@@ -117,15 +122,20 @@ class _MainPageContainerState extends State<_MainPageContainer>

@override
Widget build(BuildContext context) {
double top = MediaQueryData
.fromWindow(window)
.padding
.top;
return StreamBuilder<List<Map<String, dynamic>>>(
stream: _bloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) {
List widgets = _createContent(context, snapshot.data ?? []);
_refreshController.refreshCompleted();
return Scaffold(
backgroundColor: Color(0xfff9f9f9),
floatingActionButton: _floatWidget,
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
FloatingActionButtonLocation.centerDocked,
body: MediaQuery.removePadding(
removeTop: true,
context: context,
@@ -140,7 +150,9 @@ class _MainPageContainerState extends State<_MainPageContainer>
SmartRefresher(
enablePullDown: true,
enablePullUp: false,
header: RefreshHeader(),
header: RefreshHeader(
offsetY: top,
),
controller: _refreshController,
onLoading: _onLoading,
onRefresh: _onRefresh,
@@ -157,12 +169,12 @@ class _MainPageContainerState extends State<_MainPageContainer>
});
}

List<Widget> _createContent(
BuildContext context, List<Map<String, dynamic>> datas) {
List<Widget> _createContent(BuildContext context,
List<Map<String, dynamic>> datas) {
List<Widget> list = List();
for (int i = 0; i < datas.length; i++) {
WidgetModel item =
WidgetModel.fromJson(Map<String, dynamic>.from(datas[i]));
WidgetModel.fromJson(Map<String, dynamic>.from(datas[i]));

print('item.modName ${item.modName}');
if (item.modName == 'index_taobao_auth_tip') {


+ 20
- 4
lib/widgets/refresh/refresh_header/refresh_header.dart Zobrazit soubor

@@ -1,17 +1,33 @@
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:loading_indicator/loading_indicator.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

class RefreshHeader extends StatelessWidget {
final double offsetY;
final double _height = 44;

const RefreshHeader({Key key, this.offsetY = 0}) : super(key: key);

@override
Widget build(BuildContext context) {
// double top = MediaQueryData.fromWindow(window).padding.top;
return CustomHeader(
height: _height + offsetY,
builder: (BuildContext context, RefreshStatus mode) {
return Container(
height: 120,
margin: EdgeInsets.only(top: offsetY),
// color: Colors.blue,
width: double.infinity,
child: Center(child: LoadingIndicator(
indicatorType: Indicator.lineScale, color: Colors.white,),),
child: Center(
child: Container(
width: 36,
height: 36,
child: LoadingIndicator(
indicatorType: Indicator.ballSpinFadeLoader,
color: Colors.white,
),
),
),
// color: Colors.blue,
);
},


Načítá se…
Zrušit
Uložit