From 0e0a77ad54919f11e2106f32d3c6214f32b7045f Mon Sep 17 00:00:00 2001 From: Weller <1812208341@qq.com> Date: Wed, 14 Oct 2020 16:35:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dart_tool/package_config.json | 8 +++- lib/pages/main_page/main_page.dart | 42 ++++++++++--------- .../refresh_header/refresh_header.dart | 20 +++++++++ pubspec.yaml | 2 + 4 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 lib/widgets/refresh/refresh_header/refresh_header.dart diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 37a01a6..751d7a5 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -259,6 +259,12 @@ "packageUri": "lib/", "languageVersion": "2.1" }, + { + "name": "loading_indicator", + "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/loading_indicator-1.2.0", + "packageUri": "lib/", + "languageVersion": "2.7" + }, { "name": "matcher", "rootUri": "file:///Users/fnuser/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.6", @@ -614,7 +620,7 @@ "languageVersion": "2.1" } ], - "generated": "2020-10-14T06:28:04.630762Z", + "generated": "2020-10-14T08:31:49.974712Z", "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 969cdab..9f2969d 100644 --- a/lib/pages/main_page/main_page.dart +++ b/lib/pages/main_page/main_page.dart @@ -11,6 +11,7 @@ import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier. import 'package:zhiying_base_widget/utils/contants.dart'; import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; +import 'package:zhiying_base_widget/widgets/refresh/refresh_header/refresh_header.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; @@ -67,7 +68,7 @@ class _MainPageContainerState extends State<_MainPageContainer> // _refreshController.loadComplete(); } - void _onRefresh() async{ + void _onRefresh() async { await Duration(microseconds: 3); _refreshController.refreshCompleted(); } @@ -107,6 +108,7 @@ class _MainPageContainerState extends State<_MainPageContainer> Provider.of(context, listen: false).reset(); } }); + ///监听app生命周期变化 WidgetsBinding.instance.addObserver(this); IntellectCreate.checkAndCreateFirst(context); @@ -127,27 +129,27 @@ class _MainPageContainerState extends State<_MainPageContainer> body: MediaQuery.removePadding( removeTop: true, context: context, - child: SmartRefresher( - enablePullDown: true, - enablePullUp: true, - header: WaterDropHeader(), - controller: _refreshController, - onLoading: _onLoading, - onRefresh: _onRefresh, - child: Container( - width: double.infinity, - child: Stack( - fit: StackFit.passthrough, - children: [ - MineHeaderBgWidget( - controller: _controller, - ), - CustomScrollView( + child: Container( + width: double.infinity, + child: Stack( + fit: StackFit.passthrough, + children: [ + MineHeaderBgWidget( + controller: _controller, + ), + SmartRefresher( + enablePullDown: true, + enablePullUp: false, + header: RefreshHeader(), + controller: _refreshController, + onLoading: _onLoading, + onRefresh: _onRefresh, + child: CustomScrollView( controller: _controller, slivers: widgets, - ) - ], - ), + ), + ) + ], ), ), ), diff --git a/lib/widgets/refresh/refresh_header/refresh_header.dart b/lib/widgets/refresh/refresh_header/refresh_header.dart new file mode 100644 index 0000000..4ba5b59 --- /dev/null +++ b/lib/widgets/refresh/refresh_header/refresh_header.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:loading_indicator/loading_indicator.dart'; + +class RefreshHeader extends StatelessWidget { + @override + Widget build(BuildContext context) { + return CustomHeader( + builder: (BuildContext context, RefreshStatus mode) { + return Container( + height: 120, + width: double.infinity, + child: Center(child: LoadingIndicator( + indicatorType: Indicator.lineScale, color: Colors.white,),), + // color: Colors.blue, + ); + }, + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index ec210bf..d1d67f5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,6 +42,8 @@ dependencies: path: ../zhiying_comm intl: 0.16.1 + loading_indicator: ^1.2.0 + dev_dependencies: flutter_test: sdk: flutter