diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 968fe029..014ba7fb 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -49,7 +49,7 @@ class ProductDetailViewModel extends BaseViewModel{ Future notifyMe(customerId, itemID) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _productDetailService.notifyMe(customerId, itemID); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -60,7 +60,7 @@ class ProductDetailViewModel extends BaseViewModel{ Future addToCartData(quantity, itemID) async { hasError = false; - setState(ViewState.Busy); + setState(ViewState.BusyLocal); await _productDetailService.addToCart(quantity, itemID); if (_productDetailService.hasError) { error = _productDetailService.error; diff --git a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart index 854f5d4c..583c904f 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/footor/quantity_box.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; @@ -10,6 +11,7 @@ import 'package:hexcolor/hexcolor.dart'; import '../../../../../locator.dart'; import '../../../../../routes.dart'; import '../../cart-order-page.dart'; +import '../product-detail.dart'; class FooterWidget extends StatefulWidget { final bool isAvailable; @@ -18,13 +20,17 @@ class FooterWidget extends StatefulWidget { final int quantityLimit; final PharmacyProduct item; final Function addToCartFunction; + final ProductDetailViewModel model; int quantity; bool isOverQuantity; FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item, - {this.quantity, this.isOverQuantity = false, this.addToCartFunction}); + {this.quantity, + this.isOverQuantity = false, + this.addToCartFunction, + this.model}); @override _FooterWidgetState createState() => _FooterWidgetState(); @@ -98,38 +104,31 @@ class _FooterWidgetState extends State { label: i, onTapFunc: onChangeValue, isSelected: widget.quantity == i), - Column( - children: [ - Container( - width: 100, - decoration: BoxDecoration( - border: - Border.all(color: Colors.grey[300]), - color: Colors.white, - ), - child: TextField( - decoration: InputDecoration( - labelText: 'quantity #'), - onChanged: (text) { - print(widget.quantity); - print(widget.quantityLimit); - if (int.tryParse(text) == null) { - text = ''; + Container( + width: 100, + decoration: BoxDecoration( + border: Border.all(color: Colors.grey[300]), + color: Colors.white, + ), + child: TextField( + decoration: InputDecoration( + labelText: ' Quantity # '), + onChanged: (text) { + if (int.tryParse(text) == null) { + text = ''; + } else { + setState(() { + widget.quantity = int.parse(text); + if (widget.quantity >= + widget.quantityLimit) { + widget.isOverQuantity = true; } else { - setState(() { - widget.quantity = int.parse(text); - if (widget.quantity >= - widget.quantityLimit) { - widget.isOverQuantity = true; - } else { - widget.isOverQuantity = false; - } - }); + widget.isOverQuantity = false; } - }, - ), - ), - ], + }); + } + }, + ), ), ], ), @@ -175,7 +174,7 @@ class _FooterWidgetState extends State { quantityUI = 80; showUI = false; } else { - quantityUI = 150; + quantityUI = 160; showUI = true; } }); @@ -197,10 +196,13 @@ class _FooterWidgetState extends State { ); } else await widget.addToCartFunction( - widget.quantity, widget.item.id, context); + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); }, + fontWeight: FontWeight.w600, borderColor: Color(0xFF4CAF50), - borderRadius: 5, + borderRadius: 3, color: Color(0xFF4CAF50), ), ), @@ -215,14 +217,18 @@ class _FooterWidgetState extends State { widget.quantity > widget.quantityLimit || widget.item.rxMessage != null, onTap: () async { - await widget.addToCartFunction( - widget.quantity, widget.item.id, context); + await widget.addToCartFunction( + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); Navigator.push( context, FadePage(page: CartOrderPage()), ); }, - borderRadius: 5, + fontWeight: FontWeight.w600, + borderColor: Colors.grey[800], + borderRadius: 3, disableColor: Colors.grey[700], color: !widget.isAvailable && widget.quantity > 0 || widget.quantity > widget.quantityLimit || diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 6ac5ec25..db43e6da 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -103,7 +103,8 @@ class __ProductDetailPageState extends State { deleteFromWishlistFunction: () async { await deleteFromWishlistFunction(itemID: itemID, model: model); }, - isInWishList:isInWishList + isInWishList:isInWishList, + addToCartFunction:addToCartFunction , ), body: SingleChildScrollView( child: Column( @@ -323,6 +324,7 @@ class __ProductDetailPageState extends State { quantity: quantity, isOverQuantity: isOverQuantity, addToCartFunction: addToCartFunction, + model: model, ), )); } @@ -338,17 +340,17 @@ class __ProductDetailPageState extends State { await model.deleteWishlistData(itemID); setState(() {}); } + addToCartFunction( + {quantity, + itemID, + ProductDetailViewModel model}) async { + GifLoaderDialogUtils.showMyDialog(context); + await model.addToCartData(quantity, itemID); + GifLoaderDialogUtils.hideDialog(context); + } } -addToCartFunction( - {quantity, - itemID, - BuildContext context, - ProductDetailViewModel model}) async { - GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); - GifLoaderDialogUtils.hideDialog(context); -} + notifyMeWhenAvailable( {itemId, customerId, ProductDetailViewModel model}) async { 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 8069d0ed..ee1bcd60 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 @@ -23,6 +23,8 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { final Function deleteFromWishlistFunction; final int quantity; final bool isInWishList; + final Function addToCartFunction; + ProductAppBar( {Key key, @@ -31,7 +33,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { this.addToWishlistFunction, this.quantity, this.deleteFromWishlistFunction, - this.isInWishList}) + this.isInWishList, this.addToCartFunction}) : super(key: key); AuthenticatedUserObject authenticatedUserObject = @@ -83,7 +85,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { top:0, right: -1.0, child: Container( decoration: BoxDecoration( - color: Colors.red, + color: Colors.red[800], borderRadius: BorderRadius.circular(15), ), @@ -136,7 +138,6 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { await addToCartFunction( quantity: quantity, itemID: itemID, - context: context, model: model); Navigator.of(context).pop(); diff --git a/lib/widgets/buttons/secondary_button.dart b/lib/widgets/buttons/secondary_button.dart index 4b2f23a9..4ada4d86 100644 --- a/lib/widgets/buttons/secondary_button.dart +++ b/lib/widgets/buttons/secondary_button.dart @@ -29,7 +29,10 @@ class SecondaryButton extends StatefulWidget { this.small = false, this.disabled = false, this.borderColor, - this.noBorderRadius = false, this.borderRadius, this.disableColor}) + this.noBorderRadius = false, + this.borderRadius, + this.disableColor, + this.fontWeight}) : super(key: key); final String label; @@ -45,7 +48,7 @@ class SecondaryButton extends StatefulWidget { final bool noBorderRadius; final double borderRadius; final Color disableColor; - + final FontWeight fontWeight; @override @@ -173,7 +176,8 @@ class _SecondaryButtonState extends State child: ClipRRect( borderRadius: widget.noBorderRadius ? BorderRadius.all(Radius.circular(0.0)) - : BorderRadius.all(Radius.circular(widget.borderRadius??10.0)), + : BorderRadius.all( + Radius.circular(widget.borderRadius ?? 10.0), ), child: Stack( children: [ Positioned( @@ -184,7 +188,7 @@ class _SecondaryButtonState extends State height: 100, decoration: BoxDecoration( color: widget.disabled - ? widget.disableColor??Colors.grey + ? widget.disableColor ?? Colors.grey : widget.color ?? Theme.of(context).buttonColor), ), ), @@ -246,7 +250,7 @@ class _SecondaryButtonState extends State style: TextStyle( color: widget.textColor, fontSize: widget.small ? 12.0 : 14.0, - // fontWeight: FontWeight.w800, + fontWeight: widget.fontWeight, fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans'),