|
|
|
// import 'dart:async';
|
|
|
|
|
|
|
|
// import 'package:common_utils/common_utils.dart';
|
|
|
|
// import 'package:dotted_border/dotted_border.dart';
|
|
|
|
// 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/models/notebook_detail.dart';
|
|
|
|
// import 'package:one_key/models/tableOuter.dart';
|
|
|
|
// import 'package:one_key/pages/table/area_item_table.dart';
|
|
|
|
// import 'package:one_key/provider/table_manager_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/route/navigator_util.dart';
|
|
|
|
// import 'package:one_key/utils/utils.dart';
|
|
|
|
// import 'package:one_key/widgets/MyDivider.dart';
|
|
|
|
// import 'package:one_key/widgets/app_bar.dart';
|
|
|
|
// import 'package:one_key/widgets/area_item.dart';
|
|
|
|
// import 'package:one_key/widgets/common_button.dart';
|
|
|
|
// import 'package:one_key/widgets/page_exception.dart';
|
|
|
|
// import 'package:one_key/widgets/system_app_bar.dart';
|
|
|
|
// import 'package:one_key/widgets/table_item.dart';
|
|
|
|
// import 'package:one_key/models/table.dart' as t;
|
|
|
|
// import 'package:one_key/widgets/v_empty_view.dart';
|
|
|
|
// import 'package:provider/provider.dart';
|
|
|
|
// import 'dart:convert' as convert;
|
|
|
|
// import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
|
|
|
|
// import 'package:scroll_to_index/scroll_to_index.dart';
|
|
|
|
|
|
|
|
// const scrollDuration = Duration(microseconds: 500);
|
|
|
|
|
|
|
|
// class TableManagerPage extends StatefulWidget {
|
|
|
|
// @override
|
|
|
|
// State<StatefulWidget> createState() {
|
|
|
|
// // TODO: implement createState
|
|
|
|
// return new TableManagerPageState();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// class TableManagerPageState extends State<TableManagerPage> {
|
|
|
|
// TableManagerModel tableManagerModel;
|
|
|
|
// final ItemScrollController itemScrollController = ItemScrollController();
|
|
|
|
// bool isTap = false;
|
|
|
|
// // 进度监听对象
|
|
|
|
// int min;
|
|
|
|
// int max;
|
|
|
|
|
|
|
|
// ScrollController _areaController = ScrollController();
|
|
|
|
// AutoScrollController controller;
|
|
|
|
// List<String> personNumList = [];
|
|
|
|
|
|
|
|
// final ItemPositionsListener itemPositionsListener =
|
|
|
|
// ItemPositionsListener.create();
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// void initState() {
|
|
|
|
// // TODO: implement initState
|
|
|
|
// super.initState();
|
|
|
|
// LogUtil.v("table_manager_page initState");
|
|
|
|
// for (int i = 1; i < 31; i++) {
|
|
|
|
// personNumList.add(i.toString());
|
|
|
|
// }
|
|
|
|
// controller = AutoScrollController(
|
|
|
|
// viewportBoundaryGetter: () =>
|
|
|
|
// Rect.fromLTRB(0, 0, 0, MediaQuery.of(context).padding.bottom),
|
|
|
|
// axis: Axis.vertical);
|
|
|
|
// // personNumList.add('30以上');
|
|
|
|
// tableManagerModel = Provider.of<TableManagerModel>(context, listen: false);
|
|
|
|
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
// tableManagerModel.initTime(context);
|
|
|
|
// EventBus().on("refresh_tablemanager", (arg) {
|
|
|
|
// //订座-完成预订 刷新管理桌位
|
|
|
|
// tableManagerModel.getReserveList(context);
|
|
|
|
// print(tableManagerModel);
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Widget list(List data) => new ListView.custom(
|
|
|
|
// controller: controller,
|
|
|
|
// cacheExtent: 1.0, // 只有设置了1.0 才能够准确的标记position 位置
|
|
|
|
// childrenDelegate: MyChildrenDelegate(
|
|
|
|
// (BuildContext context, int index) {
|
|
|
|
// if (!isTap) {
|
|
|
|
// print(index);
|
|
|
|
// // setState(() {
|
|
|
|
|
|
|
|
// // });
|
|
|
|
// // tableManagerModel.selectIndex = index;
|
|
|
|
// // // tableManagerModel.notifyListeners();
|
|
|
|
|
|
|
|
// // tableManagerModel.currentArea =
|
|
|
|
// // tableManagerModel.areas[tableManagerModel.selectIndex].name;
|
|
|
|
// _areaController.animateTo(index * ScreenUtil().setWidth(104 * 2),
|
|
|
|
// duration: new Duration(milliseconds: 500),
|
|
|
|
// curve: Curves.ease);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return item(index);
|
|
|
|
// },
|
|
|
|
// childCount: data.length,
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
|
|
|
|
// // ;
|
|
|
|
|
|
|
|
// // void scrollTo(int index) => itemScrollController
|
|
|
|
// // .scrollTo(
|
|
|
|
// // index: index,
|
|
|
|
// // duration: scrollDuration,
|
|
|
|
// // curve: Curves.easeInOutCubic,
|
|
|
|
// // alignment: 0)
|
|
|
|
// // .then((value) {
|
|
|
|
// // print(tableManagerModel.selectIndex);
|
|
|
|
// // // _selectIndex = _selectIndex;
|
|
|
|
// // // // }
|
|
|
|
// // // isTap = false;
|
|
|
|
// // // this.setState(() {});
|
|
|
|
// // }).whenComplete(() {
|
|
|
|
// // // print('');
|
|
|
|
// // });
|
|
|
|
|
|
|
|
// // void jumpTo(int index) =>
|
|
|
|
// // itemScrollController.jumpTo(index: index, alignment: 0);
|
|
|
|
// Widget item(int index) {
|
|
|
|
// return _wrapScrollTag(index: index, child: itemSun(index));
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Widget _wrapScrollTag({int index, Widget child}) => AutoScrollTag(
|
|
|
|
// key: ValueKey(index),
|
|
|
|
// controller: controller,
|
|
|
|
// index: index,
|
|
|
|
// child: child,
|
|
|
|
// highlightColor: Colors.black.withOpacity(0.1),
|
|
|
|
// );
|
|
|
|
|
|
|
|
// /// Generate item number [i].
|
|
|
|
// Widget itemSun(int i) {
|
|
|
|
// return SingleChildScrollView(
|
|
|
|
// child: Column(
|
|
|
|
// children: [
|
|
|
|
// VEmptyView(40),
|
|
|
|
// Container(
|
|
|
|
// alignment: Alignment.center,
|
|
|
|
// height: ScreenUtil().setWidth(21 * 2),
|
|
|
|
// child: Text(tableManagerModel.areas[i].name,
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: ScreenUtil().setWidth(30),
|
|
|
|
// color: MyColours.color_199095)),
|
|
|
|
// ),
|
|
|
|
// VEmptyView(30),
|
|
|
|
// GridView.builder(
|
|
|
|
// // controller: _areaController,
|
|
|
|
// physics: NeverScrollableScrollPhysics(),
|
|
|
|
// padding: EdgeInsets.only(top: 0),
|
|
|
|
// shrinkWrap: true,
|
|
|
|
// itemCount: tableManagerModel
|
|
|
|
// .areaTableMap[tableManagerModel.areas[i].name].length +
|
|
|
|
// 1,
|
|
|
|
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
|
|
// crossAxisCount: 4,
|
|
|
|
// childAspectRatio: 8 / 9,
|
|
|
|
// ),
|
|
|
|
// // mainAxisSpacing: ScreenUtil().setWidth(15 * 2),
|
|
|
|
// // crossAxisSpacing: ScreenUtil().setWidth(38 * 2)),
|
|
|
|
// itemBuilder: (BuildContext context, int index) {
|
|
|
|
// if (index ==
|
|
|
|
// tableManagerModel
|
|
|
|
// .areaTableMap[tableManagerModel.areas[i].name].length ||
|
|
|
|
// tableManagerModel
|
|
|
|
// .areaTableMap[tableManagerModel.areas[i].name].length ==
|
|
|
|
// 0) {
|
|
|
|
// return InkWell(
|
|
|
|
// onTap: () async {
|
|
|
|
// List<String> areas = [];
|
|
|
|
// for (int i = 0; i < tableManagerModel.areas.length; i++) {
|
|
|
|
// areas.add(tableManagerModel.areas[i].name);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //添加桌位弹框
|
|
|
|
// await DialogUtil.openCreateTableDialog(
|
|
|
|
// context, areas, i, personNumList,
|
|
|
|
// onTap: (Map<String, String> value) async {
|
|
|
|
// print(value);
|
|
|
|
// // 'areaname':
|
|
|
|
// // areas[currentAreaIndex],
|
|
|
|
// // 'name': controller.text,
|
|
|
|
// // 'pnumMin': pnumMin,
|
|
|
|
// // 'pnumMax': pnumMax
|
|
|
|
// //添加桌位 接口参数带整合???
|
|
|
|
// // 以下是旧的不去,明天添加桌位接口
|
|
|
|
// String rid;
|
|
|
|
// for (Area item in tableManagerModel.areas) {
|
|
|
|
// if (item.name == value['areaname']) {
|
|
|
|
// rid = item.rid;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// Map<String, String> params = {
|
|
|
|
// 'rid': rid,
|
|
|
|
// 'name': value['name'],
|
|
|
|
// };
|
|
|
|
// if (value['pnumMin'] != '') {
|
|
|
|
// params['pnum'] = value['pnumMin'];
|
|
|
|
// }
|
|
|
|
// if (value['pnumMax'] != '') {
|
|
|
|
// params['most_pnum'] = value['pnumMax'];
|
|
|
|
// }
|
|
|
|
// bool success =
|
|
|
|
// await tableManagerModel.addTable(context, params);
|
|
|
|
// print(success);
|
|
|
|
// if (success) {
|
|
|
|
// Utils.showToast('添加成功!');
|
|
|
|
// // TableOuter tableOuter = TableOuter();
|
|
|
|
// // tableOuter.name = value;
|
|
|
|
// // tableOuter.list = [];
|
|
|
|
// // tableManagerModel.tableOuterList.add(tableOuter);
|
|
|
|
// // tableManagerModel.initData();
|
|
|
|
// // Timer(
|
|
|
|
// // Duration(milliseconds: 500),
|
|
|
|
// // () => _areaController.jumpTo(
|
|
|
|
// // _areaController.position.maxScrollExtent));
|
|
|
|
|
|
|
|
// // await tableManagerModel
|
|
|
|
// // .getTableList(context);
|
|
|
|
// // await tableManagerModel
|
|
|
|
// // .initData();
|
|
|
|
// tableManagerModel.refreshTable(context);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// child: Container(
|
|
|
|
// margin: EdgeInsets.all(ScreenUtil().setWidth(9)),
|
|
|
|
// child: DottedBorder(
|
|
|
|
// dashPattern: [5, 5, 5, 5],
|
|
|
|
// borderType: BorderType.RRect,
|
|
|
|
// radius: Radius.circular(ScreenUtil().setWidth(10)),
|
|
|
|
// // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
// color: MyColours.color_199095,
|
|
|
|
// strokeWidth: ScreenUtil().setWidth(2),
|
|
|
|
// child: ClipRRect(
|
|
|
|
// borderRadius: BorderRadius.all(
|
|
|
|
// Radius.circular(ScreenUtil().setWidth(10))),
|
|
|
|
// child: Container(
|
|
|
|
// height: ScreenUtil().setWidth(90 * 2),
|
|
|
|
// width: ScreenUtil().setWidth(80 * 2),
|
|
|
|
// child: Column(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
// children: [
|
|
|
|
// Image.asset(Utils.getImgPath('add_area'),
|
|
|
|
// width: ScreenUtil().setWidth(32)),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// )));
|
|
|
|
// } else {
|
|
|
|
// return Selector<TableManagerModel, t.Table>(
|
|
|
|
// shouldRebuild: (pre, next) => true,
|
|
|
|
// selector: (context, model) => tableManagerModel
|
|
|
|
// .areaTableMap[tableManagerModel.areas[i].name][index],
|
|
|
|
// builder: (context, table, _) {
|
|
|
|
// return TableItem(table, onSelected: (table) {
|
|
|
|
// if ((table as t.Table).selected) {
|
|
|
|
// tableManagerModel.selectTables.add(table);
|
|
|
|
// } else {
|
|
|
|
// tableManagerModel.selectTables
|
|
|
|
// .removeWhere((t) => t.id == table.id);
|
|
|
|
// }
|
|
|
|
// DialogUtil.showTableManagerDialog(context, table)
|
|
|
|
// .then((value) {
|
|
|
|
// if (value != null) {
|
|
|
|
// switch (value) {
|
|
|
|
// case 1: //查看详情
|
|
|
|
// NavigatorUtil.goNotebookDetailPage(context,
|
|
|
|
// tableManagerModel.tableMap[table.id].id);
|
|
|
|
// break;
|
|
|
|
// case 2: //订座
|
|
|
|
// NavigatorUtil.goNoteBookChangePage(
|
|
|
|
// context,
|
|
|
|
// NotebookDetail.fromTableManager(
|
|
|
|
// tableManagerModel.getCurrDdateStr(),
|
|
|
|
// tableManagerModel.currTimeIndex.toString(),
|
|
|
|
// table),
|
|
|
|
// "");
|
|
|
|
// break;
|
|
|
|
// case 3: //停用,启用桌位
|
|
|
|
// Map<String, String> params = {
|
|
|
|
// "id": (table as t.Table).id,
|
|
|
|
// "status":
|
|
|
|
// (table as t.Table).enable == "1" ? "0" : "1"
|
|
|
|
// };
|
|
|
|
// tableManagerModel
|
|
|
|
// .setSwitchStatus(context, params)
|
|
|
|
// .then((value) {
|
|
|
|
// if (value != null) {
|
|
|
|
// (table as t.Table).enable =
|
|
|
|
// ((int.parse((table as t.Table).enable) +
|
|
|
|
// 1) %
|
|
|
|
// 2)
|
|
|
|
// .toString();
|
|
|
|
// if ((table as t.Table).enable == "1") {
|
|
|
|
// for (Area area in tableManagerModel.areas) {
|
|
|
|
// if (area.name ==
|
|
|
|
// tableManagerModel.currentArea) {
|
|
|
|
// if (table.sign != '5' &&
|
|
|
|
// table.sign != '1') {
|
|
|
|
// //已预订
|
|
|
|
// area.count++;
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// for (Area area in tableManagerModel.areas) {
|
|
|
|
// if (area.name ==
|
|
|
|
// tableManagerModel.currentArea) {
|
|
|
|
// if (table.sign != '5' &&
|
|
|
|
// table.sign != '1') {
|
|
|
|
// //已预订
|
|
|
|
// area.count--;
|
|
|
|
// }
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// tableManagerModel.notifyListeners();
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// canSelected: false,
|
|
|
|
// fromPage: 'table_manage',
|
|
|
|
// tableMap: tableManagerModel.tableMap,
|
|
|
|
// rid: "");
|
|
|
|
// },
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ));
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// Widget build(BuildContext context) {
|
|
|
|
// return Consumer<TableManagerModel>(
|
|
|
|
// builder: (context, model, child) {
|
|
|
|
// return Column(
|
|
|
|
// children: <Widget>[
|
|
|
|
// SystemAppBar("桌位", showLeading: false),
|
|
|
|
// Container(
|
|
|
|
// color: MyColours.color_ffffff,
|
|
|
|
// width: double.infinity,
|
|
|
|
// padding:
|
|
|
|
// EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)),
|
|
|
|
// child: Row(
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
// children: <Widget>[
|
|
|
|
// Expanded(
|
|
|
|
// child: Center(
|
|
|
|
// child: GestureDetector(
|
|
|
|
// onTap: () {
|
|
|
|
// DialogUtil.showCalendarDialog(
|
|
|
|
// context, tableManagerModel.dateTime)
|
|
|
|
// .then((day) {
|
|
|
|
// if (day != null) {
|
|
|
|
// tableManagerModel.createDateText(context, day);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// child: Container(
|
|
|
|
// child: Text(
|
|
|
|
// tableManagerModel.dateText,
|
|
|
|
// style: TextStyle(
|
|
|
|
// color: MyColours.color_199095,
|
|
|
|
// fontSize: ScreenUtil().setSp(34)),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// MyDivider(
|
|
|
|
// ScreenUtil().setWidth(2),
|
|
|
|
// ScreenUtil().setHeight(68),
|
|
|
|
// color: MyColours.color_E0E0E0,
|
|
|
|
// ),
|
|
|
|
// Expanded(
|
|
|
|
// child: Padding(
|
|
|
|
// padding: EdgeInsets.symmetric(
|
|
|
|
// horizontal: ScreenUtil().setWidth(30)),
|
|
|
|
// child: Row(
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
// children: <Widget>[
|
|
|
|
// Offstage(
|
|
|
|
// offstage:
|
|
|
|
// tableManagerModel.morning == "00:00-00:00"
|
|
|
|
// ? true
|
|
|
|
// : false,
|
|
|
|
// child: Padding(
|
|
|
|
// padding: EdgeInsets.only(
|
|
|
|
// right: ScreenUtil().setWidth(18)),
|
|
|
|
// child: CommonButton(
|
|
|
|
// content: "早市",
|
|
|
|
// state: tableManagerModel.currTimeIndex == 1
|
|
|
|
// ? 1
|
|
|
|
// : 0,
|
|
|
|
// width: 92,
|
|
|
|
// height: 48,
|
|
|
|
// fontSize: 32,
|
|
|
|
// onPress: () {
|
|
|
|
// if (tableManagerModel.currTimeIndex == 1)
|
|
|
|
// return;
|
|
|
|
// tableManagerModel.currTimeIndex = 1;
|
|
|
|
// tableManagerModel.getReserveList(context);
|
|
|
|
// },
|
|
|
|
// ))),
|
|
|
|
// Offstage(
|
|
|
|
// offstage: tableManagerModel.noon == "00:00-00:00"
|
|
|
|
// ? true
|
|
|
|
// : false,
|
|
|
|
// child: Padding(
|
|
|
|
// padding: EdgeInsets.only(
|
|
|
|
// right: ScreenUtil().setWidth(18)),
|
|
|
|
// child: CommonButton(
|
|
|
|
// content: "午市",
|
|
|
|
// state: tableManagerModel.currTimeIndex == 2
|
|
|
|
// ? 1
|
|
|
|
// : 0,
|
|
|
|
// width: 92,
|
|
|
|
// height: 48,
|
|
|
|
// fontSize: 32,
|
|
|
|
// onPress: () {
|
|
|
|
// if (tableManagerModel.currTimeIndex == 2)
|
|
|
|
// return;
|
|
|
|
// tableManagerModel.currTimeIndex = 2;
|
|
|
|
// tableManagerModel.getReserveList(context);
|
|
|
|
// },
|
|
|
|
// ))),
|
|
|
|
// Offstage(
|
|
|
|
// offstage: tableManagerModel.night == "00:00-00:00"
|
|
|
|
// ? true
|
|
|
|
// : false,
|
|
|
|
// child: Container(
|
|
|
|
// // padding: EdgeInsets.symmetric(
|
|
|
|
// // horizontal: ScreenUtil().setWidth(10)),
|
|
|
|
// child: CommonButton(
|
|
|
|
// content: "晚市",
|
|
|
|
// state:
|
|
|
|
// tableManagerModel.currTimeIndex == 3 ? 1 : 0,
|
|
|
|
// width: 92,
|
|
|
|
// height: 48,
|
|
|
|
// fontSize: 32,
|
|
|
|
// onPress: () {
|
|
|
|
// if (tableManagerModel.currTimeIndex == 3)
|
|
|
|
// return;
|
|
|
|
// tableManagerModel.currTimeIndex = 3;
|
|
|
|
// tableManagerModel.getReserveList(context);
|
|
|
|
// },
|
|
|
|
// )),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// Expanded(
|
|
|
|
// child: Consumer<TableManagerModel>(
|
|
|
|
// builder: (context, model, child) {
|
|
|
|
// if (model.pageState != PageState.Success) {
|
|
|
|
// return ExceptionPage(
|
|
|
|
// pageState: model.pageState,
|
|
|
|
// callback: () {
|
|
|
|
// if (tableManagerModel.tableOuterList.isEmpty) {
|
|
|
|
// tableManagerModel.getTableList(context);
|
|
|
|
// } else {
|
|
|
|
// tableManagerModel.getReserveList(context);
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// emptyMsg: "暂时没有桌位哦",
|
|
|
|
// emptyImg: "empty_search",
|
|
|
|
// showMsg: "加载中,请稍后...",
|
|
|
|
// );
|
|
|
|
// } else {
|
|
|
|
// return Container(
|
|
|
|
// color: MyColours.color_ffffff,
|
|
|
|
// child: Column(children: <Widget>[
|
|
|
|
// ValueListenableBuilder<Iterable<ItemPosition>>(
|
|
|
|
// valueListenable:
|
|
|
|
// itemPositionsListener.itemPositions,
|
|
|
|
// builder: (context, positions, child) {
|
|
|
|
// if (positions.isNotEmpty) {
|
|
|
|
// max = positions
|
|
|
|
// .where((ItemPosition position) =>
|
|
|
|
// position.itemLeadingEdge < 1)
|
|
|
|
// .reduce((ItemPosition max,
|
|
|
|
// ItemPosition position) =>
|
|
|
|
// position.itemLeadingEdge >
|
|
|
|
// max.itemLeadingEdge
|
|
|
|
// ? position
|
|
|
|
// : max)
|
|
|
|
// .index;
|
|
|
|
|
|
|
|
// min = positions
|
|
|
|
// .where((ItemPosition position) =>
|
|
|
|
// position.itemTrailingEdge > 0)
|
|
|
|
// .reduce((ItemPosition min,
|
|
|
|
// ItemPosition position) =>
|
|
|
|
// position.itemTrailingEdge <
|
|
|
|
// min.itemTrailingEdge
|
|
|
|
// ? position
|
|
|
|
// : min)
|
|
|
|
// .index;
|
|
|
|
|
|
|
|
// // if (isTap) {
|
|
|
|
// // if (min >= _selectIndex) {
|
|
|
|
// // _selectIndex = min;
|
|
|
|
// // } else {
|
|
|
|
// // //点击按钮的时候
|
|
|
|
// // _selectIndex = _selectIndex;
|
|
|
|
// // }
|
|
|
|
// // isTap = false;
|
|
|
|
// // } else {
|
|
|
|
// //手动滑动列表的时候
|
|
|
|
// // if (max == tableManagerModel.areas.length - 1) {
|
|
|
|
// // _selectIndex = _selectIndex;
|
|
|
|
// // } else if (min >= _selectIndex ||
|
|
|
|
// // max <= _selectIndex) {
|
|
|
|
// // _selectIndex = min;
|
|
|
|
// // } else {
|
|
|
|
// // //点击按钮的时候
|
|
|
|
// // _selectIndex = _selectIndex;
|
|
|
|
// // }
|
|
|
|
// // tableManagerModel.currentArea =
|
|
|
|
// // tableManagerModel.areas[_selectIndex].name;
|
|
|
|
// // _areaController.animateTo(
|
|
|
|
// // _selectIndex *
|
|
|
|
// // ScreenUtil().setWidth(104 * 2),
|
|
|
|
// // duration: new Duration(milliseconds: 500),
|
|
|
|
// // curve: Curves.ease);
|
|
|
|
// }
|
|
|
|
// return Container(
|
|
|
|
// height: ScreenUtil().setWidth(80),
|
|
|
|
// color: MyColours.color_ffffff,
|
|
|
|
// margin: EdgeInsets.only(
|
|
|
|
// bottom: ScreenUtil().setWidth(20)),
|
|
|
|
// child: ListView.builder(
|
|
|
|
// padding: EdgeInsets.symmetric(
|
|
|
|
// horizontal: ScreenUtil().setWidth(40)),
|
|
|
|
// controller: _areaController,
|
|
|
|
// scrollDirection: Axis.horizontal,
|
|
|
|
// itemBuilder: (context, index) {
|
|
|
|
// if (index ==
|
|
|
|
// tableManagerModel.areas.length ||
|
|
|
|
// tableManagerModel.areas.length == 0) {
|
|
|
|
// return InkWell(
|
|
|
|
// onTap: () async {
|
|
|
|
// //添加区域弹框
|
|
|
|
// await DialogUtil
|
|
|
|
// .openCreateAreaDialog(context,
|
|
|
|
// onTap: (value) async {
|
|
|
|
// print(value);
|
|
|
|
// //添加区域
|
|
|
|
// bool success =
|
|
|
|
// await tableManagerModel
|
|
|
|
// .addTableAreas(
|
|
|
|
// context, value);
|
|
|
|
// print(success);
|
|
|
|
// if (success) {
|
|
|
|
// Utils.showToast('添加成功!');
|
|
|
|
// // TableOuter tableOuter =
|
|
|
|
// // TableOuter();
|
|
|
|
// // tableOuter.name = value;
|
|
|
|
// // tableOuter.list = [];
|
|
|
|
// // tableManagerModel.tableOuterList
|
|
|
|
// // .add(tableOuter);
|
|
|
|
// await tableManagerModel
|
|
|
|
// .getTableList(context,
|
|
|
|
// needLoading: false);
|
|
|
|
// tableManagerModel.initData();
|
|
|
|
// Timer(
|
|
|
|
// Duration(milliseconds: 500),
|
|
|
|
// () => _areaController
|
|
|
|
// .jumpTo(_areaController
|
|
|
|
// .position
|
|
|
|
// .maxScrollExtent));
|
|
|
|
|
|
|
|
// // await tableManagerModel
|
|
|
|
// // .getTableList(context);
|
|
|
|
// // await tableManagerModel
|
|
|
|
// // .initData();
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// child: Column(
|
|
|
|
// children: [
|
|
|
|
// VEmptyView(20),
|
|
|
|
// DottedBorder(
|
|
|
|
// dashPattern: [5, 5, 5, 5],
|
|
|
|
// borderType: BorderType.RRect,
|
|
|
|
// radius: Radius.circular(
|
|
|
|
// ScreenUtil().setWidth(10)),
|
|
|
|
// // padding: EdgeInsets.all(ScreenUtil().setWidth(70)),
|
|
|
|
// color: MyColours.color_199095,
|
|
|
|
// strokeWidth:
|
|
|
|
// ScreenUtil().setWidth(2),
|
|
|
|
// child: ClipRRect(
|
|
|
|
// borderRadius: BorderRadius
|
|
|
|
// .all(Radius.circular(
|
|
|
|
// ScreenUtil()
|
|
|
|
// .setWidth(10))),
|
|
|
|
// child: Container(
|
|
|
|
// height: ScreenUtil()
|
|
|
|
// .setWidth(25 * 2),
|
|
|
|
// width: ScreenUtil()
|
|
|
|
// .setWidth(104 * 2),
|
|
|
|
// child: Column(
|
|
|
|
// mainAxisAlignment:
|
|
|
|
// MainAxisAlignment
|
|
|
|
// .center,
|
|
|
|
// children: [
|
|
|
|
// Image.asset(
|
|
|
|
// Utils.getImgPath(
|
|
|
|
// 'add_area'),
|
|
|
|
// width: ScreenUtil()
|
|
|
|
// .setWidth(24)),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// ],
|
|
|
|
// ));
|
|
|
|
// } else {
|
|
|
|
// return Selector<TableManagerModel, Area>(
|
|
|
|
// selector: (context, model) =>
|
|
|
|
// model.areas[index],
|
|
|
|
// builder: (context, area, _) {
|
|
|
|
// return AreaItemTable(area,
|
|
|
|
// tableManagerModel.currentArea,
|
|
|
|
// (area) async {
|
|
|
|
// isTap = true;
|
|
|
|
// setState(() {
|
|
|
|
// tableManagerModel.selectIndex =
|
|
|
|
// index;
|
|
|
|
// });
|
|
|
|
// await controller.scrollToIndex(
|
|
|
|
// index,
|
|
|
|
// preferPosition:
|
|
|
|
// AutoScrollPosition.begin);
|
|
|
|
// // scrollTo(index);
|
|
|
|
|
|
|
|
// tableManagerModel.currentArea =
|
|
|
|
// tableManagerModel
|
|
|
|
// .areas[index].name;
|
|
|
|
// tableManagerModel.currentTables =
|
|
|
|
// tableManagerModel.areaTableMap[
|
|
|
|
// tableManagerModel
|
|
|
|
// .currentArea];
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// itemExtent: ScreenUtil().setWidth(104 * 2),
|
|
|
|
// itemCount: tableManagerModel.areas.length + 1,
|
|
|
|
// ),
|
|
|
|
// );
|
|
|
|
// }),
|
|
|
|
// Expanded(
|
|
|
|
// child: Container(
|
|
|
|
// color: MyColours.color_f5f5f5,
|
|
|
|
// padding: EdgeInsets.symmetric(
|
|
|
|
// horizontal: ScreenUtil().setWidth(24)),
|
|
|
|
// width: double.infinity,
|
|
|
|
// child: list(tableManagerModel.areas)),
|
|
|
|
// ),
|
|
|
|
// ]),
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// ],
|
|
|
|
// );
|
|
|
|
// },
|
|
|
|
// );
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// void dispose() {
|
|
|
|
// // TODO: implement dispose
|
|
|
|
// super.dispose();
|
|
|
|
// EventBus().off("refresh_tablemanager");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// class _SaltedValueKey extends ValueKey<Key> {
|
|
|
|
// const _SaltedValueKey(Key key)
|
|
|
|
// : assert(key != null),
|
|
|
|
// super(key);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// class MyChildrenDelegate extends SliverChildBuilderDelegate {
|
|
|
|
// MyChildrenDelegate(
|
|
|
|
// Widget Function(BuildContext, int) builder, {
|
|
|
|
// int childCount,
|
|
|
|
// bool addAutomaticKeepAlive = true,
|
|
|
|
// bool addRepaintBoundaries = true,
|
|
|
|
// }) : super(builder,
|
|
|
|
// childCount: childCount,
|
|
|
|
// addAutomaticKeepAlives: addAutomaticKeepAlive,
|
|
|
|
// addRepaintBoundaries: addRepaintBoundaries);
|
|
|
|
// // Return a Widget for the given Exception
|
|
|
|
// Widget _createErrorWidget(dynamic exception, StackTrace stackTrace) {
|
|
|
|
// final FlutterErrorDetails details = FlutterErrorDetails(
|
|
|
|
// exception: exception,
|
|
|
|
// stack: stackTrace,
|
|
|
|
// library: 'widgets library',
|
|
|
|
// context: ErrorDescription('building'),
|
|
|
|
// );
|
|
|
|
// FlutterError.reportError(details);
|
|
|
|
// return ErrorWidget.builder(details);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// Widget build(BuildContext context, int index) {
|
|
|
|
// assert(builder != null);
|
|
|
|
// if (index < 0 || (childCount != null && index >= childCount)) return null;
|
|
|
|
// Widget child;
|
|
|
|
// try {
|
|
|
|
// child = builder(context, index);
|
|
|
|
// } catch (exception, stackTrace) {
|
|
|
|
// child = _createErrorWidget(exception, stackTrace);
|
|
|
|
// }
|
|
|
|
// if (child == null) return null;
|
|
|
|
// final Key key = child.key != null ? _SaltedValueKey(child.key) : null;
|
|
|
|
// if (addRepaintBoundaries) child = RepaintBoundary(child: child);
|
|
|
|
// if (addSemanticIndexes) {
|
|
|
|
// final int semanticIndex = semanticIndexCallback(child, index);
|
|
|
|
// if (semanticIndex != null)
|
|
|
|
// child = IndexedSemantics(
|
|
|
|
// index: semanticIndex + semanticIndexOffset, child: child);
|
|
|
|
// }
|
|
|
|
// if (addAutomaticKeepAlives) child = AutomaticKeepAlive(child: child);
|
|
|
|
// return KeyedSubtree(child: child, key: key);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @override
|
|
|
|
// void didFinishLayout(int firstIndex, int lastIndex) {
|
|
|
|
// // TODO: implement didFinishLayout
|
|
|
|
// super.didFinishLayout(firstIndex, lastIndex);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// ///监听 在可见的列表中 显示的第一个位置和最后一个位置
|
|
|
|
// @override
|
|
|
|
// double estimateMaxScrollOffset(int firstIndex, int lastIndex,
|
|
|
|
// double leadingScrollOffset, double trailingScrollOffset) {
|
|
|
|
// print(
|
|
|
|
// 'firstIndex sss : $firstIndex, lastIndex ssss : $lastIndex, leadingScrollOffset ssss : $leadingScrollOffset,'
|
|
|
|
// 'trailingScrollOffset ssss : $trailingScrollOffset ');
|
|
|
|
// return super.estimateMaxScrollOffset(
|
|
|
|
// firstIndex, lastIndex, leadingScrollOffset, trailingScrollOffset);
|
|
|
|
// }
|
|
|
|
// } |
...
|
...
|
|