|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/coupon.dart';
|
|
|
|
import 'package:huixiang/view_widget/separator.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
|
|
class NewCouponWidget extends StatelessWidget {
|
|
|
|
final Function(int type) 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) {
|
|
|
|
// if(coupon != null) {
|
|
|
|
// coupon.isEx = fa;
|
|
|
|
// }
|
|
|
|
return Container(
|
|
|
|
height: (coupon != null && coupon.isEx) ? 152.h : 140.h,
|
|
|
|
width: double.infinity,
|
|
|
|
margin: EdgeInsets.fromLTRB(14.w, 6.h, 14.w, 6.h),
|
|
|
|
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: Container(
|
|
|
|
child: priceWidget(context),
|
|
|
|
),
|
|
|
|
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.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.sp,
|
|
|
|
color: Color(0xFFFF7A1A),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 8.w,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
coupon != null ? coupon.couponName : "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xff353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
coupon != null ? coupon.couponName : "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14.sp,
|
|
|
|
color: Color(0xff727272),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
Visibility(
|
|
|
|
child: Text(
|
|
|
|
S.of(context).quanchangtongyong,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
fontSize: 12.sp,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
visible:
|
|
|
|
(coupon != null && (coupon.bizType == 1)) ??
|
|
|
|
false,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(right: 23.w),
|
|
|
|
child: rightBtn(context),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
flex: (coupon != null && coupon.isEx) ? 95 : 97,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 23.w),
|
|
|
|
child: MySeparator(
|
|
|
|
width: 5.w,
|
|
|
|
height: 1.h,
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: (coupon != null && coupon.isEx) ? 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(
|
|
|
|
(coupon != null && !coupon.isEx)
|
|
|
|
? Icons.keyboard_arrow_down
|
|
|
|
: Icons.keyboard_arrow_up,
|
|
|
|
color: Colors.black,
|
|
|
|
size: 18,
|
|
|
|
), //点击按钮布局
|
|
|
|
onTap: callbackEx,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
if (coupon != null && coupon.isEx)
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
S.of(context).shiyongriqi(""),
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
fontSize: 10.sp,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
(coupon.useStartTime == null &&
|
|
|
|
coupon.useEndTime == null)
|
|
|
|
? "全天"
|
|
|
|
: "${coupon.useStartTime.replaceAll("-", ".").split(" ")[0]}-${coupon.useEndTime.replaceAll("-", ".").split(" ")[0]}",
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
fontSize: 10.sp,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget priceWidget(BuildContext context) {
|
|
|
|
if (coupon.bizType == 1) {
|
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Baseline(
|
|
|
|
baseline: 40,
|
|
|
|
baselineType: TextBaseline.alphabetic,
|
|
|
|
child: Text(
|
|
|
|
"¥",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 22.sp,
|
|
|
|
color: Color(0xff32A060),
|
|
|
|
textBaseline: TextBaseline.alphabetic,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 4.h,
|
|
|
|
),
|
|
|
|
Baseline(
|
|
|
|
baseline: 40,
|
|
|
|
baselineType: TextBaseline.alphabetic,
|
|
|
|
child: Text(
|
|
|
|
coupon != null
|
|
|
|
? double.tryParse("${coupon.discountAmount}" ?? "0")
|
|
|
|
.toInt()
|
|
|
|
.toString()
|
|
|
|
: "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 40.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xff32A060),
|
|
|
|
textBaseline: TextBaseline.alphabetic,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
S.of(context).manyuankeyong(coupon != null
|
|
|
|
? double.tryParse("${coupon.fullAmount}" ?? "0")
|
|
|
|
.toInt()
|
|
|
|
.toString()
|
|
|
|
: ""),
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xff32A060),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Baseline(
|
|
|
|
baseline: 40,
|
|
|
|
baselineType: TextBaseline.alphabetic,
|
|
|
|
child: Text(
|
|
|
|
coupon != null
|
|
|
|
? double.tryParse("${coupon.discountPercent}" ?? "0")
|
|
|
|
.toInt()
|
|
|
|
.toString()
|
|
|
|
: "",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 40.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xff32A060),
|
|
|
|
textBaseline: TextBaseline.alphabetic,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 4.h,
|
|
|
|
),
|
|
|
|
Baseline(
|
|
|
|
baseline: 40,
|
|
|
|
baselineType: TextBaseline.alphabetic,
|
|
|
|
child: Text(
|
|
|
|
"折",
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 20.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xff32A060),
|
|
|
|
textBaseline: TextBaseline.alphabetic,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
S.of(context).quanchangtongyong,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xff32A060),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget rightBtn(context) {
|
|
|
|
if (coupon != null && coupon.status == 0) {
|
|
|
|
return Align(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
callback(1);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(16.w, 2.h, 16.w, 2.h),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10.5)),
|
|
|
|
color: Color(0xFF32A060),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
S.of(context).lingqu,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else if (coupon != null && coupon.status == 1) {
|
|
|
|
return Align(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
callback(2);
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(16.w, 2.h, 16.w, 2.h),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.all(Radius.circular(10.5)),
|
|
|
|
color: Color(0xFF32A060),
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
S.of(context).qushiyong,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
} else if (coupon != null && coupon.status == 2) {
|
|
|
|
return Align(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(16.w, 2.h, 16.w, 2.h),
|
|
|
|
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).yishiyong,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12.sp,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return Align(
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.fromLTRB(16.w, 2.h, 16.w, 2.h),
|
|
|
|
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.sp,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|