From b6364e7919dd113581323e378cbb38132da5a5b6 Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Wed, 14 Oct 2020 17:34:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=8B=E6=8B=89=E5=88=B7?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dart_tool/package_config.json | 4 +-- lib/pages/main_page/main_page.dart | 32 +++++++++++++------ .../refresh_header/refresh_header.dart | 24 +++++++++++--- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 751d7a5..f980bb6 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -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" } diff --git a/lib/pages/main_page/main_page.dart b/lib/pages/main_page/main_page.dart index 9f2969d..5223be8 100644 --- a/lib/pages/main_page/main_page.dart +++ b/lib/pages/main_page/main_page.dart @@ -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 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>>( 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 _createContent( - BuildContext context, List> datas) { + List _createContent(BuildContext context, + List> datas) { List list = List(); for (int i = 0; i < datas.length; i++) { WidgetModel item = - WidgetModel.fromJson(Map.from(datas[i])); + WidgetModel.fromJson(Map.from(datas[i])); print('item.modName ${item.modName}'); if (item.modName == 'index_taobao_auth_tip') { diff --git a/lib/widgets/refresh/refresh_header/refresh_header.dart b/lib/widgets/refresh/refresh_header/refresh_header.dart index 4ba5b59..eb81664 100644 --- a/lib/widgets/refresh/refresh_header/refresh_header.dart +++ b/lib/widgets/refresh/refresh_header/refresh_header.dart @@ -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, ); },