wurong
2 years ago
11 changed files with 888 additions and 946 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,334 @@
|
||||
import 'package:flutter/material.dart'; |
||||
import 'package:huixiang/generated/l10n.dart'; |
||||
import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; |
||||
import 'package:huixiang/retrofit/data/shoppingCart.dart'; |
||||
import 'package:huixiang/utils/flutter_utils.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'package:huixiang/view_widget/custom_image.dart'; |
||||
import 'package:huixiang/view_widget/round_button.dart'; |
||||
|
||||
class ShopGoodsCar extends StatefulWidget { |
||||
final Function(String id, int count) queryMiNiDetail; |
||||
final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) add; |
||||
final Function(ShoppingCartSkuItemListBean shoppingCartSkuItemListBean) |
||||
reduce; |
||||
final ProductListBean productListBean; |
||||
final ShoppingCartSkuItemListBean shoppingCartSkuItemListBean; |
||||
final int count; |
||||
final bool isShopCart; |
||||
|
||||
ShopGoodsCar( |
||||
this.add, |
||||
this.reduce, { |
||||
this.productListBean, |
||||
this.count = 0, |
||||
this.isShopCart = false, |
||||
this.queryMiNiDetail, |
||||
this.shoppingCartSkuItemListBean, |
||||
}); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _ShopGoodsCar(); |
||||
} |
||||
} |
||||
|
||||
class _ShopGoodsCar extends State<ShopGoodsCar> { |
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
color: Colors.white, |
||||
padding: EdgeInsets.only( |
||||
right: 16.w, |
||||
// bottom: 20.h, |
||||
), |
||||
child:Column( |
||||
children: [ |
||||
Row( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
mainAxisAlignment: MainAxisAlignment.start, |
||||
mainAxisSize: MainAxisSize.max, |
||||
children: [ |
||||
SizedBox(width: 12.w), |
||||
MImage( |
||||
widget.productListBean != null |
||||
? widget.productListBean.imgPath |
||||
: (widget.shoppingCartSkuItemListBean != null |
||||
? widget.shoppingCartSkuItemListBean.skuImg |
||||
: ""), |
||||
width: 70.h, |
||||
height: 70.h, |
||||
radius: BorderRadius.circular(4), |
||||
fit: BoxFit.cover, |
||||
errorSrc: "assets/image/default_1.webp", |
||||
fadeSrc: "assets/image/default_1.webp", |
||||
), |
||||
SizedBox( |
||||
width: 10, |
||||
), |
||||
Expanded( |
||||
child: Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Row( |
||||
children: [ |
||||
Expanded( |
||||
child: Text( |
||||
widget.productListBean != null |
||||
? widget.productListBean.productName |
||||
: widget.shoppingCartSkuItemListBean.productName, |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 2, |
||||
style: TextStyle( |
||||
color: Colors.black, |
||||
fontSize: 13.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
), |
||||
), |
||||
), |
||||
// Image.asset( |
||||
// "assets/image/green_leaf.webp", |
||||
// fit: BoxFit.cover, |
||||
// width: 12, |
||||
// height: 12, |
||||
// ), |
||||
// Text( |
||||
// "X300", |
||||
// style: TextStyle( |
||||
// color: Color(0xFF55BC51), |
||||
// fontSize: 10.sp, |
||||
// fontWeight: MyFontWeight.semi_bold, |
||||
// ), |
||||
// ), |
||||
], |
||||
), |
||||
SizedBox( |
||||
height: 2.h, |
||||
), |
||||
Row( |
||||
children: [ |
||||
Expanded( |
||||
child: Text( |
||||
(widget.productListBean != null |
||||
? widget.productListBean.shortName |
||||
: ((widget.shoppingCartSkuItemListBean.skuName == "0") ? "": widget.shoppingCartSkuItemListBean.skuName ) ?? ""), |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 2, |
||||
style: TextStyle( |
||||
color: Color(0xFF4C4C4C), |
||||
fontSize: 10.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
), |
||||
), |
||||
SizedBox( |
||||
width: 10, |
||||
), |
||||
], |
||||
), |
||||
SizedBox( |
||||
height: 7.h, |
||||
), |
||||
Row( |
||||
children: [ |
||||
Row( |
||||
children: [ |
||||
Text( |
||||
"¥${AppUtils.calculateDouble(double.tryParse(widget.isShopCart ? widget.shoppingCartSkuItemListBean.skuPrice : widget.productListBean.price) ?? 0)}", |
||||
style: TextStyle( |
||||
color: Color(0xFFFF7A1A), |
||||
fontSize: 16.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
), |
||||
), |
||||
SizedBox( |
||||
width: 2.w, |
||||
), |
||||
// Container( |
||||
// width: 44.w, |
||||
// height: 18.h, |
||||
// decoration: BoxDecoration( |
||||
// color: Color(0xFFFF4500), |
||||
// borderRadius: BorderRadius.circular(2), |
||||
// ), |
||||
// alignment: Alignment.center, |
||||
// child: Text( |
||||
// "APP专享", |
||||
// style: TextStyle( |
||||
// color: Color(0xFFFFFFFF), |
||||
// fontSize: 10.sp, |
||||
// fontWeight: MyFontWeight.medium, |
||||
// ), |
||||
// ), |
||||
// ), |
||||
], |
||||
), |
||||
Spacer(), |
||||
if (!widget.isShopCart && |
||||
(widget.productListBean?.attrStyle ?? 0) == 1) |
||||
Stack( |
||||
children: [ |
||||
Container( |
||||
margin: EdgeInsets.only(right: 8, top: 4), |
||||
child: RoundButton( |
||||
width: 49.w, |
||||
text: S.of(context).xuanguige, |
||||
textColor: Colors.white, |
||||
fontWeight: MyFontWeight.medium, |
||||
radius: 3, |
||||
backgroup: Color(0xFF32A060), |
||||
fontSize: 11.sp, |
||||
padding: EdgeInsets.symmetric(vertical: 5.h), |
||||
callback: () { |
||||
widget.queryMiNiDetail( |
||||
widget.productListBean != null |
||||
? widget.productListBean.id |
||||
: widget.shoppingCartSkuItemListBean |
||||
.productId, |
||||
0); |
||||
}, |
||||
), |
||||
), |
||||
Positioned( |
||||
right: 0, |
||||
child: Visibility( |
||||
visible: widget.count > 0, |
||||
child: RoundButton( |
||||
width: 17, |
||||
height: 17.h, |
||||
text: "${widget.count}", |
||||
textColor: Color(0xFF32A060), |
||||
fontWeight: MyFontWeight.regular, |
||||
backgroup: Colors.white, |
||||
fontSize: 12.sp, |
||||
radius: 100, |
||||
), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
if (widget.isShopCart || |
||||
(widget.productListBean?.attrStyle ?? 0) == 0) |
||||
InkWell( |
||||
onTap: () { |
||||
widget.reduce(widget.shoppingCartSkuItemListBean); |
||||
}, |
||||
child: Image.asset( |
||||
"assets/image/reduce.webp", |
||||
width: 22, |
||||
height: 22.h, |
||||
), |
||||
), |
||||
if (widget.isShopCart || |
||||
(widget.productListBean?.attrStyle ?? 0) == 0) |
||||
Container( |
||||
width: 30, |
||||
alignment: Alignment.center, |
||||
child: Text( |
||||
"${widget.count}", |
||||
style: TextStyle( |
||||
color: Colors.black, |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.medium, |
||||
), |
||||
), |
||||
), |
||||
if (widget.isShopCart || |
||||
(widget.productListBean?.attrStyle ?? 0) == 0) |
||||
GestureDetector( |
||||
onTap: () { |
||||
widget.add(widget.shoppingCartSkuItemListBean); |
||||
}, |
||||
child: Image.asset( |
||||
"assets/image/add.webp", |
||||
width: 22, |
||||
height: 22.h, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
SizedBox( |
||||
height: 4.h, |
||||
), |
||||
Text( |
||||
"¥${AppUtils.calculateDouble(double.tryParse(widget.isShopCart ? widget.shoppingCartSkuItemListBean.skuPrice : widget.productListBean.applyPrice) ?? 0)}", |
||||
style: TextStyle( |
||||
color: Color(0xFFA29E9E), |
||||
fontSize: 12.sp, |
||||
decoration: TextDecoration.lineThrough, |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
], |
||||
), |
||||
if(widget.shoppingCartSkuItemListBean.setMealDataList.length != 0) |
||||
ListView.builder( |
||||
itemCount: widget.shoppingCartSkuItemListBean.setMealDataList.length, |
||||
scrollDirection: Axis.vertical, |
||||
physics: BouncingScrollPhysics(), |
||||
shrinkWrap: true, |
||||
padding: EdgeInsets.zero, |
||||
itemBuilder: (context, index) { |
||||
return shopCarMealsItem(widget.shoppingCartSkuItemListBean.setMealDataList[index]); |
||||
}, |
||||
), |
||||
SizedBox(height:15.h,) |
||||
], |
||||
) |
||||
); |
||||
} |
||||
|
||||
|
||||
Widget shopCarMealsItem(SetMealDataList setMealDataList) { |
||||
return Container( |
||||
margin: EdgeInsets.symmetric(vertical:10.h,horizontal: 16.w), |
||||
child: Row( |
||||
children: [ |
||||
Expanded( |
||||
flex: 3, |
||||
child: Text( |
||||
setMealDataList.productInfoList[0].productName, |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 1, |
||||
style: TextStyle( |
||||
color: Color(0xffA29E9E), |
||||
fontSize: 14.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
), |
||||
), |
||||
Expanded(flex: 2, |
||||
child: Text( |
||||
"${(setMealDataList.productInfoList[0].skuName == "") ? "默认": setMealDataList.productInfoList[0].skuName}", |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 1, |
||||
style: TextStyle( |
||||
color: Color(0xffA29E9E), |
||||
fontSize: 13.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
), |
||||
), |
||||
Expanded( |
||||
flex: 1, |
||||
child: Text( |
||||
"x1", |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 1, |
||||
style: TextStyle( |
||||
color: Color(0xffFF7A1A), |
||||
fontSize: 13.sp, |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue