invitation_page.dart 14.1 KB
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/user.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';

class InvicationPage extends StatefulWidget {
  final String rid; //预订订单id
  final String tableInfo; //桌位信息
  final String ddate;
  final String ddateStr;
  final String phone;

  InvicationPage(
      this.rid, this.tableInfo, this.ddate, this.ddateStr, this.phone);

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

class InvicationPageState extends State<InvicationPage> {
  User user;
  DateTime dateTime;
  String dateTimeStr = "";
  ScrollController controller = ScrollController();
  final double couponHeight = 180.0;
  CouponProvider couponProvider;

  @override
  void initState() {
    super.initState();
    Utils.changeStatusColor(color: Colors.transparent);
    dateTime =
        DateTime.fromMillisecondsSinceEpoch(int.parse(widget.ddate) * 1000);
    user = Provider.of<UserModel>(context, listen: false).user;
    dateTimeStr =
        "${dateTime.year}/${Utils.addZeroNumber(dateTime.month)}/${Utils.addZeroNumber(dateTime.day)} 星期${Utils.formatWeekDayNum(dateTime.weekday)} ${widget.ddateStr}";
  }

  @override
  void dispose() {
    Utils.changeStatusColor();
    super.dispose();
  }

  //中间内容显示组件
  Widget _middleWidget(String title, String content) {
    return Column(
      children: <Widget>[
        VEmptyView(38),
        Row(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Image.asset(
              "assets/invication_line_left.png",
              width: ScreenUtil().setWidth(44),
              height: ScreenUtil().setWidth(4),
            ),
            Container(
              margin:
                  EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(13)),
              child: Text(title,
                  style: TextStyle(
                      color: MyColours.color_eadab9,
                      fontSize: ScreenUtil().setSp(32))),
            ),
            Image.asset(
              "assets/invication_line_right.png",
              width: ScreenUtil().setWidth(44),
              height: ScreenUtil().setWidth(4),
            )
          ],
        ),
        Container(
          margin: EdgeInsets.only(top: ScreenUtil().setHeight(20)),
          child: Text(
            content,
            style: TextStyle(
                color: MyColours.color_ffffff,
                fontSize: ScreenUtil().setSp(34)),
          ),
        )
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build

    couponProvider = Provider.of<CouponProvider>(context, listen: true);
    return Container(
        width: double.infinity,
        // height: double.infinity,
        decoration: BoxDecoration(
          image: DecorationImage(
              image: AssetImage("assets/bg_invication.png"), fit: BoxFit.cover),
        ),
        child: Scaffold(
            backgroundColor: Colors.transparent,
            body: SafeArea(
                child: Stack(
              children: [
                Padding(
                    padding: EdgeInsets.only(top: ScreenUtil().setWidth(0)),
                    child: Column(children: [
                      Expanded(
                          child: ListView(
                              controller: controller,
                              physics: BouncingScrollPhysics(),
                              children: <Widget>[
                            VEmptyView(60),
                            Center(
                              child: Column(
                                children: <Widget>[
                                  Image.asset(
                                    "assets/img_ydap.png",
                                    width: ScreenUtil().setWidth(500),
                                    height: ScreenUtil().setHeight(300),
                                  ),
                                  VEmptyView(69),
                                  Row(
                                    mainAxisSize: MainAxisSize.min,
                                    children: <Widget>[
                                      Container(
                                        width: ScreenUtil().setWidth(108),
                                        height: ScreenUtil().setHeight(2),
                                        color: MyColours.color_ffffff,
                                      ),
                                      Container(
                                        width: ScreenUtil().setWidth(442),
                                        height: ScreenUtil().setHeight(43),
                                        alignment: Alignment.center,
                                        decoration: BoxDecoration(
                                            border: Border.all(
                                                color: MyColours.color_ffffff,
                                                width:
                                                    ScreenUtil().setWidth(2)),
                                            borderRadius: BorderRadius.all(
                                                Radius.circular(ScreenUtil()
                                                    .setWidth(18)))),
                                        child: Text(
                                          "订包间,用周到安排",
                                          style: TextStyle(
                                              color: MyColours.color_ffffff,
                                              fontSize: ScreenUtil().setSp(28)),
                                        ),
                                      ),
                                      Container(
                                        width: ScreenUtil().setWidth(108),
                                        height: ScreenUtil().setHeight(2),
                                        color: MyColours.color_ffffff,
                                      ),
                                    ],
                                  ),
                                  _middleWidget("餐厅", user.sellername),
                                  _middleWidget("包间",
                                      widget.tableInfo.replaceAll("\n", "")),
                                  _middleWidget("时间", dateTimeStr),
                                  VEmptyView(38),
                                  Column(
                                    children: <Widget>[
                                      Row(
                                        mainAxisSize: MainAxisSize.min,
                                        children: <Widget>[
                                          Image.asset(
                                            "assets/invication_map.png",
                                            width: ScreenUtil().setWidth(22),
                                            height: ScreenUtil().setWidth(28),
                                          ),
                                          Container(
                                            margin: EdgeInsets.symmetric(
                                                horizontal:
                                                    ScreenUtil().setWidth(13)),
                                            child: Text("地址导航",
                                                style: TextStyle(
                                                    color:
                                                        MyColours.color_eadab9,
                                                    fontSize: ScreenUtil()
                                                        .setSp(32))),
                                          ),
                                          Image.asset(
                                            "assets/invication_arrow_right.png",
                                            width: ScreenUtil().setWidth(14),
                                            height: ScreenUtil().setWidth(22),
                                          ),
                                        ],
                                      ),
                                      Container(
                                        margin: EdgeInsets.only(
                                            top: ScreenUtil().setHeight(20)),
                                        child: Text(
                                          user.sellerAddr,
                                          style: TextStyle(
                                              color: MyColours.color_ffffff,
                                              fontSize: ScreenUtil().setSp(34)),
                                        ),
                                      )
                                    ],
                                  )
                                ],
                              ),
                            ),
                            VEmptyView(couponHeight),
                          ])),
                      Container(
                        width: double.infinity,
                        height: ScreenUtil().setHeight(99),
                        child: Row(
                          children: <Widget>[
                            GestureDetector(
                              onTap: () {
                                if (widget.phone.isEmpty) {
                                  Utils.showToast("没有预订人电话信息");
                                  return;
                                }
                                NavigatorUtil.goSmsPage(context, widget.rid);
                              },
                              child: Container(
                                width: ScreenUtil().setWidth(232),
                                height: double.infinity,
                                color: MyColours.color_000000,
                                alignment: Alignment.center,
                                child: Text(
                                  "发短信",
                                  style: TextStyle(
                                      color: MyColours.color_eadab9,
                                      fontSize: ScreenUtil().setSp(34)),
                                ),
                              ),
                            ),
                            Expanded(
                              child: GestureDetector(
                                onTap: () {
                                  Utils.goShareInvicationToWeChat(widget.rid);
                                },
                                child: Container(
                                  width: double.infinity,
                                  height: double.infinity,
                                  color: MyColours.color_e3d2ac,
                                  alignment: Alignment.center,
                                  child: Text(
                                    "通知客户",
                                    style: TextStyle(
                                        color: MyColours.color_83734d,
                                        fontSize: ScreenUtil().setSp(34)),
                                  ),
                                ),
                              ),
                            )
                          ],
                        ),
                      )
                    ])),
                Positioned(
                  left: ScreenUtil().setWidth(0),
                  top: ScreenUtil().setWidth(0),
                  child: GestureDetector(
                    onTap: () {
                      Navigator.of(context).pop();
                    },
                    behavior: HitTestBehavior.opaque,
                    child: Container(
                        padding: EdgeInsets.fromLTRB(
                          ScreenUtil().setWidth(40),
                          ScreenUtil().setWidth(40),
                          ScreenUtil().setWidth(200),
                          ScreenUtil().setWidth(100),
                        ),
                        alignment: Alignment.centerLeft,
                        // color: Colors.red,
                        child: Image.asset(
                          "assets/invication_back.png",
                          width: ScreenUtil().setWidth(20),
                          height: ScreenUtil().setHeight(31),
                        )),
                  ),
                ),
                Positioned(
                  left: ScreenUtil().setWidth(180),
                  bottom: ScreenUtil().setWidth(130),
                  right: ScreenUtil().setWidth(180),
                  child: GestureDetector(
                    onTap: () {
                      NavigatorUtil.goCouponSelectPage(context);
                    },
                    behavior: HitTestBehavior.opaque,
                    child: Center(
                      child: Container(
                        // width: ScreenUtil().setWidth(400),
                        padding: EdgeInsets.symmetric(
                            horizontal: ScreenUtil().setWidth(40),
                            vertical: ScreenUtil().setWidth(20)),
                        // height: ScreenUtil().setWidth(100),
                        decoration: BoxDecoration(
                            color: MyColours.color_ffffff,
                            borderRadius: BorderRadius.circular(
                                ScreenUtil().setWidth(20))),
                        child: Text(
                          '共赠送${couponProvider.coupons.length}张优惠券\n点击查看',
                          textAlign: TextAlign.center,
                          style: TextStyle(
                            fontSize: ScreenUtil().setSp(28),
                          ),
                        ),
                      ),
                    ),
                  ),
                )
              ],
            ))));
  }
}