|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:one_key/constant/state.dart';
|
|
|
|
import 'package:one_key/models/area.dart';
|
|
|
|
import 'package:one_key/provider/my_table_manage_home_model.dart';
|
|
|
|
import 'package:one_key/provider/user_model.dart';
|
|
|
|
import 'package:one_key/res/colors.dart';
|
|
|
|
import 'package:one_key/utils/dialog_util.dart';
|
|
|
|
import 'package:one_key/utils/event_bus.dart';
|
|
|
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
import 'package:one_key/widgets/h_empty_view.dart';
|
|
|
|
import 'package:one_key/widgets/page_exception.dart';
|
|
|
|
import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
import '../../../provider/table_manager_model.dart';
|
|
|
|
import '../../../utils/screen_util.dart';
|
|
|
|
import '../../../widgets/round_button.dart';
|
|
|
|
|
|
|
|
/*
|
|
|
|
**** 区域选择管理
|
|
|
|
*/
|
|
|
|
class AreasSelectPage extends StatefulWidget {
|
|
|
|
final String rid;
|
|
|
|
final String name;
|
|
|
|
AreasSelectPage({Key key, this.rid, this.name}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_AreasSelectPageState createState() => _AreasSelectPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AreasSelectPageState extends State<AreasSelectPage> {
|
|
|
|
MyTableManageHomeModel tableManagerModel;
|
|
|
|
String rid;
|
|
|
|
String name;
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
// TODO: implement initState
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
rid = widget.rid;
|
|
|
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
tableManagerModel.initTime(context);
|
|
|
|
|
|
|
|
// EventBus().on("refresh_tablemanager", (arg) {
|
|
|
|
// //订座-完成预订 刷新管理桌位
|
|
|
|
// tableManagerModel.getReserveList(context,
|
|
|
|
// needLoading: false, needKeep: true);
|
|
|
|
// print(tableManagerModel);
|
|
|
|
// });
|
|
|
|
// EventBus().on("refresh_tablePhoto", (arg) {
|
|
|
|
// ///刷新图片显示
|
|
|
|
// _refreshTablePhoto();
|
|
|
|
// });
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
tableManagerModel =
|
|
|
|
Provider.of<MyTableManageHomeModel>(context, listen: true);
|
|
|
|
return Scaffold(
|
|
|
|
resizeToAvoidBottomInset: false, //输入框抵住键盘
|
|
|
|
appBar: SystemAppBar(
|
|
|
|
"区域选择",
|
|
|
|
showLeading: true,
|
|
|
|
onTap: () {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
backgroundColor: MyColours.color_ffffff,
|
|
|
|
body: SafeArea(child:
|
|
|
|
Consumer<MyTableManageHomeModel>(builder: (context, model, child) {
|
|
|
|
return model.pageState != PageState.Success
|
|
|
|
? ExceptionPage(
|
|
|
|
pageState: model.pageState,
|
|
|
|
callback: () {
|
|
|
|
// if (tableManagerModel.tableOuterList.isEmpty) {
|
|
|
|
// tableManagerModel.getTableList(context);
|
|
|
|
// } else {
|
|
|
|
// tableManagerModel.getReserveList(context);
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
emptyMsg: "暂时没有区域数据哦",
|
|
|
|
emptyImg: "table_manage_empty",
|
|
|
|
showMsg: "加载中,请稍后...",
|
|
|
|
)
|
|
|
|
: Column(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: ListView.builder(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(32),
|
|
|
|
vertical: ScreenUtil().setWidth(54)),
|
|
|
|
itemCount: tableManagerModel.areas.length,
|
|
|
|
shrinkWrap: true,
|
|
|
|
// scrollDirection: Axis.horizontal,
|
|
|
|
itemBuilder: (BuildContext contxt, int index) {
|
|
|
|
Area area = tableManagerModel.areas[index];
|
|
|
|
return InkWell(
|
|
|
|
onTap: () async {
|
|
|
|
if (rid == area.rid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
rid = area.rid;
|
|
|
|
name = area.name;
|
|
|
|
setState(() {});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.symmetric(
|
|
|
|
horizontal: ScreenUtil().setWidth(16),
|
|
|
|
vertical: ScreenUtil().setWidth(30)),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border(
|
|
|
|
bottom: BorderSide(
|
|
|
|
width: ScreenUtil().setWidth(2),
|
|
|
|
color:
|
|
|
|
MyColours.color_E7E7E7))),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Image.asset(
|
|
|
|
Utils.getImgPath(rid == area.rid
|
|
|
|
? 'select'
|
|
|
|
: 'unselect'),
|
|
|
|
width: w(20),
|
|
|
|
),
|
|
|
|
HEmptyView(30),
|
|
|
|
Expanded(
|
|
|
|
child: Text(area.name,
|
|
|
|
// textAlign: TextAlign.end,
|
|
|
|
style: TextStyle(
|
|
|
|
color:
|
|
|
|
MyColours.color_000000,
|
|
|
|
fontSize: ScreenUtil()
|
|
|
|
.setSp(32)))),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
));
|
|
|
|
})),
|
|
|
|
Container(
|
|
|
|
color: MyColours.color_ffffff,
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: w(48)),
|
|
|
|
margin: EdgeInsets.only(bottom: w(35), top: w(25)),
|
|
|
|
child: RoundButton(
|
|
|
|
// content: widget.fromPage == 'tablePhoto'
|
|
|
|
// ? '确定'
|
|
|
|
// : "已选${selectNum}个 确定",
|
|
|
|
text: '确定',
|
|
|
|
// width: w(128),
|
|
|
|
height: w(40),
|
|
|
|
radius: r(4),
|
|
|
|
isBold: false,
|
|
|
|
gradientStart: MyColours.color_438E93,
|
|
|
|
gradientEnd: MyColours.color_438E93,
|
|
|
|
fontSize: 28,
|
|
|
|
textColor: MyColours.color_ffffff,
|
|
|
|
onPressed: () {
|
|
|
|
// // if (widget.fromPage == "tablePhoto") {
|
|
|
|
// // Map temp = {
|
|
|
|
// // 'tid': selectTables.length > 0
|
|
|
|
// // ? selectTables[0].id
|
|
|
|
// // : '',
|
|
|
|
// // 'tname': selectTables.length > 0
|
|
|
|
// // ? selectTables[0].name
|
|
|
|
// // : ''
|
|
|
|
// // };
|
|
|
|
// // Navigator.of(context).pop(temp);
|
|
|
|
// // } else {
|
|
|
|
// if (widget.canChoose) {
|
|
|
|
// // // if (widget.tableList.length > 0) {
|
|
|
|
// // String tid = "";
|
|
|
|
// // for (TableList table
|
|
|
|
// // in widget.tableList) {
|
|
|
|
// // tid += table.id + ",";
|
|
|
|
// // }
|
|
|
|
// // if (widget.tableList.length > 0) {
|
|
|
|
// // tid = tid.substring(
|
|
|
|
// // 0, tid.length - 1);
|
|
|
|
// // }
|
|
|
|
|
|
|
|
Map temp = {
|
|
|
|
'rid': rid,
|
|
|
|
'name':name
|
|
|
|
};
|
|
|
|
Navigator.of(context).pop(temp);
|
|
|
|
// // // }
|
|
|
|
// // } else {
|
|
|
|
|
|
|
|
// String tid = "";
|
|
|
|
// for (t.Table table in selectTables) {
|
|
|
|
// tid += table.id + ",";
|
|
|
|
// }
|
|
|
|
// if (selectTables.length > 0) {
|
|
|
|
// tid = tid.substring(0, tid.length - 1);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Map temp = {'object': selectTables, 'tid': tid};
|
|
|
|
// Navigator.of(context).pop(temp);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
|
|
|
})));
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|