|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
|
|
|
|
import '../../../res/colors.dart';
|
|
|
|
import '../../../route/navigator_util.dart';
|
|
|
|
import '../../../utils/dialog_util.dart';
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
import '../../../utils/utils.dart';
|
|
|
|
import '../../../widgets/h_empty_view.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
import '../../../widgets/system_app_bar.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 套餐添加
|
|
|
|
*/
|
|
|
|
class FeastSetmealManageEditPage extends StatefulWidget {
|
|
|
|
final isCreate;
|
|
|
|
FeastSetmealManageEditPage({
|
|
|
|
Key key,
|
|
|
|
this.isCreate = true,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_FeastSetmealManageEditPageState createState() =>
|
|
|
|
_FeastSetmealManageEditPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _FeastSetmealManageEditPageState
|
|
|
|
extends State<FeastSetmealManageEditPage> {
|
|
|
|
TextEditingController mealNameC = TextEditingController(); //套餐名称
|
|
|
|
FocusNode mealF = FocusNode();
|
|
|
|
TextEditingController mealPriceC = TextEditingController(); //套餐价格
|
|
|
|
FocusNode mealPriceF = FocusNode();
|
|
|
|
bool canBargaining = true; //是否议价
|
|
|
|
ScrollController controller = ScrollController();
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
Utils.changeStatusColor(color: MyColours.color_438E93);
|
|
|
|
}
|
|
|
|
|
|
|
|
///请输入
|
|
|
|
///输入框
|
|
|
|
Widget _textfield(
|
|
|
|
String title,
|
|
|
|
String hintText,
|
|
|
|
TextEditingController editingController,
|
|
|
|
FocusNode focusNode,
|
|
|
|
String subTitle,
|
|
|
|
{TextInputType inputType = TextInputType.number}) {
|
|
|
|
return Container(
|
|
|
|
height: w(48),
|
|
|
|
margin: EdgeInsets.only(top: w(12)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom:
|
|
|
|
BorderSide(width: h(0.5), color: MyColours.color_E7E7E7))),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: w(81),
|
|
|
|
height: w(48),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
color: MyColours.color_E5000000),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(32),
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
// height: ScreenUtil().setHeight(120),
|
|
|
|
height: w(48),
|
|
|
|
padding: EdgeInsets.only(top: w(4)),
|
|
|
|
child: TextField(
|
|
|
|
controller: editingController,
|
|
|
|
// textAlign: TextAlign.right,
|
|
|
|
// textAlignVertical: TextAlignVertical.bottom,
|
|
|
|
maxLines: 1,
|
|
|
|
inputFormatters: [],
|
|
|
|
|
|
|
|
// //光标颜色
|
|
|
|
// cursorColor:
|
|
|
|
// widget.isSelect ? Colors.white : MyColours.color_199095,
|
|
|
|
//输入文本的样式
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
color: MyColours.color_515151),
|
|
|
|
focusNode: focusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border: OutlineInputBorder(borderSide: BorderSide.none),
|
|
|
|
hintText: hintText,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: hintText == '请输入'
|
|
|
|
? MyColours.color_999999
|
|
|
|
: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
),
|
|
|
|
contentPadding: EdgeInsets.zero,
|
|
|
|
),
|
|
|
|
onChanged: (value) {},
|
|
|
|
onEditingComplete: () {
|
|
|
|
FocusScope.of(context)
|
|
|
|
.requestFocus(FocusNode()); //点击空白处隐藏键盘
|
|
|
|
},
|
|
|
|
keyboardType: inputType,
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.only(left: w(16), right: w(12)),
|
|
|
|
child: Text(
|
|
|
|
subTitle,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_000000,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget buildFeastTypeItem(String title) {
|
|
|
|
return Container(
|
|
|
|
height: h(48),
|
|
|
|
margin: EdgeInsets.only(bottom: w(12)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(width: w(0.5), color: MyColours.color_E7E7E7))),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
title,
|
|
|
|
style:
|
|
|
|
TextStyle(fontSize: font(16), color: MyColours.color_E5000000),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
NavigatorUtil.goFeastDishPage(context);
|
|
|
|
},
|
|
|
|
child: Text(
|
|
|
|
'修改',
|
|
|
|
style: TextStyle(
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
fontSize: font(16),
|
|
|
|
color: MyColours.color_438E93),
|
|
|
|
)),
|
|
|
|
HEmptyView(32),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
//已经传到服务器,弹提醒窗口,是否删除
|
|
|
|
//修改之前有内容,则弹框
|
|
|
|
DialogUtil.cupertinoAlertDialogFeast(context,
|
|
|
|
rTitle: '删除',
|
|
|
|
title: "是否确认删除",
|
|
|
|
content: "热菜(18道)", lCallback: () {
|
|
|
|
print("取消");
|
|
|
|
}, rCallback: () {
|
|
|
|
print("确定");
|
|
|
|
// widget.deleteCallback(index);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath(true ? 'f_delete_red_un' : 'f_delete_red'),
|
|
|
|
width: w(32),
|
|
|
|
height: w(32),
|
|
|
|
)),
|
|
|
|
HEmptyView(32),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _callButton(
|
|
|
|
{GestureTapCallback onPress,
|
|
|
|
content,
|
|
|
|
hasLeftBorder = true,
|
|
|
|
isSelect = false}) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: onPress,
|
|
|
|
child: Container(
|
|
|
|
height: h(48),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: isSelect ? MyColours.color_438E93 : MyColours.color_ffffff,
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
width: ScreenUtil().setWidth(2)),
|
|
|
|
top: BorderSide(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
width: ScreenUtil().setWidth(2)),
|
|
|
|
left: hasLeftBorder
|
|
|
|
? BorderSide(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
width: ScreenUtil().setWidth(2))
|
|
|
|
: BorderSide.none,
|
|
|
|
right: BorderSide(
|
|
|
|
color: MyColours.color_438E93,
|
|
|
|
width: ScreenUtil().setWidth(2)))),
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
content,
|
|
|
|
style: TextStyle(
|
|
|
|
color:
|
|
|
|
isSelect ? MyColours.color_F6F6F6 : MyColours.color_438E93,
|
|
|
|
fontSize: ScreenUtil().setSp(36)),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
widget.isCreate ? '添加套餐' : mealNameC.text,
|
|
|
|
needWhite: true,
|
|
|
|
bgColor: MyColours.color_438E93,
|
|
|
|
titleColor: MyColours.color_F6F6F6,
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(16),
|
|
|
|
),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
controller: controller,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
_textfield('套餐名称', '1299套餐', mealNameC, mealF, ''),
|
|
|
|
_textfield(
|
|
|
|
'套餐价格', '1299', mealPriceC, mealPriceF, '元'),
|
|
|
|
Container(
|
|
|
|
height: w(48),
|
|
|
|
margin: EdgeInsets.only(top: w(12)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
width: h(0.5),
|
|
|
|
color: MyColours.color_E7E7E7))),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: w(81),
|
|
|
|
height: w(48),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
'是否议价',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
color: MyColours.color_E5000000),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Spacer(),
|
|
|
|
InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
canBargaining = !canBargaining;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(16), right: w(16)),
|
|
|
|
child: Image.asset(
|
|
|
|
Utils.getImgPath(canBargaining
|
|
|
|
? 'swich_on'
|
|
|
|
: 'swich_off'),
|
|
|
|
width: w(44),
|
|
|
|
))),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
VEmptyView(52),
|
|
|
|
Text(
|
|
|
|
'套餐菜品',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: ScreenUtil().setSp(32),
|
|
|
|
color: MyColours.color_999999),
|
|
|
|
),
|
|
|
|
VEmptyView(30),
|
|
|
|
RoundButton(
|
|
|
|
onPressed: () async {
|
|
|
|
DialogUtil.textfeildAlertDialog(context,
|
|
|
|
title: '菜品分类',
|
|
|
|
hintText: '输入分类名称',
|
|
|
|
text: '',
|
|
|
|
lenghtLimit: false,
|
|
|
|
toast: '请输入分类名称', rCallback: (name) {
|
|
|
|
// _addCookbookClass(name, showLoading: true);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
text: '添加菜品分类',
|
|
|
|
fontSize: 32,
|
|
|
|
isBold: false,
|
|
|
|
height: h(32),
|
|
|
|
width: w(112),
|
|
|
|
textColor: MyColours.color_438E93,
|
|
|
|
gradientStart: MyColours.color_ffffff,
|
|
|
|
gradientEnd: MyColours.color_ffffff,
|
|
|
|
borderColor: MyColours.color_438E93,
|
|
|
|
radius: r(6),
|
|
|
|
),
|
|
|
|
VEmptyView(14),
|
|
|
|
ListView.builder(
|
|
|
|
itemCount: 100,
|
|
|
|
shrinkWrap: true,
|
|
|
|
controller: controller,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return buildFeastTypeItem('热菜(18道)');
|
|
|
|
})
|
|
|
|
],
|
|
|
|
)))),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: _callButton(
|
|
|
|
onPress: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
content: '返回',
|
|
|
|
hasLeftBorder: true,
|
|
|
|
isSelect: false)),
|
|
|
|
Expanded(
|
|
|
|
child: _callButton(
|
|
|
|
onPress: () {},
|
|
|
|
content: '保存',
|
|
|
|
hasLeftBorder: true,
|
|
|
|
isSelect: true))
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|