import 'dart:math'; import 'package:flutter/material.dart'; import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/retrofit/data/coupon.dart'; import 'package:huixiang/view_widget/round_button.dart'; import 'package:huixiang/view_widget/separator.dart'; class NewCouponWidget extends StatelessWidget { final GestureTapCallback callback; final GestureTapCallback callbackEx; final Coupon coupon; NewCouponWidget(this.coupon, this.callback, this.callbackEx); @override Widget build(BuildContext context) { return buildCoupon(context); } Widget buildCoupon(BuildContext context) { return Container( height: coupon.isEx?170:150, width: double.infinity, margin: EdgeInsets.fromLTRB(14, 6, 14, 6), child:Stack( children: [ Image.asset( "assets/image/ic_coupon_bg.png", fit: BoxFit.fill, width: double.infinity, height: double.infinity, ), Column( children: [ Padding( padding: EdgeInsets.only(left: 20, top: 18, bottom: 8, right: 20), child: Row( children: [ Column( children: [ Row( children: [ Text( "¥", style: TextStyle( fontSize: 22, color: Color(0xff32A060)), ), SizedBox( width: 5, ), Text( "5", style: TextStyle( fontSize: 40, fontWeight: FontWeight.bold, color: Color(0xff32A060)), ), ], ), Text(S.of(context).manyuankeyong(30), style: TextStyle( fontSize: 12, fontWeight: FontWeight.bold, color: Color(0xff32A060))), ], ), SizedBox( width: 31, ), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( children: [ Container( padding: EdgeInsets.fromLTRB(4, 2, 4, 2), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(2)), border: Border.all( width: 1, color: Color(0xFFFF7A1A), style: BorderStyle.solid)), child: Text( S.of(context).shangjiaquan, style: TextStyle( fontSize: 10, color: Color(0xFFFF7A1A), ), ), ), SizedBox( width: 4, ), Text( "百年川椒火锅店", style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, color: Color(0xff353535)), ), ], ), SizedBox(height: 11,), Text( "#新客户满减优惠#", style: TextStyle( fontSize: 14, color: Color(0xff727272)), ), Row( children: [ Text( "全场通用", style: TextStyle( fontSize: 12, color: Color(0xff353535)), ), if (coupon.status == 0) Expanded( child: Align( alignment: Alignment.centerRight, child: Container( padding: EdgeInsets.fromLTRB(9, 3, 9, 3), decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10.5)), color: Color(0xFF32A060), ), child: Text( S.of(context).qushiyong, style: TextStyle( fontSize: 12, color: Colors.white, ), ), )), ) else if (coupon.status == 1) Expanded( child: Align( alignment: Alignment.centerRight, child: Container( padding: EdgeInsets.fromLTRB(9, 3, 9, 3), decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10.5)), color: Color(0xFF32A060), ), child: GestureDetector( onTap: () { showAlertDialog(context); }, child: Text( S.of(context).lingqu, style: TextStyle( fontSize: 12, color: Colors.white, ), ), ), ))) else if (coupon.status == 2) Expanded( child: Align( alignment: Alignment.centerRight, child: Container( padding: EdgeInsets.fromLTRB(9, 3, 9, 3), decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(10.5)), // border: Border.all( // width: 1, color: Color(0xFFA0A0A0), style: BorderStyle.solid) color: Color(0xFFA0A0A0), ), child: Text( S.of(context).yishixiao, style: TextStyle( fontSize: 12, color: Colors.white, ), ), ))) ], ), ], )), ], ), ), Padding( padding: EdgeInsets.only(top:10,left: 23, right: 23), child: MySeparator( width: 5, height: 1, color: Color(0xFF353535), ), ), Expanded( child: Padding( padding: EdgeInsets.only(left: 20, right: 20, top: 15), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( "详情", style: TextStyle( color: Color(0xFF353535), fontSize: 10, ), ), GestureDetector( child: Icon( !coupon.isEx ? Icons.keyboard_arrow_down : Icons.keyboard_arrow_up, color: Colors.black, size: 18, ), //点击按钮布局 onTap: callbackEx, ), ], ), SizedBox( height: 5, ), if (coupon.isEx) Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( S.of(context).shiyongriqi, style: TextStyle( color: Color(0xFF353535), fontSize: 10, ), ), Text( coupon.useTime??"暂无", style: TextStyle( color: Color(0xFF353535), fontSize: 10, ), ), ], ), ], ), ), ), ], ), ], ), ); } showAlertDialog(BuildContext context) { //显示对话框 showDialog( context: context, builder: (BuildContext context) { return SimpleDialog( titlePadding: EdgeInsets.all(10), backgroundColor: Colors.transparent, elevation: 0, shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(6))), children: [ Stack( alignment: Alignment.topCenter, children: [ Container( margin: EdgeInsets.only(top: 40), decoration: new BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(8))), width: 218, height: 210, child: Column( children: [ Padding( padding: EdgeInsets.only(top: 50, bottom: 19), child: Text( "领取成功", style: TextStyle( color: Color(0xff353535), fontSize: 16, fontWeight: FontWeight.bold), ), ), Text( "您已成功领取优惠劵,请在", style: TextStyle(color: Color(0xff353535), fontSize: 14), ), Row( mainAxisAlignment: MainAxisAlignment.center, children: [ GestureDetector( child: Text( S.of(context).kaquan, style: TextStyle( color: Color(0xffFF7A1A), fontSize: 14, fontWeight: FontWeight.bold), ), onTap: () { Navigator.of(context) .pushNamed('/router/mine_card'); }, ), Text( "中查看", style: TextStyle( color: Color(0xff353535), fontSize: 14), ), ], ), Padding( padding: EdgeInsets.only(top: 30), child: RoundButton( width: 130, height: 34, text: S.of(context).queren, textColor: Colors.white, fontSize: 12, callback: () { Navigator.of(context).pop(); }, padding: EdgeInsets.only( top: 2, bottom: 2, left: 8, right: 8), backgroup: Color(0xff32A060), ), ) ], ), ), Image.asset( "assets/image/icon_order_success.png", fit: BoxFit.cover, width: 80, height: 80, ), ], ) ], ); }, ); } }