diff --git a/assets/images/pharmacy_module/payment.png b/assets/images/pharmacy_module/payment.png new file mode 100644 index 00000000..275aa40a Binary files /dev/null and b/assets/images/pharmacy_module/payment.png differ diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 3979e982..25f236cd 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -899,7 +899,7 @@ const Map localizedValues = { "reset": {"en": "Reset", "ar": "اعادة تعيين"}, "apply": {"en": "Apply", "ar": "تطبيق"}, "viewCategorise": {"en": "View All Categories", "ar": "عرض جميع الفئات"}, - "categorise": {"en": "Categories", "ar": "التطبيقات"}, + "categorise": {"en": "Categories", "ar": "الفئات"}, "wishList": {"en": "WishList", "ar": "المفضلة"}, "myAccount": {"en": "My Account", "ar": "حسابي"}, "cart": {"en": "Cart", "ar": "التسوق"}, @@ -1091,6 +1091,8 @@ const Map localizedValues = { "camera-permission": {"en": "Camera", "ar": "الكاميرا"}, "location-permission": {"en": "Location", "ar": "تحديد المواقع"}, + "needPrescription": {"en": "This product requires a prescription", "ar": " هذا المنتج يتطلب وصفة طبية"}, + "outOfStockMsg": {"en": "You have added product which is out of stock now, Please remove that!", "ar": "لقد قمت بإضافة المنتج الذي نفذ من المخزون الآن. يرجى إزالة ذلك"}, "accessibility": {"en": "Accessibility Mode", "ar": "وضع امكانية الوصول"}, "orderStatus": {"en": "Order Status", "ar": "حالة الطلب"}, "CancelOrder": {"en": "Cancel Order", "ar": "الغاء الطلب"}, diff --git a/lib/core/model/pharmacies/PharmacyProduct.dart b/lib/core/model/pharmacies/PharmacyProduct.dart index dbef5737..8f846480 100644 --- a/lib/core/model/pharmacies/PharmacyProduct.dart +++ b/lib/core/model/pharmacies/PharmacyProduct.dart @@ -20,7 +20,7 @@ class PharmacyProduct { bool allowCustomerReviews; int approvedRatingSum; int notApprovedRatingSum; - int approvedTotalReviews; + dynamic approvedTotalReviews; int notApprovedTotalReviews; dynamic sku; bool isRx; diff --git a/lib/core/model/pharmacies/orders_model.dart b/lib/core/model/pharmacies/orders_model.dart index 0ad94767..cef20c30 100644 --- a/lib/core/model/pharmacies/orders_model.dart +++ b/lib/core/model/pharmacies/orders_model.dart @@ -24,7 +24,7 @@ class OrdersModel { class Orders { String id; int productCount; - double orderTotal; + dynamic orderTotal; String createdOnUtc; int orderStatusId; String orderStatus; @@ -32,9 +32,9 @@ class Orders { bool canCancel; bool canRefund; dynamic customerId; - double orderSubtotalExclTax; + dynamic orderSubtotalExclTax; dynamic orderShippingExclTax; - double orderTax; + dynamic orderTax; Orders( @@ -64,9 +64,9 @@ class Orders { canCancel = json['can_cancel']; canRefund = json['can_refund']; customerId = json['customer_id']; - orderSubtotalExclTax= json["order_subtotal_excl_tax"].toDouble(); + orderSubtotalExclTax= json["order_subtotal_excl_tax"]; orderShippingExclTax= json["order_shipping_excl_tax"]; - orderTax= json["order_tax"].toDouble(); + orderTax= json["order_tax"]; }catch(e){ print(e); } diff --git a/lib/core/model/pharmacies/payment-checkout-data.dart b/lib/core/model/pharmacies/payment-checkout-data.dart index dd9e0e54..5d91c829 100644 --- a/lib/core/model/pharmacies/payment-checkout-data.dart +++ b/lib/core/model/pharmacies/payment-checkout-data.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'ShippingOption.dart'; -class PaymentCheckoutData with ChangeNotifier{ +class PaymentCheckoutData { Addresses address; PaymentOption paymentOption; LacumAccountInformation lacumInformation; @@ -15,7 +15,5 @@ class PaymentCheckoutData with ChangeNotifier{ PaymentCheckoutData({this.address, this.paymentOption, this.lacumInformation, this.cartDataVisible = false, this.shippingOption, this.usedLakumPoints = 0}); - void updateData() { - notifyListeners(); - } + } diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index e27b0e03..4dd9ad26 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -47,9 +47,11 @@ class OrderPreviewViewModel extends BaseViewModel { getShoppingCart(); } } - void update(){ + + void update() { notifyListeners(); } + Future getShoppingCart() async { // setState(ViewState.Busy); // GifLoaderDialogUtils.showMyDialog( @@ -66,7 +68,7 @@ class OrderPreviewViewModel extends BaseViewModel { } // GifLoaderDialogUtils.hideDialog( // locator().navigatorKey.currentContext); - setState(ViewState.Idle); + setState(ViewState.Idle); } } @@ -197,7 +199,7 @@ class OrderPreviewViewModel extends BaseViewModel { .getShippingOption(paymentCheckoutData.address) .then((res) { paymentCheckoutData.shippingOption = ShippingOption.fromJson(res); - paymentCheckoutData.updateData(); + setState(ViewState.Idle); }); if (_orderService.hasError) { error = _orderService.error; @@ -220,6 +222,17 @@ class OrderPreviewViewModel extends BaseViewModel { setState(ViewState.Idle); } } + + bool isCartItemsOutOfStock() { + bool outOfStock = false; + for (int i = 0; i < cartResponse.shoppingCarts.length; i++) { + if (cartResponse.shoppingCarts[i].product.stockQuantity == 0) { + outOfStock = true; + break; + } + } + return outOfStock; + } } enum PaymentOption { meda, sadad, visa, mastercard, installments } diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index fff272b3..854b66a6 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -1,5 +1,11 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; @@ -16,6 +22,8 @@ dynamic languageID; class FinalProductsPage extends StatefulWidget { final String id; final int productType; // 1 : default, 2 : manufacturer , 3 : recently viewed + AuthenticatedUserObject authenticatedUserObject = + locator(); FinalProductsPage({this.id, this.productType = 1}); @@ -488,7 +496,7 @@ class _FinalProductsPageState extends State { context) .size .width / - 3.5 + 5.3 : 0, padding: EdgeInsets.all( @@ -605,6 +613,30 @@ class _FinalProductsPageState extends State { ], ), ), + + widget.authenticatedUserObject.isLogin + ? Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 18, + color: Colors.blue,), + onPressed: () async { + if(model.finalProducts[index].rxMessage == null){ + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.finalProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push( + context, + FadePage(page: CartOrderPage())); + } + else{ + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } +// + } + + ), + ):Container(), ], ), ), @@ -651,4 +683,9 @@ class _FinalProductsPageState extends State { ), )); } + + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); + } } diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index 5094db04..6ae272e2 100644 --- a/lib/pages/landing/landing_page_pharmcy.dart +++ b/lib/pages/landing/landing_page_pharmcy.dart @@ -5,7 +5,7 @@ import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; import 'package:diplomaticquarterapp/core/service/parmacyModule/parmacy_module_service.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/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/wishlist.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/profile/profile.dart'; @@ -50,7 +50,7 @@ class _LandingPagePharmacyState extends State { @override Widget build(BuildContext context) { return WillPopScope( - onWillPop: ()async{ + onWillPop: () async { return false; }, child: Scaffold( diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index ff1fc5b7..18133bb2 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -1,9 +1,15 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/pages/sub_categorise_page.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; @@ -15,14 +21,19 @@ import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:diplomaticquarterapp/pages/sub_categories_modalsheet.dart'; import 'base/base_view.dart'; + class ParentCategorisePage extends StatefulWidget { String id; String titleName; + AuthenticatedUserObject authenticatedUserObject = + locator(); + ParentCategorisePage({this.id, this.titleName}); @override @@ -33,8 +44,11 @@ class ParentCategorisePage extends StatefulWidget { class _ParentCategorisePageState extends State { String id; String titleName; + final dynamic productID; + - _ParentCategorisePageState({this.id, this.titleName}); + + _ParentCategorisePageState({this.id, this.titleName, this.productID,}); Map values = {'huusam': false, 'ali': false, 'noor': false}; bool checkedBrands = false; @@ -1034,7 +1048,7 @@ class _ParentCategorisePageState extends State { context) .size .width / - 5 + 5.3 : 0, padding: EdgeInsets.all(4), @@ -1117,8 +1131,7 @@ class _ParentCategorisePageState extends State { padding: const EdgeInsets .only( - top: 4, - bottom: 4), + top: 4, bottom: 4), child: Texts( "SAR ${model.parentProducts[index].price}", bold: true, @@ -1154,6 +1167,30 @@ class _ParentCategorisePageState extends State { ], ), ), + + widget.authenticatedUserObject.isLogin ? + Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 18, + color: Colors.blue,), + onPressed: () async { + if(model.parentProducts[index].rxMessage == null){ + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.parentProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push( + context, + FadePage(page: CartOrderPage())); + } + else{ + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + + } + + ), + ): Container(), ], ), ), @@ -1201,6 +1238,13 @@ class _ParentCategorisePageState extends State { ), ), )); + + + } + + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); } bool isEntityListSelected(CategoriseParentModel masterKey) { @@ -1220,4 +1264,7 @@ class _ParentCategorisePageState extends State { } return false; } + + + } diff --git a/lib/pages/pharmacies/ProductCheckTypeWidget.dart b/lib/pages/pharmacies/ProductCheckTypeWidget.dart index aac971a0..2b88d30a 100644 --- a/lib/pages/pharmacies/ProductCheckTypeWidget.dart +++ b/lib/pages/pharmacies/ProductCheckTypeWidget.dart @@ -32,6 +32,7 @@ class _ProductCheckTypeWidgetState extends State { : widget.model.wishListList[index].product.name, productPrice: widget.model.wishListList[index].subtotal, productRate: double.parse(widget.model.wishListList[index].subtotalVatRate), + approvedTotalReviews:widget.model.wishListList[index].product.approvedTotalReviews, productImage: widget.model.wishListList[index].product.images[0].src, productID: widget.model.wishListList[index].product.id, onDelete: deleteWishListItem, diff --git a/lib/pages/pharmacies/product-brands.dart b/lib/pages/pharmacies/product-brands.dart index 42a78d5c..fb3e38e4 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -97,7 +97,7 @@ class _ProductBrandsPageState extends State { height: 10, ), Container( - height: 290, + height: 420, width: double.infinity, color: Colors.white, child: ListView.builder( diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index fe469b32..d93c3637 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -4,9 +4,9 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse. import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-preview.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; @@ -19,10 +19,14 @@ import 'package:flutter/material.dart'; import 'package:http/http.dart'; import 'package:provider/provider.dart'; +import 'cart-page/cart-order-preview.dart'; + class CartOrderPage extends StatefulWidget { - final Function(int) changeTab; - const CartOrderPage({Key key, this.changeTab}) : super(key: key); + + const CartOrderPage({ Key key}) + : super(key: key); + @override _CartOrderPageState createState() => _CartOrderPageState(); @@ -35,6 +39,7 @@ class _CartOrderPageState extends State { void initState() { super.initState(); getData(); + } @override @@ -55,7 +60,6 @@ class _CartOrderPageState extends State { showHomeAppBarIcon: false, isShowDecPage: true, baseViewModel: model, - backButtonTab: widget.changeTab != null ? () => widget.changeTab(0) : null, backgroundColor: Colors.white, body: !(model.cartResponse.shoppingCarts == null || model.cartResponse.shoppingCarts.length == 0) @@ -188,7 +192,7 @@ class _CartOrderPageState extends State { fontWeight: FontWeight.bold, ), Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, @@ -203,7 +207,7 @@ class _CartOrderPageState extends State { endIndent: 0, ), Image.asset( - "assets/images/pharmacy_module/payment_image.png", + "assets/images/pharmacy_module/payment.png", width: mediaQuery.size.width - 20, height: 30.0, fit: BoxFit.scaleDown, @@ -344,6 +348,7 @@ class _OrderBottomWidgetState extends State { Icons.info, size: 25, color: Color(0xff005aff), +// color: Color(0xff005aff), ), ), ), @@ -367,7 +372,7 @@ class _OrderBottomWidgetState extends State { child: Row( children: [ Texts( - "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: projectProvider.isArabic ? 12 : 14, fontWeight: FontWeight.bold, ), @@ -395,24 +400,52 @@ class _OrderBottomWidgetState extends State { ), RaisedButton( onPressed: isAgree +// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { - Navigator.push( - context, - FadePage( - page: - OrderPreviewPage(widget.addresses))) - } + if(cart.isCartItemsOutOfStock()){ + // Toast msg + AppToast.showErrorToast(message: TranslationBase.of(context).outOfStockMsg) + }else { + Navigator.push( + context, + FadePage( + page: + OrderPreviewPage(widget.addresses))) + } + } : null, child: new Text( "${TranslationBase.of(context).checkOut}", style: new TextStyle( color: - isAgree ? Colors.white : Colors.grey.shade300, + isAgree ? Colors.white : Colors.grey.shade300, fontSize: 14), ), - color: Color(0xff005aff), - disabledColor: Color(0xff005aff), - ), + color: Color(0xFF4CAF50), + disabledColor:Color(0xFF4CAF50), +// disabledColor: Color(0xff005aff), + ) +// RaisedButton( +// onPressed: isAgree +//// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 +// ? () => { +// Navigator.push( +// context, +// FadePage( +// page: +// OrderPreviewPage(widget.addresses))) +// } +// : null, +// child: new Text( +// "${TranslationBase.of(context).checkOut}", +// style: new TextStyle( +// color: +// isAgree ? Colors.white : Colors.grey.shade300, +// fontSize: 14), +// ), +// color: Color(0xff005aff), +// disabledColor: Color(0xff005aff), +// ) ], ), ), diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart deleted file mode 100644 index f6e1d392..00000000 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ /dev/null @@ -1,903 +0,0 @@ -import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; -import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; -import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; -import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; -import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; -import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.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:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; -import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; -import 'package:flutter/material.dart'; -import 'package:provider/provider.dart'; - -class OrderPreviewPage extends StatefulWidget { - final List addresses; - - OrderPreviewPage(this.addresses); - - @override - _OrderPreviewPageState createState() => _OrderPreviewPageState(); -} - -class _OrderPreviewPageState extends State { - MyInAppBrowser browser; - bool isLoading = true; - - @override - void initState() { - super.initState(); - getData(); - } - - void getData() async { - if (isLoading) - await Provider.of(context, listen: false) - .getShoppingCart(); - setState(() { - isLoading = false; - }); - } - - @override - Widget build(BuildContext context) { - - final mediaQuery = MediaQuery.of(context); - final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; - OrderPreviewViewModel model = Provider.of(context); - return AppScaffold( - appBarTitle: "${TranslationBase.of(context).checkOut}", - isShowAppBar: true, - isPharmacy: true, - isShowDecPage: false, - isLoading: isLoading, - isLocalLoader: true, - backgroundColor: Colors.white, - // baseViewModel: model, - body: Container( - color: Color(0xFFF1F1F1), - height: height * 0.90, - child: SingleChildScrollView( - child: Container( - color: Color(0xFFF1F1F1), - child: Column( - children: [ - SelectAddressWidget(model, widget.addresses), - SizedBox( - height: 10, - ), - SelectPaymentOptionWidget(model), - SizedBox( - height: 10, - ), - Consumer( - builder: (ctx, paymentData, _) => - paymentData.lacumInformation != null - ? Container( - child: Column( - children: [ - LakumWidget(model), - SizedBox( - height: 10, - ), - ], - ), - ) - : Container()), - Container( - color: Colors.white, - width: double.infinity, - padding: EdgeInsets.all(8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase.of(context).reviewOrder, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ...List.generate( - model.cartResponse.shoppingCarts != null - ? model.cartResponse.shoppingCarts.length - : 0, - (index) => ProductOrderPreviewItem( - model.cartResponse.shoppingCarts[index]), - ), - ], - ), - ), - Container( - width: double.infinity, - padding: EdgeInsets.all(8), - child: model.cartResponse.subtotal != null - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - TranslationBase.of(context).orderSummary, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - SizedBox( - height: 20, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase.of(context).subtotal}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase.of(context).shipping}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - "${TranslationBase.of(context).vat}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.w500, - ), - ], - ), - const Divider( - color: Color(0xFFD6D6D6), - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts( - TranslationBase.of(context).total, - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, - ), - ], - ), - SizedBox( - height: 10, - ), - ], - ) - : Container(), - ) - ], - ), - ), - ), - ), - bottomSheet: Container( - height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, - color: Colors.white, - child: PaymentBottomWidget(model), - ), - ); - } -} - -class SelectAddressWidget extends StatefulWidget { - final OrderPreviewViewModel model; - final List addresses; - - SelectAddressWidget(this.model, this.addresses); - - @override - _SelectAddressWidgetState createState() => _SelectAddressWidgetState(); -} - -class _SelectAddressWidgetState extends State { - Addresses address; - - _navigateToAddressPage() { - Navigator.push(context, FadePage(page: PharmacyAddressesPage())) - .then((result) { - if (result != null) { - address = result; - widget.model.paymentCheckoutData.address = address; - widget.model.getInformationsByAddress(); - } - - /* setState(() { - if (result != null) { - address = result; - widget.model.paymentCheckoutData.address = address; - widget.model.getInformationsByAddress(); - } - })*/ - }); - } - - @override - void initState() { - if (widget.model.paymentCheckoutData.address != null) { - address = widget.model.paymentCheckoutData.address; - } - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Consumer( - builder: (ctx, paymentData, _) => Container( - color: Colors.white, - child: address == null - ? InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_address.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).selectAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), - ), - ), - Icon( - Icons.arrow_forward_ios, - size: 20, - color: Colors.grey.shade400, - ), - ], - ), - ), - ) - : Container( - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_mark.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).shippingAddress, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToAddressPage()}, - child: Texts( - TranslationBase.of(context).changeAddress, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), - ), - ), - ], - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.firstName} ${address.lastName}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - Padding( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Texts( - "${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}", - fontSize: 12, - fontWeight: FontWeight.normal, - color: Colors.grey.shade500, - ), - ), - Row( - children: [ - Container( - margin: const EdgeInsets.only(right: 8), - child: Icon( - Icons.phone, - size: 20, - color: Colors.black, - ), - ), - Texts( - "${address.phoneNumber}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.grey, - ), - ], - ), - Container( - margin: EdgeInsets.symmetric(vertical: 8), - child: SizedBox( - height: 2, - width: double.infinity, - child: Container( - color: Color(0xffefefef), - ), - ), - ), - Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_shipping_truck.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - padding: EdgeInsets.symmetric( - vertical: 0, horizontal: 6), - child: Texts( - "${TranslationBase.of(context).shipBy}", - fontSize: 12, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - Container( - child: Image.asset( - paymentData.shippingOption - .shippingRateComputationMethodSystemName == - "Shipping.FixedOrByWeight" - ? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png" - : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", - fit: BoxFit.contain, - ), - margin: EdgeInsets.symmetric(horizontal: 8), - ), - ], - ), - ], - ), - ), - ), // ic_shipping_mark.png - ), - ); - } -} - -class SelectPaymentOptionWidget extends StatefulWidget { - final OrderPreviewViewModel model; - - SelectPaymentOptionWidget(this.model); - - @override - _SelectPaymentOptionWidgetState createState() => - _SelectPaymentOptionWidgetState(); -} - -class _SelectPaymentOptionWidgetState extends State { - PaymentOption paymentOption; - - _navigateToPaymentOption() { - Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) - .then((result) => { - setState(() { - if (result != null) { - paymentOption = result; - widget.model.paymentCheckoutData.paymentOption = - paymentOption; - widget.model.paymentCheckoutData.updateData(); - } - }) - }); - } - - @override - void initState() { - if (widget.model.paymentCheckoutData.paymentOption != null) { - paymentOption = widget.model.paymentCheckoutData.paymentOption; - } - super.initState(); - } - - @override - Widget build(BuildContext context) { - return Container( - color: Colors.white, - child: paymentOption == null - ? InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Expanded( - child: Container( - padding: - EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - TranslationBase.of(context).selectPaymentOption, - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff0000ff), - ), - ), - ), - Icon( - Icons.arrow_forward_ios, - size: 20, - color: Colors.grey.shade400, - ), - ], - ), - ), - ) - : Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/ic_payment_option.png", - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - margin: EdgeInsets.symmetric(horizontal: 8), - padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), - decoration: new BoxDecoration( - color: Colors.grey.shade100, - shape: BoxShape.rectangle, - ), - child: Image.asset( - widget.model.getPaymentOptionImage(paymentOption), - width: 30.0, - height: 30.0, - fit: BoxFit.scaleDown, - ), - ), - Expanded( - child: Container( - padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), - child: Texts( - widget.model.getPaymentOptionName(paymentOption), - fontSize: 14, - fontWeight: FontWeight.bold, - color: Colors.black, - ), - ), - ), - InkWell( - onTap: () => {_navigateToPaymentOption()}, - child: Texts( - TranslationBase.of(context).changeMethod, - fontSize: 12, - fontWeight: FontWeight.normal, - color: Color(0xff0000ff), - ), - ), - ], - ), - ), - ); - } -} - -class LakumWidget extends StatefulWidget { - final OrderPreviewViewModel model; - - LakumWidget(this.model); - - @override - _LakumWidgetState createState() => _LakumWidgetState(); -} - -class _LakumWidgetState extends State { - TextEditingController _pointsController = new TextEditingController(); - - @override - Widget build(BuildContext context) { - ProjectViewModel projectProvider = Provider.of(context); - - return Container( - color: Colors.white, - padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12), - child: Row( - children: [ - Image.asset( - "assets/images/pharmacy_module/lakum/lakum_checkout.png", - width: 30.0, - fit: BoxFit.scaleDown, - ), - Container( - decoration: BoxDecoration(color: Color(0x99ffffff)), - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - "${TranslationBase.of(context).lakumPoints}", - fontSize: 12, - fontWeight: FontWeight.bold, - ), - Texts( - "${widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount}", - fontSize: 12, - fontWeight: FontWeight.normal, - ), - ], - ), - ), - Expanded( - child: Container( - decoration: BoxDecoration(color: Color(0x99ffffff)), - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Row( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Texts( - "${TranslationBase.of(context).riyal}", - fontSize: 12, - fontWeight: FontWeight.bold, - ), - Container( - margin: projectProvider.isArabic - ? EdgeInsets.only(right: 4) - : EdgeInsets.only(left: 4), - width: 60, - height: 50, - child: TextField( - decoration: InputDecoration( - border: OutlineInputBorder( - borderSide: - BorderSide(color: Colors.black, width: 0.2), - gapPadding: 0, - borderRadius: projectProvider.isArabic - ? BorderRadius.only( - topRight: Radius.circular(8), - bottomRight: Radius.circular(8)) - : BorderRadius.only( - topLeft: Radius.circular(8), - bottomLeft: Radius.circular(8)), - ), - disabledBorder: OutlineInputBorder( - borderSide: - BorderSide(color: Colors.black, width: 0.4), - gapPadding: 0, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - bottomLeft: Radius.circular(8)), - ), - ), - controller: _pointsController, - keyboardType: TextInputType.number, - style: TextStyle( - fontSize: 14, - color: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount > - 0 - ? Colors.black - : Colors.grey, - ), - enabled: widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount == - 0 - ? false - : true, - onChanged: (val) { - var value = int.tryParse(val); - if (value != null && - value <= - widget - .model - .paymentCheckoutData - .lacumInformation - .lakumInquiryInformationObjVersion - .pointsBalanceAmount) { - widget.model.paymentCheckoutData.usedLakumPoints = - value; - } else { - widget.model.paymentCheckoutData.usedLakumPoints = 0; - } - _pointsController.text = - "${widget.model.paymentCheckoutData.usedLakumPoints}"; - }, - ), - ), - Container( - height: 50, - padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12), - decoration: new BoxDecoration( - color: Color(0xff3666E0), - shape: BoxShape.rectangle, - borderRadius: projectProvider.isArabic - ? BorderRadius.only( - topLeft: Radius.circular(6), - bottomLeft: Radius.circular(6)) - : BorderRadius.only( - topRight: Radius.circular(6), - bottomRight: Radius.circular(6)), - border: Border.fromBorderSide(BorderSide( - color: Color(0xff3666E0), - width: 0.8, - )), - ), - child: Texts( - "${TranslationBase.of(context).use}", - fontSize: 12, - color: Colors.white, - fontWeight: FontWeight.bold, - ), - ), - ], - ), - ), - ), - ], - ), - ); - } -} - -class PaymentBottomWidget extends StatelessWidget { - final OrderPreviewViewModel model; - - BuildContext context; - MyInAppBrowser browser; - - PaymentBottomWidget(this.model); - - @override - Widget build(BuildContext context) { - final scaffold = Scaffold.of(context); - this.context = context; - - return Container( - margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), - child: Consumer( - builder: (ctx, paymentData, _) => paymentData.cartDataVisible - ? Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - margin: - EdgeInsets.symmetric(horizontal: 0, vertical: 4), - child: Row( - children: [ - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", - fontSize: 14, - fontWeight: FontWeight.bold, - color: Color(0xff929295), - ), - Padding( - padding: - const EdgeInsets.symmetric(horizontal: 4), - child: Texts( - "${TranslationBase.of(context).inclusiveVat}", - fontSize: 8, - color: Color(0xff929295), - fontWeight: FontWeight.w600, - ), - ), - ], - ), - ), - Texts( - "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", - fontSize: 10, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ], - ), - Container( - child: RaisedButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide( - color: Color(0xff929295), - width: 1, - ), - ), - onPressed: (paymentData.address != null && - paymentData.paymentOption != null) - ? () async { - await model.makeOrder(); - if (model.state == ViewState.Idle) { - AppToast.showSuccessToast( - message: - "Order has been placed successfully!!"); - openPayment( - model.orderListModel[0], model.user); - } else { - AppToast.showErrorToast(message: model.error); - } - Navigator.pop(context); - Navigator.pop(context); - } - : null, - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 16), - child: new Text( - "${TranslationBase.of(context).proceedPay}", - style: new TextStyle( - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.white - : Colors.grey.shade400, - fontWeight: FontWeight.bold, - fontSize: 12), - ), - ), - color: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - disabledColor: (paymentData.address != null && - paymentData.paymentOption != null) - ? Colors.green - : Color(0xff929295), - ), - ), - ], - ), - ) - : Container(), - ), - ); - } - - openPayment( - OrderDetailModel order, - AuthenticatedUser authenticatedUser, - ) { - browser = new MyInAppBrowser( - onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart); - - browser.openPharmacyPaymentBrowser( - order, - order.orderTotal, - 'ePharmacy Order', - order.id, - order.billingAddress.email, - order.customValuesXml, - "${authenticatedUser.firstName} ${authenticatedUser.middleName} ${authenticatedUser.lastName}", - authenticatedUser.patientID, - authenticatedUser, - browser); - } - - onBrowserLoadStart(String url) { - print("onBrowserLoadStart"); - print(url); - - MyInAppBrowser.successURLS.forEach((element) { - if (url.contains(element)) { - if (browser.isOpened()) browser.close(); - MyInAppBrowser.isPaymentDone = true; - return; - } - }); - - MyInAppBrowser.errorURLS.forEach((element) { - if (url.contains(element)) { - if (browser.isOpened()) browser.close(); - MyInAppBrowser.isPaymentDone = false; - return; - } - }); - } - - onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { - print("onBrowserExit Called!!!!"); - if (isPaymentMade) { - AppToast.showSuccessToast( - message: "شكراً\nPayment status for your order is Paid"); - Navigator.pop(context); - Navigator.pop(context); - } else { - AppToast.showErrorToast( - message: - "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); - } - } -} diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart new file mode 100644 index 00000000..ef4904b2 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -0,0 +1,420 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-preview.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class CartOrderPage extends StatefulWidget { + final Function(int) changeTab; + + const CartOrderPage({Key key, this.changeTab}) : super(key: key); + + @override + _CartOrderPageState createState() => _CartOrderPageState(); +} + +class _CartOrderPageState extends State { + bool isLoading = true; + + @override + void initState() { + super.initState(); + getData(); + } + + @override + Widget build(BuildContext context) { + final mediaQuery = MediaQuery.of(context); + OrderPreviewViewModel model = Provider.of(context); + + final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; + AppScaffold appScaffold; + return NetworkBaseView( + // baseViewModel: model, + isLoading: isLoading, + isLocalLoader: true, + child: AppScaffold( + appBarTitle: TranslationBase.of(context).shoppingCart, + isShowAppBar: true, + isPharmacy: true, + showHomeAppBarIcon: false, + isShowDecPage: true, + baseViewModel: model, + backButtonTab: + widget.changeTab != null ? () => widget.changeTab(0) : null, + backgroundColor: Colors.white, + body: !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) + ? Container( + height: height * 0.85, + width: double.infinity, + child: SingleChildScrollView( + child: Container( + margin: EdgeInsets.all(10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + GestureIconButton( + TranslationBase.of(context).deleteAllItems, + Icon( + Icons.delete_outline_sharp, + color: Colors.grey.shade700, + ), + onTap: () => {model.deleteShoppingCart()}, + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Container( + child: Column( + children: [ + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model.cartResponse.shoppingCarts.length + : 0, + (index) => ProductOrderItem( + model.cartResponse + .shoppingCarts[index], () { + print(model.cartResponse + .shoppingCarts[index].quantity); + model + .changeProductQuantity(model + .cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); + } + if (model.state == + ViewState.ErrorLocal) { + Utils.showErrorToast(model.error); + } + }); + }, () { + model + .deleteProduct(model.cartResponse + .shoppingCarts[index]) + .then((value) { + if (model.state != ViewState.Error) { + appScaffold.appBar.badgeUpdater( + '${value.quantityCount ?? 0}'); + } + }); + })) + ], + ), + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 2, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).subtotal, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).vat}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).total, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Image.asset( + "assets/images/pharmacy_module/payment_image.png", + width: mediaQuery.size.width - 20, + height: 30.0, + fit: BoxFit.scaleDown, + ), + SizedBox( + height: 120, + ) + ], + ), + ), + ), + ) + : Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: Image.asset( + 'assets/images/new-design/empty_box.png', + width: 100, + height: 100, + fit: BoxFit.cover, + ), + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context).noData, +// 'There is no data', + style: TextStyle(fontSize: 30), + ), + ) + ], + ), + ), + bottomSheet: Container( + height: !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) + ? height * 0.15 + : 0, + color: Colors.white, + child: OrderBottomWidget(model.addresses, height), + ), + ), + ); + } + + void getData() async { + await Provider.of(context, listen: false) + .getShoppingCart(); + setState(() { + isLoading = false; + }); + } +} + +class OrderBottomWidget extends StatefulWidget { + final List addresses; + final double height; + + OrderBottomWidget(this.addresses, this.height); + + @override + _OrderBottomWidgetState createState() => _OrderBottomWidgetState(); +} + +class _OrderBottomWidgetState extends State { + bool isAgree = false; + + @override + Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); + OrderPreviewViewModel cart = Provider.of(context); + return !(cart.cartResponse.shoppingCarts == null || + cart.cartResponse.shoppingCarts.length == 0) + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Divider( + color: Color(0xFFD6D6D6), + height: 1, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Container( + height: widget.height * 0.070, + color: Color(0xffe6ffe0), + padding: EdgeInsets.symmetric(horizontal: 4), + child: Row( + children: [ + InkWell( + onTap: () { + setState(() { + isAgree = !isAgree; + }); + }, + child: Container( + width: 25.0, + height: widget.height * 0.070, + decoration: new BoxDecoration( + 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, + ), + ), + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 4), + margin: const EdgeInsets.symmetric(vertical: 4), + child: Texts( + TranslationBase.of(context) + .pharmacyServiceTermsCondition, + fontSize: 13, + color: Colors.grey.shade800, + fontWeight: FontWeight.normal, + ), + ), + ), + InkWell( + onTap: () => { + Navigator.push( + context, FadePage(page: PharmacyTermsConditions())) + }, + child: Container( + child: Icon( + Icons.info, + size: 25, + color: Color(0xff005aff), + ), + ), + ), + ], + ), + ), + Container( + height: widget.height * 0.065, + margin: EdgeInsets.symmetric(vertical: 2), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.symmetric( + horizontal: 0, vertical: 0), + child: Row( + children: [ + Texts( + "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: projectProvider.isArabic ? 12 : 14, + fontWeight: FontWeight.bold, + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + Texts( + "${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ], + ), + ), + RaisedButton( + onPressed: isAgree + ? () => { + Navigator.push( + context, + FadePage( + page: + OrderPreviewPage(widget.addresses))) + } + : null, + child: new Text( + "${TranslationBase.of(context).checkOut}", + style: new TextStyle( + color: + isAgree ? Colors.white : Colors.grey.shade300, + fontSize: 14), + ), + color: Color(0xff005aff), + disabledColor: Color(0xff005aff), + ), + ], + ), + ), + ], + ) + : Container(); + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart new file mode 100644 index 00000000..25c02dd0 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -0,0 +1,238 @@ +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/select_address_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import 'lakum_widget.dart'; + +class OrderPreviewPage extends StatefulWidget { + final List addresses; + + OrderPreviewPage(this.addresses); + + @override + _OrderPreviewPageState createState() => _OrderPreviewPageState(); +} + +class _OrderPreviewPageState extends State { + MyInAppBrowser browser; + bool isLoading = true; + + @override + void initState() { + super.initState(); + getData(); + } + + void getData() async { + if (isLoading) + await Provider.of(context, listen: false) + .getShoppingCart(); + setState(() { + isLoading = false; + }); + } + + @override + Widget build(BuildContext context) { + final mediaQuery = MediaQuery.of(context); + final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; + OrderPreviewViewModel model = Provider.of(context); + return AppScaffold( + appBarTitle: "${TranslationBase.of(context).checkOut}", + isShowAppBar: true, + isPharmacy: true, + isShowDecPage: false, + isLoading: isLoading, + isLocalLoader: true, + backgroundColor: Colors.white, + // baseViewModel: model, + body: Container( + color: Color(0xFFF1F1F1), + height: height * 0.90, + child: SingleChildScrollView( + child: Container( + color: Color(0xFFF1F1F1), + child: Column( + children: [ + SelectAddressWidget(model, widget.addresses), + SizedBox( + height: 10, + ), + SelectPaymentOptionWidget(model), + SizedBox( + height: 10, + ), + model.paymentCheckoutData.lacumInformation != null + ? Container( + child: Column( + children: [ + LakumWidget(model), + SizedBox( + height: 10, + ), + ], + ), + ) + : Container(), + Container( + color: Colors.white, + width: double.infinity, + padding: EdgeInsets.all(8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context).reviewOrder, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ...List.generate( + model.cartResponse.shoppingCarts != null + ? model.cartResponse.shoppingCarts.length + : 0, + (index) => ProductOrderPreviewItem( + model.cartResponse.shoppingCarts[index]), + ), + ], + ), + ), + Container( + width: double.infinity, + padding: EdgeInsets.all(8), + child: model.cartResponse.subtotal != null + ? Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + TranslationBase.of(context).orderSummary, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + SizedBox( + height: 20, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).subtotal}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).shipping}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + "${TranslationBase.of(context).vat}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.w500, + ), + ], + ), + const Divider( + color: Color(0xFFD6D6D6), + height: 20, + thickness: 1, + indent: 0, + endIndent: 0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts( + TranslationBase.of(context).total, + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + color: Colors.black, + fontWeight: FontWeight.bold, + ), + ], + ), + SizedBox( + height: 10, + ), + ], + ) + : Container(), + ), + SizedBox( + height: model.cartResponse.shoppingCarts != null + ? height * 0.10 + : 0, + ) + ], + ), + ), + ), + ), + bottomSheet: Container( + height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, + color: Colors.white, + child: PaymentBottomWidget(model), + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/lakum_widget.dart b/lib/pages/pharmacies/screens/cart-page/lakum_widget.dart new file mode 100644 index 00000000..cdd26ddc --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/lakum_widget.dart @@ -0,0 +1,187 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.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:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class LakumWidget extends StatefulWidget { + final OrderPreviewViewModel model; + + LakumWidget(this.model); + + @override + _LakumWidgetState createState() => _LakumWidgetState(); +} + +class _LakumWidgetState extends State { + TextEditingController _pointsController = new TextEditingController(); + + @override + Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); + + return Container( + color: Colors.white, + padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/lakum/lakum_checkout.png", + width: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + decoration: BoxDecoration(color: Color(0x99ffffff)), + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + "${TranslationBase.of(context).lakumPoints}", + fontSize: 12, + fontWeight: FontWeight.bold, + ), + Texts( + "${widget.model.paymentCheckoutData.lacumInformation.lakumInquiryInformationObjVersion.pointsBalanceAmount}", + fontSize: 12, + fontWeight: FontWeight.normal, + ), + ], + ), + ), + Expanded( + child: Container( + decoration: BoxDecoration(color: Color(0x99ffffff)), + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Texts( + "${TranslationBase.of(context).riyal}", + fontSize: 12, + fontWeight: FontWeight.bold, + ), + Container( + margin: projectProvider.isArabic + ? EdgeInsets.only(right: 4) + : EdgeInsets.only(left: 4), + width: 60, + height: 50, + child: TextField( + decoration: InputDecoration( + border: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.black, width: 0.2), + gapPadding: 0, + borderRadius: projectProvider.isArabic + ? BorderRadius.only( + topRight: Radius.circular(8), + bottomRight: Radius.circular(8)) + : BorderRadius.only( + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8)), + ), + disabledBorder: OutlineInputBorder( + borderSide: + BorderSide(color: Colors.black, width: 0.4), + gapPadding: 0, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8)), + ), + ), + controller: _pointsController, + keyboardType: TextInputType.number, + style: TextStyle( + fontSize: 14, + color: widget + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount > + 0 + ? Colors.black + : Colors.grey, + ), + enabled: widget + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount == + 0 + ? false + : true, + onChanged: (val) { + var value = int.tryParse(val); + if (value != null && + value <= + widget + .model + .paymentCheckoutData + .lacumInformation + .lakumInquiryInformationObjVersion + .pointsBalanceAmount) { + widget.model.paymentCheckoutData.usedLakumPoints = + value; + } else { + widget.model.paymentCheckoutData.usedLakumPoints = 0; + } + _pointsController.text = + "${widget.model.paymentCheckoutData.usedLakumPoints}"; + }, + ), + ), + Container( + height: 50, + padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12), + decoration: new BoxDecoration( + color: Color(0xff3666E0), + shape: BoxShape.rectangle, + borderRadius: projectProvider.isArabic + ? BorderRadius.only( + topLeft: Radius.circular(6), + bottomLeft: Radius.circular(6)) + : BorderRadius.only( + topRight: Radius.circular(6), + bottomRight: Radius.circular(6)), + border: Border.fromBorderSide(BorderSide( + color: Color(0xff3666E0), + width: 0.8, + )), + ), + child: Texts( + "${TranslationBase.of(context).use}", + fontSize: 12, + color: Colors.white, + fontWeight: FontWeight.bold, + ), + ), + ], + ), + ), + ), + ], + ), + ); + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart new file mode 100644 index 00000000..e0063878 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart @@ -0,0 +1,195 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.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:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class PaymentBottomWidget extends StatelessWidget { + final OrderPreviewViewModel model; + + BuildContext context; + MyInAppBrowser browser; + + PaymentBottomWidget(this.model); + + @override + Widget build(BuildContext context) { + final scaffold = Scaffold.of(context); + this.context = context; + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + return Container( + margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), + child: orderPreviewViewModel.paymentCheckoutData.cartDataVisible + ? Container( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + margin: + EdgeInsets.symmetric(horizontal: 0, vertical: 4), + child: Row( + children: [ + Texts( + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff929295), + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Color(0xff929295), + fontWeight: FontWeight.w600, + ), + ), + ], + ), + ), + Texts( + "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ], + ), + Container( + child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide( + color: Color(0xff929295), + width: 1, + ), + ), + onPressed: (orderPreviewViewModel + .paymentCheckoutData.address != + null && + orderPreviewViewModel + .paymentCheckoutData.paymentOption != + null) + ? () async { + await model.makeOrder(); + if (model.state == ViewState.Idle) { + AppToast.showSuccessToast( + message: + "Order has been placed successfully!!"); + openPayment( + model.orderListModel[0], model.user); + } else { + AppToast.showErrorToast(message: model.error); + } + Navigator.pop(context); + Navigator.pop(context); + } + : null, + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 16), + child: new Text( + "${TranslationBase.of(context).proceedPay}", + style: new TextStyle( + color: (orderPreviewViewModel + .paymentCheckoutData.address != + null && + orderPreviewViewModel.paymentCheckoutData + .paymentOption != + null) + ? Colors.white + : Colors.grey.shade400, + fontWeight: FontWeight.bold, + fontSize: 12), + ), + ), + color: + (orderPreviewViewModel.paymentCheckoutData.address != + null && + orderPreviewViewModel + .paymentCheckoutData.paymentOption != + null) + ? Colors.green + : Color(0xff929295), + disabledColor: + (orderPreviewViewModel.paymentCheckoutData.address != + null && + orderPreviewViewModel + .paymentCheckoutData.paymentOption != + null) + ? Colors.green + : Color(0xff929295), + ), + ), + ], + ), + ) + : Container(), + ); + } + + openPayment( + OrderDetailModel order, + AuthenticatedUser authenticatedUser, + ) { + browser = new MyInAppBrowser( + onExitCallback: onBrowserExit, onLoadStartCallback: onBrowserLoadStart); + + browser.openPharmacyPaymentBrowser( + order, + order.orderTotal, + 'ePharmacy Order', + order.id, + order.billingAddress.email, + order.customValuesXml, + "${authenticatedUser.firstName} ${authenticatedUser.middleName} ${authenticatedUser.lastName}", + authenticatedUser.patientID, + authenticatedUser, + browser); + } + + onBrowserLoadStart(String url) { + print("onBrowserLoadStart"); + print(url); + + MyInAppBrowser.successURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = true; + return; + } + }); + + MyInAppBrowser.errorURLS.forEach((element) { + if (url.contains(element)) { + if (browser.isOpened()) browser.close(); + MyInAppBrowser.isPaymentDone = false; + return; + } + }); + } + + onBrowserExit(AppoitmentAllHistoryResultList appo, bool isPaymentMade) { + print("onBrowserExit Called!!!!"); + if (isPaymentMade) { + AppToast.showSuccessToast( + message: "شكراً\nPayment status for your order is Paid"); + Navigator.pop(context); + Navigator.pop(context); + } else { + AppToast.showErrorToast( + message: + "Transaction Failed!\Your transaction is field to some reason please try again or contact to the administration"); + } + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart new file mode 100644 index 00000000..bf958a36 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -0,0 +1,226 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.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:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class SelectAddressWidget extends StatefulWidget { + final OrderPreviewViewModel model; + final List addresses; + + SelectAddressWidget(this.model, this.addresses); + + @override + _SelectAddressWidgetState createState() => _SelectAddressWidgetState(); +} + +class _SelectAddressWidgetState extends State { + Addresses address; + + _navigateToAddressPage() { + Navigator.push(context, FadePage(page: PharmacyAddressesPage())) + .then((result) { + if (result != null) { + address = result; + widget.model.paymentCheckoutData.address = address; + widget.model.getInformationsByAddress(); + } + + /* setState(() { + if (result != null) { + address = result; + widget.model.paymentCheckoutData.address = address; + widget.model.getInformationsByAddress(); + } + })*/ + }); + } + + @override + void initState() { + if (widget.model.paymentCheckoutData.address != null) { + address = widget.model.paymentCheckoutData.address; + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + OrderPreviewViewModel model = Provider.of(context); + return Container( + color: Colors.white, + child: address == null + ? InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_address.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).selectAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), + ), + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], + ), + ), + ) + : Container( + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_mark.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric( + vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).shippingAddress, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToAddressPage()}, + child: Texts( + TranslationBase.of(context).changeAddress, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), + ), + ), + ], + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.firstName} ${address.lastName}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + Padding( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Texts( + "${address.address1} ${address.address2} ${address.address2},, ${address.city}, ${address.country} ${address.zipPostalCode}", + fontSize: 12, + fontWeight: FontWeight.normal, + color: Colors.grey.shade500, + ), + ), + Row( + children: [ + Container( + margin: const EdgeInsets.only(right: 8), + child: Icon( + Icons.phone, + size: 20, + color: Colors.black, + ), + ), + Texts( + "${address.phoneNumber}", + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.grey, + ), + ], + ), + Container( + margin: EdgeInsets.symmetric(vertical: 8), + child: SizedBox( + height: 2, + width: double.infinity, + child: Container( + color: Color(0xffefefef), + ), + ), + ), + Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_shipping_truck.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + "${TranslationBase.of(context).shipBy}", + fontSize: 12, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + Container( + child: Image.asset( + model.paymentCheckoutData.shippingOption == null + ? "" + : model.paymentCheckoutData.shippingOption + .shippingRateComputationMethodSystemName == + "Shipping.FixedOrByWeight" + ? "assets/images/pharmacy_module/payment/hmg_shipping_logo.png" + : "assets/images/pharmacy_module/payment/aramex_shipping_logo.png", + fit: BoxFit.contain, + ), + margin: EdgeInsets.symmetric(horizontal: 8), + ), + ], + ), + ], + ), + ), + ), // ic_shipping_mark.png + ); + } +} diff --git a/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart new file mode 100644 index 00000000..9234bb38 --- /dev/null +++ b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart @@ -0,0 +1,146 @@ +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/order_detail.dart'; +import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/order_model_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart'; +import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart'; +import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/payment_bottom_widget.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.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:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class SelectPaymentOptionWidget extends StatefulWidget { + final OrderPreviewViewModel model; + + SelectPaymentOptionWidget(this.model); + + @override + _SelectPaymentOptionWidgetState createState() => + _SelectPaymentOptionWidgetState(); +} + +class _SelectPaymentOptionWidgetState extends State { + PaymentOption paymentOption; + + _navigateToPaymentOption() { + Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) + .then((result) => { + setState(() { + if (result != null) { + paymentOption = result; + widget.model.paymentCheckoutData.paymentOption = + paymentOption; + } + }) + }); + } + + @override + void initState() { + if (widget.model.paymentCheckoutData.paymentOption != null) { + paymentOption = widget.model.paymentCheckoutData.paymentOption; + } + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Container( + color: Colors.white, + child: paymentOption == null + ? InkWell( + onTap: () => {_navigateToPaymentOption()}, + child: Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Expanded( + child: Container( + padding: + EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + TranslationBase.of(context).selectPaymentOption, + fontSize: 14, + fontWeight: FontWeight.bold, + color: Color(0xff0000ff), + ), + ), + ), + Icon( + Icons.arrow_forward_ios, + size: 20, + color: Colors.grey.shade400, + ), + ], + ), + ), + ) + : Container( + margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + child: Row( + children: [ + Image.asset( + "assets/images/pharmacy_module/ic_payment_option.png", + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.symmetric(horizontal: 4, vertical: 0), + decoration: new BoxDecoration( + color: Colors.grey.shade100, + shape: BoxShape.rectangle, + ), + child: Image.asset( + widget.model.getPaymentOptionImage(paymentOption), + width: 30.0, + height: 30.0, + fit: BoxFit.scaleDown, + ), + ), + Expanded( + child: Container( + padding: EdgeInsets.symmetric(vertical: 0, horizontal: 6), + child: Texts( + widget.model.getPaymentOptionName(paymentOption), + fontSize: 14, + fontWeight: FontWeight.bold, + color: Colors.black, + ), + ), + ), + InkWell( + onTap: () => {_navigateToPaymentOption()}, + child: Texts( + TranslationBase.of(context).changeMethod, + fontSize: 12, + fontWeight: FontWeight.normal, + color: Color(0xff0000ff), + ), + ), + ], + ), + ), + ); + } +} 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 583c904f..19286b6a 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -10,7 +10,7 @@ import 'package:hexcolor/hexcolor.dart'; import '../../../../../locator.dart'; import '../../../../../routes.dart'; -import '../../cart-order-page.dart'; +import '../../cart-page/cart-order-page.dart'; import '../product-detail.dart'; class FooterWidget extends StatefulWidget { @@ -20,6 +20,7 @@ class FooterWidget extends StatefulWidget { final int quantityLimit; final PharmacyProduct item; final Function addToCartFunction; + final Function addToShoppingCartFunction; final ProductDetailViewModel model; int quantity; @@ -30,6 +31,7 @@ class FooterWidget extends StatefulWidget { {this.quantity, this.isOverQuantity = false, this.addToCartFunction, + this.addToShoppingCartFunction, this.model}); @override @@ -185,7 +187,7 @@ class _FooterWidgetState extends State { width: MediaQuery.of(context).size.width * 0.45, child: SecondaryButton( label: TranslationBase.of(context).addToCart.toUpperCase(), - disabled: !widget.isAvailable && widget.quantity > 0 || + disabled: !widget.isAvailable && widget.quantity == 0 || widget.quantity > widget.quantityLimit || widget.item.rxMessage != null, disableColor: Color(0xFF4CAF50), @@ -196,9 +198,9 @@ class _FooterWidgetState extends State { ); } else await widget.addToCartFunction( - quantity: widget.quantity, - itemID: widget.item.id, - model: widget.model); + quantity: widget.quantity, + itemID: widget.item.id, + model: widget.model); }, fontWeight: FontWeight.w600, borderColor: Color(0xFF4CAF50), @@ -217,7 +219,7 @@ class _FooterWidgetState extends State { widget.quantity > widget.quantityLimit || widget.item.rxMessage != null, onTap: () async { - await widget.addToCartFunction( + await widget.addToShoppingCartFunction( quantity: widget.quantity, itemID: widget.item.id, model: widget.model); diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 229fec19..07c5d0e8 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart'; @@ -13,6 +14,7 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'availability_info.dart'; @@ -313,7 +315,12 @@ class __ProductDetailPageState extends State { SizedBox( height: 10, ), - RecommendedProducts(product: widget.product) + RecommendedProducts(product: widget.product,productDetailViewModel: model, + addToWishlistFunction: (itemID) async { + await addToWishlistFunction(itemID: itemID, model: model); + }, deleteFromWishlistFunction: (itemID) async { + await deleteFromWishlistFunction(itemID: itemID, model: model); + },) ], ), ), @@ -326,6 +333,7 @@ class __ProductDetailPageState extends State { quantity: quantity, isOverQuantity: isOverQuantity, addToCartFunction: addToCartFunction, + addToShoppingCartFunction: addToShoppingCartFunction, model: model, ), )); diff --git a/lib/pages/pharmacies/screens/product-details/recommended_products.dart b/lib/pages/pharmacies/screens/product-details/recommended_products.dart index 2070a29e..6e0fbba9 100644 --- a/lib/pages/pharmacies/screens/product-details/recommended_products.dart +++ b/lib/pages/pharmacies/screens/product-details/recommended_products.dart @@ -1,9 +1,11 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; @@ -24,6 +26,9 @@ class RecommendedProducts extends StatefulWidget { final Function addToWishlistFunction; final Function deleteFromWishlistFunction; + AuthenticatedUserObject authenticatedUserObject = + locator(); + RecommendedProducts( {Key key, this.product, @@ -134,63 +139,27 @@ class _RecommendedProductsState extends State { child: Align( alignment: Alignment.topRight, child: IconButton( - icon: Icon(model - .recommendedProductList[ - index] - .isinwishlist != - true - ? Icons.favorite_border - : Icons.favorite), - color: model - .recommendedProductList[ - index] - .isinwishlist != - true - ? Colors.grey - : Colors.red, + icon: Icon(model.recommendedProductList[index].isinwishlist != true + ? Icons.favorite_border : Icons.favorite), + color: model.recommendedProductList[index].isinwishlist != true + ? Colors.grey : Colors.red, onPressed: () async { - if (widget.customerId != null) { - if (!widget.isInWishList && - model - .recommendedProductList[ - index] - .isinwishlist != - true) { - GifLoaderDialogUtils - .showMyDialog(context); - await widget.addToWishlistFunction( - itemID: model - .recommendedProductList[ - index] - .id, - model: widget - .productDetailViewModel); -// checkWishlist(); - GifLoaderDialogUtils - .hideDialog(context); + if (widget.authenticatedUserObject.isLogin + ) { + if (!widget.isInWishList && model.recommendedProductList[index].isinwishlist != true) { + GifLoaderDialogUtils.showMyDialog(context); + await widget.addToWishlistFunction(model.recommendedProductList[index].id, + ); + GifLoaderDialogUtils.hideDialog(context); setState(() { - model - .recommendedProductList[ - index] - .isinwishlist = true; - }); + model.recommendedProductList[index].isinwishlist = true;}); } else { - GifLoaderDialogUtils - .showMyDialog(context); - await widget.deleteFromWishlistFunction( - itemID: model - .recommendedProductList[ - index] - .id, - model: widget - .productDetailViewModel); - GifLoaderDialogUtils - .hideDialog(context); + GifLoaderDialogUtils.showMyDialog(context); + await widget.deleteFromWishlistFunction(model.recommendedProductList[index].id, + ); + GifLoaderDialogUtils.hideDialog(context); setState(() { - model - .recommendedProductList[ - index] - .isinwishlist = false; + model.recommendedProductList[index].isinwishlist = false; }); } } else { 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 82c1b5cf..18277bad 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 @@ -12,7 +12,7 @@ import 'package:provider/provider.dart'; import '../../../../../locator.dart'; import '../../../compare-list.dart'; -import '../../cart-order-page.dart'; +import '../../cart-page/cart-order-page.dart'; import 'icon_with_bg.dart'; class ProductAppBar extends StatelessWidget with PreferredSizeWidget { diff --git a/lib/pages/pharmacies/widgets/ProductOrderItem.dart b/lib/pages/pharmacies/widgets/ProductOrderItem.dart index d7a82cc6..11976175 100644 --- a/lib/pages/pharmacies/widgets/ProductOrderItem.dart +++ b/lib/pages/pharmacies/widgets/ProductOrderItem.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; class ProductOrderItem extends StatefulWidget { @@ -39,12 +40,13 @@ class _ProductOrderItemState extends State { leading: InkWell( onTap: () => {widget.deleteCartItems()}, child: Icon( - Icons.delete_outline_sharp, + FontAwesomeIcons.trashAlt,size: 15, color: Colors.grey.shade700, ), ), title: Container( child: Row( +// widget.item.product.stock_quantity===0 crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ @@ -166,10 +168,22 @@ class _ProductOrderItemState extends State { "$_totalPrice ${projectProvider.isArabic ? widget.item.currencyn : widget.item.currency}", fontSize: 12, fontWeight: FontWeight.bold, - ) + ), + widget.item.product.stockQuantity == 0 ? + Texts( + projectProvider.isArabic + ? widget.item.product.stockAvailabilityn + : widget.item.product.stockAvailability, + fontWeight: FontWeight.normal, + fontSize: 13, + color:Colors.red, + + ): Texts(""), ], ), - ) + ), + + ], ), ) diff --git a/lib/pages/pharmacies/widgets/home/GridViewButtons.dart b/lib/pages/pharmacies/widgets/home/GridViewButtons.dart index 5d979136..1a33ce74 100644 --- a/lib/pages/pharmacies/widgets/home/GridViewButtons.dart +++ b/lib/pages/pharmacies/widgets/home/GridViewButtons.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/pages/landing/home_page.dart'; import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; +import 'package:diplomaticquarterapp/pages/search_products_page.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -44,6 +45,9 @@ class GridViewButtons extends StatelessWidget { hasColorFilter: false, child: GridViewCard(TranslationBase.of(context).medicationRefill, 'assets/images/pharmacy_module/medication_icon.png', () { + Navigator.push( + context, FadePage(page: HomePrescriptionsPage())); + // model.checkUserIsActivated().then((isActivated) { // if (isActivated) { // Navigator.push(context, FadePage(page: LakumMainPage())); @@ -71,7 +75,7 @@ class GridViewButtons extends StatelessWidget { child: GridViewCard( TranslationBase.of(context).searchAndScanMedication, 'assets/images/pharmacy_module/search_scan_icon.png', - () {}), + () {Navigator.push(context, FadePage(page: SearchProductsPage()));}), ), ], ), diff --git a/lib/pages/pharmacy/order/Order.dart b/lib/pages/pharmacy/order/Order.dart index 7ffcbdbd..4e4a0cc9 100644 --- a/lib/pages/pharmacy/order/Order.dart +++ b/lib/pages/pharmacy/order/Order.dart @@ -70,6 +70,7 @@ class _OrderPageState extends State TabBar( labelPadding: EdgeInsets.only(left: 3.0, right: 3.0), labelColor: Colors.black, + indicatorColor: Colors.green, tabs: [ Tab(text: TranslationBase.of(context).delivered), Tab(text: TranslationBase.of(context).processing), @@ -127,86 +128,86 @@ class _OrderPageState extends State return Container( child: Column( children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Container( - margin: EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - margin: EdgeInsets.only(right: 5), - child: Text( - TranslationBase.of(context) - .orderNumber, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, + InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: OrderDetailsPage( + orderModel: + deliveredOrderList[ + index]), + )); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5), + child: Text( + TranslationBase.of(context) + .orderNumber, + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + ), ), ), - ), - Container( - child: Text( - deliveredOrderList[index] - .id - .toString(), - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, + Container( + child: Text( + deliveredOrderList[index] + .id + .toString(), + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + ), ), ), - ), - ], - ), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - margin: EdgeInsets.only(right: 5), - child: Text( - TranslationBase.of(context) - .orderDate, - style: TextStyle( - fontSize: 14.0, + ], + ), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5), + child: Text( + TranslationBase.of(context) + .orderDate, + style: TextStyle( + fontSize: 14.0, + ), ), ), - ), - Container( - child: Text( - deliveredOrderList[index] - .createdOnUtc - .toString() - .substring(0, 10), - style: TextStyle( - fontSize: 14.0, + Container( + child: Text( + deliveredOrderList[index] + .createdOnUtc + .toString() + .substring(0, 10), + style: TextStyle( + fontSize: 14.0, + ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ), - Container( - margin: EdgeInsets.all(8.0), - child: InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: OrderDetailsPage( - orderModel: - deliveredOrderList[ - index]), - )); - }, + Container( + margin: EdgeInsets.all(8.0), child: SvgPicture.asset( languageID == "ar" ? 'assets/images/pharmacy/arrow_left.svg' @@ -215,8 +216,8 @@ class _OrderPageState extends State width: 20, ), ), - ), - ], + ], + ), ), Divider( color: Colors.grey[350], @@ -394,85 +395,85 @@ class _OrderPageState extends State return Container( child: Column( children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Container( - margin: EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - margin: EdgeInsets.only(right: 5), - child: Text( - TranslationBase.of(context) - .orderNumber, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, + InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: OrderDetailsPage( + orderModel: + processingOrderList[ + index]))); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5), + child: Text( + TranslationBase.of(context) + .orderNumber, + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + ), ), ), - ), - Container( - child: Text( - processingOrderList[index] - .id - .toString(), - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, + Container( + child: Text( + processingOrderList[index] + .id + .toString(), + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + ), ), ), - ), - ], - ), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - margin: EdgeInsets.only(right: 5), - child: Text( - TranslationBase.of(context) - .orderDate, - style: TextStyle( - fontSize: 14.0, + ], + ), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + margin: EdgeInsets.only(right: 5), + child: Text( + TranslationBase.of(context) + .orderDate, + style: TextStyle( + fontSize: 14.0, + ), ), ), - ), - Container( - child: Text( - processingOrderList[index] - .createdOnUtc - .toString() - .substring(0, 10), - style: TextStyle( - fontSize: 14.0, + Container( + child: Text( + processingOrderList[index] + .createdOnUtc + .toString() + .substring(0, 10), + style: TextStyle( + fontSize: 14.0, + ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ), - Container( - margin: EdgeInsets.all(8.0), - child: InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: OrderDetailsPage( - orderModel: - processingOrderList[ - index]))); - }, + Container( + margin: EdgeInsets.all(8.0), child: SvgPicture.asset( languageID == "ar" ? 'assets/images/pharmacy/arrow_left.svg' @@ -481,8 +482,8 @@ class _OrderPageState extends State width: 20, ), ), - ), - ], + ], + ), ), Divider( color: Colors.grey[350], @@ -837,87 +838,87 @@ class _OrderPageState extends State child: SingleChildScrollView( child: Column( children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Container( - margin: EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - margin: - EdgeInsets.only(right: 5), - child: Text( - TranslationBase.of(context) - .orderNumber, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, + InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: OrderDetailsPage( + orderModel: + pendingOrderList[ + index]))); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + margin: + EdgeInsets.only(right: 5), + child: Text( + TranslationBase.of(context) + .orderNumber, + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + ), ), ), - ), - Container( - child: Text( - pendingOrderList[index] - .id - .toString(), - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, + Container( + child: Text( + pendingOrderList[index] + .id + .toString(), + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + ), ), ), - ), - ], - ), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - margin: - EdgeInsets.only(right: 5), - child: Text( - TranslationBase.of(context) - .orderDate, - style: TextStyle( - fontSize: 14.0, + ], + ), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + margin: + EdgeInsets.only(right: 5), + child: Text( + TranslationBase.of(context) + .orderDate, + style: TextStyle( + fontSize: 14.0, + ), ), ), - ), - Container( - child: Text( - pendingOrderList[index] - .createdOnUtc - .toString() - .substring(0, 10), - style: TextStyle( - fontSize: 14.0, + Container( + child: Text( + pendingOrderList[index] + .createdOnUtc + .toString() + .substring(0, 10), + style: TextStyle( + fontSize: 14.0, + ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ), - Container( - margin: EdgeInsets.all(8.0), - child: InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: OrderDetailsPage( - orderModel: - pendingOrderList[ - index]))); - }, + Container( + margin: EdgeInsets.all(8.0), child: SvgPicture.asset( languageID == "ar" ? 'assets/images/pharmacy/arrow_left.svg' @@ -926,8 +927,8 @@ class _OrderPageState extends State width: 20, ), ), - ), - ], + ], + ), ), Divider( color: Colors.grey[350], @@ -1106,87 +1107,87 @@ class _OrderPageState extends State child: SingleChildScrollView( child: Column( children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - children: [ - Container( - margin: EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - margin: - EdgeInsets.only(right: 5), - child: Text( - TranslationBase.of(context) - .orderNumber, - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, + InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: OrderDetailsPage( + orderModel: + cancelledOrderList[ + index]))); + }, + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Container( + margin: EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + margin: + EdgeInsets.only(right: 5), + child: Text( + TranslationBase.of(context) + .orderNumber, + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + ), ), ), - ), - Container( - child: Text( - cancelledOrderList[index] - .id - .toString(), - style: TextStyle( - fontSize: 16.0, - fontWeight: FontWeight.bold, + Container( + child: Text( + cancelledOrderList[index] + .id + .toString(), + style: TextStyle( + fontSize: 16.0, + fontWeight: FontWeight.bold, + ), ), ), - ), - ], - ), - SizedBox( - height: 5, - ), - Row( - children: [ - Container( - margin: - EdgeInsets.only(right: 5), - child: Text( - TranslationBase.of(context) - .orderDate, - style: TextStyle( - fontSize: 14.0, + ], + ), + SizedBox( + height: 5, + ), + Row( + children: [ + Container( + margin: + EdgeInsets.only(right: 5), + child: Text( + TranslationBase.of(context) + .orderDate, + style: TextStyle( + fontSize: 14.0, + ), ), ), - ), - Container( - child: Text( - cancelledOrderList[index] - .createdOnUtc - .toString() - .substring(0, 10), - style: TextStyle( - fontSize: 14.0, + Container( + child: Text( + cancelledOrderList[index] + .createdOnUtc + .toString() + .substring(0, 10), + style: TextStyle( + fontSize: 14.0, + ), ), ), - ), - ], - ), - ], + ], + ), + ], + ), ), - ), - Container( - margin: EdgeInsets.all(8.0), - child: InkWell( - onTap: () { - Navigator.push( - context, - FadePage( - page: OrderDetailsPage( - orderModel: - cancelledOrderList[ - index]))); - }, + Container( + margin: EdgeInsets.all(8.0), child: SvgPicture.asset( languageID == "ar" ? 'assets/images/pharmacy/arrow_left.svg' @@ -1195,8 +1196,8 @@ class _OrderPageState extends State width: 20, ), ), - ), - ], + ], + ), ), Divider( color: Colors.grey[350], diff --git a/lib/pages/pharmacy/order/OrderDetails.dart b/lib/pages/pharmacy/order/OrderDetails.dart index 1275042a..aadb5a90 100644 --- a/lib/pages/pharmacy/order/OrderDetails.dart +++ b/lib/pages/pharmacy/order/OrderDetails.dart @@ -321,8 +321,7 @@ class _OrderDetailsPageState extends State { margin: EdgeInsets.only(bottom: 10.0, top: 10.0), child: Text( model.orderListModel[0].paymentName - .toString() - .substring(12), + .toString(), style: TextStyle( fontSize: 13.0, fontWeight: FontWeight.bold, diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 51256e11..8670f0d2 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -78,6 +78,8 @@ class _PharmacyAddressesState extends State { }, ), ), + SizedBox(height: height * 0.10,) + ], ), ), diff --git a/lib/pages/sub_categories_modalsheet.dart b/lib/pages/sub_categories_modalsheet.dart index f1ff0e08..d6499c8e 100644 --- a/lib/pages/sub_categories_modalsheet.dart +++ b/lib/pages/sub_categories_modalsheet.dart @@ -42,6 +42,7 @@ class _SubCategoriseModalsheetState extends State { appBarTitle: TranslationBase.of(context).categorise, isBottomBar: false, isShowAppBar: true, + isPharmacy: true, backgroundColor: Colors.white, isShowDecPage: false, baseViewModel: model, diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index bfa7e343..6c41f550 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -1,6 +1,11 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model.dart'; +import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.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/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; @@ -20,6 +25,9 @@ class SubCategorisePage extends StatefulWidget { String title; String parentId; + AuthenticatedUserObject authenticatedUserObject = + locator(); + SubCategorisePage({this.id, this.parentId, this.title}); @override @@ -942,7 +950,7 @@ class _SubCategorisePageState extends State { context) .size .width / - 5 + 5.3 : 0, padding: EdgeInsets.all(4), @@ -1057,6 +1065,28 @@ class _SubCategorisePageState extends State { ], ), ), + widget.authenticatedUserObject.isLogin? + Container( + child: IconButton( + icon: Icon(Icons.shopping_cart, + size: 18, + color: Colors.blue,), + onPressed: () async { + if(model.subProducts[index].rxMessage == null){ + GifLoaderDialogUtils.showMyDialog(context); + await addToCartFunction(1, model.subProducts[index].id); + GifLoaderDialogUtils.hideDialog(context); + Navigator.push( + context, + FadePage(page: CartOrderPage()));} + else{ + AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); + } + + } + + ), + ):Container(), ], ), ), @@ -1123,4 +1153,8 @@ class _SubCategorisePageState extends State { } return false; } + addToCartFunction(quantity, itemID) async { + ProductDetailViewModel x = new ProductDetailViewModel(); + await x.addToCartData(quantity, itemID); + } } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index d8c3ff7b..6a131d09 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1365,6 +1365,8 @@ class TranslationBase { String get referralNumber => localizedValues['referralNumber'][locale.languageCode]; + String get needPrescription => localizedValues['needPrescription'][locale.languageCode]; + String get outOfStockMsg => localizedValues['outOfStockMsg'][locale.languageCode]; String get requestID => localizedValues['requestID'][locale.languageCode]; String get OrderStatus => localizedValues['OrderStatus'][locale.languageCode]; String get pickupDate => localizedValues['pickupDate'][locale.languageCode]; diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index f5ce682a..f80acf75 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -9,7 +9,7 @@ import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreview import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/robo_search/event_provider.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart index fba53c1c..24986c74 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_home_item.dart @@ -45,9 +45,9 @@ class BottomNavHomeItem extends StatelessWidget { mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - height: 15, - ), +// SizedBox( +// height: 15, +// ), currentIndex == index ? Divider( // color: Color(0xff5AB145), @@ -57,19 +57,24 @@ class BottomNavHomeItem extends StatelessWidget { thickness: 0, ), Container( + margin: EdgeInsets.only(bottom: 5.0), child: Image.asset( 'assets/images/habib-logo.png', ), height: 22.0, + ), SizedBox( - height: 9, + height: 5, ), - Texts( - title, - textAlign: TextAlign.start, - color: currentIndex == index ? Colors.grey : Colors.grey, - fontSize: 11, + Container( + margin: EdgeInsets.only(bottom: 7.0), + child: Texts( + title, + textAlign: TextAlign.start, + color: currentIndex == index ? Colors.grey : Colors.grey, + fontSize: 11, + ), ), // Added TextAlign Property ], diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index 1b8eaefa..6e6a5f53 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -39,7 +39,7 @@ class BottomNavPharmacyItem extends StatelessWidget { return Expanded( child: SizedBox( - // height: 72.0, + height: 66.0, child: Stack( clipBehavior: Clip.none, children: [ @@ -50,7 +50,7 @@ class BottomNavPharmacyItem extends StatelessWidget { splashColor: Colors.transparent, onTap: () { if (!Provider.of(context, listen: false) - .isLogin && + .isLogin && (currentIndex == 2 || currentIndex == 3)) Navigator.push( context, @@ -63,25 +63,26 @@ class BottomNavPharmacyItem extends StatelessWidget { mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - height: 15, - ), +// SizedBox( +// height: 15, +// ), currentIndex == index ? Divider( - color: Color(0xff5AB145), - thickness: 3.5, - ) + color: Color(0xff5AB133), + thickness: 3.5, + ) : Divider( - thickness: 0, - ), + thickness: 0, + ), + Container( child: Icon(currentIndex == index ? activeIcon : icon, color: isHome ? Color(0xff5AB145) : currentIndex == index - ? Colors.grey - : Colors.grey, - size: 22.0), + ? Colors.grey + : Colors.grey, + size: 20.0), ), SizedBox( height: 11, @@ -92,26 +93,37 @@ class BottomNavPharmacyItem extends StatelessWidget { title, textAlign: TextAlign.center, color: currentIndex == index ? Colors.grey : Colors.grey, - fontWeight: - currentIndex == index ? FontWeight.bold : FontWeight.w400, + fontWeight: currentIndex == index + ? FontWeight.normal + : FontWeight.w400, fontSize: currentIndex == index ? 13 : 11, ), ], ), ), ), - if(projectViewModel.isLogin && currentIndex == 3 && orderPreviewViewModel.cartResponse.quantityCount !=0) + if (currentIndex == 3 && + Provider.of(context, listen: false) + .cartResponse + .quantityCount != + 0) Positioned( - top: 5, right: -3.5, + top: 11.5, + right: -3.5, child: Container( decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(15), - + color: Colors.red, + borderRadius: BorderRadius.circular(15), ), - padding: EdgeInsets.only(left: 5, right: 4.5), + padding: EdgeInsets.only(left: 6.5, right: 6.5), height: 18, - child: Center(child: Texts(orderPreviewViewModel.cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white,)), + child: Center( + child: Texts( + orderPreviewViewModel.cartResponse.quantityCount.toString(), + style: "caption", + medium: true, + color: Colors.white, + )), ), ) ], diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 6d942c53..15eab3ed 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -1,6 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-page.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/order/ProductReview.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -25,6 +25,7 @@ class productTile extends StatelessWidget { final PharmacyProduct product; final dynamic productID; final Function onDelete; + final dynamic approvedTotalReviews; // final VoidCallback deleteWishlistItems; productTile( @@ -43,6 +44,8 @@ class productTile extends StatelessWidget { this.product, this.productID, this.onDelete, + this.approvedTotalReviews, + }); @override @@ -112,22 +115,33 @@ class productTile extends StatelessWidget { ), ), this.isOrderDetails == false - ? Container( - margin: EdgeInsets.all(5), - child: Align( - alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: productRate, - size: 15.0, - filledColor: Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, + ? Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.all(5), + child: Align( + alignment: Alignment.topLeft, + child: RatingBar.readOnly( + initialRating: productRate, + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + ), ), + Text( '$approvedTotalReviews', + style: TextStyle( + fontWeight: FontWeight.bold, + color: Colors.grey, + fontSize: 13), ), - ) + ], + ) : Container(), ], ), @@ -150,7 +164,9 @@ class productTile extends StatelessWidget { height: 50, ), IconButton( - icon: Icon(FontAwesomeIcons.shoppingCart, size: 15), + icon: Icon(Icons.shopping_cart, + size: 18, + color: Colors.blue,), onPressed: () async { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, productID, context);