|
|
|
import 'package:amap_map_fluttify/amap_map_fluttify.dart';
|
|
|
|
import 'package:cached_network_image/cached_network_image.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
|
|
|
import 'package:flutter_screenutil/screenutil.dart';
|
|
|
|
import 'package:one_key/constant/state.dart';
|
|
|
|
import 'package:one_key/models/cookbook_model.dart';
|
|
|
|
import 'package:one_key/provider/menu_provider.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/route/navigator_util.dart';
|
|
|
|
import 'package:one_key/utils/event_bus.dart';
|
|
|
|
import 'package:one_key/widgets/MyDivider.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/page_exception.dart';
|
|
|
|
import 'package:one_key/widgets/round_button.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
class MenuManagePage extends StatefulWidget {
|
|
|
|
MenuManagePage({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_MenuManagePageState createState() => _MenuManagePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _MenuManagePageState extends State<MenuManagePage> {
|
|
|
|
ScrollController _controller = ScrollController();
|
|
|
|
MenuManageProvider menuManageProvider;
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
|
|
|
|
_getCookbookByClass();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_getCookbookByClass() async {
|
|
|
|
Map<String, String> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user.sellerid,
|
|
|
|
};
|
|
|
|
|
|
|
|
await menuManageProvider.getCookbookByClass(context, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
menuManageProvider = Provider.of<MenuManageProvider>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
'菜单管理',
|
|
|
|
onTap: () {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
),
|
|
|
|
body: WillPopScope(
|
|
|
|
onWillPop: () {
|
|
|
|
EventBus().emit('changeStatusColor');
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
},
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(child: Consumer<MenuManageProvider>(
|
|
|
|
builder: (context, model, _) {
|
|
|
|
if (model.pageState != PageState.Success) {
|
|
|
|
return ExceptionPage(
|
|
|
|
pageState: model.pageState,
|
|
|
|
callback: () {
|
|
|
|
// offset = 0;
|
|
|
|
// getMessage(showLoading: true);
|
|
|
|
// _couponNetworkData();
|
|
|
|
},
|
|
|
|
emptyMsg: "菜品是空哒,快点击分类管理添加分类和菜品吧",
|
|
|
|
emptyImg: "empty_search",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return ListView.builder(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(40),
|
|
|
|
vertical: ScreenUtil().setWidth(40)),
|
|
|
|
itemCount: menuManageProvider.menuModel.length,
|
|
|
|
shrinkWrap: true,
|
|
|
|
controller: _controller,
|
|
|
|
itemBuilder: (BuildContext context, int indexOut) {
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: ScreenUtil().setWidth(10),
|
|
|
|
height: ScreenUtil().setWidth(10),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_0D0D0D,
|
|
|
|
shape: BoxShape.circle),
|
|
|
|
),
|
|
|
|
MyDivider(ScreenUtil().setWidth(80),
|
|
|
|
ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_0D0D0D),
|
|
|
|
HEmptyView(20),
|
|
|
|
Text(
|
|
|
|
menuManageProvider
|
|
|
|
.menuModel[indexOut].className,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours.color_333333,
|
|
|
|
fontSize: ScreenUtil().setSp(28),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
HEmptyView(20),
|
|
|
|
MyDivider(ScreenUtil().setWidth(80),
|
|
|
|
ScreenUtil().setWidth(2),
|
|
|
|
color: MyColours.color_0D0D0D),
|
|
|
|
Container(
|
|
|
|
width: ScreenUtil().setWidth(10),
|
|
|
|
height: ScreenUtil().setWidth(10),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: MyColours.color_0D0D0D,
|
|
|
|
shape: BoxShape.circle),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
GridView.builder(
|
|
|
|
controller: _controller,
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
vertical: ScreenUtil().setWidth(40)),
|
|
|
|
shrinkWrap: true,
|
|
|
|
cacheExtent: ScreenUtil().setWidth(0),
|
|
|
|
itemCount: menuManageProvider
|
|
|
|
.menuModel[indexOut]
|
|
|
|
.cookbooklist
|
|
|
|
.length,
|
|
|
|
gridDelegate:
|
|
|
|
SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
crossAxisCount: 2,
|
|
|
|
childAspectRatio: 80 / 56,
|
|
|
|
mainAxisSpacing:
|
|
|
|
ScreenUtil().setWidth(15 * 2),
|
|
|
|
crossAxisSpacing:
|
|
|
|
ScreenUtil().setWidth(15 * 2)),
|
|
|
|
itemBuilder:
|
|
|
|
(BuildContext context, int index) {
|
|
|
|
MenuSunModel model = menuManageProvider
|
|
|
|
.menuModel[indexOut]
|
|
|
|
.cookbooklist[index];
|
|
|
|
return Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: index % 2 == 0
|
|
|
|
? Color.fromRGBO(
|
|
|
|
247, 230, 230, 1)
|
|
|
|
: Color.fromRGBO(
|
|
|
|
234, 236, 252, 1),
|
|
|
|
borderRadius: BorderRadius.circular(
|
|
|
|
ScreenUtil().setWidth(10))),
|
|
|
|
child: model.image != null
|
|
|
|
? ClipRRect(
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.circular(
|
|
|
|
ScreenUtil()
|
|
|
|
.setWidth(10)),
|
|
|
|
child: CachedNetworkImage(
|
|
|
|
imageUrl: model.image,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
width: ScreenUtil()
|
|
|
|
.setWidth(30 * 2),
|
|
|
|
height: ScreenUtil()
|
|
|
|
.setWidth(30 * 2),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
: Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil()
|
|
|
|
.setWidth(20)),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment:
|
|
|
|
CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
model.name,
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours
|
|
|
|
.color_333333,
|
|
|
|
fontSize: ScreenUtil()
|
|
|
|
.setSp(34),
|
|
|
|
fontWeight:
|
|
|
|
FontWeight.bold),
|
|
|
|
),
|
|
|
|
VEmptyView(40),
|
|
|
|
Text(
|
|
|
|
'${model.price}元/${model.unit}',
|
|
|
|
style: TextStyle(
|
|
|
|
color: MyColours
|
|
|
|
.color_333333,
|
|
|
|
fontSize: ScreenUtil()
|
|
|
|
.setSp(28),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
})
|
|
|
|
],
|
|
|
|
// onRefresh: () async {
|
|
|
|
// // offset = 0;
|
|
|
|
// // getMessage(showLoading: false);
|
|
|
|
// },
|
|
|
|
// onLoad: () async {
|
|
|
|
// // offset++;
|
|
|
|
// // getMessage(showLoading: false);
|
|
|
|
// },
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
)),
|
|
|
|
// VEmptyView(20),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
0,
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
ScreenUtil().setWidth(40)),
|
|
|
|
child: RoundButton(
|
|
|
|
onPressed: () async {
|
|
|
|
bool needRefresh =
|
|
|
|
await NavigatorUtil.goCouponEditPage(context);
|
|
|
|
print(needRefresh);
|
|
|
|
if (needRefresh != null && needRefresh) {
|
|
|
|
//刷新页面数据
|
|
|
|
// _controller.callRefresh();
|
|
|
|
// _couponNetworkData();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
text: '添加\n菜品',
|
|
|
|
fontSize: 26,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(120),
|
|
|
|
width: ScreenUtil().setWidth(120),
|
|
|
|
radius: ScreenUtil().setWidth(60),
|
|
|
|
)),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
0,
|
|
|
|
ScreenUtil().setWidth(40),
|
|
|
|
ScreenUtil().setWidth(40)),
|
|
|
|
child: RoundButton(
|
|
|
|
onPressed: () async {
|
|
|
|
bool needRefresh =
|
|
|
|
await NavigatorUtil.goCouponEditPage(context);
|
|
|
|
print(needRefresh);
|
|
|
|
if (needRefresh != null && needRefresh) {
|
|
|
|
//刷新页面数据
|
|
|
|
// _controller.callRefresh();
|
|
|
|
// _couponNetworkData();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
text: '分类\n管理',
|
|
|
|
fontSize: 26,
|
|
|
|
isBold: false,
|
|
|
|
height: ScreenUtil().setWidth(120),
|
|
|
|
width: ScreenUtil().setWidth(120),
|
|
|
|
radius: ScreenUtil().setWidth(60),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|