admin
2022-05-12 fa705507ba574c857b1667553737d23b1b7ff495
src/main/resources/code/flutter_module/lib/ui/widget/refresh_listview.dart
@@ -1,10 +1,12 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/widget/button.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
typedef OnRefresh = void Function();
typedef OnLoadMore = void Function();
typedef BoolCallback = void Function(bool b);
typedef StringCallback = void Function(String s);
typedef GetViewState = RefreshListViewState Function();
class MyRefreshController extends RefreshController {
@@ -47,8 +49,10 @@
class RefreshListView extends StatefulWidget {
  final MyRefreshController refreshController;
  final Widget content;
  final Widget? emptyView;
  final OnRefresh? refresh;
  final OnLoadMore? loadMore;
  final Color loadTextColor;
  bool? enablePullDown;
  bool? enablePullUp;
@@ -56,7 +60,9 @@
  RefreshListView(
      {required this.refreshController,
      required this.content,
        this.emptyView,
      this.refresh,
        this.loadTextColor = const Color(0xFFB8AFB5),
      this.loadMore,
      this.enablePullDown = true,
      this.enablePullUp = true});
@@ -88,7 +94,6 @@
        editMode = enable;
      });
    };
  }
  //视图状态 0-正常  1-空视图  2-网络请求错误
@@ -153,12 +158,15 @@
        : SmartRefresher(
            enablePullDown: widget.enablePullDown!,
            enablePullUp: widget.enablePullUp!,
            header: const WaterDropHeader(
              complete: Text(
                "刷新完成",
                style: TextStyle(color: Color(0xFFB8AFB5)),
              ),
            ),
      header:
      MaterialClassicHeader(),
      // const WaterDropHeader(
      //   complete: Text(
      //     "刷新完成",
      //     style: TextStyle(color: Color(0xFFB8AFB5)),
      //   ),
      // ),
            footer: CustomFooter(
              builder: (BuildContext context, LoadStatus? mode) {
                Widget body;
@@ -174,8 +182,8 @@
                  body = const Text("松手,加载更多!",
                      style: TextStyle(color: Color(0xFFB8AFB5)));
                } else {
                  body = const Text("没有更多数据了!",
                      style: TextStyle(color: Color(0xFFB8AFB5)));
            body = Text("~到底了~",
                style: TextStyle(color: widget.loadTextColor));
                }
                return SizedBox(
                  height: 55.0,
@@ -191,7 +199,8 @@
  }
  Widget emptyView() {
    return Container(
    return widget.emptyView ??
        Container(
      width: MediaQuery.of(context).size.width * 2 / 3,
      alignment: Alignment.center,
      // color: Colors.yellow,
@@ -202,8 +211,8 @@
            "assets/imgs/common/ic_empty.png",
          ),
          const Text(
            "暂无数据     ",
            style: TextStyle(color: Color(0xFFF698C9), fontSize: 18),
                "~空空如也~",
                style: TextStyle(color: Color(0xFF999999), fontSize: 18),
          )
        ],
      ),
@@ -211,25 +220,36 @@
  }
  Widget errorView() {
    return InkWell(
        onTap: () {
          _onRefresh();
        },
        child: Container(
    return Container(
          alignment: Alignment.center,
          // color: Colors.yellow,
          child: Stack(
            alignment: Alignment.bottomCenter,
            children: [
              Image.asset("assets/imgs/common/ic_network_error.png",
                  width: MediaQuery.of(context).size.width * 2 / 5),
              const Text(
                "网络异常,点击重新加载",
                style: TextStyle(color: Color(0xFFF698C9), fontSize: 18),
              width: MediaQuery.of(context).size.width * 3 / 5),
          const Positioned(
              bottom: 50,
              left: 0,
              right: 0,
              child: Text(
                "网络请求出错",
                textAlign: TextAlign.center,
                style: TextStyle(fontSize: 15, color: Color(0xFF999999)),
              )),
          MyFillButton(
            "点击重新加载",
            18,
            width: 170,
            height: 36,
            fontSize: 15,
            onClick: () {
              _onRefresh();
            },
              )
            ],
          ),
        ));
    );
  }
  @override