Browse Source

添加loading

tags/0.0.1
Weller 4 years ago
parent
commit
0e0a77ad54
4 changed files with 51 additions and 21 deletions
  1. +7
    -1
      .dart_tool/package_config.json
  2. +22
    -20
      lib/pages/main_page/main_page.dart
  3. +20
    -0
      lib/widgets/refresh/refresh_header/refresh_header.dart
  4. +2
    -0
      pubspec.yaml

+ 7
- 1
.dart_tool/package_config.json View File

@@ -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"
}

+ 22
- 20
lib/pages/main_page/main_page.dart View File

@@ -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<MainPageNotifier>(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: <Widget>[
MineHeaderBgWidget(
controller: _controller,
),
CustomScrollView(
child: Container(
width: double.infinity,
child: Stack(
fit: StackFit.passthrough,
children: <Widget>[
MineHeaderBgWidget(
controller: _controller,
),
SmartRefresher(
enablePullDown: true,
enablePullUp: false,
header: RefreshHeader(),
controller: _refreshController,
onLoading: _onLoading,
onRefresh: _onRefresh,
child: CustomScrollView(
controller: _controller,
slivers: widgets,
)
],
),
),
)
],
),
),
),


+ 20
- 0
lib/widgets/refresh/refresh_header/refresh_header.dart View File

@@ -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,
);
},
);
}
}

+ 2
- 0
pubspec.yaml View File

@@ -42,6 +42,8 @@ dependencies:
path: ../zhiying_comm
intl: 0.16.1

loading_indicator: ^1.2.0

dev_dependencies:
flutter_test:
sdk: flutter


Loading…
Cancel
Save