pageAbler method

Widget pageAbler(
  1. Widget child, {
  2. bool enablePullDown = true,
  3. bool enablePullUp = true,
})

Implementation

Widget pageAbler(
  Widget child, {
  bool enablePullDown = true,
  bool enablePullUp = true,
}) {
  return SmartRefresher(
    enablePullDown: enablePullDown,
    enablePullUp: enablePullUp,
    header: CustomHeader(
      builder: (BuildContext context, RefreshStatus? mode) {
        Widget? body;

        switch (mode ?? RefreshStatus.idle) {
          case RefreshStatus.idle:
            body = Text("下拉刷新", style: TextStyle(color: Colors.grey));
            break;
          case RefreshStatus.canRefresh:
            body = Row(
              children: <Widget>[
                Text("准备刷新 ", style: TextStyle(color: Colors.grey)),
                CupertinoActivityIndicator()
              ],
              mainAxisSize: MainAxisSize.min,
            );
            break;
          case RefreshStatus.refreshing:
            body = Row(
              children: <Widget>[
                Text("数据刷新中 ", style: TextStyle(color: Colors.grey)),
                CupertinoActivityIndicator()
              ],
              mainAxisSize: MainAxisSize.min,
            );
            break;
          case RefreshStatus.completed:
            body = Text("刷新成功", style: TextStyle(color: Colors.grey));
            break;
          case RefreshStatus.failed:
            body = Text("刷新失败", style: TextStyle(color: Colors.grey));
            break;
          case RefreshStatus.canTwoLevel:
            break;
          case RefreshStatus.twoLevelOpening:
            break;
          case RefreshStatus.twoLeveling:
            break;
          case RefreshStatus.twoLevelClosing:
            break;
        }

        return Container(
          height: 55,
          child: Center(
            child: body,
          ),
        );
      },
    ),
    footer: CustomFooter(
      builder: (BuildContext context, LoadStatus? mode) {
        Widget? body;
        switch (mode ?? LoadStatus.idle) {
          case LoadStatus.idle:
            body = Text("上拉加载更多", style: TextStyle(color: Colors.grey));
            break;
          case LoadStatus.canLoading:
            body = Row(
              children: <Widget>[
                Text("准备加载更多", style: TextStyle(color: Colors.grey)),
                CupertinoActivityIndicator()
              ],
              mainAxisSize: MainAxisSize.min,
            );
            break;
          case LoadStatus.loading:
            body = Row(
              children: <Widget>[
                Text("数据加载中", style: TextStyle(color: Colors.grey)),
                CupertinoActivityIndicator()
              ],
              mainAxisSize: MainAxisSize.min,
            );
            break;
          case LoadStatus.noMore:
            body = Text("没有更多数据", style: TextStyle(color: Colors.grey));
            break;
          case LoadStatus.failed:
            body = Text("数据加载失败,点击重试", style: TextStyle(color: Colors.grey));
            break;
        }

        return Container(
          height: 55,
          child: Center(
            child: body,
          ),
        );
      },
    ),
    controller: refreshController,
    onRefresh: _onRefresh,
    onLoading: _onLoading,
    child: child,
  );
}