sms_recharge_item_page.dart 5.49 KB
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/sms_info.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/v_empty_view.dart';

class SmsRechargeItemPage extends StatefulWidget {
  Meals meals;
  GestureTapCallback callback;
  SmsRechargeItemPage({Key key, this.meals, this.callback}) : super(key: key);

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

class _SmsRechargeItemPageState extends State<SmsRechargeItemPage> {
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: widget.callback,
      child: Stack(
        clipBehavior: Clip.none,
        children: [
          Container(
              decoration: BoxDecoration(
                  color: widget.meals.selected
                      ? MyColours.color_199095
                      : MyColours.color_ffffff,
                  borderRadius:
                      BorderRadius.circular(ScreenUtil().setWidth(10)),
                  border: Border.all(
                    width: ScreenUtil().setWidth(2),
                    color: MyColours.color_E0E0E0,
                  )),
              padding: EdgeInsets.symmetric(
                  horizontal: ScreenUtil().setWidth(30),
                  vertical: ScreenUtil().setWidth(20)),
              margin: EdgeInsets.only(bottom: ScreenUtil().setWidth(30)),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      Text(
                        '${widget.meals.total}条',
                        style: TextStyle(
                            fontWeight: FontWeight.bold,
                            fontSize: ScreenUtil().setSp(34),
                            color: widget.meals.selected
                                ? MyColours.color_F0F0F0
                                : MyColours.color_333333),
                      ),
                      VEmptyView(20),
                      Text('约${widget.meals.priceAve}元/条',
                          style: TextStyle(
                              fontSize: ScreenUtil().setSp(30),
                              color: widget.meals.selected
                                  ? MyColours.color_F0F0F0
                                  : MyColours.color_333333)),
                    ],
                  ),
                  Expanded(
                      child: Container(
                    // width: ScreenUtil().setWidth(150),
                    alignment: Alignment.centerRight,
                    margin: EdgeInsets.only(top: ScreenUtil().setWidth(30)),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        Text(
                          '¥${widget.meals.price}',
                          style: TextStyle(
                              fontWeight: FontWeight.bold,
                              fontSize: ScreenUtil().setSp(34),
                              color: widget.meals.selected
                                  ? MyColours.color_F0F0F0
                                  : MyColours.color_333333),
                        ),
                        widget.meals.price == widget.meals.priceOld
                            ? SizedBox()
                            : Text('¥${widget.meals.priceOld}',
                                style: TextStyle(
                                    decoration: TextDecoration.lineThrough,
                                    fontSize: ScreenUtil().setSp(30),
                                    color: widget.meals.selected
                                        ? MyColours.color_F0F0F0
                                        : MyColours.color_999999)),
                      ],
                    ),
                  )),
                ],
              )),
          widget.meals.discount == '0'
              ? SizedBox()
              : Positioned(
                  top: -5,
                  right: -2,
                  child: Container(
                      // padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(16),vertical: ScreenUtil().setWidth(4)),
                      padding: EdgeInsets.only(
                          left: ScreenUtil().setWidth(6),
                          bottom: ScreenUtil().setWidth(10)),
                      alignment: Alignment.center,
                      width: ScreenUtil().setWidth(44 * 2),
                      height: ScreenUtil().setWidth(61),
                      decoration: BoxDecoration(
                        // color: Colors.red,
                        image: DecorationImage(
                          image: ExactAssetImage(
                            Utils.getImgPath('sms_manager'),
                          ),
                          fit: BoxFit.cover,
                        ),
                      ),
                      child: Text(
                        '${widget.meals.discount}折',
                        style: TextStyle(
                            color: MyColours.color_fefefe,
                            fontSize: ScreenUtil().setSp(24)),
                      )))
        ],
      ),
    );
  }
}