From 1a5dff9efd41550d5adab5771678f9f0e2e46da3 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 28 Oct 2020 21:34:09 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E8=B7=B3=E8=BD=AC=E7=BA=A2=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/setting_page/setting_page.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/pages/setting_page/setting_page.dart b/lib/pages/setting_page/setting_page.dart index 8673b521..dfa5d78a 100644 --- a/lib/pages/setting_page/setting_page.dart +++ b/lib/pages/setting_page/setting_page.dart @@ -249,14 +249,15 @@ class _SettingPageState extends State { ), ), onPressed: () { - Navigator.popUntil(context, (route) { - return !Navigator.canPop(context); - }); - Navigator.pushReplacement( - context, - CupertinoPageRoute( - builder: (context) => SignInPage(), - )); + // Navigator.popUntil(context, (route) { + // return !Navigator.canPop(context); + // }); + // Navigator.pushReplacement( + // context, + // CupertinoPageRoute( + // builder: (context) => SignInPage(), + // )); + ARoute.push(context, SignInPage()); }, ), ], From 0051648ce410bca0a89bb7979252f8d28bcad66c Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 28 Oct 2020 22:19:37 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=95=E9=80=89?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=A4=8D=E5=88=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/provider/cart.dart | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/provider/cart.dart b/lib/provider/cart.dart index 4c5e7b6b..97e17af1 100644 --- a/lib/provider/cart.dart +++ b/lib/provider/cart.dart @@ -110,21 +110,22 @@ class CartProvidde with ChangeNotifier { ///单选商品 changeCheckState(AkuShopModel cartItem) async { - SharedPreferences prefs = await SharedPreferences.getInstance(); - cartString = prefs.getString("cartInfo"); - List tempList = (json.decode(cartString.toString()) as List).cast(); - int tempIndex = 0; - int changeIndex = 0; - tempList.forEach((item) { - if (item["itemid"] == cartItem.itemid) { - changeIndex = tempIndex; - } - tempIndex++; - }); - tempList[changeIndex] = cartItem.toJson(); - cartString = json.encode(tempList).toString(); - prefs.setString("cartInfo", cartString); - await getCartInfo(); + // SharedPreferences prefs = await SharedPreferences.getInstance(); + // cartString = prefs.getString("cartInfo"); + // List tempList = (json.decode(cartString.toString()) as List).cast(); + // int tempIndex = 0; + // int changeIndex = 0; + // tempList.forEach((item) { + // if (item["itemid"] == cartItem.itemid) { + // changeIndex = tempIndex; + // } + // tempIndex++; + // }); + // tempList[changeIndex] = cartItem.toJson(); + // cartString = json.encode(tempList).toString(); + // prefs.setString("cartInfo", cartString); + // await getCartInfo(); + notifyListeners(); } ///全选商品 From d79a767978f388c4a122829ad5750e6f40443abe Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Wed, 28 Oct 2020 23:53:20 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=8E=A8=E8=8D=90=E7=90=86=E7=94=B1?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/goods_details/widget/product_content.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/goods_details/widget/product_content.dart b/lib/pages/goods_details/widget/product_content.dart index cc29e95e..9ec09968 100644 --- a/lib/pages/goods_details/widget/product_content.dart +++ b/lib/pages/goods_details/widget/product_content.dart @@ -150,7 +150,7 @@ class ProductContent extends StatelessWidget { Positioned _positionedRecommend() { return Positioned( right: ScreenUtil().setWidth(453), - top: ScreenUtil().setWidth(252), + bottom: 100.w, child: Row( children: [ Icon( From 68dc58901fd49dd1a033cc70a6c48ccbc5ebfc0e Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Thu, 29 Oct 2020 11:46:20 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=85=A8?= =?UTF-8?q?=E9=80=89=EF=BC=8C=E6=80=BB=E4=BB=B7=E5=8F=8A=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E4=B8=AA=E6=95=B0=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../market_cart_page/market_cart_page.dart | 329 +++++++++++++++++- .../widget/market_cart_bottom_bar.dart | 107 ------ .../widget/market_cart_card.dart | 225 ------------ lib/provider/cart.dart | 3 +- 4 files changed, 315 insertions(+), 349 deletions(-) delete mode 100644 lib/pages/market/market_cart_page/widget/market_cart_bottom_bar.dart delete mode 100644 lib/pages/market/market_cart_page/widget/market_cart_card.dart diff --git a/lib/pages/market/market_cart_page/market_cart_page.dart b/lib/pages/market/market_cart_page/market_cart_page.dart index 044c20e4..28172f65 100644 --- a/lib/pages/market/market_cart_page/market_cart_page.dart +++ b/lib/pages/market/market_cart_page/market_cart_page.dart @@ -1,15 +1,96 @@ +import 'package:akuCommunity/model/aku_shop_class_model.dart'; +import 'package:akuCommunity/model/aku_shop_model.dart'; +import 'package:akuCommunity/utils/screenutil.dart'; +import 'package:akuCommunity/widget/cached_image_wrapper.dart'; +import 'package:akuCommunity/widget/cart_count.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; +import 'package:flutter_slidable/flutter_slidable.dart'; import 'package:provider/provider.dart'; import 'package:akuCommunity/provider/cart.dart'; -import 'package:akuCommunity/routers/page_routers.dart'; -import 'package:akuCommunity/model/aku_shop_model.dart'; import 'widget/market_cart_app_bar.dart'; -import 'widget/market_cart_card.dart'; -import 'widget/market_cart_bottom_bar.dart'; -class MarketCartPage extends StatelessWidget { - MarketCartPage({Key key}) : super(key: key); +class MarketCartPage extends StatefulWidget { + final AkuShopModel cartItem; + + MarketCartPage({Key key, this.cartItem}) : super(key: key); + + @override + _MarketCartPageState createState() => _MarketCartPageState(); +} + +class _MarketCartPageState extends State { + Widget _cardRadio( + BuildContext context, AkuShopModel cartItem, CartProvidde model,index) { + return InkWell( + onTap: () { + setState(() { + cartItem.isCheck = !cartItem.isCheck; + int _goods = shopList.indexWhere( + (element) => element.itemid == _cartList[index].itemid); + _goods > -1 + ? shopList.removeAt(_goods) + : shopList.add(_cartList[index]); + print(shopList); + }); + }, + child: Container( + alignment: Alignment.center, + child: Icon( + Icons.check_circle, + color: cartItem.isCheck ? Color(0xffdb0000) : Color(0xff999999), + size: Screenutil.length(36), + ), + ), + ); + } + + Widget _image(String imagePath) { + return Container( + margin: EdgeInsets.symmetric(horizontal: Screenutil.length(20)), + child: ClipRRect( + borderRadius: BorderRadius.all(Radius.circular(2)), + child: CachedImageWrapper( + url: imagePath, + width: Screenutil.length(180), + height: Screenutil.length(180), + ), + ), + ); + } + + Widget _content(String content, specs, price) { + return Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: Screenutil.length(394), + child: Text( + content, + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle( + fontSize: Screenutil.size(24), + color: Color(0xff333333), + ), + ), + ), + Container( + margin: EdgeInsets.only(top: Screenutil.length(40)), + child: Text( + '¥${price}', + style: TextStyle( + fontSize: Screenutil.size(28), + color: Color(0xffe60e0e), + ), + ), + ), + ], + ), + ); + } // List> _listGoods = [ // { // 'imagePath': @@ -108,36 +189,252 @@ class MarketCartPage extends StatelessWidget { // // isAll = !isAll; // // }); // } + List shopList = []; + bool get _selectALl { + for (var element in _cartList) { + int _selectGoods = + shopList.indexWhere((index) => element.itemid == index.itemid); + if (_selectGoods == -1) return false; + } + return true; + } + + double get _allprice{ + double _price=0; + for(var element in shopList){ + _price+=double.parse(element.itemprice)*element.count; + } + return _price; + } + int get _goodsCount=>shopList.length; + + List _cartList; + Future _getCartInfo(BuildContext context) async { - await Provider.of(context, listen: false).getCartInfo(); + await Provider.of(context, listen: true).getCartInfo(); return 'end'; } + Widget _selectAll(CartProvidde model,) { + return InkWell( + onTap: () { + for(var element in _cartList){ + element.isCheck=!element.isCheck; + } + model.changeALlCheckState(true); + setState(() { + if (_selectALl == true) + shopList.clear(); + else { + shopList.clear(); + shopList.addAll(_cartList); + } + }); + }, + child: Container( + margin: EdgeInsets.symmetric(vertical: Screenutil.length(29)), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Icon( + _selectALl + ? Icons.radio_button_checked + : Icons.radio_button_unchecked, + color: model.isAllCheck ? Color(0xffdb0000) : Color(0xff999999), + size: Screenutil.length(40), + ), + Container( + margin: EdgeInsets.only(left: Screenutil.length(18)), + child: Text( + '全选', + style: TextStyle( + fontSize: Screenutil.size(28), + color: Color(0xff333333), + ), + ), + ), + ], + ), + ), + ); + } + + Widget _settlement(CartProvidde model, BuildContext context) { + return Row( + children: [ + model.allPrice != null + ? Container( + margin: EdgeInsets.only(right: Screenutil.length(10)), + child: Text( + '合计:¥${_allprice.toStringAsFixed(2)}', + style: TextStyle( + fontSize: Screenutil.size(28), + color: Color(0xffe60e0e), + ), + ), + ) + : SizedBox(), + InkWell( + onTap: model.allGoodsCount != 0 ? () {} : null, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + color: model.allGoodsCount != 0 + ? Color(0xffffc40c) + : Color(0xffd8d8d8), + borderRadius: BorderRadius.all(Radius.circular(30)), + ), + width: Screenutil.length(198), + margin: EdgeInsets.symmetric(vertical: Screenutil.length(16)), + padding: EdgeInsets.symmetric(vertical: Screenutil.length(12)), + child: Text( + '结算(${_goodsCount})', + style: TextStyle( + fontSize: Screenutil.size(30), + color: + model.allGoodsCount != 0 ? Color(0xff333333) : Colors.white, + ), + ), + ), + ), + ], + ); + } + + Widget _marketCartCard(AkuShopModel cartItem,index) { + return Consumer(builder: (context, model, child) { + return Container( + margin: EdgeInsets.only( + top: Screenutil.length(20), + left: Screenutil.length(32), + right: Screenutil.length(32), + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(6)), + ), + child: Slidable.builder( + actionPane: SlidableBehindActionPane(), + actionExtentRatio: 0.25, + secondaryActionDelegate: SlideActionBuilderDelegate( + actionCount: 2, + builder: (context, index, animation, renderingMode) { + if (index == 0) { + return SlideAction( + child: Text( + '移至收藏夹', + style: TextStyle( + fontSize: Screenutil.size(28), color: Colors.white), + ), + color: renderingMode == SlidableRenderingMode.slide + ? Color(0xffffc40c).withOpacity(animation.value) + : Color(0xffffc40c), + // onTap: () => _showSnackBar(context, 'More'), + closeOnTap: false, + ); + } else { + return SlideAction( + onTap: () { + model.deleteGoods(cartItem.itemid); + }, + decoration: BoxDecoration( + color: renderingMode == SlidableRenderingMode.slide + ? Color(0xffe60e0e).withOpacity(animation.value) + : Color(0xffe60e0e), + borderRadius: BorderRadius.only( + topRight: Radius.circular(6), + bottomRight: Radius.circular(6), + ), + ), + child: Text( + '删除', + style: TextStyle( + fontSize: Screenutil.size(28), color: Colors.white), + ), + // onTap: () => _showSnackBar(context, 'Delete'), + ); + } + }, + ), + child: Container( + color: Colors.white, + padding: EdgeInsets.only( + top: Screenutil.length(30), + left: Screenutil.length(15), + bottom: Screenutil.length(37), + ), + child: Stack( + children: [ + Row( + children: [ + _cardRadio(context, cartItem, model,index), + _image(cartItem.itempic), + _content(cartItem.itemtitle, '默认', cartItem.itemprice), + ], + ), + Positioned( + bottom: 0, + right: Screenutil.length(16), + child: CartCount( + cartItem: cartItem, + // goodsNum: widget.goodsNum, + // index: widget.index, + // reduce: widget.reduce, + // add: widget.add, + ), + ), + ], + ), + ), + ), + ); + }); + } + @override Widget build(BuildContext context) { return Scaffold( appBar: PreferredSize( - child: MarketCartAppBar(), preferredSize: Size.fromHeight(kToolbarHeight), + child: MarketCartAppBar(), ), + bottomNavigationBar: + Consumer(builder: (context, model, child) { + return Container( + color: Colors.white, + height: Screenutil.length(98), + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.symmetric(horizontal: Screenutil.length(32)), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _selectAll(model), + _settlement( + model, + context, + ) + ], + ), + ); + }), body: Stack( children: [ Consumer( builder: (context, model, child) { - List cartList = model.cartList; + List cartList = model.cartList; + _cartList = model.cartList; return ListView.builder( itemCount: cartList.length, itemBuilder: (BuildContext context, int index) { - return MarketCartCard( - cartItem: cartList[index], - ); + return _marketCartCard(cartList[index],index); }); }, ), - Positioned( - bottom: 0, - child: MarketCartBottomBar(), - ), + // Positioned( + // bottom: 0, + // child: MarketCartBottomBar( + // selectAll: _selectALl, + // ), + // ), ], )); } diff --git a/lib/pages/market/market_cart_page/widget/market_cart_bottom_bar.dart b/lib/pages/market/market_cart_page/widget/market_cart_bottom_bar.dart deleted file mode 100644 index ec530d4b..00000000 --- a/lib/pages/market/market_cart_page/widget/market_cart_bottom_bar.dart +++ /dev/null @@ -1,107 +0,0 @@ - -import 'package:akuCommunity/pages/confirm_order_page/confirm_order_page.dart'; -import 'package:akuCommunity/routers/page_routers.dart'; -import 'package:ani_route/ani_route.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:provider/provider.dart'; -import 'package:akuCommunity/utils/screenutil.dart'; -import 'package:akuCommunity/provider/cart.dart'; - -class MarketCartBottomBar extends StatelessWidget { - const MarketCartBottomBar({Key key}) : super(key: key); - - Widget _selectAll(CartProvidde model) { - return InkWell( - onTap: () { - model.changeALlCheckState(!model.isAllCheck); - }, - child: Container( - margin: EdgeInsets.symmetric(vertical: Screenutil.length(29)), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Icon( - model.isAllCheck - ? Icons.radio_button_checked - : Icons.radio_button_unchecked, - color: model.isAllCheck ? Color(0xffdb0000) : Color(0xff999999), - size: Screenutil.length(40), - ), - Container( - margin: EdgeInsets.only(left: Screenutil.length(18)), - child: Text( - '全选', - style: TextStyle( - fontSize: Screenutil.size(28), - color: Color(0xff333333), - ), - ), - ), - ], - ), - ), - ); - } - - Widget _settlement(CartProvidde model,BuildContext context) { - return Row( - children: [ - model.allPrice != 0 - ? Container( - margin: EdgeInsets.only(right: Screenutil.length(10)), - child: Text( - '合计:¥${model.allPrice.toStringAsFixed(2)}', - style: TextStyle( - fontSize: Screenutil.size(28), - color: Color(0xffe60e0e), - ), - ), - ) - : SizedBox(), - InkWell( - onTap: model.allGoodsCount != 0 ? () {} : null, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - color: model.allGoodsCount != 0 - ? Color(0xffffc40c) - : Color(0xffd8d8d8), - borderRadius: BorderRadius.all(Radius.circular(30)), - ), - width: Screenutil.length(198), - margin: EdgeInsets.symmetric(vertical: Screenutil.length(16)), - padding: EdgeInsets.symmetric(vertical: Screenutil.length(12)), - child: Text( - '结算(${model.allGoodsCount})', - style: TextStyle( - fontSize: Screenutil.size(30), - color: - model.allGoodsCount != 0 ? Color(0xff333333) : Colors.white, - ), - ), - ), - ), - ], - ); - } - - @override - Widget build(BuildContext context) { - return Consumer(builder: (context, model, child) { - return Container( - color: Colors.white, - height: Screenutil.length(98), - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.symmetric(horizontal: Screenutil.length(32)), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - _selectAll(model), - _settlement(model,context,) - ], - ), - ); - }); - } -} diff --git a/lib/pages/market/market_cart_page/widget/market_cart_card.dart b/lib/pages/market/market_cart_page/widget/market_cart_card.dart deleted file mode 100644 index f0f1b831..00000000 --- a/lib/pages/market/market_cart_page/widget/market_cart_card.dart +++ /dev/null @@ -1,225 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:flutter_icons/flutter_icons.dart'; -import 'package:flutter_slidable/flutter_slidable.dart'; -import 'package:akuCommunity/widget/cached_image_wrapper.dart'; -import 'package:akuCommunity/widget/cart_count.dart'; -import 'package:akuCommunity/utils/screenutil.dart'; -import 'package:akuCommunity/widget/goods_specs_sheet.dart'; -import 'package:akuCommunity/model/aku_shop_model.dart'; -import 'package:provider/provider.dart'; -import 'package:akuCommunity/provider/cart.dart'; - -class MarketCartCard extends StatelessWidget { - final AkuShopModel cartItem; - MarketCartCard({Key key, this.cartItem}) : super(key: key); - - void _showGoodsSpecsSheet() { - // showModalBottomSheet( - // isScrollControlled: true, - // context: context, - // backgroundColor: Colors.white, - // builder: (context) { - // return GoodsSpecsSheet( - // goodsNum: widget.goodsNum, - // index: widget.index, - // reduce: widget.reduce, - // add: widget.add, - // ); - // }, - // ); - } - - Widget _cardRadio( - BuildContext context, AkuShopModel cartItem, CartProvidde model) { - return InkWell( - onTap: () { - cartItem.isCheck = !cartItem.isCheck; - model.changeCheckState(cartItem); - }, - child: Container( - alignment: Alignment.center, - child: Icon( - Icons.check_circle, - color: cartItem.isCheck ? Color(0xffdb0000) : Color(0xff999999), - size: Screenutil.length(36), - ), - ), - ); - } - - Widget _image(String imagePath) { - return Container( - margin: EdgeInsets.symmetric(horizontal: Screenutil.length(20)), - child: ClipRRect( - borderRadius: BorderRadius.all(Radius.circular(2)), - child: CachedImageWrapper( - url: imagePath, - width: Screenutil.length(180), - height: Screenutil.length(180), - ), - ), - ); - } - - Widget _content(String content, specs, price) { - return Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: Screenutil.length(394), - child: Text( - content, - maxLines: 2, - overflow: TextOverflow.ellipsis, - style: TextStyle( - fontSize: Screenutil.size(24), - color: Color(0xff333333), - ), - ), - ), - // InkWell( - // onTap: _showGoodsSpecsSheet, - // child: Container( - // margin: EdgeInsets.only(top: Screenutil.length(10)), - // padding: EdgeInsets.symmetric( - // vertical: Screenutil.length(5), - // horizontal: Screenutil.length(19), - // ), - // alignment: Alignment.center, - // decoration: BoxDecoration( - // color: Color(0xfff5f5f5), - // border: Border.all(color: Color(0xffd3d3d3), width: 0.5), - // borderRadius: BorderRadius.all(Radius.circular(15)), - // ), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.center, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // Text( - // specs, - // style: TextStyle( - // fontSize: Screenutil.size(18), - // color: Color(0xff333333), - // ), - // ), - // Container( - // alignment: Alignment.center, - // margin: EdgeInsets.only(left: Screenutil.length(16)), - // child: Icon( - // AntDesign.down, - // color: Color(0xff333333), - // size: Screenutil.size(22), - // ), - // ), - // ], - // ), - // ), - // ), - Container( - margin: EdgeInsets.only(top: Screenutil.length(40)), - child: Text( - '¥${price}', - style: TextStyle( - fontSize: Screenutil.size(28), - color: Color(0xffe60e0e), - ), - ), - ), - ], - ), - ); - } - - @override - Widget build(BuildContext context) { - return Consumer(builder: (context, model, child) { - return Container( - margin: EdgeInsets.only( - top: Screenutil.length(20), - left: Screenutil.length(32), - right: Screenutil.length(32), - ), - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(6)), - ), - child: Slidable.builder( - actionPane: SlidableBehindActionPane(), - actionExtentRatio: 0.25, - secondaryActionDelegate: SlideActionBuilderDelegate( - actionCount: 2, - builder: (context, index, animation, renderingMode) { - if (index == 0) { - return SlideAction( - child: Text( - '移至收藏夹', - style: TextStyle( - fontSize: Screenutil.size(28), color: Colors.white), - ), - color: renderingMode == SlidableRenderingMode.slide - ? Color(0xffffc40c).withOpacity(animation.value) - : Color(0xffffc40c), - // onTap: () => _showSnackBar(context, 'More'), - closeOnTap: false, - ); - } else { - return SlideAction( - onTap: () { - model.deleteGoods(cartItem.itemid); - }, - decoration: BoxDecoration( - color: renderingMode == SlidableRenderingMode.slide - ? Color(0xffe60e0e).withOpacity(animation.value) - : Color(0xffe60e0e), - borderRadius: BorderRadius.only( - topRight: Radius.circular(6), - bottomRight: Radius.circular(6), - ), - ), - child: Text( - '删除', - style: TextStyle( - fontSize: Screenutil.size(28), color: Colors.white), - ), - // onTap: () => _showSnackBar(context, 'Delete'), - ); - } - }, - ), - child: Container( - color: Colors.white, - padding: EdgeInsets.only( - top: Screenutil.length(30), - left: Screenutil.length(15), - bottom: Screenutil.length(37), - ), - child: Stack( - children: [ - Row( - children: [ - _cardRadio(context, cartItem, model), - _image(cartItem.itempic), - _content(cartItem.itemtitle, '默认', cartItem.itemprice), - ], - ), - Positioned( - bottom: 0, - right: Screenutil.length(16), - child: CartCount( - cartItem: cartItem, - // goodsNum: widget.goodsNum, - // index: widget.index, - // reduce: widget.reduce, - // add: widget.add, - ), - ), - ], - ), - ), - ), - ); - }); - } -} diff --git a/lib/provider/cart.dart b/lib/provider/cart.dart index 97e17af1..a634e3dd 100644 --- a/lib/provider/cart.dart +++ b/lib/provider/cart.dart @@ -141,7 +141,8 @@ class CartProvidde with ChangeNotifier { }); cartString = json.encode(newList).toString(); prefs.setString("cartInfo", cartString); - await getCartInfo(); + // await getCartInfo(); + notifyListeners(); } ///商品数量加减 From 8777517b13201b6c82d62c6a236dac6cc5666f3b Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Thu, 29 Oct 2020 12:00:52 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=A8=E9=80=89bug?= =?UTF-8?q?=EF=BC=8C=E7=89=88=E6=9C=AC=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../market_cart_page/market_cart_page.dart | 29 ++++++++++--------- pubspec.yaml | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/pages/market/market_cart_page/market_cart_page.dart b/lib/pages/market/market_cart_page/market_cart_page.dart index 28172f65..dfaab33b 100644 --- a/lib/pages/market/market_cart_page/market_cart_page.dart +++ b/lib/pages/market/market_cart_page/market_cart_page.dart @@ -12,7 +12,7 @@ import 'widget/market_cart_app_bar.dart'; class MarketCartPage extends StatefulWidget { final AkuShopModel cartItem; - + MarketCartPage({Key key, this.cartItem}) : super(key: key); @override @@ -21,7 +21,7 @@ class MarketCartPage extends StatefulWidget { class _MarketCartPageState extends State { Widget _cardRadio( - BuildContext context, AkuShopModel cartItem, CartProvidde model,index) { + BuildContext context, AkuShopModel cartItem, CartProvidde model, index) { return InkWell( onTap: () { setState(() { @@ -199,14 +199,15 @@ class _MarketCartPageState extends State { return true; } - double get _allprice{ - double _price=0; - for(var element in shopList){ - _price+=double.parse(element.itemprice)*element.count; + double get _allprice { + double _price = 0; + for (var element in shopList) { + _price += double.parse(element.itemprice) * element.count; } return _price; } - int get _goodsCount=>shopList.length; + + int get _goodsCount => shopList.length; List _cartList; @@ -215,11 +216,13 @@ class _MarketCartPageState extends State { return 'end'; } - Widget _selectAll(CartProvidde model,) { + Widget _selectAll( + CartProvidde model, + ) { return InkWell( onTap: () { - for(var element in _cartList){ - element.isCheck=!element.isCheck; + for (var element in _cartList) { + element.isCheck = !_selectALl; } model.changeALlCheckState(true); setState(() { @@ -301,7 +304,7 @@ class _MarketCartPageState extends State { ); } - Widget _marketCartCard(AkuShopModel cartItem,index) { + Widget _marketCartCard(AkuShopModel cartItem, index) { return Consumer(builder: (context, model, child) { return Container( margin: EdgeInsets.only( @@ -366,7 +369,7 @@ class _MarketCartPageState extends State { children: [ Row( children: [ - _cardRadio(context, cartItem, model,index), + _cardRadio(context, cartItem, model, index), _image(cartItem.itempic), _content(cartItem.itemtitle, '默认', cartItem.itemprice), ], @@ -425,7 +428,7 @@ class _MarketCartPageState extends State { return ListView.builder( itemCount: cartList.length, itemBuilder: (BuildContext context, int index) { - return _marketCartCard(cartList[index],index); + return _marketCartCard(cartList[index], index); }); }, ), diff --git a/pubspec.yaml b/pubspec.yaml index 56e770c2..36f14c88 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.7+8 +version: 1.0.8+9 environment: sdk: ">=2.7.0 <3.0.0" From 83ede8be8ffe88834734a0a2e02503107a55413a Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Thu, 29 Oct 2020 14:47:44 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 2 + lib/pages/personal/personal_page.dart | 9 ++- lib/pages/setting_page/setting_page.dart | 73 ++++++++++++++------ lib/pages/sign/user_authentication_page.dart | 6 +- lib/pages/tab_navigator.dart | 5 +- lib/provider/user_provider.dart | 10 +++ 6 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 lib/provider/user_provider.dart diff --git a/lib/main.dart b/lib/main.dart index a8dd81c4..8510d1be 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ import 'package:akuCommunity/pages/tab_navigator.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; import 'package:amap_map_fluttify/amap_map_fluttify.dart'; import 'package:ani_route/ani_route.dart'; import 'package:flutter/material.dart'; @@ -39,6 +40,7 @@ class _MyAppState extends State { return MultiProvider( providers: [ ChangeNotifierProvider(create: (context) => CartProvidde()), + ChangeNotifierProvider(create: (context)=>UserProvider()), ], child: OKToast( textStyle: TextStyle(fontSize: 19.0, color: Colors.white), diff --git a/lib/pages/personal/personal_page.dart b/lib/pages/personal/personal_page.dart index bb81148e..e0778b00 100644 --- a/lib/pages/personal/personal_page.dart +++ b/lib/pages/personal/personal_page.dart @@ -1,4 +1,5 @@ import 'package:akuCommunity/pages/sign/sign_in_page.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; import 'package:ani_route/ani_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; @@ -11,6 +12,7 @@ import 'package:akuCommunity/widget/single_ad_space.dart'; import 'package:akuCommunity/widget/cached_image_wrapper.dart'; import 'package:akuCommunity/routers/page_routers.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:provider/provider.dart'; class PersonalIndex extends StatefulWidget { final bool isSign; @@ -33,6 +35,7 @@ class _PersonalIndexState extends State } SliverAppBar _sliverAppBar(double height) { + final userProvider=Provider.of(context); return SliverAppBar( pinned: true, elevation: 0, @@ -71,18 +74,18 @@ class _PersonalIndexState extends State 'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1851283359,3457678391&fm=26&gp=0.jpg', width: Screenutil.length(106), height: Screenutil.length(106), - isSigned: _isSigned, + isSigned: userProvider.isSigned, ), ), ), InkWell( onTap: (){ - _isSigned? null:ARoute.push(context, SignInPage()); + userProvider.isSigned? null:ARoute.push(context, SignInPage()); }, child: Container( margin: EdgeInsets.only( left: Screenutil.length(16)), - child: _isSigned + child: userProvider.isSigned ? Text( 'Cheailune', style: TextStyle( diff --git a/lib/pages/setting_page/setting_page.dart b/lib/pages/setting_page/setting_page.dart index dfa5d78a..64c2c950 100644 --- a/lib/pages/setting_page/setting_page.dart +++ b/lib/pages/setting_page/setting_page.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:akuCommunity/pages/setting_page/agreement_page/agreement_page.dart'; import 'package:akuCommunity/pages/sign/sign_in_page.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; import 'package:ani_route/ani_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; @@ -10,6 +11,8 @@ import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/widget/common_app_bar.dart'; import 'package:akuCommunity/routers/page_routers.dart'; import 'package:akuCommunity/widget/custom_action_sheet.dart'; +import 'package:provider/provider.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'agreement_page/privacy_page.dart'; @@ -50,7 +53,7 @@ class _SettingPageState extends State { 'isSwitch': false, }, { - 'title':'隐私政策', + 'title': '隐私政策', 'isSwitch': false, } ]; @@ -176,10 +179,10 @@ class _SettingPageState extends State { ); break; case '用户协议': - ARoute.push(context, AgreementPage()); + ARoute.push(context, AgreementPage()); break; - case '隐私政策': - ARoute.push(context,PrivacyPage()); + case '隐私政策': + ARoute.push(context, PrivacyPage()); break; default: } @@ -233,8 +236,10 @@ class _SettingPageState extends State { } Widget _containerQuit() { + final userProvider = Provider.of(context); return InkWell( onTap: () { + userProvider.isSigned? showCupertinoModalPopup( context: context, builder: (context) { @@ -249,6 +254,8 @@ class _SettingPageState extends State { ), ), onPressed: () { + userProvider.setisSigned(false); + ARoute.pop(context); // Navigator.popUntil(context, (route) { // return !Navigator.canPop(context); // }); @@ -257,7 +264,6 @@ class _SettingPageState extends State { // CupertinoPageRoute( // builder: (context) => SignInPage(), // )); - ARoute.push(context, SignInPage()); }, ), ], @@ -269,25 +275,46 @@ class _SettingPageState extends State { ), ); }, - ); + ):ARoute.push(context, SignInPage()); }, - child: Container( - color: Colors.white, - height: Screenutil.length(96), - padding: EdgeInsets.only( - top: Screenutil.length(26), - bottom: Screenutil.length(25), - ), - alignment: Alignment.center, - child: Text( - '退出当前帐号', - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: BaseStyle.fontSize32, - color: BaseStyle.color333333, - ), - ), - ), + child: userProvider.isSigned + ? Container( + color: Colors.white, + height: Screenutil.length(96), + padding: EdgeInsets.only( + top: Screenutil.length(26), + bottom: Screenutil.length(25), + ), + alignment: Alignment.center, + child: Text( + '退出当前帐号', + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: BaseStyle.fontSize32, + color: BaseStyle.color333333, + ), + ), + ) + : Container( + alignment: Alignment.center, + height: Screenutil.length(89), + width: Screenutil.length(586), + padding: EdgeInsets.only( + top: Screenutil.length(25), bottom: Screenutil.length(24)), + margin: EdgeInsets.symmetric(horizontal: Screenutil.length(82)), + decoration: BoxDecoration( + color: Color(0xffffc40c), + borderRadius: BorderRadius.all(Radius.circular(36)), + ), + child: Text( + '登录', + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: BaseStyle.fontSize28, + color: BaseStyle.color333333, + ), + ), + ), ); } diff --git a/lib/pages/sign/user_authentication_page.dart b/lib/pages/sign/user_authentication_page.dart index 1ee5f43f..86e007bd 100644 --- a/lib/pages/sign/user_authentication_page.dart +++ b/lib/pages/sign/user_authentication_page.dart @@ -1,10 +1,12 @@ import 'package:akuCommunity/pages/tab_navigator.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; import 'package:ani_route/ani_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_icons/flutter_icons.dart'; import 'package:akuCommunity/utils/screenutil.dart'; import 'package:akuCommunity/base/base_style.dart'; +import 'package:provider/provider.dart'; class UserAuthenticationPage extends StatefulWidget { final BuildContext context; @@ -26,6 +28,7 @@ class _UserAuthenticationPageState extends State { ]; AppBar _appBar() { + final userProvider=Provider.of(context); return AppBar( elevation: 0, backgroundColor: Colors.white, @@ -39,8 +42,9 @@ class _UserAuthenticationPageState extends State { MaterialButton( child: Text('跳过'), onPressed: () { + userProvider.setisSigned(true); ARoute.pop(context,root: true); - ARoute.pushReplace(context, TabNavigator(isSign: true,)); + ARoute.pushReplace(context, TabNavigator()); }, ), ], diff --git a/lib/pages/tab_navigator.dart b/lib/pages/tab_navigator.dart index 5cece989..b55f7ea2 100644 --- a/lib/pages/tab_navigator.dart +++ b/lib/pages/tab_navigator.dart @@ -11,9 +11,7 @@ import 'personal/personal_page.dart'; class TabNavigator extends StatefulWidget { - final bool isSign; - - const TabNavigator({Key key, this.isSign=false}) : super(key: key); + const TabNavigator({Key key, }) : super(key: key); @override _TabNavigatorState createState() => _TabNavigatorState(); } @@ -37,7 +35,6 @@ _pages=[ PropertyIndex(), CommunityIndex(), PersonalIndex( - isSign: widget.isSign, ) ]; } diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart new file mode 100644 index 00000000..453b878f --- /dev/null +++ b/lib/provider/user_provider.dart @@ -0,0 +1,10 @@ +import 'package:flutter/material.dart'; +class UserProvider extends ChangeNotifier{ + //登录状态管理 + bool _isSigned =false; + get isSigned => _isSigned; + setisSigned(bool state){ + _isSigned=state; + notifyListeners(); + } +} \ No newline at end of file