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.

359 lines
15 KiB

4 years ago
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(
4 years ago
height: coupon.isEx?170:150,
width: double.infinity,
4 years ago
margin: EdgeInsets.fromLTRB(14, 6, 14, 6),
4 years ago
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(
4 years ago
children: [
4 years ago
Column(
children: [
Row(
4 years ago
children: [
4 years ago
Text(
"¥",
style: TextStyle(
fontSize: 22, color: Color(0xff32A060)),
4 years ago
),
SizedBox(
4 years ago
width: 5,
4 years ago
),
4 years ago
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(
4 years ago
children: [
4 years ago
Container(
padding: EdgeInsets.fromLTRB(4, 2, 4, 2),
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(2)),
border: Border.all(
width: 1,
4 years ago
color: Color(0xFFFF7A1A),
4 years ago
style: BorderStyle.solid)),
child: Text(
S.of(context).shangjiaquan,
style: TextStyle(
fontSize: 10,
color: Color(0xFFFF7A1A),
4 years ago
),
4 years ago
),
4 years ago
),
SizedBox(
4 years ago
width: 4,
4 years ago
),
Text(
4 years ago
"百年川椒火锅店",
4 years ago
style: TextStyle(
4 years ago
fontSize: 16,
fontWeight: FontWeight.bold,
color: Color(0xff353535)),
4 years ago
),
4 years ago
],
),
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,
4 years ago
),
4 years ago
),
)),
)
else if (coupon.status == 1)
Expanded(
child: Align(
4 years ago
alignment: Alignment.centerRight,
child: Container(
padding:
4 years ago
EdgeInsets.fromLTRB(9, 3, 9, 3),
4 years ago
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,
),
),
),
4 years ago
)))
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),
4 years ago
),
4 years ago
child: Text(
S.of(context).yishixiao,
style: TextStyle(
fontSize: 12,
color: Colors.white,
),
),
)))
4 years ago
],
4 years ago
),
4 years ago
],
4 years ago
)),
],
),
),
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,
),
],
4 years ago
),
4 years ago
SizedBox(
height: 5,
4 years ago
),
4 years ago
if (coupon.isEx)
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
4 years ago
children: [
4 years ago
Text(
4 years ago
S.of(context).shiyongriqi(""),
4 years ago
style: TextStyle(
color: Color(0xFF353535),
fontSize: 10,
),
4 years ago
),
4 years ago
Text(
coupon.useTime??"暂无",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 10,
4 years ago
),
4 years ago
),
4 years ago
],
),
4 years ago
],
),
4 years ago
),
),
4 years ago
],
),
],
4 years ago
),
);
}
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,
),
],
)
],
);
},
);
}
}