import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/settleOrderInfo.dart'; import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/separator.dart'; class CouponWidget extends StatefulWidget { final CouponListBean couponList; final StoreInfo storeInfo; final bool selected; CouponWidget( this.couponList, this.storeInfo, { this.selected = false, }); @override State createState() { return _CouponWidget(); } } class _CouponWidget extends State { @override Widget build(BuildContext context) { return Container( height: 170, width: double.infinity, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8), boxShadow: [ BoxShadow( color: Colors.black.withAlpha(12), offset: Offset(0, 3), blurRadius: 14, spreadRadius: 0, ), ], ), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Container( margin: EdgeInsets.only(top: 14.h, bottom: 8.h), child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Expanded( child: Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [ Text( "¥", style: TextStyle( fontSize: 22.sp, fontWeight: MyFontWeight.medium, color: Color(0xff32A060), ), ), SizedBox( height: 4.h, ), Text( "${double.tryParse(widget.couponList.discountAmount).toInt()}", style: TextStyle( fontSize: 40.sp, fontWeight: MyFontWeight.semi_bold, color: Color(0xff32A060), ), ), ], ), ), Text( S .of(context) .manyuankeyong(widget.couponList.fullAmount), style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.semi_bold, color: Color(0xff32A060), ), ), ], ), flex: 1, ), Expanded( flex: 2, child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( padding: EdgeInsets.fromLTRB(4, 2, 4, 2), decoration: BoxDecoration( borderRadius: BorderRadius.circular(2), border: Border.all( width: 1, color: Color(0xFFFF7A1A), style: BorderStyle.solid, ), ), child: Text( S.of(context).shangjiaquan, style: TextStyle( fontSize: 10.sp, fontWeight: MyFontWeight.medium, color: Color(0xFFFF7A1A), ), ), ), SizedBox( width: 8.w, ), Expanded( child: Text( widget.storeInfo.storeName, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 16.sp, fontWeight: MyFontWeight.semi_bold, color: Color(0xff353535), ), ), flex: 1, ), ], ), Text( widget.couponList.promotionName, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 14.sp, color: Color(0xff727272), ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.end, children: [ Text( S.of(context).quanchangtongyong, style: TextStyle( color: Color(0xFF353535), fontSize: 12.sp, ), ), if (widget.couponList.usable) Container( margin: EdgeInsets.only(right: 23.w), child: GestureDetector( onTap: () { Navigator.of(context).pop(widget.selected?null:widget.couponList); }, child: Image.asset( widget.selected ? "assets/image/icon_radio_selected.webp" : "assets/image/icon_radio_unselected.webp", width: 24, height: 24, ), ), ), ], ), ], ), ), ], ), ), flex: (widget.couponList?.isEx ?? false) ? 97 : 97, ), Container( padding: EdgeInsets.symmetric(horizontal: 23.w), child: MySeparator( width: 5.w, height: 1.h, color: Color(0xFF353535), ), ), Expanded( flex: (widget.couponList?.isEx ?? false) ? 56 : 42, child: Container( margin: EdgeInsets.symmetric( horizontal: 23.w, vertical: 8.h, ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( S.of(context).xiangqing, style: TextStyle( color: Color(0xFF353535), fontSize: 10.sp, ), ), GestureDetector( child: Icon( (!(widget.couponList?.isEx ?? false)) ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_up, color: Colors.black, size: 18, ), //点击按钮布局 onTap: () { setState(() { widget.couponList.isEx = !(widget.couponList.isEx ?? false); }); }, ), ], ), if (widget.couponList?.isEx ?? false) Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( S.of(context).shiyongriqi, style: TextStyle( color: Color(0xFF353535), fontSize: 10.sp, ), ), Text( (widget.couponList.useStartTime == null && widget.couponList.useEndTime == null) ? S.of(context).quantian : "${widget.couponList.useStartTime.replaceAll("-", ".").split(" ")[0]} - ${widget.couponList.useEndTime.replaceAll("-", ".").split(" ")[0]}", style: TextStyle( color: Color(0xFF353535), fontSize: 10.sp, ), ), ], ), ], ), ), ), ], ), ); } }