You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
392 lines
18 KiB
392 lines
18 KiB
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( |
|
margin: EdgeInsets.fromLTRB(14, 6, 14, 6), |
|
child: AspectRatio( |
|
aspectRatio: 2.485, |
|
child: Stack( |
|
children: [ |
|
Image.asset( |
|
"assets/image/ic_coupon_bg.png", |
|
fit: BoxFit.cover, |
|
width: double.infinity, |
|
height: double.infinity, |
|
), |
|
Opacity( |
|
opacity: coupon.status != 3 ? 1 : 0.54, |
|
child: Container( |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.start, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Expanded( |
|
flex: 7, |
|
child: Container( |
|
padding: EdgeInsets.only(top: 18, bottom: 8), |
|
child: Row( |
|
children: [ |
|
Container( |
|
margin: EdgeInsets.only(left: 20), |
|
child: 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, |
|
), |
|
Column( |
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
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: 6, |
|
), |
|
Text( |
|
"#新客户满减优惠#", |
|
style: TextStyle( |
|
fontSize: 14, color: Color(0xff727272)), |
|
), |
|
Row( |
|
mainAxisAlignment: |
|
MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Text( |
|
"全场通用", |
|
style: TextStyle( |
|
fontSize: 12, |
|
color: Color(0xff353535)), |
|
), |
|
if (coupon.status == 0) |
|
Container( |
|
width: 200, |
|
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) |
|
Container( |
|
width: 200, |
|
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) |
|
Container( |
|
width: 200, |
|
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, |
|
), |
|
), |
|
)) |
|
], |
|
), |
|
SizedBox( |
|
height: 2, |
|
), |
|
], |
|
) |
|
], |
|
), |
|
), |
|
), |
|
Container( |
|
margin: EdgeInsets.only(left: 23, right: 23), |
|
child: MySeparator( |
|
width: 5, |
|
height: 1, |
|
color: Color(0xFF353535), |
|
), |
|
), |
|
Expanded( |
|
flex: 4, |
|
child: Container( |
|
padding: EdgeInsets.only(left: 20, right: 20, top: 5), |
|
alignment: Alignment.center, |
|
child: Column( |
|
children: [ |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
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, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Text( |
|
S.of(context).shiyongriqi(coupon.useTime), |
|
style: TextStyle( |
|
color: Color(0xFF353535), |
|
fontSize: 10, |
|
), |
|
), |
|
Text( |
|
"2020.01.20~2020.01.21", |
|
style: TextStyle( |
|
color: Color(0xFF353535), |
|
fontSize: 10, |
|
), |
|
), |
|
// Text( |
|
// S.of(context).shiyongriqi(coupon.useTime), |
|
// style: TextStyle( |
|
// color: Color(0xFF727272), |
|
// 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: <Widget>[ |
|
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, |
|
), |
|
], |
|
) |
|
], |
|
); |
|
}, |
|
); |
|
} |
|
}
|
|
|