page_empty.dart 2.63 KB

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/v_empty_view.dart';

class EmptyPage extends StatefulWidget {
  final String? content;
  final String imgname;
  final Color bgcolor;

  final String? showText;
  final VoidCallback? callback;

  const EmptyPage(
      {Key? key,
      this.content,
      this.imgname = "bg_error",
      this.bgcolor = MyColours.color_ffffff,
      this.showText,
      this.callback})
      : super(key: key);

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new EmptyPageState();
  }
}

class EmptyPageState extends State<EmptyPage> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
        width: double.infinity,
        height: double.infinity,
        color: widget.bgcolor,
        child: Stack(
          children: <Widget>[
            Container(
              width: double.infinity,
              height: double.infinity,
              margin: EdgeInsets.only(top: ScreenUtil().setWidth(132)),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: <Widget>[
                  Image.asset(
                    Utils.getImgPath(widget.imgname),
                    width: ScreenUtil().setWidth(520),
                    height: ScreenUtil().setWidth(384),
                  ),
                  VEmptyView(40),
                  Row(mainAxisAlignment: MainAxisAlignment.center, children: [
                    Text(
                      widget.content ?? "数据为空",
                      textAlign: TextAlign.center,
                      strutStyle: StrutStyle(leading: ScreenUtil().setWidth(1)),
                      style: TextStyle(
                          fontSize: ScreenUtil().setSp(28),
                          color: MyColours.color_353535),
                    ),
                    widget.showText != null
                        ? InkWell(
                            onTap: () {
                              widget.callback!();
                            },
                            child: Text(
                              widget.showText!,
                              style: TextStyle(
                                  fontSize: ScreenUtil().setSp(28),
                                  color: MyColours.color_438E93),
                            ))
                        : SizedBox()
                  ])
                ],
              ),
            ),
          ],
        ));
  }
}