my_page.dart 14.6 KB
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx/fluwx.dart';
import 'package:one_key/provider/update_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/app_bar.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/my_item.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';

import '../../app.dart';

class MyPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new MyPageState();
  }
}

class MyPageState extends State<MyPage> {
  String cur_version = "";
  bool newVersion = false;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    Utils.getCurrVersion().then((version) {
      setState(() {
        cur_version = "v" + version;
      });
    });
  }

  //检查版本更新
  checkUpdate() {
    UpdateModel updateModel = new UpdateModel();
    updateModel.checkUpdate(context);
  }


  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Padding(
            padding: EdgeInsets.only(top: ScreenUtil().setHeight(242 + 121)),
            child: Column(
              children: <Widget>[
                VEmptyView(40),
                MyItem(
                  title: "包间类型置满管理",
                  content: "",
                  callback: () {
                    Utils.goMiniProgramZm(context);
                  },
                ),
                VEmptyView(40),
                MyItem(
                  title: "联系客服",
                  content: "09:00~21:00",
                  callback: () {
                    Utils.goPhone("400-000-9690");
                  },
                ),
                MyDivider(
                  double.infinity,
                  ScreenUtil().setHeight(1),
                  color: MyColours.color_f3f3f3,
                ),
                MyItem(
                  title: "帮助与反馈",
                  content: "",
                  callback: () {
                    Utils.goHelp(context);
                  },
                ),
                MyDivider(double.infinity, ScreenUtil().setHeight(1),
                    color: MyColours.color_f3f3f3),
                GestureDetector(
                  onTap: checkUpdate,
                  child: Container(
                    width: double.infinity,
                    height: ScreenUtil().setHeight(122),
                    color: MyColours.color_ffffff,
                    padding: EdgeInsets.symmetric(
                        horizontal: ScreenUtil().setWidth(40)),
                    alignment: Alignment.center,
                    child: Row(
                      children: <Widget>[
                        Text(
                          "版本更新",
                          style: TextStyle(
                              fontSize: ScreenUtil().setSp(30),
                              color: MyColours.color_353535),
                        ),
                        Spacer(),
                        newVersion
                            ? Container(
                                width: ScreenUtil().setWidth(120),
                                height: ScreenUtil().setWidth(34),
                                decoration: BoxDecoration(
                                  color: MyColours.color_E14553,
                                  borderRadius: BorderRadius.all(
                                      Radius.circular(
                                          ScreenUtil().setWidth(6))),
                                ),
                                child: Center(
                                  child: Text(
                                    "发现新版本",
                                    style: TextStyle(
                                        fontSize: ScreenUtil().setSp(24),
                                        color: MyColours.color_ffffff),
                                  ),
                                ),
                              )
                            : Text(
                                cur_version,
                                style: TextStyle(
                                    fontSize: ScreenUtil().setSp(28),
                                    color: MyColours.color_666666),
                              ),
                        HEmptyView(20),
                        Image.asset(
                          "assets/arr_right_gray.png",
                          width: ScreenUtil().setWidth(14),
                          height: ScreenUtil().setWidth(22),
                        )
                      ],
                    ),
                  ),
                ),
                MyDivider(
                  double.infinity,
                  ScreenUtil().setHeight(1),
                  color: MyColours.color_f3f3f3,
                ),
                VEmptyView(40),
                Consumer<UserModel>(
                  builder:
                      (BuildContext context, UserModel model, Widget child) {
                    return GestureDetector(
                      onTap: () {
                        model.showLoginOutDialog(context);
                      },
                      child: Container(
                        height: ScreenUtil().setHeight(122),
                        color: MyColours.color_ffffff,
                        child: Center(
                          child: Row(
                            mainAxisSize: MainAxisSize.min,
                            crossAxisAlignment: CrossAxisAlignment.center,
                            children: <Widget>[
                              Image.asset(
                                "assets/icon_exist.png",
                                width: ScreenUtil().setWidth(30),
                                height: ScreenUtil().setWidth(30),
                              ),
                              HEmptyView(18),
                              Text("退出登录",
                                  style: TextStyle(
                                    color: MyColours.color_199095,
                                    fontSize: ScreenUtil().setSp(34),
                                  ))
                            ],
                          ),
                        ),
                      ),
                    );
                  },
                )
              ],
            )),
        Container(
            width: double.infinity,
            height: ScreenUtil().setHeight(242 + 121),
            alignment: Alignment.centerLeft,
            color: MyColours.color_199095,
            child: Scaffold(
                backgroundColor: Colors.transparent, //把scaffold的背景色改成透明
                appBar: AppBar(
                    backgroundColor: Colors.transparent, //把appbar的背景色改成透明
                    elevation: 0, //appbar的阴影
                    centerTitle: true, // 标题居中
                    title: Text(
                      '我的',
                      style: TextStyle(
                          color: MyColours.color_fefefe,
                          fontSize: ScreenUtil().setSp(34),
                          fontWeight: FontWeight.normal,
                          decoration: TextDecoration.none),
                    )),
                body: Consumer<UserModel>(
                  builder:
                      (BuildContext context, UserModel model, Widget child) {
                    return Padding(
                        padding:
                            EdgeInsets.only(left: ScreenUtil().setWidth(40)),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            VEmptyView(38),
                            Text(
                              model.user.sellername,
                              style: TextStyle(
                                  color: MyColours.color_ffffff,
                                  fontSize: ScreenUtil().setSp(36)),
                            ),
                            VEmptyView(38),
                            Text(
                              model.user.account +
                                  "  |  " +
                                  model.user.role_name,
                              style: TextStyle(
                                  color: MyColours.color_ffffff,
                                  fontSize: ScreenUtil().setSp(30)),
                            ),
                          ],
                        ));
                  },
                )))
      ],
    );
    // TODO: implement build
    /*   原来的
    return Container(
      width: double.infinity,
      height: double.infinity,
      color: MyColours.color_f5f5f5,
      child: Column(
        children: <Widget>[
          MyAppBar(
            "我的",
            showBack: false,
            backgroundColor: MyColours.color_199095,
            fontColor: MyColours.color_fefefe,
          ),
          Container(
              width: double.infinity,
              height: ScreenUtil().setHeight(242),
              alignment: Alignment.centerLeft,
              padding: EdgeInsets.only(left: ScreenUtil().setWidth(40)),
              color: MyColours.color_199095,
              child: Consumer<UserModel>(
                builder: (BuildContext context, UserModel model, Widget child) {
                  return Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      VEmptyView(38),
                      Text(
                        model.user.sellername,
                        style: TextStyle(
                            color: MyColours.color_ffffff,
                            fontSize: ScreenUtil().setSp(36)),
                      ),
                      VEmptyView(38),
                      Text(
                        model.user.account + "  |  " + model.user.role_name,
                        style: TextStyle(
                            color: MyColours.color_ffffff,
                            fontSize: ScreenUtil().setSp(30)),
                      ),
                    ],
                  );
                },
              )),
          VEmptyView(44),
          MyItem(
            title: "联系客服",
            content: "09:00~21:00",
            callback: () {
              Utils.goPhone("400-000-9690");
            },
          ),
          MyDivider(
            double.infinity,
            ScreenUtil().setHeight(1),
            color: MyColours.color_f3f3f3,
          ),
          MyItem(
            title: "帮助与反馈",
            content: "",
            callback: () {
              Utils.goHelp(context);
            },
          ),
          MyDivider(double.infinity, ScreenUtil().setHeight(1),
              color: MyColours.color_f3f3f3),
          GestureDetector(
            onTap: checkUpdate,
            child: Container(
              width: double.infinity,
              height: ScreenUtil().setHeight(122),
              color: MyColours.color_ffffff,
              padding:
                  EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40)),
              alignment: Alignment.center,
              child: Row(
                children: <Widget>[
                  Text(
                    "版本更新",
                    style: TextStyle(
                        fontSize: ScreenUtil().setSp(30),
                        color: MyColours.color_353535),
                  ),
                  Spacer(),
                  newVersion
                      ? Container(
                          width: ScreenUtil().setWidth(120),
                          height: ScreenUtil().setWidth(34),
                          decoration: BoxDecoration(
                            color: MyColours.color_E14553,
                            borderRadius: BorderRadius.all(
                                Radius.circular(ScreenUtil().setWidth(6))),
                          ),
                          child: Center(
                            child: Text(
                              "发现新版本",
                              style: TextStyle(
                                  fontSize: ScreenUtil().setSp(24),
                                  color: MyColours.color_ffffff),
                            ),
                          ),
                        )
                      : Text(
                          cur_version,
                          style: TextStyle(
                              fontSize: ScreenUtil().setSp(28),
                              color: MyColours.color_666666),
                        ),
                  HEmptyView(20),
                  Image.asset(
                    "assets/arr_right_gray.png",
                    width: ScreenUtil().setWidth(14),
                    height: ScreenUtil().setWidth(22),
                  )
                ],
              ),
            ),
          ),
          MyDivider(
            double.infinity,
            ScreenUtil().setHeight(1),
            color: MyColours.color_f3f3f3,
          ),
          VEmptyView(40),
          Consumer<UserModel>(
            builder: (BuildContext context, UserModel model, Widget child) {
              return GestureDetector(
                onTap: () {
                  model.showLoginOutDialog(context);
                },
                child: Container(
                  height: ScreenUtil().setHeight(122),
                  color: MyColours.color_ffffff,
                  child: Center(
                    child: Row(
                      mainAxisSize: MainAxisSize.min,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        Image.asset(
                          "assets/icon_exist.png",
                          width: ScreenUtil().setWidth(30),
                          height: ScreenUtil().setWidth(30),
                        ),
                        HEmptyView(18),
                        Text("退出登录",
                            style: TextStyle(
                              color: MyColours.color_199095,
                              fontSize: ScreenUtil().setSp(34),
                            ))
                      ],
                    ),
                  ),
                ),
              );
            },
          )
        ],
      ),
    );
    */
  }
}