import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../generated/l10n.dart';
import '../../retrofit/data/user_info.dart';
import '../../view_widget/my_appbar.dart';

class ExclusiveCoupon extends StatefulWidget {
  final UserInfo userInfo;

  ExclusiveCoupon(this.userInfo);
  @override
  State<StatefulWidget> createState() {
    return _ExclusiveCoupon();
  }
}

class _ExclusiveCoupon extends State<ExclusiveCoupon> {
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        (widget?.userInfo?.isVip ?? false)
            ? Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Image.asset(
              "assets/image/vip_discount_left.webp",
              width: 21.w,
              height: 39.h,
              fit: BoxFit.fill,
            ),
            SizedBox(
              width: 11.w,
            ),
            Text(
              S.of(context).huixiangvipkazhuanxiang,
              style: TextStyle(
                color: Color(0xff32A060),
                fontSize: 15.sp,
                fontWeight: MyFontWeight.semi_bold,
              ),
            ),
            SizedBox(
              width: 11.w,
            ),
            Image.asset(
              "assets/image/vip_discount_right.webp",
              width: 21.w,
              height: 39.h,
              fit: BoxFit.fill,
            ),
          ],
        )
            : Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Image.asset(
              "assets/image/vip_lock.webp",
              width: 20,
              height: 20,
              fit: BoxFit.cover,
            ),
            SizedBox(
              width: 2.w,
            ),
            Text(
              "解锁回乡VIP卡获取更多权益",
              style: TextStyle(
                color: Colors.black,
                fontSize: 15.sp,
                fontWeight: MyFontWeight.semi_bold,
              ),
            ),
          ],
        ),
        Container(
          margin: EdgeInsets.only(left: 14.w, right: 14.w, bottom:16.h,top: 17.h),
          width: double.infinity,
          padding:
          EdgeInsets.only(top: 20.h, left: 20.h, bottom: 10.h, right: 20.w),
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(6.w),
            color: Colors.white,
            boxShadow: [
              BoxShadow(
                color: Colors.black.withAlpha(12),
                offset: Offset(0, 3),
                blurRadius: 14,
                spreadRadius: 0,
              )
            ],
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Row(
                children: [
                  SizedBox(
                    width: 7.w,
                  ),
                  Image.asset(
                    "assets/image/vip_title.webp",
                    fit: BoxFit.fill, //填充剩余空间
                    height: 13.h,
                    width: 27.w,
                  ),
                  SizedBox(
                    width: 4.w,
                  ),
                  Text(
                    "会员卡专享",
                    style: TextStyle(
                      color: Colors.black,
                      fontSize: 15.sp,
                      fontWeight: MyFontWeight.semi_bold,
                    ),
                  ),
                  // GestureDetector(
                  //   behavior: HitTestBehavior.translucent,
                  //   onTap: () {
                  //     showAlertDialog();
                  //   },
                  //   child: Container(
                  //     padding: EdgeInsets.only(
                  //         left: 8.w, right: 30.w, top: 3.h, bottom: 3.h),
                  //     child: Image.asset(
                  //       "assets/image/vip_tips.webp",
                  //       fit: BoxFit.fill, //填充剩余空间
                  //       height: 14,
                  //       width: 14,
                  //     ),
                  //   ),
                  // ),
                ],
              ),
              SizedBox(
                height: 10.h,
              ),
              Container(
                height: 124.h,
                margin: EdgeInsets.only(bottom: 16.h),
                child: Stack(
                  children: [
                    Image.asset(
                      "assets/image/vip_shop_bj.webp",
                      fit: BoxFit.fill, //填充剩余空间
                      height: double.infinity,
                      width: double.infinity,
                    ),
                    Container(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Expanded(
                              child: Padding(
                                padding: EdgeInsets.only(top: 25.h, left: 19.w),
                                child: Column(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      "海峡姐妹饮品券",
                                      style: TextStyle(
                                        color: Color(0xff32A060),
                                        fontSize: 15.sp,
                                        fontWeight: MyFontWeight.semi_bold,
                                      ),
                                    ),
                                    SizedBox(
                                      height: 5.h,
                                    ),
                                    Text.rich(
                                      TextSpan(
                                        children: [
                                          TextSpan(
                                            text: "6",
                                            style: TextStyle(
                                              fontWeight: MyFontWeight.extra_bold,
                                              fontSize: 36.sp,
                                              fontFamily: 'JDZhengHT',
                                              color: Color(0xffFF7E12),
                                            ),
                                          ),
                                          TextSpan(
                                            text: " 折",
                                            style: TextStyle(
                                              fontSize: 24.sp,
                                              color: Color(0xffFF7E12),
                                              fontWeight: MyFontWeight.semi_bold,
                                            ),
                                          ),
                                        ],
                                      ),
                                      textDirection: TextDirection.ltr,
                                    ),
                                  ],
                                ),
                              )),
                          Image.asset(
                            "assets/image/vip_shop_hx.webp",
                            fit: BoxFit.fill, //填充剩余空间
                            height: 85,
                            width: 85,
                          ),
                        ],
                      ),
                    )
                  ],
                ),
              ),
              Container(
                height: 124.h,
                margin: EdgeInsets.only(bottom: 16.h),
                child: Stack(
                  children: [
                    Image.asset(
                      "assets/image/vip_shop_bj.webp",
                      fit: BoxFit.fill, //填充剩余空间
                      height: double.infinity,
                      width: double.infinity,
                    ),
                    Container(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Expanded(
                              child: Padding(
                                padding: EdgeInsets.only(top: 25.h, left: 19.w),
                                child: Column(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      "前进麦味烘焙券",
                                      style: TextStyle(
                                        color: Color(0xff32A060),
                                        fontSize: 15.sp,
                                        fontWeight: MyFontWeight.semi_bold,
                                      ),
                                    ),
                                    SizedBox(
                                      height: 5.h,
                                    ),
                                    Text.rich(
                                      TextSpan(
                                        children: [
                                          TextSpan(
                                            text: "7",
                                            style: TextStyle(
                                              fontWeight: MyFontWeight.extra_bold,
                                              fontSize: 36.sp,
                                              fontFamily: 'JDZhengHT',
                                              color: Color(0xffFF7E12),
                                            ),
                                          ),
                                          TextSpan(
                                            text: " 折",
                                            style: TextStyle(
                                              fontSize: 24.sp,
                                              color: Color(0xffFF7E12),
                                              fontWeight: MyFontWeight.semi_bold,
                                            ),
                                          ),
                                        ],
                                      ),
                                      textDirection: TextDirection.ltr,
                                    ),
                                  ],
                                ),
                              )),
                          Image.asset(
                            "assets/image/vip_shop_qj.webp",
                            fit: BoxFit.fill, //填充剩余空间
                            height: 85,
                            width: 85,
                          ),
                        ],
                      ),
                    )
                  ],
                ),
              ),
              Container(
                height: 124.h,
                margin: EdgeInsets.only(bottom: 22.h),
                child: Stack(
                  children: [
                    Image.asset(
                      "assets/image/vip_shop_bj.webp",
                      fit: BoxFit.fill, //填充剩余空间
                      height: double.infinity,
                      width: double.infinity,
                    ),
                    Container(
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.start,
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Expanded(
                              child: Padding(
                                padding: EdgeInsets.only(top: 25.h, left: 19.w),
                                child: Column(
                                  mainAxisAlignment: MainAxisAlignment.start,
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      "门店火锅券",
                                      style: TextStyle(
                                        color: Color(0xff32A060),
                                        fontSize: 15.sp,
                                        fontWeight: MyFontWeight.semi_bold,
                                      ),
                                    ),
                                    SizedBox(
                                      height: 5.h,
                                    ),
                                    Text.rich(
                                      TextSpan(
                                        children: [
                                          TextSpan(
                                            text: "8",
                                            style: TextStyle(
                                              fontWeight: MyFontWeight.extra_bold,
                                              fontSize: 36.sp,
                                              fontFamily: 'JDZhengHT',
                                              color: Color(0xffFF7E12),
                                            ),
                                          ),
                                          TextSpan(
                                            text: " 折",
                                            style: TextStyle(
                                              fontSize: 24.sp,
                                              color: Color(0xffFF7E12),
                                              fontWeight: MyFontWeight.semi_bold,
                                            ),
                                          ),
                                        ],
                                      ),
                                      textDirection: TextDirection.ltr,
                                    ),
                                  ],
                                ),
                              )),
                          Image.asset(
                            "assets/image/vip_shop_hg.webp",
                            fit: BoxFit.fill, //填充剩余空间
                            height: 85,
                            width: 85,
                          ),
                        ],
                      ),
                    )
                  ],
                ),
              ),
            ],
          ),
        )
      ],
    );
  }

  ///会员优惠规则弹窗
  showAlertDialog() {
    showModalBottomSheet(
        builder: (BuildContext context) {
          return StatefulBuilder(builder: (
              context,
              state,
              ) {
            return WillPopScope(
              ///点击背景不收起弹窗;
                // onWillPop: () async => false,
                child:Stack(
                  alignment: Alignment.topRight,
                  children: [
                    Container(
                      width: double.infinity,
                      height: 370.h,
                      padding: EdgeInsets.symmetric(horizontal: 14.w, vertical: 16.h),
                      decoration: new BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(8),
                          topRight: Radius.circular(8),
                        ),
                      ),
                      child: SingleChildScrollView(
                        physics: BouncingScrollPhysics(),
                        child: Container(
                          padding: EdgeInsets.only(right: 18.w),
                          child:
                          Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              SizedBox(
                                height: 10.h,
                              ),
                              Text(
                                "VIP会员专享优惠券:"
                                    "\n ①海峡姐妹饮品券"
                                    "\n *用户开通回乡VIP卡,可享全单饮品6折优惠。"
                                    "\n *适用饮品:门店现制奶茶类饮品及现制咖啡类饮品。"
                                    "\n *适用门店:海峡姐妹茶汉街店、前进麦味*海峡姐妹茶哈乐城店"
                                    "\n ②前进麦味烘焙券"
                                    "\n *用户开通回乡VIP卡,可享全单面包7折优惠。"
                                    "\n *适用产品:门店现制面包类产品及甜品类产品。"
                                    "\n *适用门店:前进麦味凯德1818店、前进麦味*海峡姐妹茶哈乐城店"
                                    "\n ③回乡农场火锅券"
                                    "\n *用户开通回乡VIP卡,可享全单菜品(小料、酒水、饮品不参与)8折优惠。"
                                    "\n *适用产品:门店现制菜品"
                                    "\n *适用门店:回乡农场火锅汉街店"
                                    "\n ④百年川椒火锅券"
                                    "\n *用户开通回乡VIP卡,可享全单菜品(小料、酒水、饮品不参与)8折优惠。"
                                    "\n *适用产品:门店现制菜品"
                                    "\n *适用门店:百年川椒重庆老火锅光谷店",
                                style: TextStyle(
                                  fontWeight: MyFontWeight.medium,
                                  fontSize: 14.sp,
                                  height: 1.7.h,
                                  color: Colors.black,
                                ),
                              ),
                            ],
                          ),
                        ),
                      ),
                    ),
                    GestureDetector(
                      onTap: () {
                        Navigator.of(context).pop();
                      },
                      child: Container(
                        margin: EdgeInsets.only(right: 14.w,top: 16.h),
                        child: Image.asset(
                          "assets/image/cancel.webp",
                          width: 24,
                          height: 24,
                        ),
                      ),
                    )],
                ));
          });
        },
        backgroundColor: Colors.transparent,
        context: context);
  }
}