|
|
@@ -3,7 +3,9 @@ import 'package:deus_app/common/style/gsy_style.dart';
|
|
|
import 'package:deus_app/common/utils/ConstantString.dart';
|
|
|
import 'package:deus_app/common/utils/ToastUtils.dart';
|
|
|
import 'package:deus_app/widget/MyDrawer.dart';
|
|
|
+import 'package:flutter/cupertino.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
+import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
|
|
class DeviceManagePage extends StatefulWidget {
|
|
|
static var routeName = '/DeviceManagePage';
|
|
|
@@ -19,25 +21,46 @@ class DeviceManagePage extends StatefulWidget {
|
|
|
class _DeviceManage extends State<DeviceManagePage> {
|
|
|
String deviceNum = "0";
|
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
|
|
|
+ RefreshController _refreshController =
|
|
|
+ RefreshController(initialRefresh: false);
|
|
|
+
|
|
|
+ void _onRefresh() async {
|
|
|
+ // monitor network fetch
|
|
|
+ await Future.delayed(Duration(milliseconds: 1000));
|
|
|
+ // if failed,use refreshFailed()
|
|
|
+ _refreshController.refreshCompleted();
|
|
|
+ }
|
|
|
+
|
|
|
+ void _onLoading() async {
|
|
|
+ // monitor network fetch
|
|
|
+ await Future.delayed(Duration(milliseconds: 1000));
|
|
|
+ // if failed,use loadFailed(),if no data return,use LoadNodata()
|
|
|
+ // items.add((items.length+1).toString());
|
|
|
+ if (mounted) setState(() {});
|
|
|
+ _refreshController.loadComplete();
|
|
|
+ }
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext contexts) {
|
|
|
return Scaffold(
|
|
|
key: _scaffoldKey,
|
|
|
appBar: TitleBar().drawAppBar(ConstantString.deviceManageText, () {
|
|
|
- _scaffoldKey.currentState?.openEndDrawer();
|
|
|
+ _scaffoldKey.currentState?.openEndDrawer();
|
|
|
}),
|
|
|
backgroundColor: const Color(0xfff2f2f2),
|
|
|
- endDrawer: MyDrawer(callback: (index, str){
|
|
|
- showToast(str);
|
|
|
- },), //抽屉
|
|
|
+ endDrawer: MyDrawer(
|
|
|
+ callback: (index, str) {
|
|
|
+ showToast(str);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ //抽屉
|
|
|
body: Column(
|
|
|
children: [
|
|
|
SizedBox(
|
|
|
height: 10,
|
|
|
),
|
|
|
Row(
|
|
|
- mainAxisAlignment:MainAxisAlignment.start,
|
|
|
+ mainAxisAlignment: MainAxisAlignment.start,
|
|
|
children: [
|
|
|
SizedBox(
|
|
|
width: 15,
|
|
|
@@ -48,7 +71,33 @@ class _DeviceManage extends State<DeviceManagePage> {
|
|
|
],
|
|
|
),
|
|
|
Expanded(
|
|
|
- child: Container(
|
|
|
+ child: SmartRefresher(
|
|
|
+ enablePullDown: true,
|
|
|
+ enablePullUp: true,
|
|
|
+ header: WaterDropHeader(),
|
|
|
+ footer: CustomFooter(
|
|
|
+ builder: (BuildContext context, LoadStatus? mode) {
|
|
|
+ Widget body;
|
|
|
+ if (mode == LoadStatus.idle) {
|
|
|
+ body = Text("上拉加载");
|
|
|
+ } else if (mode == LoadStatus.loading) {
|
|
|
+ body = CupertinoActivityIndicator();
|
|
|
+ } else if (mode == LoadStatus.failed) {
|
|
|
+ body = Text("加载失败!点击重试!");
|
|
|
+ } else if (mode == LoadStatus.canLoading) {
|
|
|
+ body = Text("松手,加载更多!");
|
|
|
+ } else {
|
|
|
+ body = Text("没有更多数据了!");
|
|
|
+ }
|
|
|
+ return Container(
|
|
|
+ height: 55.0,
|
|
|
+ child: Center(child: body),
|
|
|
+ );
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ controller: _refreshController,
|
|
|
+ onRefresh: _onRefresh,
|
|
|
+ onLoading: _onLoading,
|
|
|
child: ListView.builder(
|
|
|
itemCount: 20,
|
|
|
itemBuilder: (context, index) {
|