recharge_item.dart 9.03 KB
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/coupon_model.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/dashed_line_widget.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';

import '../../../../provider/user_model.dart';
import '../../../../utils/screen_util.dart';

class RechargeItem extends StatefulWidget {
  final String from;
  final VoidCallback onPressed;
  final VoidCallback onPressedDel;
  final VoidCallback onPressedUse;
  final CouponSunModel couponSonModel;
  final bool showBtn;
  final bool showCheck;
  RechargeItem({
    Key key,
    this.from,
    this.onPressed,
    this.onPressedDel,
    this.onPressedUse,
    this.couponSonModel,
    this.showBtn = false,
    this.showCheck = false,
  }) : super(key: key);

  @override
  _RechargeItemState createState() => _RechargeItemState();
}

class _RechargeItemState extends State<RechargeItem> {
  // bool showText = false;
  @override
  Widget build(BuildContext context) {
    // CouponSunModel sunModel = widget.couponSonModel;
    bool notSelect = true;
    if (widget.from == 'history') {
      notSelect = false;
    } else {
      // notSelect = sunModel.isOpenBool;
    }
    // double explainH = 0.0;

    // if (ObjectUtil.isNotEmpty(sunModel.explain)) {
    //   explainH = Utils.calculateTextHeight(
    //       '说明:fdgdfgdgfgsdgsg',
    //       ScreenUtil().setSp(20),
    //       FontWeight.normal,
    //       ScreenUtil().screenWidth -
    //           ScreenUtil().setWidth(92 * 2) +
    //           ScreenUtil().setWidth(20),
    //       5,
    //       context);
    // }
    return InkWell(
        onTap: widget.onPressed,
        child: Container(
          // width: ScreenUtil().setWidth(610),
          margin: EdgeInsets.fromLTRB(
              ScreenUtil().setWidth(40),
              ScreenUtil().setWidth(30),
              ScreenUtil().setWidth(40),
              ScreenUtil().setWidth(0)),
          decoration: BoxDecoration(
            color: MyColours.color_ffffff,
            boxShadow: [
              BoxShadow(
                  spreadRadius: ScreenUtil().setWidth(2),
                  color: Color.fromRGBO(0, 0, 0, 0.25),
                  offset: Offset(0, ScreenUtil().setWidth(8)),
                  blurRadius: ScreenUtil().setWidth(8))
            ],
            borderRadius: BorderRadius.all(
              Radius.circular(ScreenUtil().setWidth(16)),
            ),
          ),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                height: ScreenUtil().setWidth(60),
                padding:
                    EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40)),
                decoration: BoxDecoration(
                    color: widget.from == 'history'
                        ? MyColours.color_BFC4D4
                        : notSelect
                            ? true
                                ? MyColours.color_438E93
                                : MyColours.color_ED7B2F
                            : MyColours.color_999999,
                    borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(ScreenUtil().setWidth(16)),
                        topRight: Radius.circular(ScreenUtil().setWidth(16)))),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      '充500赠100',
                      style: TextStyle(
                          color: MyColours.color_ffffff,
                          fontWeight: FontWeight.bold,
                          fontSize: ScreenUtil().setSp(32)),
                    ),
                    Text('更新时间:2022-12-18',
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                            color: MyColours.color_ffffff,
                            fontSize: ScreenUtil().setSp(20))),
                  ],
                ),
              ),
              Container(
                padding: EdgeInsets.fromLTRB(
                    ScreenUtil().setWidth(20 * 2),
                    ScreenUtil().setWidth(26),
                    ScreenUtil().setWidth(40),
                    ScreenUtil().setWidth(26)),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      // height: ScreenUtil().setWidth(14 * 2),
                      // width: ScreenUtil().setWidth(232 * 2),
                      child: Text('会员充值满1000元赠余额200元;',
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(
                            color: MyColours.color_999999,
                            fontSize: ScreenUtil().setSp(20),
                          )),
                    ),
                    VEmptyView(10),
                    Container(
                      // height: ScreenUtil().setWidth(14 * 2),
                      // width: ScreenUtil().setWidth(232 * 2),
                      child: Text('会员充值满1000元赠送50元代金券;',
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(
                            color: MyColours.color_999999,
                            fontSize: ScreenUtil().setSp(20),
                          )),
                    ),
                    VEmptyView(10),
                    Container(
                      // height: ScreenUtil().setWidth(14 * 2),
                      // width: ScreenUtil().setWidth(232 * 2),
                      child: Text('会员充值满1000元赠送50元菜品券。',
                          maxLines: 1,
                          overflow: TextOverflow.ellipsis,
                          style: TextStyle(
                            color: MyColours.color_999999,
                            fontSize: ScreenUtil().setSp(20),
                          )),
                    ),
                  ],
                ),

                // widget.from == 'select'
                //     ? widget.showCheck
                //         ? Positioned(
                //             right: 0,
                //             top: ScreenUtil().setWidth(20),
                //             child: Image.asset(
                //               Utils.getImgPath(widget.couponSonModel.isCheck
                //                   ? 'check_r'
                //                   : 'check_un'),
                //               width: ScreenUtil().setWidth(40),
                //               height: ScreenUtil().setWidth(40),
                //             ))
                //         : Container()
                //     :
              ),
              if (widget.showBtn)
                MySeparator(width: w(4), color: MyColours.color_BFC4D4),
              if (widget.showBtn) VEmptyView(15),
              if (widget.showBtn)
                Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    RoundButton(
                      width: widget.from == 'history'
                          ? ScreenUtil().setWidth(50 * 2)
                          : ScreenUtil().setWidth(50 * 2),
                      height: ScreenUtil().setWidth(20 * 2),
                      radius: ScreenUtil().setWidth(10),
                      text: '删除',
                      fontSize: 24,
                      textColor: MyColours.color_E34D59,
                      gradientStart: MyColours.color_ffffff,
                      gradientEnd: MyColours.color_ffffff,
                      borderColor: MyColours.color_E34D59,
                      onPressed: widget.onPressedDel,
                    ),
                    HEmptyView(34),
                    RoundButton(
                      width: ScreenUtil().setWidth(50 * 2),
                      height: ScreenUtil().setWidth(20 * 2),
                      radius: ScreenUtil().setWidth(10),
                      text: '禁用',

                      ///启用
                      fontSize: 24,
                      textColor: MyColours.color_438E93,
                      gradientStart: MyColours.color_ffffff,
                      gradientEnd: MyColours.color_ffffff,
                      borderColor: MyColours.color_438E93,
                      onPressed: widget.onPressedUse,
                    ),
                    HEmptyView(38),
                  ],
                ),
             if (widget.showBtn) VEmptyView(15)
            ],
          ),
        ));
  }
}