|
|
|
@ -1,9 +1,14 @@
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
import '../../../generated/l10n.dart'; |
|
|
|
|
import '../../../retrofit/business_api.dart'; |
|
|
|
|
import '../../../retrofit/data/set_specs_meal_list.dart'; |
|
|
|
|
import '../../../utils/font_weight.dart'; |
|
|
|
|
import '../../../view_widget/border_text.dart'; |
|
|
|
|
import '../../../view_widget/round_button.dart'; |
|
|
|
|
import '../../../view_widget/settlement_tips_dialog.dart'; |
|
|
|
|
|
|
|
|
|
class SetMeal extends StatefulWidget { |
|
|
|
|
final Map<String, dynamic> arguments; |
|
|
|
@ -39,6 +44,15 @@ class _SetMeal extends State<SetMeal> {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
List<dynamic> mealDetails = widget?.arguments["mealDetails"] ??[]; |
|
|
|
|
mealDetails.forEach((element) { |
|
|
|
|
var tempValue = SetSpecsMealList(); |
|
|
|
|
tempValue.groupsNameController.text = element["groupsName"]; |
|
|
|
|
tempValue.groupsTotal = element["groupsTotal"]; |
|
|
|
|
tempValue.optionalNum = element["optionalNum"]; |
|
|
|
|
tempValue.goodsMeal = element["goodsDetail"]; |
|
|
|
|
specsMeal.add(tempValue); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///离开页面记着销毁和清除 |
|
|
|
@ -65,6 +79,56 @@ class _SetMeal extends State<SetMeal> {
|
|
|
|
|
brightness: Brightness.dark, |
|
|
|
|
action: GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
bool flag = false; |
|
|
|
|
String tipText = ""; |
|
|
|
|
int index = 0; |
|
|
|
|
List<dynamic> mealDetail = []; |
|
|
|
|
if (specsMeal.length != 0) { |
|
|
|
|
specsMeal.forEach((element) { |
|
|
|
|
index += 1; |
|
|
|
|
if (element.groupsNameController.text.trim() == "") { |
|
|
|
|
flag = true; |
|
|
|
|
tipText = "分组$index未填写分组名"; |
|
|
|
|
return; |
|
|
|
|
} else if (element.goodsMeal.length == 0 || |
|
|
|
|
element.goodsMeal.length != element.groupsTotal) { |
|
|
|
|
flag = true; |
|
|
|
|
tipText = |
|
|
|
|
"分组${element.groupsNameController.text}已选商品数量与设定分组总数不符,请修改"; |
|
|
|
|
return; |
|
|
|
|
} else if (element.optionalNum > element.groupsTotal) { |
|
|
|
|
flag = true; |
|
|
|
|
tipText = |
|
|
|
|
"分组${element.groupsNameController.text}可选数量不可大于分组总数"; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
mealDetail.add({ |
|
|
|
|
"groupsName":element.groupsNameController.text, |
|
|
|
|
"groupsTotal":element.groupsTotal, |
|
|
|
|
"optionalNum":element.optionalNum, |
|
|
|
|
"goodsDetail":element.goodsMeal |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
if (flag) { |
|
|
|
|
SmartDialog.show( |
|
|
|
|
clickBgDismissTemp: false, |
|
|
|
|
widget: SettlementTips( |
|
|
|
|
() {}, |
|
|
|
|
text: tipText, |
|
|
|
|
color: Color(0xFF30415B), |
|
|
|
|
)); |
|
|
|
|
} else { |
|
|
|
|
Navigator.of(context).pop(mealDetail); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.show( |
|
|
|
|
clickBgDismissTemp: false, |
|
|
|
|
widget: SettlementTips( |
|
|
|
|
() {}, |
|
|
|
|
text: "请添加设置分组后再点击确实按钮", |
|
|
|
|
color: Color(0xFF30415B), |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
child: Text( |
|
|
|
|
"确定", |
|
|
|
@ -95,9 +159,9 @@ class _SetMeal extends State<SetMeal> {
|
|
|
|
|
return GestureDetector( |
|
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() {}); |
|
|
|
|
FocusScope.of(context).unfocus(); |
|
|
|
|
}, |
|
|
|
|
child: specsValueText(position)); |
|
|
|
|
child: mealText(position)); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
GestureDetector( |
|
|
|
@ -141,8 +205,8 @@ class _SetMeal extends State<SetMeal> {
|
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///添加规格样式 |
|
|
|
|
Widget specsValueText(index) { |
|
|
|
|
///添加套餐分组样式 |
|
|
|
|
Widget mealText(index) { |
|
|
|
|
return Column( |
|
|
|
|
children: [ |
|
|
|
|
Container( |
|
|
|
@ -158,7 +222,7 @@ class _SetMeal extends State<SetMeal> {
|
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: Text( |
|
|
|
|
"分组1", |
|
|
|
|
"分组${index + 1}", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xD9000000), |
|
|
|
|
fontSize: 14.sp, |
|
|
|
@ -364,9 +428,7 @@ class _SetMeal extends State<SetMeal> {
|
|
|
|
|
Spacer(), |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
setState(() { |
|
|
|
|
specsMeal.removeAt(index); |
|
|
|
|
}); |
|
|
|
|
deleteGroupsDialog(index); |
|
|
|
|
}, |
|
|
|
|
child: Row( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end, |
|
|
|
@ -412,7 +474,7 @@ class _SetMeal extends State<SetMeal> {
|
|
|
|
|
return GestureDetector( |
|
|
|
|
behavior: HitTestBehavior.opaque, |
|
|
|
|
onTap: () {}, |
|
|
|
|
child: specsInfoItem(index, position), |
|
|
|
|
child: addGoodsItem(index, position), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
@ -420,8 +482,85 @@ class _SetMeal extends State<SetMeal> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///规格信息样式 |
|
|
|
|
Widget specsInfoItem(specsIndex, index) { |
|
|
|
|
///删除分组弹窗提示 |
|
|
|
|
deleteGroupsDialog(index) { |
|
|
|
|
showDialog( |
|
|
|
|
context: context, |
|
|
|
|
builder: (context) { |
|
|
|
|
return AlertDialog( |
|
|
|
|
content: Container( |
|
|
|
|
width: MediaQuery.of(context).size.width - 84, |
|
|
|
|
height: 139.h, |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Text( |
|
|
|
|
"此操作将直接删除当前分组, 是否继续?", |
|
|
|
|
style: TextStyle( |
|
|
|
|
color: Color(0xFFF4524D), |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
height: 35.h, |
|
|
|
|
), |
|
|
|
|
Row( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: InkWell( |
|
|
|
|
child: BorderText( |
|
|
|
|
text: S.of(context).quxiao, |
|
|
|
|
textColor: Color(0xFF30415B), |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
borderColor: Color(0xFF30415B), |
|
|
|
|
radius: 4, |
|
|
|
|
padding: EdgeInsets.all(12), |
|
|
|
|
borderWidth: 1, |
|
|
|
|
), |
|
|
|
|
onTap: () { |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
SizedBox( |
|
|
|
|
width: 16.w, |
|
|
|
|
), |
|
|
|
|
Expanded( |
|
|
|
|
child: InkWell( |
|
|
|
|
child: RoundButton( |
|
|
|
|
text: S.of(context).queren, |
|
|
|
|
textColor: Colors.white, |
|
|
|
|
radius: 4, |
|
|
|
|
padding: EdgeInsets.all(12), |
|
|
|
|
backgroup: Color(0xFF30415B), |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
|
), |
|
|
|
|
onTap: () { |
|
|
|
|
setState((){ |
|
|
|
|
Navigator.of(context).pop(); |
|
|
|
|
specsMeal.removeAt(index); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
flex: 1, |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///增加商品Item |
|
|
|
|
Widget addGoodsItem(specsIndex, index) { |
|
|
|
|
return Container( |
|
|
|
|
color: Colors.white, |
|
|
|
|
margin: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
|