Showing
9 changed files
with
1415 additions
and
273 deletions
| @@ -11,14 +11,14 @@ if (flutterRoot == null) { | @@ -11,14 +11,14 @@ if (flutterRoot == null) { | ||
| 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | -def flutterVersionCode = "232" | 14 | +def flutterVersionCode = "250" |
| 15 | if (flutterVersionCode == null) { | 15 | if (flutterVersionCode == null) { |
| 16 | - flutterVersionCode = '232' | 16 | + flutterVersionCode = '250' |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | -def flutterVersionName = "2.3.2" | 19 | +def flutterVersionName = "2.5.0" |
| 20 | if (flutterVersionName == null) { | 20 | if (flutterVersionName == null) { |
| 21 | - flutterVersionName = '2.3.2' | 21 | + flutterVersionName = '2.5.0' |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | apply plugin: 'com.android.application' | 24 | apply plugin: 'com.android.application' |
| @@ -452,7 +452,7 @@ | @@ -452,7 +452,7 @@ | ||
| 452 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | 452 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
| 453 | GCC_WARN_UNUSED_FUNCTION = YES; | 453 | GCC_WARN_UNUSED_FUNCTION = YES; |
| 454 | GCC_WARN_UNUSED_VARIABLE = YES; | 454 | GCC_WARN_UNUSED_VARIABLE = YES; |
| 455 | - IPHONEOS_DEPLOYMENT_TARGET = 8.0; | 455 | + IPHONEOS_DEPLOYMENT_TARGET = 12.1; |
| 456 | MTL_ENABLE_DEBUG_INFO = NO; | 456 | MTL_ENABLE_DEBUG_INFO = NO; |
| 457 | PROVISIONING_PROFILE_SPECIFIER = "Push Development Profile"; | 457 | PROVISIONING_PROFILE_SPECIFIER = "Push Development Profile"; |
| 458 | SDKROOT = iphoneos; | 458 | SDKROOT = iphoneos; |
| @@ -487,7 +487,7 @@ | @@ -487,7 +487,7 @@ | ||
| 487 | "$(inherited)", | 487 | "$(inherited)", |
| 488 | "$(PROJECT_DIR)/Flutter", | 488 | "$(PROJECT_DIR)/Flutter", |
| 489 | ); | 489 | ); |
| 490 | - MARKETING_VERSION = 2.3.2; | 490 | + MARKETING_VERSION = 2.5.0; |
| 491 | PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; | 491 | PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; |
| 492 | PRODUCT_NAME = Runner; | 492 | PRODUCT_NAME = Runner; |
| 493 | PROVISIONING_PROFILE_SPECIFIER = ""; | 493 | PROVISIONING_PROFILE_SPECIFIER = ""; |
| @@ -545,7 +545,7 @@ | @@ -545,7 +545,7 @@ | ||
| 545 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | 545 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
| 546 | GCC_WARN_UNUSED_FUNCTION = YES; | 546 | GCC_WARN_UNUSED_FUNCTION = YES; |
| 547 | GCC_WARN_UNUSED_VARIABLE = YES; | 547 | GCC_WARN_UNUSED_VARIABLE = YES; |
| 548 | - IPHONEOS_DEPLOYMENT_TARGET = 8.0; | 548 | + IPHONEOS_DEPLOYMENT_TARGET = 12.1; |
| 549 | MTL_ENABLE_DEBUG_INFO = YES; | 549 | MTL_ENABLE_DEBUG_INFO = YES; |
| 550 | ONLY_ACTIVE_ARCH = YES; | 550 | ONLY_ACTIVE_ARCH = YES; |
| 551 | PROVISIONING_PROFILE_SPECIFIER = "Push Development Profile"; | 551 | PROVISIONING_PROFILE_SPECIFIER = "Push Development Profile"; |
| @@ -596,7 +596,7 @@ | @@ -596,7 +596,7 @@ | ||
| 596 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | 596 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
| 597 | GCC_WARN_UNUSED_FUNCTION = YES; | 597 | GCC_WARN_UNUSED_FUNCTION = YES; |
| 598 | GCC_WARN_UNUSED_VARIABLE = YES; | 598 | GCC_WARN_UNUSED_VARIABLE = YES; |
| 599 | - IPHONEOS_DEPLOYMENT_TARGET = 8.0; | 599 | + IPHONEOS_DEPLOYMENT_TARGET = 12.1; |
| 600 | MTL_ENABLE_DEBUG_INFO = NO; | 600 | MTL_ENABLE_DEBUG_INFO = NO; |
| 601 | PROVISIONING_PROFILE_SPECIFIER = "Push Development Profile"; | 601 | PROVISIONING_PROFILE_SPECIFIER = "Push Development Profile"; |
| 602 | SDKROOT = iphoneos; | 602 | SDKROOT = iphoneos; |
| @@ -631,7 +631,7 @@ | @@ -631,7 +631,7 @@ | ||
| 631 | "$(inherited)", | 631 | "$(inherited)", |
| 632 | "$(PROJECT_DIR)/Flutter", | 632 | "$(PROJECT_DIR)/Flutter", |
| 633 | ); | 633 | ); |
| 634 | - MARKETING_VERSION = 2.3.2; | 634 | + MARKETING_VERSION = 2.5.0; |
| 635 | PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; | 635 | PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; |
| 636 | PRODUCT_NAME = Runner; | 636 | PRODUCT_NAME = Runner; |
| 637 | PROVISIONING_PROFILE_SPECIFIER = ""; | 637 | PROVISIONING_PROFILE_SPECIFIER = ""; |
| @@ -666,7 +666,7 @@ | @@ -666,7 +666,7 @@ | ||
| 666 | "$(inherited)", | 666 | "$(inherited)", |
| 667 | "$(PROJECT_DIR)/Flutter", | 667 | "$(PROJECT_DIR)/Flutter", |
| 668 | ); | 668 | ); |
| 669 | - MARKETING_VERSION = 2.3.2; | 669 | + MARKETING_VERSION = 2.5.0; |
| 670 | PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; | 670 | PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine; |
| 671 | PRODUCT_NAME = Runner; | 671 | PRODUCT_NAME = Runner; |
| 672 | PROVISIONING_PROFILE_SPECIFIER = ""; | 672 | PROVISIONING_PROFILE_SPECIFIER = ""; |
| @@ -24,75 +24,76 @@ class AreaItemTableState extends State<AreaItemTable> { | @@ -24,75 +24,76 @@ class AreaItemTableState extends State<AreaItemTable> { | ||
| 24 | // TODO: implement build | 24 | // TODO: implement build |
| 25 | Area area = widget.area; | 25 | Area area = widget.area; |
| 26 | bool isSelected = area.name == widget.currentArea; | 26 | bool isSelected = area.name == widget.currentArea; |
| 27 | - return GestureDetector( | ||
| 28 | - onTap: () { | ||
| 29 | - if (widget.selectCallback != null) { | ||
| 30 | - widget.selectCallback(widget.area); | ||
| 31 | - } | ||
| 32 | - }, | ||
| 33 | - child: Stack( | ||
| 34 | - overflow: Overflow.visible, | ||
| 35 | - alignment: Alignment.topLeft, | ||
| 36 | - children: <Widget>[ | ||
| 37 | - Container( | ||
| 38 | - width: ScreenUtil().setWidth(104 * 2), | ||
| 39 | - height: ScreenUtil().setWidth(80), | ||
| 40 | - margin: EdgeInsets.only( | ||
| 41 | - right: ScreenUtil().setWidth(20), | ||
| 42 | - top: ScreenUtil().setWidth(20), | ||
| 43 | - ), | ||
| 44 | - padding: EdgeInsets.symmetric( | ||
| 45 | - horizontal: ScreenUtil().setWidth(20), | ||
| 46 | - vertical: ScreenUtil().setWidth(10)), | ||
| 47 | - alignment: Alignment.center, | ||
| 48 | - decoration: BoxDecoration( | ||
| 49 | - borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), | 27 | + return |
| 28 | + // GestureDetector( | ||
| 29 | + | ||
| 30 | + // onTap: () { | ||
| 31 | + // if (widget.selectCallback != null) { | ||
| 32 | + // widget.selectCallback(widget.area); | ||
| 33 | + // } | ||
| 34 | + // }, | ||
| 35 | + // child: | ||
| 36 | + Stack( | ||
| 37 | + overflow: Overflow.visible, | ||
| 38 | + alignment: Alignment.topLeft, | ||
| 39 | + children: <Widget>[ | ||
| 40 | + Container( | ||
| 41 | + width: ScreenUtil().setWidth(104 * 2), | ||
| 42 | + height: ScreenUtil().setWidth(80), | ||
| 43 | + margin: EdgeInsets.only( | ||
| 44 | + right: ScreenUtil().setWidth(20), | ||
| 45 | + top: ScreenUtil().setWidth(20), | ||
| 46 | + ), | ||
| 47 | + padding: EdgeInsets.symmetric( | ||
| 48 | + horizontal: ScreenUtil().setWidth(20), | ||
| 49 | + vertical: ScreenUtil().setWidth(10)), | ||
| 50 | + alignment: Alignment.center, | ||
| 51 | + decoration: BoxDecoration( | ||
| 52 | + borderRadius: BorderRadius.circular(ScreenUtil().setWidth(10)), | ||
| 53 | + color: | ||
| 54 | + isSelected ? MyColours.color_199095 : MyColours.color_ffffff, | ||
| 55 | + border: Border.all( | ||
| 56 | + color: MyColours.color_199095, | ||
| 57 | + width: ScreenUtil().setWidth(2))), | ||
| 58 | + child: Text( | ||
| 59 | + area.name, | ||
| 60 | + overflow: TextOverflow.ellipsis, | ||
| 61 | + style: TextStyle( | ||
| 50 | color: isSelected | 62 | color: isSelected |
| 51 | - ? MyColours.color_199095 | ||
| 52 | - : MyColours.color_ffffff, | ||
| 53 | - border: Border.all( | ||
| 54 | - color: MyColours.color_199095, | ||
| 55 | - width: ScreenUtil().setWidth(2))), | ||
| 56 | - child: Text( | ||
| 57 | - area.name, | ||
| 58 | - style: TextStyle( | ||
| 59 | - color: isSelected | ||
| 60 | - ? MyColours.color_ffffff | ||
| 61 | - : MyColours.color_199095, | ||
| 62 | - fontSize: ScreenUtil().setSp(28), | ||
| 63 | - decoration: TextDecoration.none, | ||
| 64 | - fontWeight: FontWeight.normal), | ||
| 65 | - ), | 63 | + ? MyColours.color_ffffff |
| 64 | + : MyColours.color_199095, | ||
| 65 | + fontSize: ScreenUtil().setSp(28), | ||
| 66 | + decoration: TextDecoration.none, | ||
| 67 | + fontWeight: FontWeight.normal), | ||
| 66 | ), | 68 | ), |
| 67 | - area.count == -1 | ||
| 68 | - ? Container() | ||
| 69 | - : Positioned( | ||
| 70 | - left: 0, | ||
| 71 | - top: 0, | ||
| 72 | - child: Container( | ||
| 73 | - width: ScreenUtil().setWidth(78), | ||
| 74 | - height: ScreenUtil().setWidth(30), | ||
| 75 | - alignment: Alignment.center, | ||
| 76 | - decoration: BoxDecoration( | ||
| 77 | - color: area.count <= 0 | ||
| 78 | - ? MyColours.color_999999 | ||
| 79 | - : MyColours.color_63a6d1, | ||
| 80 | - borderRadius: BorderRadius.only( | ||
| 81 | - topLeft: Radius.circular(ScreenUtil().setWidth(10)), | ||
| 82 | - topRight: | ||
| 83 | - Radius.circular(ScreenUtil().setWidth(15)), | ||
| 84 | - bottomRight: | ||
| 85 | - Radius.circular(ScreenUtil().setWidth(15)))), | ||
| 86 | - child: Text(area.count == 0 ? "满座" : "余${area.count}", | ||
| 87 | - style: TextStyle( | ||
| 88 | - color: MyColours.color_ffffff, | ||
| 89 | - fontSize: ScreenUtil().setSp(26), | ||
| 90 | - decoration: TextDecoration.none, | ||
| 91 | - fontWeight: FontWeight.normal)), | ||
| 92 | - ), | 69 | + ), |
| 70 | + area.count == -1 | ||
| 71 | + ? Container() | ||
| 72 | + : Positioned( | ||
| 73 | + left: 0, | ||
| 74 | + top: 0, | ||
| 75 | + child: Container( | ||
| 76 | + width: ScreenUtil().setWidth(78), | ||
| 77 | + height: ScreenUtil().setWidth(30), | ||
| 78 | + alignment: Alignment.center, | ||
| 79 | + decoration: BoxDecoration( | ||
| 80 | + color: area.count <= 0 | ||
| 81 | + ? MyColours.color_999999 | ||
| 82 | + : MyColours.color_63a6d1, | ||
| 83 | + borderRadius: BorderRadius.only( | ||
| 84 | + topLeft: Radius.circular(ScreenUtil().setWidth(10)), | ||
| 85 | + topRight: Radius.circular(ScreenUtil().setWidth(15)), | ||
| 86 | + bottomRight: | ||
| 87 | + Radius.circular(ScreenUtil().setWidth(15)))), | ||
| 88 | + child: Text(area.count == 0 ? "满座" : "余${area.count}", | ||
| 89 | + style: TextStyle( | ||
| 90 | + color: MyColours.color_ffffff, | ||
| 91 | + fontSize: ScreenUtil().setSp(26), | ||
| 92 | + decoration: TextDecoration.none, | ||
| 93 | + fontWeight: FontWeight.normal)), | ||
| 93 | ), | 94 | ), |
| 94 | - ], | ||
| 95 | - ), | 95 | + ), |
| 96 | + ], | ||
| 96 | ); | 97 | ); |
| 97 | } | 98 | } |
| 98 | } | 99 | } |
lib/pages/table/cc_menu_wdn.dart
0 → 100644
| 1 | +import 'dart:async'; | ||
| 2 | +import 'dart:ui'; | ||
| 3 | +import 'package:flutter/cupertino.dart'; | ||
| 4 | +import 'package:flutter/material.dart'; | ||
| 5 | +import 'package:flutter_easyrefresh/easy_refresh.dart'; | ||
| 6 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 7 | +import 'package:one_key/provider/table_manager_model.dart'; | ||
| 8 | +import 'package:one_key/res/colors.dart'; | ||
| 9 | +import 'package:one_key/utils/dialog_util.dart'; | ||
| 10 | +import 'package:one_key/utils/utils.dart'; | ||
| 11 | +import 'package:scroll_to_index/scroll_to_index.dart'; | ||
| 12 | + | ||
| 13 | +class CCMenuPage extends StatefulWidget { | ||
| 14 | + ///默认源数据数组 | ||
| 15 | + final List<String> menuList; | ||
| 16 | + | ||
| 17 | + ///头部 | ||
| 18 | + final Widget headerWidget; | ||
| 19 | + | ||
| 20 | + ///底部 | ||
| 21 | + final Widget bottomWidget; | ||
| 22 | + | ||
| 23 | + ///滚动页面列表样式 | ||
| 24 | + final IndexedWidgetBuilder itemBuilder; | ||
| 25 | + | ||
| 26 | + ///默认选中 | ||
| 27 | + final int selectIndex; | ||
| 28 | + | ||
| 29 | + ///点击顶部菜单回调 | ||
| 30 | + final ValueChanged<int> onTap; | ||
| 31 | + | ||
| 32 | + ///下拉刷新事件 | ||
| 33 | + final onRefresh; | ||
| 34 | + | ||
| 35 | + ///顶部菜单样式 | ||
| 36 | + final IndexedWidgetBuilder tabBuilder; | ||
| 37 | + | ||
| 38 | + ///菜单个数 | ||
| 39 | + final int itemCount; | ||
| 40 | + | ||
| 41 | + ///设置选中时的字体选中样式 | ||
| 42 | + final TextStyle labelStyle; | ||
| 43 | + | ||
| 44 | + ///设置未选中字体样式 | ||
| 45 | + final TextStyle unselectedLabelStyle; | ||
| 46 | + | ||
| 47 | + ///设置未选中字体颜色 | ||
| 48 | + final Color unselectedLabelColor; | ||
| 49 | + | ||
| 50 | + ///设置选中字体颜色 | ||
| 51 | + final Color labelColor; | ||
| 52 | + | ||
| 53 | + ///选中下划线的颜色 | ||
| 54 | + final Color indicatorColor; | ||
| 55 | + | ||
| 56 | + ///选中下划线的长度 | ||
| 57 | + final TabBarIndicatorSize indicatorSize; | ||
| 58 | + | ||
| 59 | + ///选中下划线的高度 | ||
| 60 | + final double indicatorWeight; | ||
| 61 | + final EdgeInsetsGeometry indicatorPadding; | ||
| 62 | + final TableManagerModel tableManagerModel; | ||
| 63 | + | ||
| 64 | + ///是否滚动 默认true | ||
| 65 | + final bool isScrollable; | ||
| 66 | + | ||
| 67 | + /// 菜单栏高度 | ||
| 68 | + final double tabHeight; | ||
| 69 | + | ||
| 70 | + /// 空数据样式 | ||
| 71 | + final Widget refreshEmptyWidget; | ||
| 72 | + | ||
| 73 | + ///下拉刷新header样式 | ||
| 74 | + final Header refreshHeaderWidget; | ||
| 75 | + | ||
| 76 | + CCMenuPage( | ||
| 77 | + {@required this.menuList, | ||
| 78 | + @required this.itemBuilder, | ||
| 79 | + this.headerWidget, | ||
| 80 | + this.bottomWidget, | ||
| 81 | + this.selectIndex = 0, | ||
| 82 | + this.onTap, | ||
| 83 | + this.onRefresh, | ||
| 84 | + this.refreshEmptyWidget, | ||
| 85 | + this.refreshHeaderWidget, | ||
| 86 | + Key key, | ||
| 87 | + this.tableManagerModel}) | ||
| 88 | + : this.tabBuilder = null, | ||
| 89 | + this.itemCount = null, | ||
| 90 | + this.labelStyle = null, | ||
| 91 | + this.unselectedLabelStyle = null, | ||
| 92 | + this.unselectedLabelColor = null, | ||
| 93 | + this.labelColor = null, | ||
| 94 | + this.indicatorColor = null, | ||
| 95 | + this.indicatorSize = null, | ||
| 96 | + this.indicatorWeight = null, | ||
| 97 | + this.indicatorPadding = null, | ||
| 98 | + this.isScrollable = null, | ||
| 99 | + this.tabHeight = null, | ||
| 100 | + super(key: key); | ||
| 101 | + | ||
| 102 | + CCMenuPage.builder({ | ||
| 103 | + Key key, | ||
| 104 | + @required this.tabBuilder, | ||
| 105 | + @required this.itemCount, | ||
| 106 | + @required this.itemBuilder, | ||
| 107 | + this.headerWidget, | ||
| 108 | + this.bottomWidget, | ||
| 109 | + this.selectIndex = 0, | ||
| 110 | + this.onTap, | ||
| 111 | + this.onRefresh, | ||
| 112 | + this.refreshEmptyWidget, | ||
| 113 | + this.refreshHeaderWidget, | ||
| 114 | + this.tableManagerModel, | ||
| 115 | + }) : this.labelStyle = null, | ||
| 116 | + this.unselectedLabelStyle = null, | ||
| 117 | + this.unselectedLabelColor = null, | ||
| 118 | + this.labelColor = null, | ||
| 119 | + this.indicatorColor = null, | ||
| 120 | + this.indicatorSize = null, | ||
| 121 | + this.indicatorWeight = null, | ||
| 122 | + this.indicatorPadding = null, | ||
| 123 | + this.isScrollable = null, | ||
| 124 | + this.menuList = null, | ||
| 125 | + this.tabHeight = null, | ||
| 126 | + super(key: key); | ||
| 127 | + | ||
| 128 | + @override | ||
| 129 | + CCMenuPageState createState() => CCMenuPageState(); | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +class CCMenuPageState extends State<CCMenuPage> with TickerProviderStateMixin { | ||
| 133 | + List _keyList = []; | ||
| 134 | + List _offsetList = []; | ||
| 135 | + ScrollController _scrollController; | ||
| 136 | + bool _isScrollView = false; | ||
| 137 | + final GlobalKey headerGlobalKey = GlobalKey(); | ||
| 138 | + double _headerHeight = 0; | ||
| 139 | + int _selectNumber = 0; | ||
| 140 | + int _itemCount = 0; | ||
| 141 | + double _tabHeight = 0; | ||
| 142 | + EasyRefreshController _easyRefreshController; | ||
| 143 | + // ScrollController _areaController = ScrollController(); | ||
| 144 | + AutoScrollController controller; | ||
| 145 | + | ||
| 146 | + @override | ||
| 147 | + void initState() { | ||
| 148 | + // TODO: implement initState | ||
| 149 | + super.initState(); | ||
| 150 | + initData(); | ||
| 151 | + controller = AutoScrollController( | ||
| 152 | + viewportBoundaryGetter: () => | ||
| 153 | + Rect.fromLTRB(0, 0, 0, MediaQuery.of(context).padding.bottom), | ||
| 154 | + axis: Axis.horizontal); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + @override | ||
| 158 | + void dispose() { | ||
| 159 | + super.dispose(); | ||
| 160 | + _easyRefreshController?.dispose(); | ||
| 161 | + _scrollController?.dispose(); | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + initData() { | ||
| 165 | + _getItemHeight(); | ||
| 166 | + _selectNumber = widget.selectIndex; | ||
| 167 | + _itemCount = _getItemCount(); | ||
| 168 | + // _getMenuList(); | ||
| 169 | + _keyList = List.generate(_itemCount, (index) => GlobalKey()); | ||
| 170 | + | ||
| 171 | + _scrollController = new ScrollController(); | ||
| 172 | + _scrollController.addListener(() { | ||
| 173 | + var of = _scrollController.offset; | ||
| 174 | + if (of == _scrollController.position.maxScrollExtent) { | ||
| 175 | + _isScrollView = false; | ||
| 176 | + } else { | ||
| 177 | + if (_isScrollView == true) { | ||
| 178 | + return; | ||
| 179 | + } | ||
| 180 | + var oneOffset = _offsetList[0]; | ||
| 181 | + bool isOffset = false; | ||
| 182 | + for (int i = _offsetList.length - 1; i > 0; i--) { | ||
| 183 | + var nowOffset = _offsetList[i]; | ||
| 184 | + if (of > (nowOffset - oneOffset)) { | ||
| 185 | + isOffset = true; | ||
| 186 | + | ||
| 187 | + // _tabController.animateTo(i); | ||
| 188 | + // _areaController.animateTo(i * ScreenUtil().setWidth(104 * 2), | ||
| 189 | + // duration: new Duration(milliseconds: 500), curve: Curves.ease); | ||
| 190 | + _scrollToIndex(i); | ||
| 191 | + widget.tableManagerModel.currentArea = | ||
| 192 | + widget.tableManagerModel.areas[i].name; | ||
| 193 | + widget.tableManagerModel.currentTables = widget.tableManagerModel | ||
| 194 | + .areaTableMap[widget.tableManagerModel.currentArea]; | ||
| 195 | + | ||
| 196 | + setState(() {}); | ||
| 197 | + break; | ||
| 198 | + } | ||
| 199 | + } | ||
| 200 | + if (isOffset == false) { | ||
| 201 | + _scrollToIndex(0); | ||
| 202 | + // _areaController.animateTo(0 * ScreenUtil().setWidth(104 * 2), | ||
| 203 | + // duration: new Duration(milliseconds: 500), curve: Curves.ease); | ||
| 204 | + widget.tableManagerModel.currentArea = | ||
| 205 | + widget.tableManagerModel.areas[0].name; | ||
| 206 | + widget.tableManagerModel.currentTables = widget.tableManagerModel | ||
| 207 | + .areaTableMap[widget.tableManagerModel.currentArea]; | ||
| 208 | + setState(() {}); | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + }); | ||
| 212 | + WidgetsBinding.instance.addPostFrameCallback((callback) { | ||
| 213 | + _subInitState(); | ||
| 214 | + _anmationMenu(); | ||
| 215 | + }); | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + updateMenu() { | ||
| 219 | + _itemCount = _getItemCount(); | ||
| 220 | + _keyList = List.generate(_itemCount, (index) => GlobalKey()); | ||
| 221 | + setState(() {}); | ||
| 222 | + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { | ||
| 223 | + _subInitState(); | ||
| 224 | + _anmationMenu(); | ||
| 225 | + }); | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + @override | ||
| 229 | + Widget build(BuildContext context) { | ||
| 230 | + // TODO: implement build | ||
| 231 | + return Column( | ||
| 232 | + children: [ | ||
| 233 | + Container( | ||
| 234 | + width: double.infinity, | ||
| 235 | + child: _tabBarWidget(), | ||
| 236 | + ), | ||
| 237 | + Expanded( | ||
| 238 | + child: Container( | ||
| 239 | + height: MediaQuery.of(context).size.height - | ||
| 240 | + _headerHeight - | ||
| 241 | + MediaQueryData.fromWindow(window).padding.top, | ||
| 242 | + child: SingleChildScrollView( | ||
| 243 | + controller: _scrollController, | ||
| 244 | + child: Column( | ||
| 245 | + children: [ | ||
| 246 | + _getListWidget(), | ||
| 247 | + ], | ||
| 248 | + ), | ||
| 249 | + ), | ||
| 250 | + )) | ||
| 251 | + ], | ||
| 252 | + ); | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + Future _scrollToIndex(int index) async { | ||
| 256 | + await controller.scrollToIndex(index, | ||
| 257 | + preferPosition: AutoScrollPosition.begin); | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + Widget _getRow(int index, Widget widget) { | ||
| 261 | + return _wrapScrollTag( | ||
| 262 | + index: index, | ||
| 263 | + child: widget, | ||
| 264 | + ); | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + Widget _wrapScrollTag({int index, Widget child}) => AutoScrollTag( | ||
| 268 | + key: ValueKey(index), | ||
| 269 | + controller: controller, | ||
| 270 | + index: index, | ||
| 271 | + child: child, | ||
| 272 | + highlightColor: Colors.transparent, | ||
| 273 | + ); | ||
| 274 | + | ||
| 275 | + Widget _tabBarWidget() { | ||
| 276 | + return Container( | ||
| 277 | + height: ScreenUtil().setWidth(80), | ||
| 278 | + color: MyColours.color_ffffff, | ||
| 279 | + margin: EdgeInsets.only(bottom: ScreenUtil().setWidth(20)), | ||
| 280 | + child: ListView.builder( | ||
| 281 | + itemCount: widget.tableManagerModel.areas.length + 1, | ||
| 282 | + padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40)), | ||
| 283 | + controller: controller, | ||
| 284 | + scrollDirection: Axis.horizontal, | ||
| 285 | + cacheExtent: ScreenUtil().setWidth(104 * 2), | ||
| 286 | + itemBuilder: (BuildContext context, int index) { | ||
| 287 | + return InkWell( | ||
| 288 | + onTap: () async { | ||
| 289 | + if (index == widget.tableManagerModel.areas.length || | ||
| 290 | + widget.tableManagerModel.areas.length == 0) { | ||
| 291 | + // widget.onTap(index); | ||
| 292 | + //添加区域弹框 | ||
| 293 | + await DialogUtil.openCreateAreaDialog(context, | ||
| 294 | + onTap: (value) async { | ||
| 295 | + print(value); | ||
| 296 | + //添加区域 | ||
| 297 | + bool success = await widget.tableManagerModel | ||
| 298 | + .addTableAreas(context, value); | ||
| 299 | + print(success); | ||
| 300 | + if (success) { | ||
| 301 | + Utils.showToast('添加成功!'); | ||
| 302 | + | ||
| 303 | + await widget.tableManagerModel | ||
| 304 | + .getTableList(context, needLoading: false); | ||
| 305 | + widget.tableManagerModel.initData(); | ||
| 306 | + | ||
| 307 | + setState(() { | ||
| 308 | + updateMenu(); | ||
| 309 | + }); | ||
| 310 | + _scrollToIndex(widget.tableManagerModel.areas.length); | ||
| 311 | + | ||
| 312 | + // Timer( | ||
| 313 | + // Duration(milliseconds: 500), | ||
| 314 | + // () => _areaController.jumpTo( | ||
| 315 | + // _areaController.position.maxScrollExtent)); | ||
| 316 | + } | ||
| 317 | + }); | ||
| 318 | + } else { | ||
| 319 | + setState(() { | ||
| 320 | + _selectNumber = index; | ||
| 321 | + widget.tableManagerModel.currentArea = | ||
| 322 | + widget.tableManagerModel.areas[index].name; | ||
| 323 | + widget.tableManagerModel.currentTables = widget | ||
| 324 | + .tableManagerModel | ||
| 325 | + .areaTableMap[widget.tableManagerModel.currentArea]; | ||
| 326 | + _anmationMenu(); | ||
| 327 | + }); | ||
| 328 | + if (widget.onTap != null) { | ||
| 329 | + widget.onTap(index); | ||
| 330 | + } | ||
| 331 | + } | ||
| 332 | + }, | ||
| 333 | + child: _getRow( | ||
| 334 | + index, | ||
| 335 | + Container( | ||
| 336 | + child: widget.tabBuilder(context, index), | ||
| 337 | + ))); | ||
| 338 | + }, | ||
| 339 | + )); | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + Widget _getListWidget() { | ||
| 343 | + if (_itemCount == 0) { | ||
| 344 | + return SizedBox(); | ||
| 345 | + } | ||
| 346 | + return ListView.builder( | ||
| 347 | + shrinkWrap: true, | ||
| 348 | + physics: new NeverScrollableScrollPhysics(), | ||
| 349 | + itemCount: widget.tableManagerModel.areas.length, | ||
| 350 | + padding: EdgeInsets.zero, | ||
| 351 | + itemBuilder: (BuildContext context, int index) { | ||
| 352 | + GlobalKey itemKey = _keyList[index]; | ||
| 353 | + return Container( | ||
| 354 | + key: itemKey, child: widget.itemBuilder(context, index)); | ||
| 355 | + }, | ||
| 356 | + ); | ||
| 357 | + } | ||
| 358 | + | ||
| 359 | + _subInitState() { | ||
| 360 | + _offsetList = []; | ||
| 361 | + for (int i = 0; i < _keyList.length; i++) { | ||
| 362 | + var globalKey = _keyList[i]; | ||
| 363 | + var offsetY = getY(globalKey.currentContext); | ||
| 364 | + _offsetList.add(offsetY); | ||
| 365 | + } | ||
| 366 | + } | ||
| 367 | + | ||
| 368 | + double getY(BuildContext buildContext) { | ||
| 369 | + if (buildContext == null) { | ||
| 370 | + return 0; | ||
| 371 | + } | ||
| 372 | + final RenderBox box = buildContext.findRenderObject(); | ||
| 373 | + final topLeftPosition = box.localToGlobal(Offset.zero); | ||
| 374 | + return topLeftPosition.dy; | ||
| 375 | + } | ||
| 376 | + | ||
| 377 | + int _getItemCount() { | ||
| 378 | + return widget.tableManagerModel.areas.length; | ||
| 379 | + } | ||
| 380 | + | ||
| 381 | + _getItemHeight() { | ||
| 382 | + if (widget.tabBuilder == null && widget.itemCount == null) { | ||
| 383 | + if (widget.tabHeight != null) { | ||
| 384 | + _tabHeight = widget.tabHeight; | ||
| 385 | + } else { | ||
| 386 | + _tabHeight = 30; | ||
| 387 | + } | ||
| 388 | + } else { | ||
| 389 | + _tabHeight = null; | ||
| 390 | + } | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + _anmationMenu() { | ||
| 394 | + if (_selectNumber == 0) { | ||
| 395 | + _isScrollView = false; | ||
| 396 | + _scrollToIndex(_selectNumber); | ||
| 397 | + // _areaController.animateTo(_selectNumber * ScreenUtil().setWidth(104 * 2), | ||
| 398 | + // duration: new Duration(milliseconds: 500), curve: Curves.ease); | ||
| 399 | + // _tabController.animateTo(_selectNumber); | ||
| 400 | + _scrollController.jumpTo(0); | ||
| 401 | + } else { | ||
| 402 | + _isScrollView = false; | ||
| 403 | + // _tabController.animateTo(_selectNumber); | ||
| 404 | + _scrollToIndex(_selectNumber); | ||
| 405 | + // _areaController.animateTo(_selectNumber * ScreenUtil().setWidth(104 * 2), | ||
| 406 | + // duration: new Duration(milliseconds: 500), curve: Curves.ease); | ||
| 407 | + var oneOffset = _offsetList[0]; | ||
| 408 | + var nowOffset = _offsetList[_selectNumber] - oneOffset + _headerHeight; | ||
| 409 | + if (nowOffset <= _scrollController.position.maxScrollExtent) { | ||
| 410 | + _scrollController | ||
| 411 | + .jumpTo(_offsetList[_selectNumber] - _offsetList[0] + 2); | ||
| 412 | + } else { | ||
| 413 | + //滚动到底部 | ||
| 414 | + _isScrollView = true; | ||
| 415 | + if (_scrollController.offset == | ||
| 416 | + _scrollController.position.maxScrollExtent) { | ||
| 417 | + //如果已经滚动到底部 不会走滚动监听回调 | ||
| 418 | + _isScrollView = false; | ||
| 419 | + } else { | ||
| 420 | + _scrollController.jumpTo(_scrollController.position.maxScrollExtent); | ||
| 421 | + } | ||
| 422 | + } | ||
| 423 | + } | ||
| 424 | + } | ||
| 425 | +} |
lib/pages/table/new.dart
0 → 100644
| 1 | +// import 'dart:async'; | ||
| 2 | + | ||
| 3 | +// import 'package:common_utils/common_utils.dart'; | ||
| 4 | +// import 'package:dotted_border/dotted_border.dart'; | ||
| 5 | +// import 'package:flutter/material.dart'; | ||
| 6 | +// import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 7 | +// import 'package:one_key/constant/state.dart'; | ||
| 8 | +// import 'package:one_key/models/area.dart'; | ||
| 9 | +// import 'package:one_key/models/notebook_detail.dart'; | ||
| 10 | +// import 'package:one_key/models/tableOuter.dart'; | ||
| 11 | +// import 'package:one_key/pages/table/area_item_table.dart'; | ||
| 12 | +// import 'package:one_key/provider/table_manager_model.dart'; | ||
| 13 | +// import 'package:one_key/res/colors.dart'; | ||
| 14 | +// import 'package:one_key/utils/dialog_util.dart'; | ||
| 15 | +// import 'package:one_key/utils/event_bus.dart'; | ||
| 16 | +// import 'package:one_key/route/navigator_util.dart'; | ||
| 17 | +// import 'package:one_key/utils/utils.dart'; | ||
| 18 | +// import 'package:one_key/widgets/MyDivider.dart'; | ||
| 19 | +// import 'package:one_key/widgets/app_bar.dart'; | ||
| 20 | +// import 'package:one_key/widgets/area_item.dart'; | ||
| 21 | +// import 'package:one_key/widgets/common_button.dart'; | ||
| 22 | +// import 'package:one_key/widgets/page_exception.dart'; | ||
| 23 | +// import 'package:one_key/widgets/system_app_bar.dart'; | ||
| 24 | +// import 'package:one_key/widgets/table_item.dart'; | ||
| 25 | +// import 'package:one_key/models/table.dart' as t; | ||
| 26 | +// import 'package:one_key/widgets/v_empty_view.dart'; | ||
| 27 | +// import 'package:provider/provider.dart'; | ||
| 28 | +// import 'dart:convert' as convert; | ||
| 29 | +// import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; | ||
| 30 | +// import 'package:scroll_to_index/scroll_to_index.dart'; | ||
| 31 | + | ||
| 32 | +// const scrollDuration = Duration(microseconds: 500); | ||
| 33 | + | ||
| 34 | +// class TableManagerPage extends StatefulWidget { | ||
| 35 | +// @override | ||
| 36 | +// State<StatefulWidget> createState() { | ||
| 37 | +// // TODO: implement createState | ||
| 38 | +// return new TableManagerPageState(); | ||
| 39 | +// } | ||
| 40 | +// } | ||
| 41 | + | ||
| 42 | +// class TableManagerPageState extends State<TableManagerPage> { | ||
| 43 | +// TableManagerModel tableManagerModel; | ||
| 44 | +// final ItemScrollController itemScrollController = ItemScrollController(); | ||
| 45 | +// bool isTap = false; | ||
| 46 | +// // 进度监听对象 | ||
| 47 | +// int min; | ||
| 48 | +// int max; | ||
| 49 | + | ||
| 50 | +// ScrollController _areaController = ScrollController(); | ||
| 51 | +// AutoScrollController controller; | ||
| 52 | +// List<String> personNumList = []; | ||
| 53 | + | ||
| 54 | +// final ItemPositionsListener itemPositionsListener = | ||
| 55 | +// ItemPositionsListener.create(); | ||
| 56 | + | ||
| 57 | +// @override | ||
| 58 | +// void initState() { | ||
| 59 | +// // TODO: implement initState | ||
| 60 | +// super.initState(); | ||
| 61 | +// LogUtil.v("table_manager_page initState"); | ||
| 62 | +// for (int i = 1; i < 31; i++) { | ||
| 63 | +// personNumList.add(i.toString()); | ||
| 64 | +// } | ||
| 65 | +// controller = AutoScrollController( | ||
| 66 | +// viewportBoundaryGetter: () => | ||
| 67 | +// Rect.fromLTRB(0, 0, 0, MediaQuery.of(context).padding.bottom), | ||
| 68 | +// axis: Axis.vertical); | ||
| 69 | +// // personNumList.add('30以上'); | ||
| 70 | +// tableManagerModel = Provider.of<TableManagerModel>(context, listen: false); | ||
| 71 | +// WidgetsBinding.instance.addPostFrameCallback((_) { | ||
| 72 | +// tableManagerModel.initTime(context); | ||
| 73 | +// EventBus().on("refresh_tablemanager", (arg) { | ||
| 74 | +// //订座-完成预订 刷新管理桌位 | ||
| 75 | +// tableManagerModel.getReserveList(context); | ||
| 76 | +// print(tableManagerModel); | ||
| 77 | +// }); | ||
| 78 | +// }); | ||
| 79 | +// } | ||
| 80 | + | ||
| 81 | +// Widget list(List data) => new ListView.custom( | ||
| 82 | +// controller: controller, | ||
| 83 | +// cacheExtent: 1.0, // 只有设置了1.0 才能够准确的标记position 位置 | ||
| 84 | +// childrenDelegate: MyChildrenDelegate( | ||
| 85 | +// (BuildContext context, int index) { | ||
| 86 | +// if (!isTap) { | ||
| 87 | +// print(index); | ||
| 88 | +// // setState(() { | ||
| 89 | + | ||
| 90 | +// // }); | ||
| 91 | +// // tableManagerModel.selectIndex = index; | ||
| 92 | +// // // tableManagerModel.notifyListeners(); | ||
| 93 | + | ||
| 94 | +// // tableManagerModel.currentArea = | ||
| 95 | +// // tableManagerModel.areas[tableManagerModel.selectIndex].name; | ||
| 96 | +// _areaController.animateTo(index * ScreenUtil().setWidth(104 * 2), | ||
| 97 | +// duration: new Duration(milliseconds: 500), | ||
| 98 | +// curve: Curves.ease); | ||
| 99 | +// } | ||
| 100 | + | ||
| 101 | +// return item(index); | ||
| 102 | +// }, | ||
| 103 | +// childCount: data.length, | ||
| 104 | +// ), | ||
| 105 | +// ); | ||
| 106 | + | ||
| 107 | +// // ; | ||
| 108 | + | ||
| 109 | +// // void scrollTo(int index) => itemScrollController | ||
| 110 | +// // .scrollTo( | ||
| 111 | +// // index: index, | ||
| 112 | +// // duration: scrollDuration, | ||
| 113 | +// // curve: Curves.easeInOutCubic, | ||
| 114 | +// // alignment: 0) | ||
| 115 | +// // .then((value) { | ||
| 116 | +// // print(tableManagerModel.selectIndex); | ||
| 117 | +// // // _selectIndex = _selectIndex; | ||
| 118 | +// // // // } | ||
| 119 | +// // // isTap = false; | ||
| 120 | +// // // this.setState(() {}); | ||
| 121 | +// // }).whenComplete(() { | ||
| 122 | +// // // print(''); | ||
| 123 | +// // }); | ||
| 124 | + | ||
| 125 | +// // void jumpTo(int index) => | ||
| 126 | +// // itemScrollController.jumpTo(index: index, alignment: 0); | ||
| 127 | +// Widget item(int index) { | ||
| 128 | +// return _wrapScrollTag(index: index, child: itemSun(index)); | ||
| 129 | +// } | ||
| 130 | + | ||
| 131 | +// Widget _wrapScrollTag({int index, Widget child}) => AutoScrollTag( | ||
| 132 | +// key: ValueKey(index), | ||
| 133 | +// controller: controller, | ||
| 134 | +// index: index, | ||
| 135 | +// child: child, | ||
| 136 | +// highlightColor: Colors.black.withOpacity(0.1), | ||
| 137 | +// ); | ||
| 138 | + | ||
| 139 | +// /// Generate item number [i]. | ||
| 140 | +// Widget itemSun(int i) { | ||
| 141 | +// return SingleChildScrollView( | ||
| 142 | +// child: Column( | ||
| 143 | +// children: [ | ||
| 144 | +// VEmptyView(40), | ||
| 145 | +// Container( | ||
| 146 | +// alignment: Alignment.center, | ||
| 147 | +// height: ScreenUtil().setWidth(21 * 2), | ||
| 148 | +// child: Text(tableManagerModel.areas[i].name, | ||
| 149 | +// style: TextStyle( | ||
| 150 | +// fontSize: ScreenUtil().setWidth(30), | ||
| 151 | +// color: MyColours.color_199095)), | ||
| 152 | +// ), | ||
| 153 | +// VEmptyView(30), | ||
| 154 | +// GridView.builder( | ||
| 155 | +// // controller: _areaController, | ||
| 156 | +// physics: NeverScrollableScrollPhysics(), | ||
| 157 | +// padding: EdgeInsets.only(top: 0), | ||
| 158 | +// shrinkWrap: true, | ||
| 159 | +// itemCount: tableManagerModel | ||
| 160 | +// .areaTableMap[tableManagerModel.areas[i].name].length + | ||
| 161 | +// 1, | ||
| 162 | +// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | ||
| 163 | +// crossAxisCount: 4, | ||
| 164 | +// childAspectRatio: 8 / 9, | ||
| 165 | +// ), | ||
| 166 | +// // mainAxisSpacing: ScreenUtil().setWidth(15 * 2), | ||
| 167 | +// // crossAxisSpacing: ScreenUtil().setWidth(38 * 2)), | ||
| 168 | +// itemBuilder: (BuildContext context, int index) { | ||
| 169 | +// if (index == | ||
| 170 | +// tableManagerModel | ||
| 171 | +// .areaTableMap[tableManagerModel.areas[i].name].length || | ||
| 172 | +// tableManagerModel | ||
| 173 | +// .areaTableMap[tableManagerModel.areas[i].name].length == | ||
| 174 | +// 0) { | ||
| 175 | +// return InkWell( | ||
| 176 | +// onTap: () async { | ||
| 177 | +// List<String> areas = []; | ||
| 178 | +// for (int i = 0; i < tableManagerModel.areas.length; i++) { | ||
| 179 | +// areas.add(tableManagerModel.areas[i].name); | ||
| 180 | +// } | ||
| 181 | + | ||
| 182 | +// //添加桌位弹框 | ||
| 183 | +// await DialogUtil.openCreateTableDialog( | ||
| 184 | +// context, areas, i, personNumList, | ||
| 185 | +// onTap: (Map<String, String> value) async { | ||
| 186 | +// print(value); | ||
| 187 | +// // 'areaname': | ||
| 188 | +// // areas[currentAreaIndex], | ||
| 189 | +// // 'name': controller.text, | ||
| 190 | +// // 'pnumMin': pnumMin, | ||
| 191 | +// // 'pnumMax': pnumMax | ||
| 192 | +// //添加桌位 接口参数带整合??? | ||
| 193 | +// // 以下是旧的不去,明天添加桌位接口 | ||
| 194 | +// String rid; | ||
| 195 | +// for (Area item in tableManagerModel.areas) { | ||
| 196 | +// if (item.name == value['areaname']) { | ||
| 197 | +// rid = item.rid; | ||
| 198 | +// } | ||
| 199 | +// } | ||
| 200 | +// Map<String, String> params = { | ||
| 201 | +// 'rid': rid, | ||
| 202 | +// 'name': value['name'], | ||
| 203 | +// }; | ||
| 204 | +// if (value['pnumMin'] != '') { | ||
| 205 | +// params['pnum'] = value['pnumMin']; | ||
| 206 | +// } | ||
| 207 | +// if (value['pnumMax'] != '') { | ||
| 208 | +// params['most_pnum'] = value['pnumMax']; | ||
| 209 | +// } | ||
| 210 | +// bool success = | ||
| 211 | +// await tableManagerModel.addTable(context, params); | ||
| 212 | +// print(success); | ||
| 213 | +// if (success) { | ||
| 214 | +// Utils.showToast('添加成功!'); | ||
| 215 | +// // TableOuter tableOuter = TableOuter(); | ||
| 216 | +// // tableOuter.name = value; | ||
| 217 | +// // tableOuter.list = []; | ||
| 218 | +// // tableManagerModel.tableOuterList.add(tableOuter); | ||
| 219 | +// // tableManagerModel.initData(); | ||
| 220 | +// // Timer( | ||
| 221 | +// // Duration(milliseconds: 500), | ||
| 222 | +// // () => _areaController.jumpTo( | ||
| 223 | +// // _areaController.position.maxScrollExtent)); | ||
| 224 | + | ||
| 225 | +// // await tableManagerModel | ||
| 226 | +// // .getTableList(context); | ||
| 227 | +// // await tableManagerModel | ||
| 228 | +// // .initData(); | ||
| 229 | +// tableManagerModel.refreshTable(context); | ||
| 230 | +// } | ||
| 231 | +// }); | ||
| 232 | +// }, | ||
| 233 | +// child: Container( | ||
| 234 | +// margin: EdgeInsets.all(ScreenUtil().setWidth(9)), | ||
| 235 | +// child: DottedBorder( | ||
| 236 | +// dashPattern: [5, 5, 5, 5], | ||
| 237 | +// borderType: BorderType.RRect, | ||
| 238 | +// radius: Radius.circular(ScreenUtil().setWidth(10)), | ||
| 239 | +// // padding: EdgeInsets.all(ScreenUtil().setWidth(70)), | ||
| 240 | +// color: MyColours.color_199095, | ||
| 241 | +// strokeWidth: ScreenUtil().setWidth(2), | ||
| 242 | +// child: ClipRRect( | ||
| 243 | +// borderRadius: BorderRadius.all( | ||
| 244 | +// Radius.circular(ScreenUtil().setWidth(10))), | ||
| 245 | +// child: Container( | ||
| 246 | +// height: ScreenUtil().setWidth(90 * 2), | ||
| 247 | +// width: ScreenUtil().setWidth(80 * 2), | ||
| 248 | +// child: Column( | ||
| 249 | +// mainAxisAlignment: MainAxisAlignment.center, | ||
| 250 | +// children: [ | ||
| 251 | +// Image.asset(Utils.getImgPath('add_area'), | ||
| 252 | +// width: ScreenUtil().setWidth(32)), | ||
| 253 | +// ], | ||
| 254 | +// ), | ||
| 255 | +// ), | ||
| 256 | +// ), | ||
| 257 | +// ))); | ||
| 258 | +// } else { | ||
| 259 | +// return Selector<TableManagerModel, t.Table>( | ||
| 260 | +// shouldRebuild: (pre, next) => true, | ||
| 261 | +// selector: (context, model) => tableManagerModel | ||
| 262 | +// .areaTableMap[tableManagerModel.areas[i].name][index], | ||
| 263 | +// builder: (context, table, _) { | ||
| 264 | +// return TableItem(table, onSelected: (table) { | ||
| 265 | +// if ((table as t.Table).selected) { | ||
| 266 | +// tableManagerModel.selectTables.add(table); | ||
| 267 | +// } else { | ||
| 268 | +// tableManagerModel.selectTables | ||
| 269 | +// .removeWhere((t) => t.id == table.id); | ||
| 270 | +// } | ||
| 271 | +// DialogUtil.showTableManagerDialog(context, table) | ||
| 272 | +// .then((value) { | ||
| 273 | +// if (value != null) { | ||
| 274 | +// switch (value) { | ||
| 275 | +// case 1: //查看详情 | ||
| 276 | +// NavigatorUtil.goNotebookDetailPage(context, | ||
| 277 | +// tableManagerModel.tableMap[table.id].id); | ||
| 278 | +// break; | ||
| 279 | +// case 2: //订座 | ||
| 280 | +// NavigatorUtil.goNoteBookChangePage( | ||
| 281 | +// context, | ||
| 282 | +// NotebookDetail.fromTableManager( | ||
| 283 | +// tableManagerModel.getCurrDdateStr(), | ||
| 284 | +// tableManagerModel.currTimeIndex.toString(), | ||
| 285 | +// table), | ||
| 286 | +// ""); | ||
| 287 | +// break; | ||
| 288 | +// case 3: //停用,启用桌位 | ||
| 289 | +// Map<String, String> params = { | ||
| 290 | +// "id": (table as t.Table).id, | ||
| 291 | +// "status": | ||
| 292 | +// (table as t.Table).enable == "1" ? "0" : "1" | ||
| 293 | +// }; | ||
| 294 | +// tableManagerModel | ||
| 295 | +// .setSwitchStatus(context, params) | ||
| 296 | +// .then((value) { | ||
| 297 | +// if (value != null) { | ||
| 298 | +// (table as t.Table).enable = | ||
| 299 | +// ((int.parse((table as t.Table).enable) + | ||
| 300 | +// 1) % | ||
| 301 | +// 2) | ||
| 302 | +// .toString(); | ||
| 303 | +// if ((table as t.Table).enable == "1") { | ||
| 304 | +// for (Area area in tableManagerModel.areas) { | ||
| 305 | +// if (area.name == | ||
| 306 | +// tableManagerModel.currentArea) { | ||
| 307 | +// if (table.sign != '5' && | ||
| 308 | +// table.sign != '1') { | ||
| 309 | +// //已预订 | ||
| 310 | +// area.count++; | ||
| 311 | +// } | ||
| 312 | +// break; | ||
| 313 | +// } | ||
| 314 | +// } | ||
| 315 | +// } else { | ||
| 316 | +// for (Area area in tableManagerModel.areas) { | ||
| 317 | +// if (area.name == | ||
| 318 | +// tableManagerModel.currentArea) { | ||
| 319 | +// if (table.sign != '5' && | ||
| 320 | +// table.sign != '1') { | ||
| 321 | +// //已预订 | ||
| 322 | +// area.count--; | ||
| 323 | +// } | ||
| 324 | +// break; | ||
| 325 | +// } | ||
| 326 | +// } | ||
| 327 | +// } | ||
| 328 | +// tableManagerModel.notifyListeners(); | ||
| 329 | +// } | ||
| 330 | +// }); | ||
| 331 | +// break; | ||
| 332 | +// } | ||
| 333 | +// } | ||
| 334 | +// }); | ||
| 335 | +// }, | ||
| 336 | +// canSelected: false, | ||
| 337 | +// fromPage: 'table_manage', | ||
| 338 | +// tableMap: tableManagerModel.tableMap, | ||
| 339 | +// rid: ""); | ||
| 340 | +// }, | ||
| 341 | +// ); | ||
| 342 | +// } | ||
| 343 | +// }, | ||
| 344 | +// ), | ||
| 345 | +// ], | ||
| 346 | +// )); | ||
| 347 | +// } | ||
| 348 | + | ||
| 349 | +// @override | ||
| 350 | +// Widget build(BuildContext context) { | ||
| 351 | +// return Consumer<TableManagerModel>( | ||
| 352 | +// builder: (context, model, child) { | ||
| 353 | +// return Column( | ||
| 354 | +// children: <Widget>[ | ||
| 355 | +// SystemAppBar("桌位", showLeading: false), | ||
| 356 | +// Container( | ||
| 357 | +// color: MyColours.color_ffffff, | ||
| 358 | +// width: double.infinity, | ||
| 359 | +// padding: | ||
| 360 | +// EdgeInsets.symmetric(vertical: ScreenUtil().setHeight(16)), | ||
| 361 | +// child: Row( | ||
| 362 | +// crossAxisAlignment: CrossAxisAlignment.center, | ||
| 363 | +// children: <Widget>[ | ||
| 364 | +// Expanded( | ||
| 365 | +// child: Center( | ||
| 366 | +// child: GestureDetector( | ||
| 367 | +// onTap: () { | ||
| 368 | +// DialogUtil.showCalendarDialog( | ||
| 369 | +// context, tableManagerModel.dateTime) | ||
| 370 | +// .then((day) { | ||
| 371 | +// if (day != null) { | ||
| 372 | +// tableManagerModel.createDateText(context, day); | ||
| 373 | +// } | ||
| 374 | +// }); | ||
| 375 | +// }, | ||
| 376 | +// child: Container( | ||
| 377 | +// child: Text( | ||
| 378 | +// tableManagerModel.dateText, | ||
| 379 | +// style: TextStyle( | ||
| 380 | +// color: MyColours.color_199095, | ||
| 381 | +// fontSize: ScreenUtil().setSp(34)), | ||
| 382 | +// ), | ||
| 383 | +// ), | ||
| 384 | +// ), | ||
| 385 | +// ), | ||
| 386 | +// ), | ||
| 387 | +// MyDivider( | ||
| 388 | +// ScreenUtil().setWidth(2), | ||
| 389 | +// ScreenUtil().setHeight(68), | ||
| 390 | +// color: MyColours.color_E0E0E0, | ||
| 391 | +// ), | ||
| 392 | +// Expanded( | ||
| 393 | +// child: Padding( | ||
| 394 | +// padding: EdgeInsets.symmetric( | ||
| 395 | +// horizontal: ScreenUtil().setWidth(30)), | ||
| 396 | +// child: Row( | ||
| 397 | +// mainAxisAlignment: MainAxisAlignment.center, | ||
| 398 | +// crossAxisAlignment: CrossAxisAlignment.center, | ||
| 399 | +// children: <Widget>[ | ||
| 400 | +// Offstage( | ||
| 401 | +// offstage: | ||
| 402 | +// tableManagerModel.morning == "00:00-00:00" | ||
| 403 | +// ? true | ||
| 404 | +// : false, | ||
| 405 | +// child: Padding( | ||
| 406 | +// padding: EdgeInsets.only( | ||
| 407 | +// right: ScreenUtil().setWidth(18)), | ||
| 408 | +// child: CommonButton( | ||
| 409 | +// content: "早市", | ||
| 410 | +// state: tableManagerModel.currTimeIndex == 1 | ||
| 411 | +// ? 1 | ||
| 412 | +// : 0, | ||
| 413 | +// width: 92, | ||
| 414 | +// height: 48, | ||
| 415 | +// fontSize: 32, | ||
| 416 | +// onPress: () { | ||
| 417 | +// if (tableManagerModel.currTimeIndex == 1) | ||
| 418 | +// return; | ||
| 419 | +// tableManagerModel.currTimeIndex = 1; | ||
| 420 | +// tableManagerModel.getReserveList(context); | ||
| 421 | +// }, | ||
| 422 | +// ))), | ||
| 423 | +// Offstage( | ||
| 424 | +// offstage: tableManagerModel.noon == "00:00-00:00" | ||
| 425 | +// ? true | ||
| 426 | +// : false, | ||
| 427 | +// child: Padding( | ||
| 428 | +// padding: EdgeInsets.only( | ||
| 429 | +// right: ScreenUtil().setWidth(18)), | ||
| 430 | +// child: CommonButton( | ||
| 431 | +// content: "午市", | ||
| 432 | +// state: tableManagerModel.currTimeIndex == 2 | ||
| 433 | +// ? 1 | ||
| 434 | +// : 0, | ||
| 435 | +// width: 92, | ||
| 436 | +// height: 48, | ||
| 437 | +// fontSize: 32, | ||
| 438 | +// onPress: () { | ||
| 439 | +// if (tableManagerModel.currTimeIndex == 2) | ||
| 440 | +// return; | ||
| 441 | +// tableManagerModel.currTimeIndex = 2; | ||
| 442 | +// tableManagerModel.getReserveList(context); | ||
| 443 | +// }, | ||
| 444 | +// ))), | ||
| 445 | +// Offstage( | ||
| 446 | +// offstage: tableManagerModel.night == "00:00-00:00" | ||
| 447 | +// ? true | ||
| 448 | +// : false, | ||
| 449 | +// child: Container( | ||
| 450 | +// // padding: EdgeInsets.symmetric( | ||
| 451 | +// // horizontal: ScreenUtil().setWidth(10)), | ||
| 452 | +// child: CommonButton( | ||
| 453 | +// content: "晚市", | ||
| 454 | +// state: | ||
| 455 | +// tableManagerModel.currTimeIndex == 3 ? 1 : 0, | ||
| 456 | +// width: 92, | ||
| 457 | +// height: 48, | ||
| 458 | +// fontSize: 32, | ||
| 459 | +// onPress: () { | ||
| 460 | +// if (tableManagerModel.currTimeIndex == 3) | ||
| 461 | +// return; | ||
| 462 | +// tableManagerModel.currTimeIndex = 3; | ||
| 463 | +// tableManagerModel.getReserveList(context); | ||
| 464 | +// }, | ||
| 465 | +// )), | ||
| 466 | +// ), | ||
| 467 | +// ], | ||
| 468 | +// ), | ||
| 469 | +// ), | ||
| 470 | +// ) | ||
| 471 | +// ], | ||
| 472 | +// ), | ||
| 473 | +// ), | ||
| 474 | +// Expanded( | ||
| 475 | +// child: Consumer<TableManagerModel>( | ||
| 476 | +// builder: (context, model, child) { | ||
| 477 | +// if (model.pageState != PageState.Success) { | ||
| 478 | +// return ExceptionPage( | ||
| 479 | +// pageState: model.pageState, | ||
| 480 | +// callback: () { | ||
| 481 | +// if (tableManagerModel.tableOuterList.isEmpty) { | ||
| 482 | +// tableManagerModel.getTableList(context); | ||
| 483 | +// } else { | ||
| 484 | +// tableManagerModel.getReserveList(context); | ||
| 485 | +// } | ||
| 486 | +// }, | ||
| 487 | +// emptyMsg: "暂时没有桌位哦", | ||
| 488 | +// emptyImg: "empty_search", | ||
| 489 | +// showMsg: "加载中,请稍后...", | ||
| 490 | +// ); | ||
| 491 | +// } else { | ||
| 492 | +// return Container( | ||
| 493 | +// color: MyColours.color_ffffff, | ||
| 494 | +// child: Column(children: <Widget>[ | ||
| 495 | +// ValueListenableBuilder<Iterable<ItemPosition>>( | ||
| 496 | +// valueListenable: | ||
| 497 | +// itemPositionsListener.itemPositions, | ||
| 498 | +// builder: (context, positions, child) { | ||
| 499 | +// if (positions.isNotEmpty) { | ||
| 500 | +// max = positions | ||
| 501 | +// .where((ItemPosition position) => | ||
| 502 | +// position.itemLeadingEdge < 1) | ||
| 503 | +// .reduce((ItemPosition max, | ||
| 504 | +// ItemPosition position) => | ||
| 505 | +// position.itemLeadingEdge > | ||
| 506 | +// max.itemLeadingEdge | ||
| 507 | +// ? position | ||
| 508 | +// : max) | ||
| 509 | +// .index; | ||
| 510 | + | ||
| 511 | +// min = positions | ||
| 512 | +// .where((ItemPosition position) => | ||
| 513 | +// position.itemTrailingEdge > 0) | ||
| 514 | +// .reduce((ItemPosition min, | ||
| 515 | +// ItemPosition position) => | ||
| 516 | +// position.itemTrailingEdge < | ||
| 517 | +// min.itemTrailingEdge | ||
| 518 | +// ? position | ||
| 519 | +// : min) | ||
| 520 | +// .index; | ||
| 521 | + | ||
| 522 | +// // if (isTap) { | ||
| 523 | +// // if (min >= _selectIndex) { | ||
| 524 | +// // _selectIndex = min; | ||
| 525 | +// // } else { | ||
| 526 | +// // //点击按钮的时候 | ||
| 527 | +// // _selectIndex = _selectIndex; | ||
| 528 | +// // } | ||
| 529 | +// // isTap = false; | ||
| 530 | +// // } else { | ||
| 531 | +// //手动滑动列表的时候 | ||
| 532 | +// // if (max == tableManagerModel.areas.length - 1) { | ||
| 533 | +// // _selectIndex = _selectIndex; | ||
| 534 | +// // } else if (min >= _selectIndex || | ||
| 535 | +// // max <= _selectIndex) { | ||
| 536 | +// // _selectIndex = min; | ||
| 537 | +// // } else { | ||
| 538 | +// // //点击按钮的时候 | ||
| 539 | +// // _selectIndex = _selectIndex; | ||
| 540 | +// // } | ||
| 541 | +// // tableManagerModel.currentArea = | ||
| 542 | +// // tableManagerModel.areas[_selectIndex].name; | ||
| 543 | +// // _areaController.animateTo( | ||
| 544 | +// // _selectIndex * | ||
| 545 | +// // ScreenUtil().setWidth(104 * 2), | ||
| 546 | +// // duration: new Duration(milliseconds: 500), | ||
| 547 | +// // curve: Curves.ease); | ||
| 548 | +// } | ||
| 549 | +// return Container( | ||
| 550 | +// height: ScreenUtil().setWidth(80), | ||
| 551 | +// color: MyColours.color_ffffff, | ||
| 552 | +// margin: EdgeInsets.only( | ||
| 553 | +// bottom: ScreenUtil().setWidth(20)), | ||
| 554 | +// child: ListView.builder( | ||
| 555 | +// padding: EdgeInsets.symmetric( | ||
| 556 | +// horizontal: ScreenUtil().setWidth(40)), | ||
| 557 | +// controller: _areaController, | ||
| 558 | +// scrollDirection: Axis.horizontal, | ||
| 559 | +// itemBuilder: (context, index) { | ||
| 560 | +// if (index == | ||
| 561 | +// tableManagerModel.areas.length || | ||
| 562 | +// tableManagerModel.areas.length == 0) { | ||
| 563 | +// return InkWell( | ||
| 564 | +// onTap: () async { | ||
| 565 | +// //添加区域弹框 | ||
| 566 | +// await DialogUtil | ||
| 567 | +// .openCreateAreaDialog(context, | ||
| 568 | +// onTap: (value) async { | ||
| 569 | +// print(value); | ||
| 570 | +// //添加区域 | ||
| 571 | +// bool success = | ||
| 572 | +// await tableManagerModel | ||
| 573 | +// .addTableAreas( | ||
| 574 | +// context, value); | ||
| 575 | +// print(success); | ||
| 576 | +// if (success) { | ||
| 577 | +// Utils.showToast('添加成功!'); | ||
| 578 | +// // TableOuter tableOuter = | ||
| 579 | +// // TableOuter(); | ||
| 580 | +// // tableOuter.name = value; | ||
| 581 | +// // tableOuter.list = []; | ||
| 582 | +// // tableManagerModel.tableOuterList | ||
| 583 | +// // .add(tableOuter); | ||
| 584 | +// await tableManagerModel | ||
| 585 | +// .getTableList(context, | ||
| 586 | +// needLoading: false); | ||
| 587 | +// tableManagerModel.initData(); | ||
| 588 | +// Timer( | ||
| 589 | +// Duration(milliseconds: 500), | ||
| 590 | +// () => _areaController | ||
| 591 | +// .jumpTo(_areaController | ||
| 592 | +// .position | ||
| 593 | +// .maxScrollExtent)); | ||
| 594 | + | ||
| 595 | +// // await tableManagerModel | ||
| 596 | +// // .getTableList(context); | ||
| 597 | +// // await tableManagerModel | ||
| 598 | +// // .initData(); | ||
| 599 | +// } | ||
| 600 | +// }); | ||
| 601 | +// }, | ||
| 602 | +// child: Column( | ||
| 603 | +// children: [ | ||
| 604 | +// VEmptyView(20), | ||
| 605 | +// DottedBorder( | ||
| 606 | +// dashPattern: [5, 5, 5, 5], | ||
| 607 | +// borderType: BorderType.RRect, | ||
| 608 | +// radius: Radius.circular( | ||
| 609 | +// ScreenUtil().setWidth(10)), | ||
| 610 | +// // padding: EdgeInsets.all(ScreenUtil().setWidth(70)), | ||
| 611 | +// color: MyColours.color_199095, | ||
| 612 | +// strokeWidth: | ||
| 613 | +// ScreenUtil().setWidth(2), | ||
| 614 | +// child: ClipRRect( | ||
| 615 | +// borderRadius: BorderRadius | ||
| 616 | +// .all(Radius.circular( | ||
| 617 | +// ScreenUtil() | ||
| 618 | +// .setWidth(10))), | ||
| 619 | +// child: Container( | ||
| 620 | +// height: ScreenUtil() | ||
| 621 | +// .setWidth(25 * 2), | ||
| 622 | +// width: ScreenUtil() | ||
| 623 | +// .setWidth(104 * 2), | ||
| 624 | +// child: Column( | ||
| 625 | +// mainAxisAlignment: | ||
| 626 | +// MainAxisAlignment | ||
| 627 | +// .center, | ||
| 628 | +// children: [ | ||
| 629 | +// Image.asset( | ||
| 630 | +// Utils.getImgPath( | ||
| 631 | +// 'add_area'), | ||
| 632 | +// width: ScreenUtil() | ||
| 633 | +// .setWidth(24)), | ||
| 634 | +// ], | ||
| 635 | +// ), | ||
| 636 | +// ), | ||
| 637 | +// ), | ||
| 638 | +// ) | ||
| 639 | +// ], | ||
| 640 | +// )); | ||
| 641 | +// } else { | ||
| 642 | +// return Selector<TableManagerModel, Area>( | ||
| 643 | +// selector: (context, model) => | ||
| 644 | +// model.areas[index], | ||
| 645 | +// builder: (context, area, _) { | ||
| 646 | +// return AreaItemTable(area, | ||
| 647 | +// tableManagerModel.currentArea, | ||
| 648 | +// (area) async { | ||
| 649 | +// isTap = true; | ||
| 650 | +// setState(() { | ||
| 651 | +// tableManagerModel.selectIndex = | ||
| 652 | +// index; | ||
| 653 | +// }); | ||
| 654 | +// await controller.scrollToIndex( | ||
| 655 | +// index, | ||
| 656 | +// preferPosition: | ||
| 657 | +// AutoScrollPosition.begin); | ||
| 658 | +// // scrollTo(index); | ||
| 659 | + | ||
| 660 | +// tableManagerModel.currentArea = | ||
| 661 | +// tableManagerModel | ||
| 662 | +// .areas[index].name; | ||
| 663 | +// tableManagerModel.currentTables = | ||
| 664 | +// tableManagerModel.areaTableMap[ | ||
| 665 | +// tableManagerModel | ||
| 666 | +// .currentArea]; | ||
| 667 | +// }); | ||
| 668 | +// }, | ||
| 669 | +// ); | ||
| 670 | +// } | ||
| 671 | +// }, | ||
| 672 | +// itemExtent: ScreenUtil().setWidth(104 * 2), | ||
| 673 | +// itemCount: tableManagerModel.areas.length + 1, | ||
| 674 | +// ), | ||
| 675 | +// ); | ||
| 676 | +// }), | ||
| 677 | +// Expanded( | ||
| 678 | +// child: Container( | ||
| 679 | +// color: MyColours.color_f5f5f5, | ||
| 680 | +// padding: EdgeInsets.symmetric( | ||
| 681 | +// horizontal: ScreenUtil().setWidth(24)), | ||
| 682 | +// width: double.infinity, | ||
| 683 | +// child: list(tableManagerModel.areas)), | ||
| 684 | +// ), | ||
| 685 | +// ]), | ||
| 686 | +// ); | ||
| 687 | +// } | ||
| 688 | +// }, | ||
| 689 | +// ), | ||
| 690 | +// ), | ||
| 691 | +// ], | ||
| 692 | +// ); | ||
| 693 | +// }, | ||
| 694 | +// ); | ||
| 695 | +// } | ||
| 696 | + | ||
| 697 | +// @override | ||
| 698 | +// void dispose() { | ||
| 699 | +// // TODO: implement dispose | ||
| 700 | +// super.dispose(); | ||
| 701 | +// EventBus().off("refresh_tablemanager"); | ||
| 702 | +// } | ||
| 703 | +// } | ||
| 704 | + | ||
| 705 | +// class _SaltedValueKey extends ValueKey<Key> { | ||
| 706 | +// const _SaltedValueKey(Key key) | ||
| 707 | +// : assert(key != null), | ||
| 708 | +// super(key); | ||
| 709 | +// } | ||
| 710 | + | ||
| 711 | +// class MyChildrenDelegate extends SliverChildBuilderDelegate { | ||
| 712 | +// MyChildrenDelegate( | ||
| 713 | +// Widget Function(BuildContext, int) builder, { | ||
| 714 | +// int childCount, | ||
| 715 | +// bool addAutomaticKeepAlive = true, | ||
| 716 | +// bool addRepaintBoundaries = true, | ||
| 717 | +// }) : super(builder, | ||
| 718 | +// childCount: childCount, | ||
| 719 | +// addAutomaticKeepAlives: addAutomaticKeepAlive, | ||
| 720 | +// addRepaintBoundaries: addRepaintBoundaries); | ||
| 721 | +// // Return a Widget for the given Exception | ||
| 722 | +// Widget _createErrorWidget(dynamic exception, StackTrace stackTrace) { | ||
| 723 | +// final FlutterErrorDetails details = FlutterErrorDetails( | ||
| 724 | +// exception: exception, | ||
| 725 | +// stack: stackTrace, | ||
| 726 | +// library: 'widgets library', | ||
| 727 | +// context: ErrorDescription('building'), | ||
| 728 | +// ); | ||
| 729 | +// FlutterError.reportError(details); | ||
| 730 | +// return ErrorWidget.builder(details); | ||
| 731 | +// } | ||
| 732 | + | ||
| 733 | +// @override | ||
| 734 | +// Widget build(BuildContext context, int index) { | ||
| 735 | +// assert(builder != null); | ||
| 736 | +// if (index < 0 || (childCount != null && index >= childCount)) return null; | ||
| 737 | +// Widget child; | ||
| 738 | +// try { | ||
| 739 | +// child = builder(context, index); | ||
| 740 | +// } catch (exception, stackTrace) { | ||
| 741 | +// child = _createErrorWidget(exception, stackTrace); | ||
| 742 | +// } | ||
| 743 | +// if (child == null) return null; | ||
| 744 | +// final Key key = child.key != null ? _SaltedValueKey(child.key) : null; | ||
| 745 | +// if (addRepaintBoundaries) child = RepaintBoundary(child: child); | ||
| 746 | +// if (addSemanticIndexes) { | ||
| 747 | +// final int semanticIndex = semanticIndexCallback(child, index); | ||
| 748 | +// if (semanticIndex != null) | ||
| 749 | +// child = IndexedSemantics( | ||
| 750 | +// index: semanticIndex + semanticIndexOffset, child: child); | ||
| 751 | +// } | ||
| 752 | +// if (addAutomaticKeepAlives) child = AutomaticKeepAlive(child: child); | ||
| 753 | +// return KeyedSubtree(child: child, key: key); | ||
| 754 | +// } | ||
| 755 | + | ||
| 756 | +// @override | ||
| 757 | +// void didFinishLayout(int firstIndex, int lastIndex) { | ||
| 758 | +// // TODO: implement didFinishLayout | ||
| 759 | +// super.didFinishLayout(firstIndex, lastIndex); | ||
| 760 | +// } | ||
| 761 | + | ||
| 762 | +// ///监听 在可见的列表中 显示的第一个位置和最后一个位置 | ||
| 763 | +// @override | ||
| 764 | +// double estimateMaxScrollOffset(int firstIndex, int lastIndex, | ||
| 765 | +// double leadingScrollOffset, double trailingScrollOffset) { | ||
| 766 | +// print( | ||
| 767 | +// 'firstIndex sss : $firstIndex, lastIndex ssss : $lastIndex, leadingScrollOffset ssss : $leadingScrollOffset,' | ||
| 768 | +// 'trailingScrollOffset ssss : $trailingScrollOffset '); | ||
| 769 | +// return super.estimateMaxScrollOffset( | ||
| 770 | +// firstIndex, lastIndex, leadingScrollOffset, trailingScrollOffset); | ||
| 771 | +// } | ||
| 772 | +// } |
| @@ -9,6 +9,7 @@ import 'package:one_key/models/area.dart'; | @@ -9,6 +9,7 @@ import 'package:one_key/models/area.dart'; | ||
| 9 | import 'package:one_key/models/notebook_detail.dart'; | 9 | import 'package:one_key/models/notebook_detail.dart'; |
| 10 | import 'package:one_key/models/tableOuter.dart'; | 10 | import 'package:one_key/models/tableOuter.dart'; |
| 11 | import 'package:one_key/pages/table/area_item_table.dart'; | 11 | import 'package:one_key/pages/table/area_item_table.dart'; |
| 12 | +import 'package:one_key/pages/table/cc_menu_wdn.dart'; | ||
| 12 | import 'package:one_key/provider/table_manager_model.dart'; | 13 | import 'package:one_key/provider/table_manager_model.dart'; |
| 13 | import 'package:one_key/res/colors.dart'; | 14 | import 'package:one_key/res/colors.dart'; |
| 14 | import 'package:one_key/utils/dialog_util.dart'; | 15 | import 'package:one_key/utils/dialog_util.dart'; |
| @@ -42,9 +43,10 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -42,9 +43,10 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 42 | TableManagerModel tableManagerModel; | 43 | TableManagerModel tableManagerModel; |
| 43 | final ItemScrollController itemScrollController = ItemScrollController(); | 44 | final ItemScrollController itemScrollController = ItemScrollController(); |
| 44 | bool isTap = false; | 45 | bool isTap = false; |
| 46 | + // 进度监听对象 | ||
| 45 | int min; | 47 | int min; |
| 46 | int max; | 48 | int max; |
| 47 | - int _selectIndex; | 49 | + int _selectIndex = 0; |
| 48 | ScrollController _areaController = ScrollController(); | 50 | ScrollController _areaController = ScrollController(); |
| 49 | List<String> personNumList = []; | 51 | List<String> personNumList = []; |
| 50 | 52 | ||
| @@ -59,6 +61,7 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -59,6 +61,7 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 59 | for (int i = 1; i < 31; i++) { | 61 | for (int i = 1; i < 31; i++) { |
| 60 | personNumList.add(i.toString()); | 62 | personNumList.add(i.toString()); |
| 61 | } | 63 | } |
| 64 | + | ||
| 62 | // personNumList.add('30以上'); | 65 | // personNumList.add('30以上'); |
| 63 | tableManagerModel = Provider.of<TableManagerModel>(context, listen: false); | 66 | tableManagerModel = Provider.of<TableManagerModel>(context, listen: false); |
| 64 | WidgetsBinding.instance.addPostFrameCallback((_) { | 67 | WidgetsBinding.instance.addPostFrameCallback((_) { |
| @@ -87,8 +90,13 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -87,8 +90,13 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 87 | curve: Curves.easeInOutCubic, | 90 | curve: Curves.easeInOutCubic, |
| 88 | alignment: 0) | 91 | alignment: 0) |
| 89 | .then((value) { | 92 | .then((value) { |
| 90 | - // print(_selectIndex); | ||
| 91 | - // this.setState(() {}); | 93 | + print(_selectIndex); |
| 94 | + // _selectIndex = _selectIndex; | ||
| 95 | + // // } | ||
| 96 | + // isTap = false; | ||
| 97 | + this.setState(() {}); | ||
| 98 | + }).whenComplete(() { | ||
| 99 | + // print(''); | ||
| 92 | }); | 100 | }); |
| 93 | 101 | ||
| 94 | void jumpTo(int index) => | 102 | void jumpTo(int index) => |
| @@ -447,204 +455,125 @@ class TableManagerPageState extends State<TableManagerPage> { | @@ -447,204 +455,125 @@ class TableManagerPageState extends State<TableManagerPage> { | ||
| 447 | showMsg: "加载中,请稍后...", | 455 | showMsg: "加载中,请稍后...", |
| 448 | ); | 456 | ); |
| 449 | } else { | 457 | } else { |
| 450 | - return Container( | ||
| 451 | - color: MyColours.color_ffffff, | ||
| 452 | - child: Column(children: <Widget>[ | ||
| 453 | - // VEmptyView(20), | ||
| 454 | - ValueListenableBuilder<Iterable<ItemPosition>>( | ||
| 455 | - valueListenable: | ||
| 456 | - itemPositionsListener.itemPositions, | ||
| 457 | - builder: (context, positions, child) { | ||
| 458 | - if (positions.isNotEmpty) { | ||
| 459 | - // max = positions | ||
| 460 | - // .where((ItemPosition position) => | ||
| 461 | - // position.itemLeadingEdge < 1) | ||
| 462 | - // .reduce((ItemPosition max, | ||
| 463 | - // ItemPosition position) => | ||
| 464 | - // position.itemLeadingEdge > | ||
| 465 | - // max.itemLeadingEdge | ||
| 466 | - // ? position | ||
| 467 | - // : max) | ||
| 468 | - // .index; | ||
| 469 | - | ||
| 470 | - min = positions | ||
| 471 | - .where((ItemPosition position) => | ||
| 472 | - position.itemTrailingEdge > 0) | ||
| 473 | - .reduce((ItemPosition min, | ||
| 474 | - ItemPosition position) => | ||
| 475 | - position.itemTrailingEdge < | ||
| 476 | - min.itemTrailingEdge | ||
| 477 | - ? position | ||
| 478 | - : min) | ||
| 479 | - .index; | 458 | + return CCMenuPage.builder( |
| 459 | + tableManagerModel: tableManagerModel, | ||
| 460 | + itemCount: tableManagerModel.areas.length, | ||
| 461 | + onTap: (index) async { | ||
| 462 | + // //添加区域弹框 | ||
| 463 | + // await DialogUtil.openCreateAreaDialog(context, | ||
| 464 | + // onTap: (value) async { | ||
| 465 | + // print(value); | ||
| 466 | + // //添加区域 | ||
| 467 | + // bool success = await tableManagerModel.addTableAreas( | ||
| 468 | + // context, value); | ||
| 469 | + // print(success); | ||
| 470 | + // if (success) { | ||
| 471 | + // Utils.showToast('添加成功!'); | ||
| 480 | 472 | ||
| 481 | - if (isTap) { | ||
| 482 | - if (min >= _selectIndex) { | ||
| 483 | - _selectIndex = min; | ||
| 484 | - } else { | ||
| 485 | - _selectIndex = _selectIndex; | ||
| 486 | - } | ||
| 487 | - isTap = false; | ||
| 488 | - } else { | ||
| 489 | - _selectIndex = min; | ||
| 490 | - } | ||
| 491 | - tableManagerModel.currentArea = | ||
| 492 | - tableManagerModel.areas[_selectIndex].name; | ||
| 493 | - _areaController.animateTo( | ||
| 494 | - _selectIndex * | ||
| 495 | - ScreenUtil().setWidth(104 * 2), | ||
| 496 | - duration: new Duration(milliseconds: 500), | ||
| 497 | - curve: Curves.ease); | ||
| 498 | - } | ||
| 499 | - return Container( | ||
| 500 | - height: ScreenUtil().setWidth(80), | ||
| 501 | - color: MyColours.color_ffffff, | ||
| 502 | - margin: EdgeInsets.only( | ||
| 503 | - bottom: ScreenUtil().setWidth(20)), | ||
| 504 | - child: ListView.builder( | ||
| 505 | - padding: EdgeInsets.symmetric( | ||
| 506 | - horizontal: ScreenUtil().setWidth(40)), | ||
| 507 | - controller: _areaController, | ||
| 508 | - scrollDirection: Axis.horizontal, | ||
| 509 | - itemBuilder: (context, index) { | ||
| 510 | - if (index == | ||
| 511 | - tableManagerModel.areas.length || | ||
| 512 | - tableManagerModel.areas.length == 0) { | ||
| 513 | - return InkWell( | ||
| 514 | - onTap: () async { | ||
| 515 | - //添加区域弹框 | ||
| 516 | - await DialogUtil | ||
| 517 | - .openCreateAreaDialog(context, | ||
| 518 | - onTap: (value) async { | ||
| 519 | - print(value); | ||
| 520 | - //添加区域 | ||
| 521 | - bool success = | ||
| 522 | - await tableManagerModel | ||
| 523 | - .addTableAreas( | ||
| 524 | - context, value); | ||
| 525 | - print(success); | ||
| 526 | - if (success) { | ||
| 527 | - Utils.showToast('添加成功!'); | ||
| 528 | - // TableOuter tableOuter = | ||
| 529 | - // TableOuter(); | ||
| 530 | - // tableOuter.name = value; | ||
| 531 | - // tableOuter.list = []; | ||
| 532 | - // tableManagerModel.tableOuterList | ||
| 533 | - // .add(tableOuter); | ||
| 534 | - await tableManagerModel | ||
| 535 | - .getTableList(context, | ||
| 536 | - needLoading: false); | ||
| 537 | - tableManagerModel.initData(); | ||
| 538 | - Timer( | ||
| 539 | - Duration(milliseconds: 500), | ||
| 540 | - () => _areaController | ||
| 541 | - .jumpTo(_areaController | ||
| 542 | - .position | ||
| 543 | - .maxScrollExtent)); | 473 | + // await tableManagerModel.getTableList(context, |
| 474 | + // needLoading: false); | ||
| 475 | + // tableManagerModel.initData(); | ||
| 544 | 476 | ||
| 545 | - // await tableManagerModel | ||
| 546 | - // .getTableList(context); | ||
| 547 | - // await tableManagerModel | ||
| 548 | - // .initData(); | ||
| 549 | - } | ||
| 550 | - }); | ||
| 551 | - }, | ||
| 552 | - child: Column( | ||
| 553 | - children: [ | ||
| 554 | - VEmptyView(20), | ||
| 555 | - DottedBorder( | ||
| 556 | - dashPattern: [5, 5, 5, 5], | ||
| 557 | - borderType: BorderType.RRect, | ||
| 558 | - radius: Radius.circular( | ||
| 559 | - ScreenUtil().setWidth(10)), | ||
| 560 | - // padding: EdgeInsets.all(ScreenUtil().setWidth(70)), | ||
| 561 | - color: MyColours.color_199095, | ||
| 562 | - strokeWidth: | ||
| 563 | - ScreenUtil().setWidth(2), | ||
| 564 | - child: ClipRRect( | ||
| 565 | - borderRadius: BorderRadius | ||
| 566 | - .all(Radius.circular( | ||
| 567 | - ScreenUtil() | ||
| 568 | - .setWidth(10))), | ||
| 569 | - child: Container( | ||
| 570 | - height: ScreenUtil() | ||
| 571 | - .setWidth(25 * 2), | ||
| 572 | - width: ScreenUtil() | ||
| 573 | - .setWidth(104 * 2), | ||
| 574 | - child: Column( | ||
| 575 | - mainAxisAlignment: | ||
| 576 | - MainAxisAlignment | ||
| 577 | - .center, | ||
| 578 | - children: [ | ||
| 579 | - Image.asset( | ||
| 580 | - Utils.getImgPath( | ||
| 581 | - 'add_area'), | ||
| 582 | - width: ScreenUtil() | ||
| 583 | - .setWidth(24)), | ||
| 584 | - ], | ||
| 585 | - ), | ||
| 586 | - ), | ||
| 587 | - ), | ||
| 588 | - ) | ||
| 589 | - ], | ||
| 590 | - )); | ||
| 591 | - } else { | ||
| 592 | - return Selector<TableManagerModel, Area>( | ||
| 593 | - selector: (context, model) => | ||
| 594 | - model.areas[index], | ||
| 595 | - builder: (context, area, _) { | ||
| 596 | - return AreaItemTable(area, | ||
| 597 | - tableManagerModel.currentArea, | ||
| 598 | - (area) { | ||
| 599 | - isTap = true; | ||
| 600 | - _selectIndex = index; | ||
| 601 | - scrollTo(index); | ||
| 602 | - // setState(() { | ||
| 603 | - tableManagerModel.currentArea = | ||
| 604 | - tableManagerModel | ||
| 605 | - .areas[index].name; | ||
| 606 | - tableManagerModel.currentTables = | ||
| 607 | - tableManagerModel.areaTableMap[ | ||
| 608 | - tableManagerModel | ||
| 609 | - .currentArea]; | 477 | + // setState(() {}); |
| 610 | 478 | ||
| 611 | - // if (position.value.first.itemLeadingEdge == | ||
| 612 | - // itemPositionsListener | ||
| 613 | - // .itemPositions.value.first.itemLeadingEdge) { | ||
| 614 | - // setState(() { | ||
| 615 | - // _selectIndex = index; | ||
| 616 | - // }); | ||
| 617 | - // } | ||
| 618 | - // setState(() {}); | 479 | + // Timer( |
| 480 | + // Duration(milliseconds: 500), | ||
| 481 | + // () => _areaController.jumpTo( | ||
| 482 | + // _areaController.position.maxScrollExtent)); | ||
| 483 | + // } | ||
| 484 | + // }); | ||
| 485 | + }, | ||
| 486 | + tabBuilder: (BuildContext context, int index) { | ||
| 487 | + if (index == tableManagerModel.areas.length || | ||
| 488 | + tableManagerModel.areas.length == 0) { | ||
| 489 | + // return InkWell( | ||
| 490 | + // onTap: () async { | ||
| 491 | + // //添加区域弹框 | ||
| 492 | + // await DialogUtil.openCreateAreaDialog(context, | ||
| 493 | + // onTap: (value) async { | ||
| 494 | + // print(value); | ||
| 495 | + // //添加区域 | ||
| 496 | + // bool success = await tableManagerModel | ||
| 497 | + // .addTableAreas(context, value); | ||
| 498 | + // print(success); | ||
| 499 | + // if (success) { | ||
| 500 | + // Utils.showToast('添加成功!'); | ||
| 501 | + // // TableOuter tableOuter = | ||
| 502 | + // // TableOuter(); | ||
| 503 | + // // tableOuter.name = value; | ||
| 504 | + // // tableOuter.list = []; | ||
| 505 | + // // tableManagerModel.tableOuterList | ||
| 506 | + // // .add(tableOuter); | ||
| 507 | + // await tableManagerModel.getTableList( | ||
| 508 | + // context, | ||
| 509 | + // needLoading: false); | ||
| 510 | + // tableManagerModel.initData(); | ||
| 511 | + // Timer( | ||
| 512 | + // Duration(milliseconds: 500), | ||
| 513 | + // () => _areaController.jumpTo( | ||
| 514 | + // _areaController | ||
| 515 | + // .position.maxScrollExtent)); | ||
| 619 | 516 | ||
| 620 | - // }); | ||
| 621 | - // setState(() { | ||
| 622 | - // tableManagerModel.currentArea = | ||
| 623 | - // (area as Area).name; | ||
| 624 | - // tableManagerModel.currentTables = | ||
| 625 | - // tableManagerModel.areaTableMap[ | ||
| 626 | - // tableManagerModel | ||
| 627 | - // .currentArea]; | ||
| 628 | - // }); | ||
| 629 | - }); | ||
| 630 | - }, | ||
| 631 | - ); | ||
| 632 | - } | ||
| 633 | - }, | ||
| 634 | - itemExtent: ScreenUtil().setWidth(104 * 2), | ||
| 635 | - itemCount: tableManagerModel.areas.length + 1, | 517 | + // // await tableManagerModel |
| 518 | + // // .getTableList(context); | ||
| 519 | + // // await tableManagerModel | ||
| 520 | + // // .initData(); | ||
| 521 | + // } | ||
| 522 | + // }); | ||
| 523 | + // }, | ||
| 524 | + return Column( | ||
| 525 | + children: [ | ||
| 526 | + VEmptyView(20), | ||
| 527 | + DottedBorder( | ||
| 528 | + dashPattern: [5, 5, 5, 5], | ||
| 529 | + borderType: BorderType.RRect, | ||
| 530 | + radius: | ||
| 531 | + Radius.circular(ScreenUtil().setWidth(10)), | ||
| 532 | + // padding: EdgeInsets.all(ScreenUtil().setWidth(70)), | ||
| 533 | + color: MyColours.color_199095, | ||
| 534 | + strokeWidth: ScreenUtil().setWidth(2), | ||
| 535 | + child: ClipRRect( | ||
| 536 | + borderRadius: BorderRadius.all( | ||
| 537 | + Radius.circular( | ||
| 538 | + ScreenUtil().setWidth(10))), | ||
| 539 | + child: Container( | ||
| 540 | + height: ScreenUtil().setWidth(25 * 2), | ||
| 541 | + width: ScreenUtil().setWidth(104 * 2), | ||
| 542 | + child: Column( | ||
| 543 | + mainAxisAlignment: | ||
| 544 | + MainAxisAlignment.center, | ||
| 545 | + children: [ | ||
| 546 | + Image.asset( | ||
| 547 | + Utils.getImgPath('add_area'), | ||
| 548 | + width: ScreenUtil().setWidth(24)), | ||
| 549 | + ], | ||
| 550 | + ), | ||
| 551 | + ), | ||
| 636 | ), | 552 | ), |
| 637 | - ); | ||
| 638 | - }), | ||
| 639 | - Expanded( | ||
| 640 | - child: Container( | ||
| 641 | - color: MyColours.color_f5f5f5, | ||
| 642 | - padding: EdgeInsets.symmetric( | ||
| 643 | - horizontal: ScreenUtil().setWidth(24)), | ||
| 644 | - width: double.infinity, | ||
| 645 | - child: list(tableManagerModel.areas)), | ||
| 646 | - ), | ||
| 647 | - ]), | 553 | + ) |
| 554 | + ], | ||
| 555 | + ); | ||
| 556 | + } else { | ||
| 557 | + return AreaItemTable( | ||
| 558 | + model.areas[index], tableManagerModel.currentArea, | ||
| 559 | + (area) { | ||
| 560 | + // isTap = true; | ||
| 561 | + | ||
| 562 | + // _selectIndex = index; | ||
| 563 | + | ||
| 564 | + // // scrollTo(index); | ||
| 565 | + | ||
| 566 | + // tableManagerModel.currentArea = | ||
| 567 | + // tableManagerModel.areas[index].name; | ||
| 568 | + // tableManagerModel.currentTables = | ||
| 569 | + // tableManagerModel.areaTableMap[ | ||
| 570 | + // tableManagerModel.currentArea]; | ||
| 571 | + }); | ||
| 572 | + } | ||
| 573 | + }, | ||
| 574 | + itemBuilder: (BuildContext context, int index) { | ||
| 575 | + return item(index); | ||
| 576 | + }, | ||
| 648 | ); | 577 | ); |
| 649 | } | 578 | } |
| 650 | }, | 579 | }, |
| @@ -31,6 +31,7 @@ class TableManagerModel with ChangeNotifier { | @@ -31,6 +31,7 @@ class TableManagerModel with ChangeNotifier { | ||
| 31 | Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单 | 31 | Map<String, Notebook> tableMap = {}; //记录已预订桌位对应的订单 |
| 32 | 32 | ||
| 33 | String currentArea; //当前选中区域 | 33 | String currentArea; //当前选中区域 |
| 34 | + int selectIndex = 0; | ||
| 34 | 35 | ||
| 35 | DateTime dateTime = DateTime.now(); | 36 | DateTime dateTime = DateTime.now(); |
| 36 | 37 | ||
| @@ -526,6 +527,8 @@ class TableManagerModel with ChangeNotifier { | @@ -526,6 +527,8 @@ class TableManagerModel with ChangeNotifier { | ||
| 526 | } else { | 527 | } else { |
| 527 | Utils.showToast(baseResp.msg ?? '新增区域失败!'); | 528 | Utils.showToast(baseResp.msg ?? '新增区域失败!'); |
| 528 | } | 529 | } |
| 530 | + } else { | ||
| 531 | + Utils.showToast(baseResp.msg ?? '新增区域失败!'); | ||
| 529 | } | 532 | } |
| 530 | return false; | 533 | return false; |
| 531 | } | 534 | } |
| @@ -554,6 +557,7 @@ class TableManagerModel with ChangeNotifier { | @@ -554,6 +557,7 @@ class TableManagerModel with ChangeNotifier { | ||
| 554 | Future<bool> addTable( | 557 | Future<bool> addTable( |
| 555 | BuildContext context, Map<String, String> params) async { | 558 | BuildContext context, Map<String, String> params) async { |
| 556 | params["sellerid"] = userModel.user.sellerid; | 559 | params["sellerid"] = userModel.user.sellerid; |
| 560 | + params["tid"] = '2'; | ||
| 557 | BaseResp<dynamic> baseResp = await DioUtil() | 561 | BaseResp<dynamic> baseResp = await DioUtil() |
| 558 | .request<dynamic>(context, Method.get, HttpUrl.add_table, | 562 | .request<dynamic>(context, Method.get, HttpUrl.add_table, |
| 559 | data: params, showLoading: true) | 563 | data: params, showLoading: true) |
| @@ -583,6 +587,8 @@ class TableManagerModel with ChangeNotifier { | @@ -583,6 +587,8 @@ class TableManagerModel with ChangeNotifier { | ||
| 583 | } else { | 587 | } else { |
| 584 | Utils.showToast(baseResp.msg ?? '新增桌位失败!'); | 588 | Utils.showToast(baseResp.msg ?? '新增桌位失败!'); |
| 585 | } | 589 | } |
| 590 | + } else { | ||
| 591 | + Utils.showToast(baseResp.msg ?? '新增桌位失败!'); | ||
| 586 | } | 592 | } |
| 587 | return false; | 593 | return false; |
| 588 | } | 594 | } |
| @@ -383,7 +383,7 @@ packages: | @@ -383,7 +383,7 @@ packages: | ||
| 383 | name: flutter_easyrefresh | 383 | name: flutter_easyrefresh |
| 384 | url: "https://pub.flutter-io.cn" | 384 | url: "https://pub.flutter-io.cn" |
| 385 | source: hosted | 385 | source: hosted |
| 386 | - version: "2.1.6" | 386 | + version: "2.2.1" |
| 387 | flutter_picker: | 387 | flutter_picker: |
| 388 | dependency: "direct main" | 388 | dependency: "direct main" |
| 389 | description: | 389 | description: |
| @@ -793,6 +793,13 @@ packages: | @@ -793,6 +793,13 @@ packages: | ||
| 793 | url: "https://pub.flutter-io.cn" | 793 | url: "https://pub.flutter-io.cn" |
| 794 | source: hosted | 794 | source: hosted |
| 795 | version: "0.24.1" | 795 | version: "0.24.1" |
| 796 | + scroll_to_index: | ||
| 797 | + dependency: "direct main" | ||
| 798 | + description: | ||
| 799 | + name: scroll_to_index | ||
| 800 | + url: "https://pub.flutter-io.cn" | ||
| 801 | + source: hosted | ||
| 802 | + version: "2.0.0" | ||
| 796 | scrollable_positioned_list: | 803 | scrollable_positioned_list: |
| 797 | dependency: "direct main" | 804 | dependency: "direct main" |
| 798 | description: | 805 | description: |
-
Please register or login to post a comment