From bfbd04e35de7bc61dcee284a6c12a7d3c78329da Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 7 Oct 2021 10:36:36 +0300 Subject: [PATCH 1/2] add count to cart --- .../shared/product_details_app_bar.dart | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart index 367e0d35..3eb58852 100644 --- a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart +++ b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart @@ -1,9 +1,11 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; @@ -63,16 +65,34 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { if (authenticatedUserObject.isLogin) Row( children: [ - IconWithBg( - icon: Icons.shopping_cart, - color: Colors.grey[800], - onPress: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => CartOrderPage()), - ); - }), + Stack( + children: [ + IconWithBg( + icon: Icons.shopping_cart, + color: Colors.grey[800], + onPress: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => CartOrderPage()), + ); + }), + + if(Provider.of(context, listen: false).cartResponse.quantityCount !=0) + Positioned( + child: Container( + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(15), + + ), + padding: EdgeInsets.only(left: 5, right: 4.5), + height: 18, + child: Center(child: Texts(Provider.of(context, listen: false).cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white,)), + ), + ) + ], + ), SizedBox( width: 10, ), From 944bbce1bfa3b72efb630de6b4a5f9dfaa8ac11c Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Thu, 7 Oct 2021 10:37:25 +0300 Subject: [PATCH 2/2] add count to cart --- .../screens/product-details/shared/product_details_app_bar.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart index 3eb58852..8069d0ed 100644 --- a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart +++ b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart @@ -80,6 +80,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { if(Provider.of(context, listen: false).cartResponse.quantityCount !=0) Positioned( + top:0, right: -1.0, child: Container( decoration: BoxDecoration( color: Colors.red,