|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/utils/repaint_boundary_utils.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../../provider/feast_model.dart';
|
|
|
|
import '../../../models/cookbook_model.dart';
|
|
|
|
import '../../../models/notebook_detail.dart';
|
|
|
|
import '../../../models/recharge_list_model.dart';
|
|
|
|
import '../../../models/setmeal_by_id_model.dart';
|
|
|
|
import '../../../models/setmeal_model.dart';
|
|
|
|
import '../../../models/user.dart';
|
|
|
|
import '../../../provider/marketing_center_provider.dart';
|
|
|
|
import '../../../provider/user_model.dart';
|
|
|
|
import '../../../res/colors.dart';
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
import '../../../utils/share_helper.dart';
|
|
|
|
import '../../../utils/utils.dart';
|
|
|
|
import '../../../widgets/MyDivider.dart';
|
|
|
|
import '../../../widgets/h_empty_view.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
import '../../../widgets/v_empty_view.dart';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 宴会套餐菜单分享
|
|
|
|
*/
|
|
|
|
|
|
|
|
class FeastDishSharePage extends StatefulWidget {
|
|
|
|
final String setmealId;
|
|
|
|
FeastDishSharePage({Key key, this.setmealId}) : super(key: key);
|
|
|
|
final SetMealSunModel setmealDetail; //套餐详情
|
|
|
|
|
|
|
|
FeastDishSharePage({
|
|
|
|
Key key,
|
|
|
|
this.setmealDetail,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_FeastDishSharePageState createState() => _FeastDishSharePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _FeastDishSharePageState extends State<FeastDishSharePage> {
|
|
|
|
FeastModel feastModel;
|
|
|
|
ScrollController controller = ScrollController();
|
|
|
|
//全局key-截图key
|
|
|
|
final GlobalKey boundaryKey = GlobalKey();
|
|
|
|
|
|
|
|
Map<String, List<Cook>> data = {};
|
|
|
|
|
|
|
|
// Map<String, List<Cook>> dataNew = {};
|
|
|
|
List<String> classNames = [];
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
_getSetmealById();
|
|
|
|
_getSetmealClass();
|
|
|
|
});
|
|
|
|
Utils.changeStatusColor(color: Colors.transparent);
|
|
|
|
_getSetmealById();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 根据ID获取宴会套餐
|
|
|
|
_getSetmealById({bool isShowLoading = true}) async {
|
|
|
|
Map<String, String> params = {"id": widget.setmealId};
|
|
|
|
bool success = await feastModel.getSetmealById(context, params,
|
|
|
|
isShowLoading: isShowLoading);
|
|
|
|
if (success) {
|
|
|
|
// mealNameC.text = feastModel.setmealDetail.mealName;
|
|
|
|
// mealPriceC.text = feastModel.setmealDetail.price;
|
|
|
|
// canBargaining = feastModel.setmealDetail.bargaining == '1' ? true : false;
|
|
|
|
setState(() {});
|
|
|
|
_getSetmealById() async {
|
|
|
|
// Map<String, String> params = {"id": widget.setmealId};
|
|
|
|
// bool success = await feastModel.getSetmealById(context, params,
|
|
|
|
// isShowLoading: isShowLoading);
|
|
|
|
// if (success) {
|
|
|
|
// if (widget.justSelData.length > 0) {
|
|
|
|
// data = widget.justSelData;
|
|
|
|
// data.forEach((key, value) {
|
|
|
|
// classNames.add(key);
|
|
|
|
// });
|
|
|
|
// } else {
|
|
|
|
for (Classify item in widget.setmealDetail.classify) {
|
|
|
|
// Map<String, List<Cook>> map = {};
|
|
|
|
String cid = item.id;
|
|
|
|
String className = item.className;
|
|
|
|
|
|
|
|
List<Cook> temp = [];
|
|
|
|
int numStr = 0;
|
|
|
|
for (Cook itemCook in widget.setmealDetail.cook) {
|
|
|
|
if (cid == itemCook.cid) {
|
|
|
|
temp.add(itemCook);
|
|
|
|
if (itemCook.numStr != null) {
|
|
|
|
numStr += int.parse(itemCook.numStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String key = className + '(${numStr}道)';
|
|
|
|
classNames.add(key);
|
|
|
|
data[key] = temp;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
setState(() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _laduWidget() {
|
|
|
|
// if (labelIcon[widget
|
|
|
|
// .cookBookList.labelList[index].icon] is int) {
|
|
|
|
// int ladu = labelIcon[
|
|
|
|
// widget.cookBookList.labelList[index].icon];
|
|
|
|
int ladu = 6;
|
|
|
|
List<Widget> widgetList = [];
|
|
|
|
for (var i = 0; i < ladu; i++) {
|
|
|
|
widgetList.add(Image.asset(
|
|
|
|
Utils.getImgPath('ladu'),
|
|
|
|
width: w(10),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
// widgetList.add(HEmptyView(10));
|
|
|
|
return Row(
|
|
|
|
children: widgetList,
|
|
|
|
);
|
|
|
|
// }else{
|
|
|
|
// return SizedBox();
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 获取宴会套餐菜品分类列表
|
|
|
|
_getSetmealClass({bool isShowLoading = true}) async {
|
|
|
|
Map<String, String> params = {"mid": widget.setmealId};
|
|
|
|
await feastModel.getSetmealClass(context, params,
|
|
|
|
isShowLoading: isShowLoading);
|
|
|
|
|
|
|
|
Widget _itemBuildWidget(BuildContext context, int index1) {
|
|
|
|
List<Cook> cookList = data[classNames[index1]];
|
|
|
|
return ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
controller: controller,
|
|
|
|
padding: EdgeInsets.only(bottom: w(20)),
|
|
|
|
itemCount: cookList.length + 1,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
if (index < 1) {
|
|
|
|
return _buildHeaderWidget(context, classNames[index1]);
|
|
|
|
} else {
|
|
|
|
int itemIndex = index - 1;
|
|
|
|
Cook setmeal = cookList[itemIndex];
|
|
|
|
|
|
|
|
return Container(
|
|
|
|
margin: new EdgeInsets.only(top: h(14), left: w(25), right: w(25)),
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
child: new GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
// _gotoProjectDetail(projectModelList[index]);
|
|
|
|
},
|
|
|
|
child: new Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
|
|
|
child: Text(
|
|
|
|
setmeal.cname,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 10,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
))),
|
|
|
|
HEmptyView(30),
|
|
|
|
Container(
|
|
|
|
// width: h(16),
|
|
|
|
child: Text(
|
|
|
|
'${setmeal.numStr ?? ''}${setmeal.spec}',
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
maxLines: 1,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_515151,
|
|
|
|
fontSize: ScreenUtil().setSp(32)),
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// // 总count数
|
|
|
|
// int _getItemListCount() {
|
|
|
|
// return data.length + 1;
|
|
|
|
// }
|
|
|
|
// 根据index展示不同的widget
|
|
|
|
Widget buildItemWidget(BuildContext context, int index) {
|
|
|
|
return _itemBuildWidget(context, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
// header内容
|
|
|
|
Widget _buildHeaderWidget(BuildContext context, String title) {
|
|
|
|
return Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(16), vertical: w(14)),
|
|
|
|
child: Text(
|
|
|
|
title,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_E6000000,
|
|
|
|
fontSize: font(16),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: w(16)),
|
|
|
|
child: MyDivider(
|
|
|
|
double.infinity,
|
|
|
|
w(0.5),
|
|
|
|
color: MyColours.color_E7E7E7,
|
|
|
|
))
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
feastModel = Provider.of<FeastModel>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
body: Container(),
|
|
|
|
);
|
|
|
|
String sellername =
|
|
|
|
Provider.of<UserModel>(context, listen: false).user.sellername;
|
|
|
|
String sellerAdr =
|
|
|
|
Provider.of<UserModel>(context, listen: false).user.sellerAddr;
|
|
|
|
User user = Provider.of<UserModel>(context, listen: false).user;
|
|
|
|
String servicePerson = '${user.nickName ?? ''} ${user.userphone ?? ''}';
|
|
|
|
|
|
|
|
return KeyboardDismissOnTap(
|
|
|
|
child: Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar('排菜单'),
|
|
|
|
body: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
controller: controller,
|
|
|
|
child: RepaintBoundary(
|
|
|
|
key: boundaryKey,
|
|
|
|
child: Container(
|
|
|
|
color: Colors.white,
|
|
|
|
child: Column(children: [
|
|
|
|
Stack(children: [
|
|
|
|
Stack(
|
|
|
|
// alignment: AlignmentDirectional.bottomCenter, // alignment:子组件对齐方式 系统默认
|
|
|
|
// alignment: const FractionalOffset(0.5, 0.9), //自己指定Stack子组件对齐 ,只对Stack中有两个子View生效。0.5表示x轴,0.9表示y轴(FractionalOffset 0.5,0.5表示中心)
|
|
|
|
//AlignmentDirectional x、y 偏移量取值范围为 [-1,1],如果 x 的偏移量大于 0,则表示向右偏移,小于 0 则向左偏移;如果 y 轴的偏移量大于 0 则向下偏移,小于 0 则向上偏移。
|
|
|
|
alignment: AlignmentDirectional(
|
|
|
|
0, 0), //AlignmentDirectional 0,0表示在正中心。
|
|
|
|
fit: StackFit.loose,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
margin: EdgeInsets.zero,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: w(20),
|
|
|
|
right: w(20),
|
|
|
|
top: w(30),
|
|
|
|
bottom: w(15)),
|
|
|
|
// height: w(200),
|
|
|
|
// constraints: new BoxConstraints.expand(
|
|
|
|
// height: w(200),
|
|
|
|
// ),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
gradient: LinearGradient(
|
|
|
|
stops: [
|
|
|
|
-0.5747,
|
|
|
|
0.5572,
|
|
|
|
1.4872
|
|
|
|
],
|
|
|
|
colors: [
|
|
|
|
MyColours.color_4C8DAD,
|
|
|
|
MyColours.color_0143A3,
|
|
|
|
MyColours.color_42A5FF
|
|
|
|
],
|
|
|
|
begin: Alignment.topLeft,
|
|
|
|
end: Alignment.bottomRight),
|
|
|
|
),
|
|
|
|
child: Container(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'${sellername} 贵宾排菜菜单',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(20),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Colors.transparent),
|
|
|
|
),
|
|
|
|
VEmptyView(26),
|
|
|
|
Text(
|
|
|
|
'套餐名称 | ${widget.setmealDetail.mealName ?? ''}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: Colors.transparent),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'套餐价格 | ${widget.setmealDetail.price}元',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: Colors.transparent),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'餐厅地址 | ${sellerAdr}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: Colors.transparent),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'专属服务 | ${servicePerson}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: Colors.transparent),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
right: w(22),
|
|
|
|
bottom: w(30),
|
|
|
|
child: Image.asset(Utils.getImgPath('menu_bg')),
|
|
|
|
width: w(170),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Positioned(
|
|
|
|
top: w(30),
|
|
|
|
left: w(20),
|
|
|
|
child: Container(
|
|
|
|
color: Colors.transparent,
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
'${sellername} 贵宾排菜菜单',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(20),
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: MyColours.color_CFB53B),
|
|
|
|
),
|
|
|
|
VEmptyView(26),
|
|
|
|
Text(
|
|
|
|
'套餐名称 | ${widget.setmealDetail.mealName ?? ''}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: MyColours.color_CFB53B),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'套餐价格 | ${widget.setmealDetail.price}元',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: MyColours.color_CFB53B),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'餐厅地址 | ${sellerAdr}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: MyColours.color_CFB53B),
|
|
|
|
),
|
|
|
|
VEmptyView(10),
|
|
|
|
Text(
|
|
|
|
'专属服务 | ${servicePerson}',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: font(14),
|
|
|
|
color: MyColours.color_CFB53B),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
))),
|
|
|
|
]),
|
|
|
|
ListView.builder(
|
|
|
|
shrinkWrap: true,
|
|
|
|
controller: controller,
|
|
|
|
// padding: EdgeInsets.only(right: w(12)),
|
|
|
|
itemCount: data.length,
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
return buildItemWidget(context, index);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
]))),
|
|
|
|
)),
|
|
|
|
Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
top: w(12), bottom: w(25), left: w(23), right: w(23)),
|
|
|
|
child: Row(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
RoundButton(
|
|
|
|
text: '返回',
|
|
|
|
gradientStart: MyColours.color_ffffff,
|
|
|
|
gradientEnd: MyColours.color_ffffff,
|
|
|
|
borderColor: MyColours.color_438E93,
|
|
|
|
textColor: MyColours.color_438E93,
|
|
|
|
width: w(100),
|
|
|
|
height: w(43),
|
|
|
|
radius: r(5),
|
|
|
|
fontSize: 32,
|
|
|
|
isBold: false,
|
|
|
|
onPressed: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
// NavigatorUtil.goFeastDishSharePage(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
HEmptyView(30),
|
|
|
|
Expanded(
|
|
|
|
child: RoundButton(
|
|
|
|
text: '分享排菜单',
|
|
|
|
gradientStart: MyColours.color_438E93,
|
|
|
|
gradientEnd: MyColours.color_438E93,
|
|
|
|
height: w(43),
|
|
|
|
radius: r(5),
|
|
|
|
fontSize: 36,
|
|
|
|
isBold: false,
|
|
|
|
onPressed: () {
|
|
|
|
ShareHelper.onShareWx(
|
|
|
|
context,
|
|
|
|
boundaryKey: boundaryKey,
|
|
|
|
);
|
|
|
|
|
|
|
|
// NavigatorUtil.goFeastDishSharePage(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|