From d6a09fc7d68805f90a1740566f06ead473fa950d Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Fri, 22 Jul 2022 17:52:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E5=8D=95=E4=BE=8B=E8=A1=A8=E6=BB=91?= =?UTF-8?q?=E5=8A=A8=E4=BC=98=E5=8C=96;=20=E5=95=86=E5=9F=8E=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=B1=95=E7=A4=BA=E6=94=B9=E7=80=91=E5=B8=83=E6=B5=81?= =?UTF-8?q?;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shopping_home/activity_banner.dart | 6 +- .../recommend_goods_list_view.dart | 274 ++++++++++-------- .../shopping/shopping_home/search_page.dart | 267 +++++++++-------- lib/store/store_order.dart | 9 +- lib/store/store_view/shop_goods.dart | 16 +- lib/store/store_view/store_order_list.dart | 51 ++-- lib/utils/flutter_utils.dart | 35 +++ pubspec.yaml | 2 +- 8 files changed, 372 insertions(+), 288 deletions(-) diff --git a/lib/store/shopping/shopping_home/activity_banner.dart b/lib/store/shopping/shopping_home/activity_banner.dart index d21cc490..4af6b558 100644 --- a/lib/store/shopping/shopping_home/activity_banner.dart +++ b/lib/store/shopping/shopping_home/activity_banner.dart @@ -38,7 +38,7 @@ class _ActivityBanner extends State { return Container( margin: EdgeInsets.only(bottom:10), child: AspectRatio( - aspectRatio: 1.27, + aspectRatio: 1.32, child: Swiper( viewportFraction: 0.9, scale: 0.7, @@ -77,7 +77,7 @@ class _ActivityBanner extends State { ) ), Container( - height: 143, + height: 145.h, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.vertical(bottom: Radius.circular(8)), @@ -85,7 +85,7 @@ class _ActivityBanner extends State { child: ListView.builder( scrollDirection: Axis.horizontal, physics: BouncingScrollPhysics(), - padding: EdgeInsets.symmetric(horizontal: 12), + padding: EdgeInsets.symmetric(horizontal: 12.w), itemCount:widget?.specialArea[position]?.productList?.length ?? 0, itemBuilder: (context, index) { return GestureDetector( diff --git a/lib/store/shopping/shopping_home/recommend_goods_list_view.dart b/lib/store/shopping/shopping_home/recommend_goods_list_view.dart index 9d294085..da79e81d 100644 --- a/lib/store/shopping/shopping_home/recommend_goods_list_view.dart +++ b/lib/store/shopping/shopping_home/recommend_goods_list_view.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:huixiang/retrofit/data/home_recommend_list.dart'; -import 'package:huixiang/retrofit/data/store_info.dart'; import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -47,43 +47,72 @@ class _RecommendGoodsListView extends State { width: 35.w, height: 5.h, ), - GridView.builder( - itemCount:widget.homeRecommendList == null ? 0 : widget.homeRecommendList.length, - padding: EdgeInsets.only( - left: 16.w, - right: 16.w, - top: 13.h, - bottom: 16.h, - ), + // GridView.builder( + // itemCount:widget.homeRecommendList == null ? 0 : widget.homeRecommendList.length, + // padding: EdgeInsets.only( + // left: 16.w, + // right: 16.w, + // top: 13.h, + // bottom: 16.h, + // ), + // shrinkWrap: true, + // physics: NeverScrollableScrollPhysics(), + // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + // //一行的Widget数量 + // crossAxisCount: 2, + // //水平子Widget之间间距 + // crossAxisSpacing: 11.w, + // //垂直子Widget之间间距 + // mainAxisSpacing: 16.w, + // //子Widget宽高比例 0.59 + // childAspectRatio: + // 185 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), + // ), + // itemBuilder: (context, index) { + // return GestureDetector( + // onTap: () { + // Navigator.of(context).pushNamed( + // '/router/shopping_goods_details', + // arguments: { + // "id":widget.homeRecommendList[index].id, + // "storeId":widget.storeId, + // "tenant":widget.tenant, + // }, + // ); + // }, + // child: goodsListItem(widget.homeRecommendList[index]), + // ); + // }, + // ), + StaggeredGridView.countBuilder( + crossAxisCount: 2, shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - //一行的Widget数量 - crossAxisCount: 2, - //水平子Widget之间间距 - crossAxisSpacing: 11.w, - //垂直子Widget之间间距 - mainAxisSpacing: 16.w, - //子Widget宽高比例 0.59 - childAspectRatio: - 185 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), - ), - itemBuilder: (context, index) { + itemCount: widget.homeRecommendList.length, + mainAxisSpacing: 8, + crossAxisSpacing: 8, + padding: EdgeInsets.all(16), + physics: BouncingScrollPhysics(), + // scrollDirection: Axis.vertical, + itemBuilder: (context, position) { return GestureDetector( - onTap: () { + onTap: (){ Navigator.of(context).pushNamed( '/router/shopping_goods_details', arguments: { - "id":widget.homeRecommendList[index].id, + "id":widget.homeRecommendList[position].id, "storeId":widget.storeId, "tenant":widget.tenant, }, ); }, - child: goodsListItem(widget.homeRecommendList[index]), + child: goodsListItem(widget.homeRecommendList[position]), ); }, - ) + staggeredTileBuilder: (position) { + // return StaggeredTile.count(1,position==0?1:1.2); + return StaggeredTile.fit(1); + }, + ), ], ); } @@ -91,9 +120,7 @@ class _RecommendGoodsListView extends State { Widget goodsListItem(HomeRecommendList homeRecommendList) { return Container( decoration: BoxDecoration( - borderRadius: BorderRadius.vertical( - top: Radius.circular(8), - ), + borderRadius: BorderRadius.circular(4), boxShadow: [ BoxShadow( color: Colors.black.withAlpha(10), @@ -110,117 +137,110 @@ class _RecommendGoodsListView extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(8), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(10), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ) - ], - ), + ClipRRect( child: - MImage( - homeRecommendList.imgs[0], - width: double.infinity, - height: 166, - fit: BoxFit.cover, - errorSrc: "assets/image/default_1.webp", - fadeSrc: "assets/image/default_1.webp", - ), + MImage( + homeRecommendList.imgs[0], + width: double.infinity, + height: 166, + fit: BoxFit.cover, + errorSrc: "assets/image/default_1.webp", + fadeSrc: "assets/image/default_1.webp", + ), + borderRadius: BorderRadius.vertical( + top: Radius.circular(4), + ), ), - Expanded( - child: Container( - padding: EdgeInsets.only(left: 12.w, right: 12.w), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Container( - margin: EdgeInsets.only(top: 8, right: 8), - padding: EdgeInsets.only(left: 2, right: 2), - height: 18.h, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: Color(0xFF5A5A5A), - ), - child: Text( - AppUtils.textSubStr(homeRecommendList?.supplierName ?? "",8), - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, - ), - ), + Container( + padding: EdgeInsets.only(left: 12.w, right: 12.w,bottom:15.h), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + margin: EdgeInsets.only(top: 8, right: 8), + padding: EdgeInsets.only(left: 2, right: 2), + height: 18.h, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: Color(0xFF5A5A5A), ), - Text( - "已售${homeRecommendList?.sellCount ?? 0}件", + child: Text( + AppUtils.textSubStr(homeRecommendList?.supplierName ?? "",8), style: TextStyle( - fontSize: 12.sp, + fontSize: 10.sp, fontWeight: MyFontWeight.regular, - color: Color(0xFF5D5D5D), + color: Colors.white, ), ), - ], - ), - Text( - homeRecommendList?.productName ?? "", - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF353535), ), + Text( + "已售${homeRecommendList?.sellCount ?? 0}件", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF5D5D5D), + ), + ), + ], + ), + SizedBox(height: 7.h,), + Text( + homeRecommendList?.productName ?? "", + // maxLines: 2, + // overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: 16.sp, + height: 1.2.h, + fontWeight: MyFontWeight.medium, + color: Color(0xFF353535), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "¥", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), + ), + SizedBox(height: 7.h,), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF32A060), ), - TextSpan( - text:homeRecommendList?.price ??"", - style: TextStyle( - fontSize: 18.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), + ), + TextSpan( + text:homeRecommendList?.price ??"", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF32A060), ), - ], - ), + ), + ], ), - Text( - "¥283.00", - style: TextStyle( - fontSize: 14.sp, - decoration: TextDecoration.lineThrough, - decorationColor: Color(0xFF585858), - fontWeight: MyFontWeight.regular, - color: Color(0xFFA2A2A2), - ), + ), + Text( + "¥283.00", + style: TextStyle( + fontSize: 14.sp, + decoration: TextDecoration.lineThrough, + decorationColor: Color(0xFF585858), + fontWeight: MyFontWeight.regular, + color: Color(0xFFA2A2A2), ), - ], - ), - ], - ), + ), + ], + ), + ], ), ) ], diff --git a/lib/store/shopping/shopping_home/search_page.dart b/lib/store/shopping/shopping_home/search_page.dart index 4e71b339..23f27ba8 100644 --- a/lib/store/shopping/shopping_home/search_page.dart +++ b/lib/store/shopping/shopping_home/search_page.dart @@ -2,6 +2,7 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; +import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/data/findMiNiGroupList.dart'; import 'package:huixiang/retrofit/min_api.dart'; @@ -644,7 +645,6 @@ class _SearchPage extends State // ), ], ), - SizedBox(height: 16.h), (productListBeans == null || productListBeans?.length == 0) ? NoDataView( src: "assets/image/ding_dan.webp", @@ -653,37 +653,66 @@ class _SearchPage extends State fontSize: 16.sp, margin: EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w), ) - : GridView.builder( - itemCount: productListBeans?.length ?? 0, - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - //一行的Widget数量 - crossAxisCount: 2, - //水平子Widget之间间距 - crossAxisSpacing: 11.w, - //垂直子Widget之间间距 - mainAxisSpacing: 16.w, - //子Widget宽高比例 0.59 - childAspectRatio: 185 / - (281 / 2 + (281 / 2) * AppUtils.textScale(context)), - ), - itemBuilder: (context, index) { - return GestureDetector( - onTap: () { - Navigator.of(context).pushNamed( - '/router/shopping_goods_details', - arguments: { - "id": productListBeans[index].id, - "storeId": widget.arguments["storeId"], - "tenant": widget.arguments["tenant"], - }, - ); - }, - child: searchListItem(productListBeans[index]), - ); - }, - ) + : + // GridView.builder( + // itemCount: productListBeans?.length ?? 0, + // shrinkWrap: true, + // physics: NeverScrollableScrollPhysics(), + // gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + // //一行的Widget数量 + // crossAxisCount: 2, + // //水平子Widget之间间距 + // crossAxisSpacing: 11.w, + // //垂直子Widget之间间距 + // mainAxisSpacing: 16.w, + // //子Widget宽高比例 0.59 + // childAspectRatio: 185 / + // (281 / 2 + (281 / 2) * AppUtils.textScale(context)), + // ), + // itemBuilder: (context, index) { + // return GestureDetector( + // onTap: () { + // Navigator.of(context).pushNamed( + // '/router/shopping_goods_details', + // arguments: { + // "id": productListBeans[index].id, + // "storeId": widget.arguments["storeId"], + // "tenant": widget.arguments["tenant"], + // }, + // ); + // }, + // child: searchListItem(productListBeans[index]), + // ); + // }, + // ) + StaggeredGridView.countBuilder( + crossAxisCount: 2, + shrinkWrap: true, + itemCount: productListBeans.length, + mainAxisSpacing: 8, + crossAxisSpacing: 8, + physics: BouncingScrollPhysics(), + // scrollDirection: Axis.vertical, + itemBuilder: (context, position) { + return GestureDetector( + onTap: (){ + Navigator.of(context).pushNamed( + '/router/shopping_goods_details', + arguments: { + "id": productListBeans[position].id, + "storeId": widget.arguments["storeId"], + "tenant": widget.arguments["tenant"], + }, + ); + }, + child: searchListItem(productListBeans[position]), + ); + }, + staggeredTileBuilder: (position) { + // return StaggeredTile.count(1,position==0?1:1.2); + return StaggeredTile.fit(1); + }, + ), ], ), ); @@ -709,19 +738,9 @@ class _SearchPage extends State child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha(10), - offset: Offset(0, 3), - blurRadius: 14, - spreadRadius: 0, - ) - ], - ), - child: MImage( + ClipRRect( + child: + MImage( productListBeans?.imgPath ?? "", width: double.infinity, height: 166, @@ -729,96 +748,98 @@ class _SearchPage extends State errorSrc: "assets/image/default_1.webp", fadeSrc: "assets/image/default_1.webp", ), + borderRadius: BorderRadius.vertical( + top: Radius.circular(4), + ), ), - Expanded( - child: Container( - padding: EdgeInsets.only(left: 8.w, right: 8.w), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceAround, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Container( - margin: EdgeInsets.only(top: 8, right: 8), - padding: EdgeInsets.only(left: 2, right: 2), - height: 18.h, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: Color(0xFF5A5A5A), - ), - child: Text( - AppUtils.textSubStr( productListBeans.supplierName ?? "",8), - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - color: Colors.white, - ), - ), + Container( + padding: EdgeInsets.only(left: 8.w, right: 8.w,bottom: 15.h), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Container( + margin: EdgeInsets.only(top: 8, right: 8), + padding: EdgeInsets.only(left: 2, right: 2), + height: 18.h, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: Color(0xFF5A5A5A), ), - Text( - "已售${productListBeans?.sellCount ?? 0}件", + child: Text( + AppUtils.textSubStr( productListBeans.supplierName ?? "",8), style: TextStyle( - fontSize: 12.sp, + fontSize: 10.sp, fontWeight: MyFontWeight.regular, - color: Color(0xFF5D5D5D), + color: Colors.white, ), ), - ], - ), - Text( - productListBeans?.productName ?? "", - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: 16.sp, - fontWeight: MyFontWeight.medium, - color: Color(0xFF353535), ), + Text( + "已售${productListBeans?.sellCount ?? 0}件", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + color: Color(0xFF5D5D5D), + ), + ), + ], + ), + SizedBox(height: 7.h,), + Text( + productListBeans?.productName ?? "", + style: TextStyle( + fontSize: 16.sp, + height: 1.2.h, + fontWeight: MyFontWeight.medium, + color: Color(0xFF353535), ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Text.rich( - TextSpan( - children: [ - TextSpan( - text: "¥", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), + ), + SizedBox(height: 7.h,), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Text.rich( + TextSpan( + children: [ + TextSpan( + text: "¥", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF32A060), ), - TextSpan( - text: productListBeans?.price ?? "", - style: TextStyle( - fontSize: 18.sp, - fontWeight: MyFontWeight.semi_bold, - color: Color(0xFF32A060), - ), + ), + TextSpan( + text: productListBeans?.price ?? "", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.semi_bold, + color: Color(0xFF32A060), ), - ], - ), + ), + ], ), - Text( - "¥283.00", - style: TextStyle( - fontSize: 14.sp, - decoration: TextDecoration.lineThrough, - decorationColor: Color(0xFF585858), - fontWeight: MyFontWeight.regular, - color: Color(0xFFA2A2A2), - ), + ), + Text( + "¥283.00", + style: TextStyle( + fontSize: 14.sp, + decoration: TextDecoration.lineThrough, + decorationColor: Color(0xFF585858), + fontWeight: MyFontWeight.regular, + color: Color(0xFFA2A2A2), ), - ], - ), - ], - ), + ), + ], + ), + ], ), ) ], diff --git a/lib/store/store_order.dart b/lib/store/store_order.dart index 0ec4ca31..ffc1c7f3 100644 --- a/lib/store/store_order.dart +++ b/lib/store/store_order.dart @@ -22,12 +22,14 @@ import 'package:huixiang/store/store_view/shop_car.dart'; import 'package:huixiang/store/store_view/store_activity.dart'; import 'package:huixiang/store/store_view/store_info.dart'; import 'package:huixiang/store/store_view/store_order_list.dart'; +import 'package:huixiang/utils/flutter_utils.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/custom_image.dart'; import 'package:huixiang/view_widget/my_tab.dart'; import 'package:huixiang/view_widget/receive_success.dart'; import 'package:huixiang/view_widget/round_button.dart'; +import 'package:intl/intl.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -498,7 +500,12 @@ class _StoreOrderPage extends State Spacer(), GestureDetector( onTap: () { - toDownOrder(); + if(AppUtils.compareTime(storeInfo.openStartTime,DateFormat('HH:mm:ss').format(DateTime.now())) + &&(!AppUtils.compareTime(storeInfo.openEndTime,DateFormat('HH:mm:ss').format(DateTime.now())))){ + toDownOrder(); + } + else + SmartDialog.showToast("营业时间:${storeInfo.openStartTime}-${storeInfo.openEndTime}", alignment: Alignment.center); }, child: RoundButton( width: 103.w, diff --git a/lib/store/store_view/shop_goods.dart b/lib/store/store_view/shop_goods.dart index b06ebb64..a706696e 100644 --- a/lib/store/store_view/shop_goods.dart +++ b/lib/store/store_view/shop_goods.dart @@ -42,8 +42,8 @@ class _ShopGoods extends State { padding: EdgeInsets.only( right: 16.w, // bottom: 20.h, - top: 10.h, ), + height: 120.h, child: Row( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, @@ -56,8 +56,8 @@ class _ShopGoods extends State { : (widget.shoppingCartSkuItemListBean != null ? widget.shoppingCartSkuItemListBean.skuImg : ""), - width: 70, - height: 70, + width: 70.h, + height: 70.h, radius: BorderRadius.circular(4), fit: BoxFit.cover, errorSrc: "assets/image/default_1.webp", @@ -103,7 +103,7 @@ class _ShopGoods extends State { ], ), SizedBox( - height: 2, + height: 2.h, ), Row( children: [ @@ -127,7 +127,7 @@ class _ShopGoods extends State { ], ), SizedBox( - height: 7, + height: 7.h, ), Row( children: [ @@ -195,7 +195,7 @@ class _ShopGoods extends State { visible: widget.count > 0, child: RoundButton( width: 17, - height: 17, + height: 17.h, text: "${widget.count}", textColor: Color(0xFF32A060), fontWeight: MyFontWeight.regular, @@ -216,7 +216,7 @@ class _ShopGoods extends State { child: Image.asset( "assets/image/reduce.webp", width: 22, - height: 22, + height: 22.h, ), ), if (widget.isShopCart || @@ -242,7 +242,7 @@ class _ShopGoods extends State { child: Image.asset( "assets/image/add.webp", width: 22, - height: 22, + height: 22.h, ), ), ], diff --git a/lib/store/store_view/store_order_list.dart b/lib/store/store_view/store_order_list.dart index 6966a8ad..081c2712 100644 --- a/lib/store/store_view/store_order_list.dart +++ b/lib/store/store_view/store_order_list.dart @@ -54,11 +54,13 @@ class _StoreOrderListPage extends State { List productListBeans = []; int currentIndex = 0; final ScrollController controller = ScrollController(); + double _viewportDimension = 0; @override void initState() { super.initState(); controller.addListener(() { + _viewportDimension = controller.position.viewportDimension; for (int i = 0; i < appletProducts.length; i++) { if (currentIndex != i && controller.offset >= appletProducts[i].goodsIndex && @@ -100,7 +102,7 @@ class _StoreOrderListPage extends State { double goodsIndex = 0; appletProducts.forEach((element) { element.goodsIndex = goodsIndex; - element.height = ((element.productList.length ?? 0) * 90.h + 76.h); + element.height = ((element.productList.length ?? 0) * 120.h + 50.h); goodsIndex += element.height; }); }); @@ -129,7 +131,7 @@ class _StoreOrderListPage extends State { // controller: controller, physics: BouncingScrollPhysics(), shrinkWrap: true, - padding: EdgeInsets.only(top: 0, bottom: 25), + padding: EdgeInsets.only(top: 0, bottom: 25.h), itemBuilder: (context, position) { return GestureDetector( onTap: () { @@ -146,7 +148,6 @@ class _StoreOrderListPage extends State { controller: controller, physics: BouncingScrollPhysics(), shrinkWrap: true, - padding: EdgeInsets.only(top: 0, bottom: 25), itemBuilder: (context, position) { return rightOrderItem(position); }, @@ -191,7 +192,7 @@ class _StoreOrderListPage extends State { Widget orderItem(int index) { int count = calculateItemCount(appletProducts[index]); return Container( - width: 100, + width: 100.w, child: GestureDetector( onTap: () { setState(() { @@ -199,6 +200,9 @@ class _StoreOrderListPage extends State { // productListBeans.clear(); // productListBeans.addAll(appletProducts[index].productList); controller.jumpTo(appletProducts[index].goodsIndex); + // controller.animateTo(appletProducts[index].goodsIndex, + // duration: Duration(milliseconds: 300), + // curve: Curves.ease); }); }, child: Stack( @@ -215,25 +219,22 @@ class _StoreOrderListPage extends State { if (currentIndex == index) Container( width: 2, - height: 17, + height: 17.h, color: Color(0xFF32A060), - margin: EdgeInsets.only(right: 10), + margin: EdgeInsets.only(right:10.w), ), - Expanded( - child: Text( - appletProducts[index].groupName, - textAlign: TextAlign.center, - style: TextStyle( - color: currentIndex != index - ? Color(0xFF4D4D4D) - : Color(0xFF000000), - fontSize: 12.sp, - fontWeight: currentIndex != index - ? MyFontWeight.medium : MyFontWeight.semi_bold , - ), + Expanded(child:Text( + appletProducts[index].groupName, + textAlign: TextAlign.center, + style: TextStyle( + color: currentIndex != index + ? Color(0xFF4D4D4D) + : Color(0xFF000000), + fontSize: 12.sp, + fontWeight: currentIndex != index + ? MyFontWeight.medium : MyFontWeight.semi_bold , ), - flex: 1, - ), + )), ], ), ), @@ -262,17 +263,17 @@ class _StoreOrderListPage extends State { Widget rightOrderItem(int rightIndex) { return Container( color: Colors.white, + margin: EdgeInsets.only(bottom: (rightIndex == appletProducts.length -1)?(_viewportDimension > appletProducts[rightIndex].height?_viewportDimension-appletProducts[rightIndex].height:30.h):0), padding: EdgeInsets.only( right: 16.w, - bottom: 30.h, - top: 10.h, ), child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ + SizedBox(height: 50.h,child: Padding( - padding: EdgeInsets.only(left: 16.w, bottom: 24.h), + padding: EdgeInsets.only(left: 16.w,top: 10.h), child: Text( appletProducts[rightIndex].groupName, textAlign: TextAlign.center, @@ -282,7 +283,7 @@ class _StoreOrderListPage extends State { fontWeight: MyFontWeight.semi_bold, ), ), - ), + ),), Column( children: appletProducts[rightIndex].productList.map((e) { return GestureDetector( @@ -298,7 +299,7 @@ class _StoreOrderListPage extends State { ); }).toList() ?? [], - ) + ), ], ), ); diff --git a/lib/utils/flutter_utils.dart b/lib/utils/flutter_utils.dart index 794d9694..4d6b7a61 100644 --- a/lib/utils/flutter_utils.dart +++ b/lib/utils/flutter_utils.dart @@ -239,4 +239,39 @@ class AppUtils { if (length < 0 || input.length < length) return input; return "${input.substring(0, length)}..."; } + + ///计算时间差/比较时间 + static bool compareTime(String time1, String time2) { + if (time1 == null || time2 == null) { + return false; + } + var time1List = time1.split(":"); + var time2List = time2.split(":"); + if (time1List.length != 3 || time2List.length != 3) { + return false; + } + var hour1 = int.parse(time1List[0]); + var hour2 = int.parse(time2List[0]); + var minute1 = int.parse(time1List[1]); + var minute2 = int.parse(time2List[1]); + var second1 = int.parse(time1List[2]); + var second2 = int.parse(time2List[2]); + if (hour1 > hour2) { + return false; + } else if (hour1 == hour2) { + if (minute1 > minute2) { + return false; + }else if (minute1 == minute2) { + if (second1 > second2) { + return false; + } else { + return true; + } + } else { + return true; + } + } else { + return true; + } + } } diff --git a/pubspec.yaml b/pubspec.yaml index 20ab8aa7..df8a9280 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: 一心回乡. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 2.0.35+23 +version: 2.0.36+24 environment: sdk: ">=2.7.0 <3.0.0"