invitation_page.dart 8.12 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/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;

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

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

}

class InvicationPageState extends State<InvicationPage>{
  
  User user;
  DateTime dateTime;
  String dateTimeStr="";

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    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}";
  }
  
  
  //中间内容显示组件
  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(22),fontWeight: FontWeight.bold)),
            ),
            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(26)),),
        )
      ],
    );
  }
  
  
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return SafeArea(
      child: Container(
        width: double.infinity,
        height: double.infinity,
        decoration: BoxDecoration(
          image: DecorationImage(image: AssetImage("assets/bg_invication.png"),fit: BoxFit.cover),
        ),
        child: DefaultTextStyle(style: TextStyle(decoration: TextDecoration.none), child: Column(
          children: <Widget>[
            GestureDetector(
              onTap: (){
                Navigator.of(context).pop();
              },
              child:  Container(
                width: double.infinity,
                alignment: Alignment.centerLeft,
                padding: EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(30)),
                child: Padding(
                    padding: EdgeInsets.symmetric(
                        horizontal: ScreenUtil().setWidth(40),
                        vertical: ScreenUtil().setHeight(15)),
                    child: Image.asset(
                      "assets/invication_back.png",
                      width: ScreenUtil().setWidth(20),
                      height: ScreenUtil().setHeight(31),
                    )
                ),
              ),
            ),
            Expanded(
              child: Center(
                child: Column(
                  children: <Widget>[
                    Image.asset("assets/img_ydap.png",width: ScreenUtil().setWidth(444),height: ScreenUtil().setHeight(234),),
                    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(22),fontWeight: FontWeight.bold),),
                        ),
                        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(22),fontWeight: FontWeight.bold)),
                            ),
                            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(26)),),
                        )
                      ],
                    )
                  ],
                ),
              ),
            ),
            Container(
              width: double.infinity,
              height: ScreenUtil().setHeight(99),
              child: Row(
                children: <Widget>[
                  GestureDetector(
                    onTap: (){
                      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(30)),),
                    ),
                  ),
                  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(30)),),
                      ),
                    ),
                  )
                ],
              ),
            )
          ],
        )),
      ),
    );
  }

}