|
|
@ -1,4 +1,5 @@ |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
import 'package:huixiang/generated/l10n.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/miNiDetail.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/miNiDetail.dart'; |
|
|
@ -23,190 +24,248 @@ class _ProductSku extends State<ProductSku> { |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return Container( |
|
|
|
String selectSku = ""; |
|
|
|
alignment: Alignment.topCenter, |
|
|
|
int selectCount = 1; |
|
|
|
padding: EdgeInsets.only(top: 16, left: 16, right: 16), |
|
|
|
return StatefulBuilder(builder: (context1, state) { |
|
|
|
width: double.infinity, |
|
|
|
return Container( |
|
|
|
decoration: BoxDecoration( |
|
|
|
alignment: Alignment.topCenter, |
|
|
|
color: Color(0xFFFAFAFA), |
|
|
|
padding: EdgeInsets.only( |
|
|
|
borderRadius: BorderRadius.only( |
|
|
|
top: 16, |
|
|
|
topLeft: Radius.circular(8), |
|
|
|
left: 16, |
|
|
|
topRight: Radius.circular(8), |
|
|
|
right: 16, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
width: double.infinity, |
|
|
|
child: Column( |
|
|
|
decoration: BoxDecoration( |
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
color: Color(0xFFFAFAFA), |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
borderRadius: BorderRadius.only( |
|
|
|
children: [ |
|
|
|
topLeft: Radius.circular(8), |
|
|
|
Row( |
|
|
|
topRight: Radius.circular(8), |
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
), |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
), |
|
|
|
children: [ |
|
|
|
child: Column( |
|
|
|
MImage( |
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
widget.miNiDetail.imgs[0], |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
width: 70, |
|
|
|
children: [ |
|
|
|
height: 70, |
|
|
|
Row( |
|
|
|
fit: BoxFit.cover, |
|
|
|
mainAxisAlignment: MainAxisAlignment.start, |
|
|
|
errorSrc: "assets/image/default_1.png", |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
fadeSrc: "assets/image/default_1.png", |
|
|
|
children: [ |
|
|
|
), |
|
|
|
MImage( |
|
|
|
SizedBox( |
|
|
|
widget.miNiDetail.imgs[0], |
|
|
|
width: 10, |
|
|
|
width: 70, |
|
|
|
), |
|
|
|
height: 70, |
|
|
|
Column( |
|
|
|
fit: BoxFit.cover, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
errorSrc: "assets/image/default_1.png", |
|
|
|
children: [ |
|
|
|
fadeSrc: "assets/image/default_1.png", |
|
|
|
Text( |
|
|
|
), |
|
|
|
widget.miNiDetail.productName, |
|
|
|
SizedBox( |
|
|
|
style: TextStyle( |
|
|
|
width: 10, |
|
|
|
color: Colors.black, |
|
|
|
), |
|
|
|
fontSize: 16.sp, |
|
|
|
Column( |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
), |
|
|
|
children: [ |
|
|
|
), |
|
|
|
Text( |
|
|
|
Padding( |
|
|
|
widget.miNiDetail.productName, |
|
|
|
padding: EdgeInsets.only(top: 4, bottom: 7), |
|
|
|
|
|
|
|
child: Text( |
|
|
|
|
|
|
|
"已选:正常冰", |
|
|
|
|
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
color: Color(0xFF727272), |
|
|
|
color: Colors.black, |
|
|
|
fontSize: 11.sp, |
|
|
|
fontSize: 16.sp, |
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Padding( |
|
|
|
Row( |
|
|
|
padding: EdgeInsets.only(top: 4, bottom: 7), |
|
|
|
children: [ |
|
|
|
child: Text( |
|
|
|
Text( |
|
|
|
"已选:" + selectSku, |
|
|
|
S.of(context).huiyuanjia, |
|
|
|
|
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
color: Color(0xFF727272), |
|
|
|
fontSize: 13.sp, |
|
|
|
fontSize: 11.sp, |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Text( |
|
|
|
), |
|
|
|
widget.miNiDetail.price, |
|
|
|
Row( |
|
|
|
style: TextStyle( |
|
|
|
children: [ |
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
Text( |
|
|
|
fontSize: 14.sp, |
|
|
|
S.of(context).huiyuanjia, |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
style: TextStyle( |
|
|
|
|
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
|
|
|
|
fontSize: 13.sp, |
|
|
|
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Text( |
|
|
|
], |
|
|
|
widget.miNiDetail.price, |
|
|
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
|
|
color: Color(0xFFFF7A1A), |
|
|
|
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
Spacer(), |
|
|
|
|
|
|
|
InkWell( |
|
|
|
|
|
|
|
onTap: () { |
|
|
|
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
child: Image.asset( |
|
|
|
|
|
|
|
"assets/image/icon_order_cancel.png", |
|
|
|
|
|
|
|
width: 22, |
|
|
|
|
|
|
|
height: 22, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
Spacer(), |
|
|
|
|
|
|
|
InkWell( |
|
|
|
|
|
|
|
onTap: () { |
|
|
|
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
child: Image.asset( |
|
|
|
|
|
|
|
"assets/image/icon_order_cancel.png", |
|
|
|
|
|
|
|
width: 22, |
|
|
|
|
|
|
|
height: 22, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
SizedBox( |
|
|
|
|
|
|
|
height: 23, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
Expanded( |
|
|
|
|
|
|
|
child: ListView.builder( |
|
|
|
|
|
|
|
itemCount: widget.miNiDetail.attrList.length, |
|
|
|
|
|
|
|
scrollDirection: Axis.vertical, |
|
|
|
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
|
|
|
return attrItem( |
|
|
|
|
|
|
|
() { |
|
|
|
|
|
|
|
state(() { |
|
|
|
|
|
|
|
for (var i = 0; |
|
|
|
|
|
|
|
i < |
|
|
|
|
|
|
|
widget.miNiDetail.attrList[position] |
|
|
|
|
|
|
|
.attrValueList.length; |
|
|
|
|
|
|
|
i++) { |
|
|
|
|
|
|
|
if (tempClickIndex == i) |
|
|
|
|
|
|
|
widget.miNiDetail.attrList[position] |
|
|
|
|
|
|
|
.attrValueList[i].isSelected = true; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
widget.miNiDetail.attrList[position] |
|
|
|
|
|
|
|
.attrValueList[i].isSelected = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
selectSku = ""; |
|
|
|
|
|
|
|
widget.miNiDetail.attrList.forEach((e0) { |
|
|
|
|
|
|
|
e0.attrValueList.forEach((e1) { |
|
|
|
|
|
|
|
if (e1.isSelected ?? false) |
|
|
|
|
|
|
|
selectSku += e1.attrValue + " "; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
widget.miNiDetail.attrList[position], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
SizedBox( |
|
|
|
|
|
|
|
height: 23, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
Expanded( |
|
|
|
|
|
|
|
child: ListView.builder( |
|
|
|
|
|
|
|
itemCount: widget.miNiDetail.attrList.length, |
|
|
|
|
|
|
|
scrollDirection: Axis.vertical, |
|
|
|
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
|
|
|
return attrItem( |
|
|
|
|
|
|
|
() { |
|
|
|
|
|
|
|
setState(() { |
|
|
|
|
|
|
|
for (var i = 0; |
|
|
|
|
|
|
|
i < |
|
|
|
|
|
|
|
widget.miNiDetail.attrList[position].attrValueList |
|
|
|
|
|
|
|
.length; |
|
|
|
|
|
|
|
i++) { |
|
|
|
|
|
|
|
if (tempClickIndex == i) |
|
|
|
|
|
|
|
widget.miNiDetail.attrList[position].attrValueList[i] |
|
|
|
|
|
|
|
.isSelected = true; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
widget.miNiDetail.attrList[position].attrValueList[i] |
|
|
|
|
|
|
|
.isSelected = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
widget.miNiDetail.attrList[position], |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox( |
|
|
|
SizedBox( |
|
|
|
height: 24, |
|
|
|
height: 24, |
|
|
|
), |
|
|
|
), |
|
|
|
Row( |
|
|
|
Row( |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
children: [ |
|
|
|
children: [ |
|
|
|
Expanded( |
|
|
|
Expanded( |
|
|
|
child: Text( |
|
|
|
child: Text( |
|
|
|
"数量", |
|
|
|
"数量", |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.black, |
|
|
|
color: Colors.black, |
|
|
|
fontSize: 14.sp, |
|
|
|
fontSize: 14.sp, |
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
InkWell( |
|
|
|
InkWell( |
|
|
|
onTap: () { |
|
|
|
onTap: () {}, |
|
|
|
state(() { |
|
|
|
child: Image.asset( |
|
|
|
if (selectCount > 1) selectCount--; |
|
|
|
"assets/image/reduce.png", |
|
|
|
}); |
|
|
|
width: 22, |
|
|
|
}, |
|
|
|
height: 22, |
|
|
|
child: Image.asset( |
|
|
|
|
|
|
|
"assets/image/reduce.png", |
|
|
|
|
|
|
|
width: 22, |
|
|
|
|
|
|
|
height: 22, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Padding( |
|
|
|
Padding( |
|
|
|
padding: EdgeInsets.only(left: 8, right: 8), |
|
|
|
padding: EdgeInsets.only(left: 8, right: 8), |
|
|
|
child: Text( |
|
|
|
child: Text( |
|
|
|
selectCount.toString(), |
|
|
|
"1", |
|
|
|
style: TextStyle( |
|
|
|
style: TextStyle( |
|
|
|
color: Colors.black, |
|
|
|
color: Colors.black, |
|
|
|
fontSize: 14.sp, |
|
|
|
fontSize: 14.sp, |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
InkWell( |
|
|
|
InkWell( |
|
|
|
onTap: () { |
|
|
|
onTap: () {}, |
|
|
|
state(() { |
|
|
|
child: Image.asset( |
|
|
|
selectCount++; |
|
|
|
"assets/image/add.png", |
|
|
|
}); |
|
|
|
width: 22, |
|
|
|
}, |
|
|
|
height: 22, |
|
|
|
child: Image.asset( |
|
|
|
|
|
|
|
"assets/image/add.png", |
|
|
|
|
|
|
|
width: 22, |
|
|
|
|
|
|
|
height: 22, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
SizedBox( |
|
|
|
|
|
|
|
height: 24, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
GestureDetector( |
|
|
|
|
|
|
|
onTap: () { |
|
|
|
|
|
|
|
bool flag = false; |
|
|
|
|
|
|
|
widget.miNiDetail.productSkuVOList.forEach((element) { |
|
|
|
|
|
|
|
if (selectSku.trim() == element.skuNameStr) { |
|
|
|
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
|
|
|
flag = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (!flag) |
|
|
|
|
|
|
|
SmartDialog.showToast("请选择規格!", alignment: Alignment.center); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
child: RoundButton( |
|
|
|
|
|
|
|
width: double.infinity, |
|
|
|
|
|
|
|
height: 54.h, |
|
|
|
|
|
|
|
text: "加入购物车", |
|
|
|
|
|
|
|
textColor: Colors.white, |
|
|
|
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
|
|
|
radius: 27, |
|
|
|
|
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
|
|
|
// padding: EdgeInsets.symmetric(vertical: 5.h), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox( |
|
|
|
SizedBox( |
|
|
|
height: 21.h, |
|
|
|
height: 24, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
RoundButton( |
|
|
|
), |
|
|
|
width: double.infinity, |
|
|
|
); |
|
|
|
height: 54.h, |
|
|
|
}); |
|
|
|
text: "加入购物车", |
|
|
|
} |
|
|
|
textColor: Colors.white, |
|
|
|
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
Widget attrItem(Function fc, AttrListBean attrListBean) { |
|
|
|
radius: 27, |
|
|
|
return Column( |
|
|
|
backgroup: Color(0xFF32A060), |
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
fontSize: 16.sp, |
|
|
|
children: [ |
|
|
|
// padding: EdgeInsets.symmetric(vertical: 5.h), |
|
|
|
Padding( |
|
|
|
callback: () { }, |
|
|
|
padding: EdgeInsets.only(top: 24, bottom: 16), |
|
|
|
|
|
|
|
child: Text( |
|
|
|
|
|
|
|
attrListBean.attrName, |
|
|
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
|
|
color: Colors.black, |
|
|
|
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
sweetnessStore(fc, attrListBean.attrValueList), |
|
|
|
|
|
|
|
], |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Widget sweetnessStore(Function fc, List<testModel> arrays) { |
|
|
|
Widget sweetnessStore(Function fc, List<AttrValueListBean> arrays) { |
|
|
|
return GridView.builder( |
|
|
|
return GridView.builder( |
|
|
|
itemCount: arrays.length, |
|
|
|
itemCount: arrays.length, |
|
|
|
shrinkWrap: true, |
|
|
|
shrinkWrap: true, |
|
|
@ -227,7 +286,8 @@ class _ProductSku extends State<ProductSku> { |
|
|
|
tempClickIndex = index; |
|
|
|
tempClickIndex = index; |
|
|
|
fc(); |
|
|
|
fc(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
child: sweetnessItem(arrays[index].name, arrays[index].isSelected), |
|
|
|
child: sweetnessItem( |
|
|
|
|
|
|
|
arrays[index].attrValue, arrays[index].isSelected ?? false), |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|