From 2265487ccda97354eb367687e225c086cb39721d Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Mon, 4 Oct 2021 16:10:00 +0300 Subject: [PATCH] remove cart cout & icon from AppBar --- .../pharmacies/screens/cart-order-page.dart | 73 ++++++++++++------- lib/widgets/others/app_scaffold_widget.dart | 53 +++++++------- 2 files changed, 73 insertions(+), 53 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 6c760fcd..c2ebf4b2 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -24,9 +24,10 @@ class CartOrderPage extends StatelessWidget { final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; AppScaffold appScaffold; return BaseView( - onModelReady: (model){ - model.getShoppingCart().then((value){ - appScaffold.appBar.badgeUpdater('${model.cartResponse.quantityCount ?? 0}'); + onModelReady: (model) { + model.getShoppingCart().then((value) { + appScaffold.appBar + .badgeUpdater('${model.cartResponse.quantityCount ?? 0}'); }); }, builder: (_, model, wi) => ChangeNotifierProvider.value( @@ -69,24 +70,40 @@ class CartOrderPage extends StatelessWidget { child: Column( children: [ ...List.generate( - cart.shoppingCarts != null ? cart.shoppingCarts.length : 0, + cart.shoppingCarts != null + ? cart.shoppingCarts.length + : 0, (index) => ProductOrderItem( - cart.shoppingCarts[index], () {print(cart.shoppingCarts[index].quantity); - model.changeProductQuantity(cart.shoppingCarts[index]).then((value) { - if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); + cart.shoppingCarts[index], () { + print(cart.shoppingCarts[index] + .quantity); + model + .changeProductQuantity( + cart.shoppingCarts[index]) + .then((value) { + if (model.state != + ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); } if (model.state == - ViewState.ErrorLocal) {Utils.showErrorToast(model.error);} + ViewState.ErrorLocal) { + Utils.showErrorToast( + model.error); + } + }); + }, () { + model + .deleteProduct( + cart.shoppingCarts[index]) + .then((value) { + if (model.state != + ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); + } }); - }, - () { - model.deleteProduct(cart.shoppingCarts[index]).then((value){ - if (model.state != ViewState.Error) { - appScaffold.appBar.badgeUpdater('${value.quantityCount ?? 0}'); - } - }); - })) + })) ], ), ), @@ -200,7 +217,8 @@ class CartOrderPage extends StatelessWidget { ), Padding( padding: const EdgeInsets.all(8.0), - child: Text(TranslationBase.of(context).noData, + child: Text( + TranslationBase.of(context).noData, // 'There is no data', style: TextStyle(fontSize: 30), ), @@ -270,21 +288,20 @@ class _OrderBottomWidgetState extends State { width: 25.0, height: widget.height * 0.070, decoration: new BoxDecoration( - color: !isAgree - ? Color(0xffeeeeee) - : Colors.green, + color: + !isAgree ? Color(0xffeeeeee) : Colors.green, shape: BoxShape.circle, ), child: !isAgree ? null : Padding( - padding: const EdgeInsets.all(0.0), - child: Icon( - Icons.check, - color: Colors.white, - size: 25, - ), - ), + padding: const EdgeInsets.all(0.0), + child: Icon( + Icons.check, + color: Colors.white, + size: 25, + ), + ), ), ), Expanded( diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index b99ac1dc..962d0506 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -177,6 +177,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { } String _badgeText = "0"; + class AppBarWidgetState extends State { @override Widget build(BuildContext context) { @@ -218,33 +219,35 @@ class AppBarWidgetState extends State { centerTitle: true, actions: [ (widget.isPharmacy && widget.showPharmacyCart) - ? IconButton( - icon: Badge( - shape: BadgeShape.circle, - badgeContent: Text(_badgeText, style: TextStyle(color: Colors.white)), - child: Icon(Icons.shopping_cart)), - color: Colors.white, - onPressed: () { - Navigator.of(context).popUntil(ModalRoute.withName('/')); - }) + ? Container() + // ? IconButton( + // icon: Badge( + // shape: BadgeShape.circle, + // badgeContent: Text(_badgeText, style: TextStyle(color: Colors.white)), + // child: Icon(Icons.shopping_cart)), + // color: Colors.white, + // onPressed: () { + // Navigator.of(context).popUntil(ModalRoute.withName('/')); + // }) : Container(), (widget.isOfferPackages && widget.showOfferPackagesCart) - ? IconButton( - icon: Badge( - position: BadgePosition.topStart(top: -15, start: -10), - badgeContent: Text( - _badgeText, - style: TextStyle( - fontSize: 9, - color: Colors.white, - fontWeight: FontWeight.normal), - ), - child: Icon(Icons.shopping_cart)), - color: Colors.white, - onPressed: () { - // Cart Click Event - if (_onCartClick != null) _onCartClick(); - }) + ? Container() + // ? IconButton( + // icon: Badge( + // position: BadgePosition.topStart(top: -15, start: -10), + // badgeContent: Text( + // _badgeText, + // style: TextStyle( + // fontSize: 9, + // color: Colors.white, + // fontWeight: FontWeight.normal), + // ), + // child: Icon(Icons.shopping_cart)), + // color: Colors.white, + // onPressed: () { + // // Cart Click Event + // if (_onCartClick != null) _onCartClick(); + // }) : Container(), if (widget.showHomeAppBarIcon) IconButton(