diff --git a/lib/config/config.dart b/lib/config/config.dart index c4fabca6..42861cce 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -546,8 +546,8 @@ const SUBSCRIBE_PRODUCT = "subscribe?"; const GET_ORDER = "orders?"; const GET_ORDER_DETAILS = "orders/"; const ADD_CUSTOMER_ADDRESS = "addcustomeraddress"; -const EDIT_CUSTOMER_ADDRESS = "epharmacy/api/editcustomeraddress"; -const DELETE_CUSTOMER_ADDRESS = "epharmacy/api/deletecustomeraddress"; +const EDIT_CUSTOMER_ADDRESS = "editcustomeraddress"; +const DELETE_CUSTOMER_ADDRESS = "deletecustomeraddress"; const GET_ADDRESS = "Customers/"; const GET_Cancel_ORDER = "cancelorder/"; const WRITE_REVIEW = "Content-Type" + "text/plain; charset=utf-8"; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 94e7349f..aa9c5b16 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1734,4 +1734,7 @@ const Map localizedValues = { "points": {"en": "Points", "ar": "نقاط"}, "availableBalance": {"en": "Available Balance", "ar": "الرصيد المتوفر"}, "ordersDashboard": {"en": "My Orders", "ar": "طلباتي"}, + "productOutOfStock": {"en": "Out Of Stock", "ar": "إنتهى من المخزن"}, + "productQuantity": {"en": "Quantity", "ar": "كمية"}, + }; diff --git a/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart b/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart index 6b6112bb..2f92fe5e 100644 --- a/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart +++ b/lib/core/service/AlHabibMedicalService/customer_addresses_service.dart @@ -66,12 +66,12 @@ class CustomerAddressesService extends BaseService { class CustomerInfo { bool isRegistered; - String userName; + dynamic userName; dynamic password; - String email; + dynamic email; dynamic errorMessage; - String mobileNumber; - int customerId; + dynamic mobileNumber; + dynamic customerId; CustomerInfo({this.isRegistered, this.userName, this.password, this.email, this.errorMessage, this.mobileNumber, this.customerId}); @@ -104,7 +104,7 @@ class AddressInfo { String lastName; String email; dynamic company; - int countryId; + dynamic countryId; String country; dynamic stateProvinceId; String city; diff --git a/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart b/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart index b6420c9c..72342b56 100644 --- a/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/PharmacyAddressesViewModel.dart @@ -75,7 +75,6 @@ class PharmacyAddressesViewModel extends BaseViewModel { sendingAddress.faxNumber = user.faxNumber; sendingAddress.customerAttributes = ""; sendingAddress.createdOnUtc = DateTime.now().toString(); - if (editedAddress == null) { ///TODO Fatima* @@ -83,15 +82,21 @@ class PharmacyAddressesViewModel extends BaseViewModel { } else { await _pharmacyAddressService.editCustomerAddress(sendingAddress); + } if (_pharmacyAddressService.hasError) { - error = _pharmacyAddressService.error; - Utils.showErrorToast(error); - setState(ViewState.Error); + await _pharmacyAddressService.getAddresses(); + setState(ViewState.Idle); + + + // setState(ViewState.Error); } else { setState(ViewState.Idle); } + + + } Future deleteAddresses(AddressInfo sendingAddress) async { 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 3520b305..abe3328b 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:flutter/material.dart'; import '../../../../../locator.dart'; @@ -28,8 +29,13 @@ class FooterWidget extends StatefulWidget { int quantity; bool isOverQuantity; - FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item, - {this.quantity, this.isOverQuantity = false, this.addToCartFunction, this.addToShoppingCartFunction, this.model}); + FooterWidget(this.isAvailable, this.maxQuantity, this.minQuantity, + this.quantityLimit, this.item, + {this.quantity, + this.isOverQuantity = false, + this.addToCartFunction, + this.addToShoppingCartFunction, + this.model}); @override _FooterWidgetState createState() => _FooterWidgetState(); @@ -38,7 +44,8 @@ class FooterWidget extends StatefulWidget { class _FooterWidgetState extends State { double quantityUI = 80; bool showUI = false; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); AppSharedPreferences sharedPref = new AppSharedPreferences(); @override @@ -74,7 +81,8 @@ class _FooterWidgetState extends State { padding: const EdgeInsets.all(8.0), child: Text( TranslationBase.of(context).quantity, - style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 15, fontWeight: FontWeight.bold), ), ), InkWell( @@ -97,7 +105,11 @@ class _FooterWidgetState extends State { SizedBox( width: 5, ), - for (int i = 1; i <= 10; i++) QuantityBox(label: i, onTapFunc: onChangeValue, isSelected: widget.quantity == i), + for (int i = 1; i <= 10; i++) + QuantityBox( + label: i, + onTapFunc: onChangeValue, + isSelected: widget.quantity == i), Container( width: 100, decoration: BoxDecoration( @@ -105,14 +117,16 @@ class _FooterWidgetState extends State { color: Colors.white, ), child: TextField( - decoration: InputDecoration(labelText: ' Quantity # '), + decoration: InputDecoration( + labelText: ' Quantity # '), onChanged: (text) { if (int.tryParse(text) == null) { text = ''; } else { setState(() { widget.quantity = int.parse(text); - if (widget.quantity >= widget.quantityLimit) { + if (widget.quantity >= + widget.quantityLimit) { widget.isOverQuantity = true; } else { widget.isOverQuantity = false; @@ -133,31 +147,50 @@ class _FooterWidgetState extends State { height: 20, ), Container( - height: 55, + height: 58, child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - width: 90, height: 60, child: FlatButton( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, + child: Row( children: [ - Expanded( - flex: 4, - child: Text( - widget.quantity.toString(), - style: TextStyle(fontSize: 20), - ), + Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + AppText( + TranslationBase.of(context).productQuantity, + fontSize: 10, + + ), + Row( + + children: [ + AppText( + widget.quantity.toString(), + fontSize: 16, + fontWeight: FontWeight.bold, + ), + SizedBox( + width: 20, + ), + Icon(Icons.keyboard_arrow_down,color: Color(0xFF2E303A),size: 25,) + ], + ), + + ], ), - Expanded( - flex: 5, - child: Text( - TranslationBase.of(context).quantityShortcut, - style: TextStyle(fontSize: 16), + SizedBox( + width: 10, + ), + SizedBox( + height: 40, + width: 1, + child: Container( + color: Color(0xFFEFEFEF), ), ), ], @@ -184,17 +217,22 @@ class _FooterWidgetState extends State { width: MediaQuery.of(context).size.width * 0.35, child: SecondaryButton( label: TranslationBase.of(context).addToCart.toUpperCase(), - disabled: (!widget.isAvailable && widget.quantity > 0) || widget.quantity > widget.quantityLimit || widget.item.isRx, + disabled: (!widget.isAvailable && widget.quantity > 0) || + widget.quantity > widget.quantityLimit || + widget.item.isRx, onTap: () async { if (!authenticatedUserObject.isLogin) { login(); } else - await widget.addToCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model); + await widget.addToCartFunction( + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); }, fontWeight: FontWeight.w600, - borderColor: Color(0xFF4CAF50), - borderRadius: 3, - color: Color(0xFF4CAF50), + borderColor: Color(0xFF4CAF50).withOpacity(0.7), + borderRadius: 6, + color: Color(0xFF5AB145).withOpacity(0.7), ), ), SizedBox( @@ -204,19 +242,28 @@ class _FooterWidgetState extends State { width: MediaQuery.of(context).size.width * 0.35, child: SecondaryButton( label: TranslationBase.of(context).buyNow.toUpperCase(), - disabled: (!widget.isAvailable && widget.quantity > 0) || (widget.quantity > widget.quantityLimit) || widget.item.isRx, + disabled: (!widget.isAvailable && widget.quantity > 0) || + (widget.quantity > widget.quantityLimit) || + widget.item.isRx, onTap: () async { if (!authenticatedUserObject.isLogin) { login(); } else { - await widget.addToShoppingCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model); + await widget.addToShoppingCartFunction( + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); } }, fontWeight: FontWeight.w600, - borderColor: Colors.grey[800], - borderRadius: 3, + borderColor: Colors.grey[800].withOpacity(0.7), + borderRadius: 6, disableColor: Colors.grey[700], - color: !widget.isAvailable && widget.quantity > 0 || widget.quantity > widget.quantityLimit || widget.item.isRx ? Colors.grey : Colors.grey[800], + color: !widget.isAvailable && widget.quantity > 0 || + widget.quantity > widget.quantityLimit || + widget.item.isRx + ? Color(0xFF535353).withOpacity(0.7) + : Colors.grey[800], ), ), ], @@ -239,7 +286,9 @@ class _FooterWidgetState extends State { Navigator.of(context).pushNamed(CONFIRM_LOGIN); } else { GifLoaderDialogUtils.showMyDialog(context); - authService.selectDeviceImei(DEVICE_TOKEN).then((SelectDeviceIMEIRES value) { + authService + .selectDeviceImei(DEVICE_TOKEN) + .then((SelectDeviceIMEIRES value) { GifLoaderDialogUtils.hideDialog(context); if (value != null) { setUserValues(value); diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 627ef5a7..efb34510 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -13,6 +13,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -121,12 +122,39 @@ class __ProductDetailPageState extends State { child: Column( children: [ if (widget.product.images.isNotEmpty) - Container( - height: MediaQuery.of(context).size.height * .40, - child: Image.network( - widget.product.images[0].src.trim(), - fit: BoxFit.contain, - ), + Stack( + children: [ + Container( + height: MediaQuery.of(context).size.height * .40, + child: Center( + child: Image.network( + widget.product.images[0].src.trim(), + fit: BoxFit.contain, + ), + ), + ), + if(model.isStockAvailable!= null && !model.isStockAvailable) + Container( + height: MediaQuery.of(context).size.height * .40, + color: Colors.white.withOpacity(0.75), + // child: AppText("Out of Stock"), + ), + if(model.isStockAvailable!= null && !model.isStockAvailable) + Positioned( + // bottom: 10, + top: MediaQuery.of(context).size.height *.088, + left: MediaQuery.of(context).size.width *.32, + child: Center( + child: Container( + height: MediaQuery.of(context).size.height * .40, + // color: Colors.white.withOpacity(0.75), + child: RotationTransition( + turns: new AlwaysStoppedAnimation(310 / 360), + child: AppText(TranslationBase.of(context).productOutOfStock ,color:Color(0xFF000000).withOpacity(0.1),fontSize: projectViewModel.isArabic?40: 50, fontWeight: FontWeight.bold ,)), + ), + ), + ), + ], ), if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) ], @@ -251,7 +279,7 @@ class __ProductDetailPageState extends State { Column( children: [ FlatButton( - onPressed: model.isStockAvailable + onPressed: model.isStockAvailable !=null && model.isStockAvailable ? () async { GifLoaderDialogUtils.showMyDialog(context); await model.getProductLocationData(widget.product.sku); diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index 65a32fe4..e9099167 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -23,10 +23,17 @@ class ProductNameAndPrice extends StatefulWidget { final bool isStockAvailable; final String stockAvailability; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); ProductNameAndPrice(this.context, this.item, - {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable = true, this.stockAvailability}); + {this.customerId, + this.isInWishList, + this.notifyMeWhenAvailable, + this.addToWishlistFunction, + this.deleteFromWishlistFunction, + this.isStockAvailable = true, + this.stockAvailability}); @override _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); @@ -45,90 +52,113 @@ class _ProductNameAndPriceState extends State { SizedBox( height: 10, ), - widget.item.rxMessage != null - ? Container( - // width: widget.item.rxMessage != null ? MediaQuery.of(context).size.width / 2.8 : 0, - width: double.infinity, - height: 40, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffD02127), - // color: Colors.red[700] - // borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), - ), - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(left: 8, right: 8), - child: Icon( - Icons.warning, - color: Colors.white, + widget.item.rxMessage != null + ? Container( + // width: widget.item.rxMessage != null ? MediaQuery.of(context).size.width / 2.8 : 0, + width: double.infinity, + height: 40, + padding: EdgeInsets.all(4), + decoration: BoxDecoration( + color: Color(0xffD02127), + // color: Colors.red[700] + // borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - ), - Text( - projectViewModel.isArabic ? widget.item.rxMessagen.toString() : widget.item.rxMessage.toString(), - style: TextStyle(color: Colors.white, - // regular: true, - fontSize: 17, - fontWeight: FontWeight.w600, letterSpacing:-0.68 - // textAlign: TextAlign.center, - ) - ), - ], - ) - ) - : Container(), + child: Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 8, right: 8), + child: Icon( + Icons.warning, + color: Colors.white, + ), + ), + Text( + projectViewModel.isArabic + ? widget.item.rxMessagen.toString() + : widget.item.rxMessage.toString(), + style: TextStyle( + color: Colors.white, + // regular: true, + fontSize: 17, + fontWeight: FontWeight.w600, + letterSpacing:-0.68 + // textAlign: TextAlign.center, + )), + ], + )) + : Container(), FractionallySizedBox( widthFactor: 0.93, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ // Texts(widget.item.price.toString() + " " + TranslationBase.of(context).sar, fontWeight: FontWeight.bold, fontSize: 20), - Container( - margin: EdgeInsets.only(top: 10.0, right: 10.0), - padding: EdgeInsets.only(left: 11, right: 11,), - decoration: BoxDecoration( - border: Border.all( + if (widget.stockAvailability != null) + Container( + margin: EdgeInsets.only(top: 10.0, right: 10.0), + padding: EdgeInsets.only( + left: 11.0, right: 11.0, top: 0, bottom: 0), + decoration: BoxDecoration( + border: Border.all( + color: getStatusBackgroundColor(), + style: BorderStyle.solid, + width: 5.0, + ), color: getStatusBackgroundColor(), - style: BorderStyle.solid, - width: 5.0, - ), - color: getStatusBackgroundColor(), - borderRadius: BorderRadius.circular(30.0)), - child: Text( - widget.stockAvailability, - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 11, color: Color(0xffFFFFFF),letterSpacing:-0.44), + borderRadius: BorderRadius.circular(30.0)), + // child: Text( + // widget.stockAvailability, + // style: TextStyle( + // fontWeight: FontWeight.w600, + // fontSize: 11, + // color: Color(0xffFFFFFF), + // ), + // color: getStatusBackgroundColor(), + // borderRadius: BorderRadius.circular(30.0)), + child: Text( + widget.stockAvailability, + style: TextStyle(fontWeight: FontWeight.w600, fontSize: 11, color: Color(0xffFFFFFF),letterSpacing:-0.44)), //color: widget.isStockAvailable ? Colors.white : Colors.red, ), - ), // SizedBox(width: 20), - if (widget.authenticatedUserObject.isLogin) - !widget.isStockAvailable && widget.customerId != null - ?IconButton( - iconSize: 25, - icon:Icon(Icons.notifications_active), - color: new Color(0xff2E303A), - onPressed: () - { widget.notifyMeWhenAvailable(context, widget.item.id);}, - - ): IconButton( - icon: Icon(!widget.isInWishList ? Icons.favorite_border : Icons.favorite), - color: !widget.isInWishList ? Color(0xff2E303A) : Color(0xffD02127), - onPressed: () async { - { - if (widget.customerId != null) { - if (!widget.isInWishList) { - await widget.addToWishlistFunction(widget.item.id); - } else { - await widget.deleteFromWishlistFunction(widget.item.id); - } - } else { - return; - } - setState(() {}); - } - }, - ) + // if ( + widget.authenticatedUserObject.isLogin && + widget.stockAvailability != null && + !widget.isStockAvailable && + widget.customerId != null + ? IconButton( + iconSize: 25, + icon: Icon(Icons.notifications_active), + color: new Color(0xff2E303A), + onPressed: () { + widget.notifyMeWhenAvailable( + context, widget.item.id); + }, + ) + : IconButton( + icon: Icon(!widget.isInWishList + ? Icons.favorite_border + : Icons.favorite), + color: !widget.isInWishList + ? Color(0xff2E303A) + : Color(0xffD02127), + onPressed: () async { + { + if (widget.customerId != null) { + if (!widget.isInWishList) { + await widget + .addToWishlistFunction(widget.item.id); + } else { + await widget.deleteFromWishlistFunction( + widget.item.id); + } + } else { + return; + } + setState(() {}); + } + }, + ) // BorderedButton( // TranslationBase.of(context).notifyMe, // hasBorder: true, @@ -177,31 +207,45 @@ class _ProductNameAndPriceState extends State { ), ), Padding( - padding: const EdgeInsets.only(left: 8,right: 8, top: 1, bottom: 12), + padding: + const EdgeInsets.only(left: 8, right: 8, top: 1, bottom: 12), child: Container( margin: EdgeInsets.only(left: 10, right: 10), child: Align( - alignment: projectViewModel.isArabic ? Alignment.topRight : Alignment.topLeft, + alignment: projectViewModel.isArabic + ? Alignment.topRight + : Alignment.topLeft, child: Text( - projectViewModel.isArabic ? widget.item.namen : widget.item.name, - style: TextStyle( fontWeight: FontWeight.w600, fontSize: 16, letterSpacing:-0.96), + projectViewModel.isArabic + ? widget.item.namen + : widget.item.name, + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 16, + letterSpacing: -0.96), ), ), ), - ), Padding( - padding: const EdgeInsets.only(left: 8,right: 8), + padding: const EdgeInsets.only(left: 8, right: 8), child: Container( margin: EdgeInsets.only(left: 10, right: 10), child: Align( - alignment: projectViewModel.isArabic ? Alignment.topRight : Alignment.topLeft, - child: Text( TranslationBase.of(context).sar+ " " + - widget.item.price.toString(), - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 19, letterSpacing:-0.76),), + alignment: projectViewModel.isArabic + ? Alignment.topRight + : Alignment.topLeft, + child: Text( + TranslationBase.of(context).sar + + " " + + widget.item.price.toString(), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 19, + letterSpacing: -0.76), + ), ), ), - ), FractionallySizedBox( widthFactor: 0.95, @@ -214,7 +258,8 @@ class _ProductNameAndPriceState extends State { child: Row( children: [ RatingBar.readOnly( - initialRating: double.parse(widget.item.approvedRatingSum.toString()), + initialRating: double.parse( + widget.item.approvedRatingSum.toString()), size: 18.0, filledColor: Color(0XFFD02127), emptyColor: Color(0XFFD02127), @@ -236,7 +281,8 @@ class _ProductNameAndPriceState extends State { // ), Text( "(${widget.item.approvedTotalReviews}${TranslationBase.of(context).review})", - style: TextStyle(fontWeight: FontWeight.w600, fontSize: 12), + style: TextStyle( + fontWeight: FontWeight.w600, fontSize: 12), ), SizedBox( width: 70, @@ -268,6 +314,7 @@ class _ProductNameAndPriceState extends State { Color getStatusBackgroundColor() { if (widget.isStockAvailable) return Color(0xFF5AB145); - else return Color(0xFFD02127); + else + return Color(0xFFD02127); } } 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 18749662..ca59a0fb 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 @@ -57,10 +57,11 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( + // mainAxisAlignment: MainAxisAlignment.start, children: [ IconWithBg( - icon: Icons.arrow_back, - color: Colors.grey, + icon: Icons.arrow_back_ios, + color: Color(0xFF2B353E), onPress: () { Navigator.pop(context); }, @@ -74,7 +75,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { children: [ IconWithBg( icon: Icons.shopping_cart, - color: Colors.grey[800], + color: Color(0xFF2B353E), onPress: () { Navigator.pushAndRemoveUntil( locator() @@ -112,7 +113,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { .quantityCount .toString(), style: "caption", - medium: true, + // medium: true, color: Colors.white, )), ), @@ -124,7 +125,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { ), IconWithBg( icon: FontAwesomeIcons.ellipsisV, - color: Colors.grey, + color: Color(0xFF2B353E), onPress: () { settingModalBottomSheet(context); }, diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index cb8560c4..fcdb0ad6 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -1,15 +1,23 @@ +import 'package:auto_size_text/auto_size_text.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/shared/icon_with_bg.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.dart'; import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; +import 'dart:math' as math; + class ProductTileItem extends StatelessWidget { final AppSharedPreferences sharedPref = AppSharedPreferences(); final PharmacyProduct item; @@ -38,13 +46,13 @@ class ProductTileItem extends StatelessWidget { }); } - if(items.length >= 15){ + if (items.length >= 15) { items.removeAt(0); // lastVisited = lastVisited.replaceFirst(RegExp('$itemToRemove'), ''); } lastVisited = ""; - for(int i = items.length - 1; i >= 0; i--){ + for (int i = items.length - 1; i >= 0; i--) { if (lastVisited == "") { // it means there is no lastVisited yet lastVisited = "${items[i]}"; @@ -54,7 +62,6 @@ class ProductTileItem extends StatelessWidget { } } - if (!isIdExist) { if (lastVisited == "") { // it means there is no lastVisited yet @@ -76,80 +83,157 @@ class ProductTileItem extends StatelessWidget { child: Container( margin: EdgeInsets.all(7), decoration: BoxDecoration( - border:Border.all(color: Colors.grey.shade300,width: 0.5), - borderRadius: BorderRadius.circular(8) - ), + border: Border.all(color: Colors.grey.shade300, width: 0.5), + borderRadius: BorderRadius.circular(8)), padding: EdgeInsets.symmetric(horizontal: 4), width: MediaQuery.of(context).size.width / 2.8, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Stack( - children: [ - Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 0), - alignment: Alignment.center, - child: (item.images != null && item.images.length > 0) - ? Image.network( - item.images[0].src, - fit: BoxFit.cover, - height: itemHeight / 2, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: itemHeight / 2, + // Stack( + // children: [ + // Container( + // margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + // alignment: Alignment.center, + // child: (item.images != null && item.images.length > 0) + // ? Image.network( + // item.images[0].src, + // fit: BoxFit.cover, + // height: itemHeight / 2, + // ) + // : Image.asset( + // "assets/images/no_image.png", + // fit: BoxFit.cover, + // height: itemHeight / 2, + // ), + // ), + // ], + // ), + + Container( + width: double.infinity, + height: MediaQuery.of(context).size.width * 0.3, + padding: + EdgeInsets.only(left: 20, right: 20, top: 14, bottom: 14), + color: Colors.white, + child: InkWell( + onTap: () {}, + child: Container( + width: double.infinity, + height: double.infinity, + clipBehavior: Clip.antiAlias, + decoration: containerRadiusWithGradientServices(33, + lightColor: Colors.transparent, + darkColor: Colors.transparent), + child: Stack( + children: [ + Container( + width: double.infinity, + height: double.infinity, + //clipBehavior: Clip.antiAlias, + // decoration: projectProvider.isArabic + // ? containerBottomRightRadiusWithGradientForAr(0, lightColor: Colors.transparent, darkColor: Colors.transparent) + // : containerBottomRightRadiusWithGradient(0, lightColor: Colors.red, darkColor: CustomColors.green), + child: Stack( + children: [ + Container( + margin: EdgeInsets.fromLTRB(0, 0, 0, 0), + alignment: Alignment.center, + child: (item.images != null && + item.images.length > 0) + ? Image.network( + item.images[0].src, + fit: BoxFit.cover, + height: itemHeight / 2, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: itemHeight / 2, + ), + ), + ], + ), + ), + if (item.rxMessage != null) + projectProvider.isArabic + ? Positioned( + right: -16, + top: 2, + child: Transform.rotate( + angle: math.pi / 4, + child: Container( + padding: EdgeInsets.only( + left: 18, right: 18, top: 6, bottom: 3), + color: CustomColors.accentColor, + child: Padding( + padding: EdgeInsets.all(2.0), + child: Text( + "الوصفة\n مطلوبة", + style: TextStyle( + color: Colors.white, + fontSize: 7.5, + height: 0.8, + fontWeight: FontWeight.bold, + letterSpacing: -0.27, + ), + ), + ), + ), + ), + ) + : Positioned( + left: -24, + top: 2, + child: Transform.rotate( + angle: -math.pi / 4, + child: Container( + padding: EdgeInsets.only( + left: 18, right: 18, top: 6, bottom: 3), + color: CustomColors.accentColor, + child: Text( + "\n E-Prescription \n Is required", + style: TextStyle( + color: Colors.white, + fontSize: 7.5, + //letterSpacing: -0.27, + height: 1.2, + fontWeight: FontWeight.w600, + ), + ), + ), + ), + ), + ], ), ), -// Container( -// width: item.rxMessage != null -// ? MediaQuery.of(context).size.width / 5 -// : 0, -// padding: EdgeInsets.all(4), -// decoration: BoxDecoration( -// color: Color(0xffb23838), -// borderRadius: -// BorderRadius.only(topLeft: Radius.circular(6)), -// ), -// child: item.rxMessage != null -// ? Texts( -// projectProvider.isArabic -// ? item.rxMessagen -// : item.rxMessage, -// color: Colors.white, -// regular: true, -// fontSize: 10, -// fontWeight: FontWeight.w400, -// ) -// : Texts(""), -// ) - ], + ), ), - Padding( - padding: EdgeInsets.fromLTRB(1,1,1,1), - child: Container( - width: item.rxMessage != null - ? MediaQuery.of(context).size.width / 1.0 - : 0, - padding: EdgeInsets.fromLTRB(8,2,8,2), - decoration: BoxDecoration( - color: Color(0xffb23838), - ), - child: item.rxMessage != null - ? Texts( - projectProvider.isArabic - ? item.rxMessagen - : item.rxMessage, - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ) - : Texts(""), - ), - ), - // SizedBox(height: 4,), + // Padding( + // padding: EdgeInsets.fromLTRB(1, 1, 1, 1), + // child: Container( + // width: item.rxMessage != null + // ? MediaQuery.of(context).size.width / 1.0 + // : 0, + // padding: EdgeInsets.fromLTRB(8, 2, 8, 2), + // decoration: BoxDecoration( + // color: Color(0xffb23838), + // ), + // child: item.rxMessage != null + // ? Texts( + // projectProvider.isArabic + // ? item.rxMessagen + // : item.rxMessage, + // color: Colors.white, + // regular: true, + // fontSize: 10, + // fontWeight: FontWeight.w400, + // ) + // : Texts(""), + // ), + // ), + // SizedBox(height: 4,), Padding( padding: const EdgeInsets.symmetric(horizontal: 4.0), child: Texts( @@ -179,23 +263,32 @@ class ProductTileItem extends StatelessWidget { ), Row( children: [ - // Expanded( - RatingBar.readOnly( - initialRating: item.approvedRatingSum.toDouble(), - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), + // Expanded( + RatingBar.readOnly( + initialRating: item.approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Color(0xffD02127), + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), Texts( "(${item.approvedTotalReviews})", regular: true, fontSize: 10, fontWeight: FontWeight.w400, - ) + ), + + SizedBox( + width: 20.0, + ), + Icon( + Icons.arrow_forward, + size: 18, + ), + // StarRating( // totalAverage: item.approvedTotalReviews > 0 // ? (item.approvedRatingSum.toDouble() / @@ -203,14 +296,16 @@ class ProductTileItem extends StatelessWidget { // .toDouble() // : 0, // forceStars: true), - // ), + // ), ], ), ], ), ), ), - SizedBox(height: 5,), + SizedBox( + height: 5, + ), ], ), ), diff --git a/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart index 2814bc1c..780adba9 100644 --- a/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart +++ b/lib/pages/pharmacies/widgets/home/BestSellerWidget.dart @@ -28,15 +28,17 @@ class BestSellerWidget extends StatelessWidget { productType: 20, )), if (model.state != ViewState.BusyLocal) - Container( - height: MediaQuery.of(context).size.height / 3 + 20, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.bestSellerProduct[i], MediaQuery.of(context).size.height / 4 + 20), - scrollDirection: Axis.horizontal, - itemCount: model.bestSellerProduct.length, - ), - ) else + Container( + height: MediaQuery.of(context).size.height / 3 + 20, + child: ListView.builder( + itemBuilder: (ctx, i) => ProductTileItem( + model.bestSellerProduct[i], + MediaQuery.of(context).size.height / 4 + 20), + scrollDirection: Axis.horizontal, + itemCount: model.bestSellerProduct.length, + ), + ) + else Container( height: 80, child: Center( diff --git a/lib/pages/pharmacies/widgets/home/MostViewedWidget.dart b/lib/pages/pharmacies/widgets/home/MostViewedWidget.dart index aa160baa..de34863d 100644 --- a/lib/pages/pharmacies/widgets/home/MostViewedWidget.dart +++ b/lib/pages/pharmacies/widgets/home/MostViewedWidget.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/final_products_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:flutter/material.dart'; diff --git a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart index 3e7cf5fe..3c2cb710 100644 --- a/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart +++ b/lib/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart @@ -18,42 +18,46 @@ class RecentlyViewedWidget extends StatelessWidget { builder: (_, model, wi) => NetworkBaseView( isLocalLoader: true, baseViewModel: model, - child: model.lastVisitedProducts.isNotEmpty ? Container( - child: Column( - children: [ - ViewAllHomeWidget( - TranslationBase.of(context).recentlyViewed, - FinalProductsPage( - id: "", - productType: 3, - )), - if (model.state != ViewState.BusyLocal) - Container( - height: model.lastVisitedProducts.length > 0 - ? MediaQuery.of(context).size.height / 3 + 20 - : 0, - child: ListView.builder( - itemBuilder: (ctx, i) => - ProductTileItem(model.lastVisitedProducts[i], MediaQuery.of(context).size.height / 4 + 20), - scrollDirection: Axis.horizontal, - itemCount: model.lastVisitedProducts.length, - ), - ) - else - Container( - height: 80, - child: Center( - child:CircularProgressIndicator( - backgroundColor: Colors.white, - valueColor: AlwaysStoppedAnimation( - Colors.grey[500], + child: model.lastVisitedProducts.isNotEmpty + ? Container( + child: Column( + children: [ + ViewAllHomeWidget( + TranslationBase.of(context).recentlyViewed, + FinalProductsPage( + id: "", + productType: 3, + )), + if (model.state != ViewState.BusyLocal) + Container( + height: model.lastVisitedProducts.length > 0 + ? MediaQuery.of(context).size.height / 3 + 20 + : 0, + child: ListView.builder( + itemBuilder: (ctx, i) => ProductTileItem( + model.lastVisitedProducts[i], + MediaQuery.of(context).size.height / 4 + + 20), + scrollDirection: Axis.horizontal, + itemCount: model.lastVisitedProducts.length, + ), + ) + else + Container( + height: 80, + child: Center( + child: CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ), + ), ), - ), - ), + ], ), - ], - ), - ) : Container(), + ) + : Container(), )); } } diff --git a/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart index 05c57f2e..1289e733 100644 --- a/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart +++ b/lib/pages/pharmacies/widgets/home/ViewAllHomeWidget.dart @@ -4,11 +4,9 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; class ViewAllHomeWidget extends StatelessWidget { - final String title; final Widget navigationWidget; - ViewAllHomeWidget(this.title, this.navigationWidget); @override @@ -23,22 +21,32 @@ class ViewAllHomeWidget extends StatelessWidget { bold: true, fontSize: 16, ), - BorderedButton( - TranslationBase.of(context).viewAll, - hasBorder: true, - borderColor: Colors.green, - textColor: Colors.green, - fontWeight: FontWeight.bold, - vPadding: 6, - hPadding: 14, - handler: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - navigationWidget)); + InkWell( + onTap: () { + Navigator.push(context, + MaterialPageRoute(builder: (context) => navigationWidget)); }, + child: Texts( + TranslationBase.of(context).viewAll, + color: Color(0xffD02127), + decoration: TextDecoration.underline, + fontWeight: FontWeight.w600, + fontSize: 12.0, + ), ), + // BorderedButton( + // TranslationBase.of(context).viewAll, + // hasBorder: true, + // borderColor: Colors.green, + // textColor: Colors.green, + // fontWeight: FontWeight.bold, + // vPadding: 6, + // hPadding: 14, + // handler: () { + // Navigator.push(context, + // MaterialPageRoute(builder: (context) => navigationWidget)); + // }, + // ), ], ), ); diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index a38104b9..6a423b82 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -34,9 +34,11 @@ class _PharmacyAddressesState extends State { Navigator.push( ctx, FadePage( - page: AddAddressPage(address, (pickResult) { + page: AddAddressPage(address, (pickResult) async { model.addEditAddress(pickResult, address); - }))); + await model.getAddressesList(); + + }))); } Widget build(BuildContext context) { diff --git a/lib/services/pharmacy_services/pharmacyAddress_service.dart b/lib/services/pharmacy_services/pharmacyAddress_service.dart index aada50da..5329c658 100644 --- a/lib/services/pharmacy_services/pharmacyAddress_service.dart +++ b/lib/services/pharmacy_services/pharmacyAddress_service.dart @@ -72,7 +72,10 @@ class PharmacyAddressService extends BaseService { } Future addCustomerAddress(AddressInfo address) async { - makeCustomerAddress(address, ADD_CUSTOMER_ADDRESS); + await makeCustomerAddress(address, ADD_CUSTOMER_ADDRESS); + // if(!hasError) { + selectedAddressIndex = addresses.length +1; + // } } Future editCustomerAddress(AddressInfo address) async { diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 4a5c8a5d..9484c69d 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1117,6 +1117,7 @@ class TranslationBase { String get myPrescription => localizedValues['myPrescription'][locale.languageCode]; String get quantity => localizedValues['quantity'][locale.languageCode]; + String get productQuantity => localizedValues['productQuantity'][locale.languageCode]; String get conditionsHMG => localizedValues['conditionsHMG'][locale.languageCode]; @@ -1827,6 +1828,7 @@ class TranslationBase { String get needPrescription => localizedValues['needPrescription'][locale.languageCode]; String get outOfStockMsg => localizedValues['outOfStockMsg'][locale.languageCode]; + String get productOutOfStock => localizedValues['productOutOfStock'][locale.languageCode]; String get noArabicLetters => localizedValues['noArabicLetters'][locale.languageCode]; diff --git a/lib/widgets/buttons/secondary_button.dart b/lib/widgets/buttons/secondary_button.dart index dadabc71..e62a4a3b 100644 --- a/lib/widgets/buttons/secondary_button.dart +++ b/lib/widgets/buttons/secondary_button.dart @@ -248,10 +248,10 @@ class _SecondaryButtonState extends State style: TextStyle( color: widget.textColor, fontSize: widget.small ? 12.0 : 14.0, - fontWeight: FontWeight.w600, + fontWeight: FontWeight.w700, fontFamily: projectViewModel.isArabic ? 'Cairo' - : 'WorkSans' + : 'Poppins' ), ), ) diff --git a/lib/widgets/data_display/text.dart b/lib/widgets/data_display/text.dart index 4a00c9fe..4b9ac2f9 100644 --- a/lib/widgets/data_display/text.dart +++ b/lib/widgets/data_display/text.dart @@ -272,7 +272,7 @@ class _TextsState extends State { style: _getFontStyle().copyWith( color: Theme.of(context).primaryColor, fontWeight: FontWeight.w800, - fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans', + fontFamily: projectViewModel.isArabic ? 'Poppins' : 'Poppins', ), ), ), diff --git a/lib/widgets/text/app_texts_widget.dart b/lib/widgets/text/app_texts_widget.dart index a143236f..ea62e89a 100644 --- a/lib/widgets/text/app_texts_widget.dart +++ b/lib/widgets/text/app_texts_widget.dart @@ -60,11 +60,13 @@ class _AppTextState extends State { widget.data, textAlign: widget.textAlign, overflow: TextOverflow.clip, + style: TextStyle( color: widget.color == null ? Theme.of(context).textTheme.bodyText1.color : widget.color, fontWeight: widget.fontWeight, fontSize: widget.fontSize ?? (SizeConfig.textMultiplier * 2), height: widget.height, + fontFamily: "Poppins", letterSpacing: widget.letterSpacing, // fontFamily: widget.fontFamily == null // ? projectViewModel.isArabic