From 8d1f3e08beca3575c575bfa0610df07f293b48ea Mon Sep 17 00:00:00 2001 From: fmk Date: Fri, 22 Oct 2021 19:21:43 +0800 Subject: [PATCH] safety --- lib/store/store_order.dart | 322 +++++++++++---------- lib/store/store_view/store_order_list.dart | 83 +++--- 2 files changed, 202 insertions(+), 203 deletions(-) diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 45348499..24ec32c6 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -43,7 +43,7 @@ class StoreOrderPage extends StatefulWidget { } class _StoreOrderPage extends State - with TickerProviderStateMixin /*, AutomaticKeepAliveClientMixin*/ { + with TickerProviderStateMixin { TabController tabcontroller; ApiService apiService; MinApiService minService; @@ -125,9 +125,7 @@ class _StoreOrderPage extends State await minService.getParentInfo("$tableId").catchError((error) { debugPrint(error); }); - if (baseData != null && baseData.isSuccess) { - - } + if (baseData != null && baseData.isSuccess) {} } ///获取桌子信息 @@ -164,6 +162,8 @@ class _StoreOrderPage extends State } } + RefreshController refreshController; + @override Widget build(BuildContext context) { return Stack( @@ -173,173 +173,181 @@ class _StoreOrderPage extends State right: 0, top: 0, bottom: 54.h, - child: DefaultTabController( - length: 2, - child: NestedScrollView( - controller: controller, - dragStartBehavior: DragStartBehavior.start, - physics: BouncingScrollPhysics(), - headerSliverBuilder: - (BuildContext context, bool innerBoxIsScrolled) { - return [ - SliverOverlapAbsorber( - handle: NestedScrollView.sliverOverlapAbsorberHandleFor( - context), - sliver: SliverAppBar( - expandedHeight: - (storeInfo != null && storeInfo.couponVOList != null) - ? 470.h - : 365.h, - floating: false, - snap: false, - pinned: true, - stretch: false, - brightness: Brightness.light, - leading: GestureDetector( - onTap: () { - Navigator.of(context).pop(); - }, - child: Container( - alignment: Alignment.centerRight, - margin: EdgeInsets.only(left: 10), - padding: EdgeInsets.all(6), - child: Icon( - Icons.arrow_back_ios, - color: Colors.black, - size: 24, - ), + child: NestedScrollView( + controller: controller, + dragStartBehavior: DragStartBehavior.start, + physics: BouncingScrollPhysics(), + headerSliverBuilder: (BuildContext context, bool innerScrolled) { + return [ + SliverOverlapAbsorber( + handle: NestedScrollView.sliverOverlapAbsorberHandleFor( + context), + sliver: SliverAppBar( + expandedHeight: + (storeInfo != null && storeInfo.couponVOList != null) + ? 470.h + : 365.h, + floating: false, + snap: false, + pinned: true, + stretch: false, + brightness: Brightness.light, + leading: GestureDetector( + onTap: () { + Navigator.of(context).pop(); + }, + child: Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.only(left: 10), + padding: EdgeInsets.all(6), + child: Icon( + Icons.arrow_back_ios, + color: Colors.black, + size: 24, ), ), - flexibleSpace: FlexibleSpaceBar( - title: Title( - controller, - storeInfo != null ? storeInfo.storeName : '', - ), - collapseMode: CollapseMode.pin, - stretchModes: [ - StretchMode.zoomBackground, - StretchMode.fadeTitle, - StretchMode.blurBackground, - ], - background: Stack( - children: [ - Positioned( + ), + flexibleSpace: FlexibleSpaceBar( + title: Title( + controller, + storeInfo != null ? storeInfo.storeName : '', + ), + collapseMode: CollapseMode.pin, + stretchModes: [ + StretchMode.zoomBackground, + StretchMode.fadeTitle, + StretchMode.blurBackground, + ], + background: Stack( + children: [ + Positioned( + child: Column( + children: [ + buildSwiper(), + Expanded( + child: Container( + color: Colors.transparent, + ), + flex: 1, + ), + ], + ), + top: 0, + bottom: 0, + left: 0, + right: 0, + ), + Positioned( + child: Container( child: Column( children: [ - buildSwiper(), - Expanded( - child: Container( - color: Colors.transparent, + ///门店信息 + StoreInfoView(storeInfo), + + ///门店对应优惠券 + if (storeInfo != null && + storeInfo.couponVOList != null) + UnionCoupon( + storeInfo, + _receiveCoupon, + coupon: true, ), - flex: 1, - ), + + if (storeInfo == null || + storeInfo.couponVOList == null) + SizedBox( + height: 8, + ), + + ///门店对应VIP信息 + Vip(storeInfo, () {}, false), ], ), - top: 0, - bottom: 0, - left: 0, - right: 0, - ), - Positioned( - child: Container( - child: Column( - children: [ - ///门店信息 - StoreInfoView(storeInfo), - - ///门店对应优惠券 - if (storeInfo != null && - storeInfo.couponVOList != null) - UnionCoupon( - storeInfo, - _receiveCoupon, - coupon: true, - ), - - if (storeInfo == null || - storeInfo.couponVOList == null) - SizedBox( - height: 8, - ), - - ///门店对应VIP信息 - Vip(storeInfo, () {}, false), - ], - ), - ), - top: 110.h, - bottom: 0, - left: 0, - right: 0, ), - ], - ), + top: 110.h, + bottom: 0, + left: 0, + right: 0, + ), + ], ), - backgroundColor: Color(0x33FAFAFA), - centerTitle: false, - elevation: 0, - bottom: PreferredSize( - preferredSize: Size( - MediaQuery.of(context).size.width, - 38, - ), - child: Container( - padding: EdgeInsets.symmetric(horizontal: 10.w), - width: MediaQuery.of(context).size.width, - child: TabBar( - controller: tabcontroller, - automaticIndicatorColorAdjustment: true, - isScrollable: true, - indicatorWeight: 1, - indicatorColor: Color(0xFFFAFAFA), - labelPadding: EdgeInsets.only( - left: 8.w, - right: 8.w, - ), - indicatorSize: TabBarIndicatorSize.label, - unselectedLabelStyle: TextStyle( - fontSize: 15.sp, - fontWeight: FontWeight.w400, - ), - labelStyle: TextStyle( - color: Colors.black, - fontSize: 18.sp, - fontWeight: FontWeight.bold, - ), - labelColor: Colors.black, - tabs: [ - MyTab(text: S.of(context).diancan), - MyTab(text: S.of(context).xindianhuodong), - ], + ), + backgroundColor: Color(0x33FAFAFA), + centerTitle: false, + elevation: 0, + bottom: PreferredSize( + preferredSize: Size( + MediaQuery.of(context).size.width, + 38, + ), + child: Container( + padding: EdgeInsets.symmetric(horizontal: 10.w), + width: MediaQuery.of(context).size.width, + child: TabBar( + controller: tabcontroller, + automaticIndicatorColorAdjustment: true, + isScrollable: true, + indicatorWeight: 1, + indicatorColor: Color(0xFFFAFAFA), + labelPadding: EdgeInsets.only( + left: 8.w, + right: 8.w, + ), + indicatorSize: TabBarIndicatorSize.label, + unselectedLabelStyle: TextStyle( + fontSize: 15.sp, + fontWeight: FontWeight.w400, + ), + labelStyle: TextStyle( + color: Colors.black, + fontSize: 18.sp, + fontWeight: FontWeight.bold, ), + labelColor: Colors.black, + tabs: [ + MyTab(text: S.of(context).diancan), + MyTab(text: S.of(context).xindianhuodong), + ], ), ), ), ), - ]; - }, - body: TabBarView( - physics: BouncingScrollPhysics(), - children: [ - StoreOrderListPage( - widget.arguments, - activitys, - storeInfo, - shopCarGoods, - controller, - _queryMiNiDetail, - ), + ), + ]; + }, + body: TabBarView( + physics: NeverScrollableScrollPhysics(), + children: [ + ///点餐 + StoreOrderListPage( + widget.arguments, + activitys, + storeInfo, + shopCarGoods, + controller, + _queryMiNiDetail, + ), - ///星店活动, - StoreActivity( - widget.arguments, - activitys, - ), - ], - controller: tabcontroller, - ), + ///星店活动, + StoreActivity( + widget.arguments, + activitys, + ), + ], + controller: tabcontroller, ), - ), + ),/*SmartRefresher( + controller: refreshController = + RefreshController(initialRefresh: false), + enablePullDown: true, + enablePullUp: false, + header: MyHeader(), + physics: BouncingScrollPhysics(), + onRefresh: () { + queryStoreInfo(); + }, + child: + ),*/ ), Positioned( bottom: 0, @@ -446,9 +454,11 @@ class _StoreOrderPage extends State ); } + ///显示选择人数的弹窗 showPeopleNum(String tableName) async { var people = await showDialog( context: context, + barrierDismissible: false, builder: (context) { return PeopleNumView(tableName); }, @@ -458,6 +468,8 @@ class _StoreOrderPage extends State setState(() { this.numberOfPeople = people; }); + } else { + Navigator.of(context).pop(); } } diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 99dc71ff..07f8fa29 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -70,10 +70,10 @@ class _StoreOrderListPage extends State { await minService.findMiNiGroupList({ "id": widget.arguments["id"], }).catchError((error) { - refreshController.refreshFailed(); + // refreshController.refreshFailed(); }); if (baseData != null && baseData.isSuccess) { - refreshController.refreshCompleted(); + // refreshController.refreshCompleted(); setState(() { appletProducts = baseData.data; productListBeans.clear(); @@ -81,11 +81,11 @@ class _StoreOrderListPage extends State { productListBeans.addAll(appletProducts[isSelected].productList); }); } else { - refreshController.refreshFailed(); + // refreshController.refreshFailed(); } } - RefreshController refreshController; + // RefreshController refreshController; @override Widget build(BuildContext context) { @@ -95,51 +95,38 @@ class _StoreOrderListPage extends State { margin: EdgeInsets.only( top: (MediaQuery.of(context).padding.top + 38 + kToolbarHeight), ), - child: SmartRefresher( - controller: refreshController = - RefreshController(initialRefresh: false), - enablePullDown: true, - enablePullUp: false, - header: MyHeader(), - physics: BouncingScrollPhysics(), - onRefresh: () { - appletGoods(); - }, - child: SingleChildScrollView( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: [ - Container( - width: 100.w, - child: ListView.builder( - itemCount: appletProducts == null ? 0 : appletProducts.length, - controller: controller1, - physics: BouncingScrollPhysics(), - shrinkWrap: true, - padding: EdgeInsets.only(top: 0, bottom: 25), - itemBuilder: (context, position) { - return orderItem(appletProducts[position], position); - }, - ), - ), - Container( - width: MediaQuery.of(context).size.width - 100.w, - child: ListView.builder( - itemCount: - productListBeans == null ? 0 : productListBeans.length, - physics: BouncingScrollPhysics(), - shrinkWrap: true, - padding: EdgeInsets.zero, - itemBuilder: (context, position) { - return goodsItem(position); - }, - ), - ), - ], + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: [ + Container( + width: 100.w, + child: ListView.builder( + itemCount: appletProducts == null ? 0 : appletProducts.length, + controller: controller1, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.only(top: 0, bottom: 25), + itemBuilder: (context, position) { + return orderItem(appletProducts[position], position); + }, + ), ), - ), + Container( + width: MediaQuery.of(context).size.width - 100.w, + child: ListView.builder( + itemCount: + productListBeans == null ? 0 : productListBeans.length, + physics: BouncingScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.zero, + itemBuilder: (context, position) { + return goodsItem(position); + }, + ), + ), + ], ), ); }