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/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index d5e5a207..cf204e6a 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -494,8 +494,7 @@ class BaseAppClient { if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode == 401) { - AppToast.showErrorToast( - message: TranslationBase.of(AppGlobal.context).pharmacyRelogin); + onFailure(TranslationBase.of(AppGlobal.context).pharmacyRelogin, statusCode); Navigator.of(AppGlobal.context).pushNamed(HOME); } else { onFailure('Error While Fetching data', statusCode); diff --git a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart index 801f6fb7..7c86f6b7 100644 --- a/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart +++ b/lib/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart @@ -192,7 +192,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; diff --git a/lib/pages/landing/landing_page_pharmcy.dart b/lib/pages/landing/landing_page_pharmcy.dart index cbc7fc01..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( @@ -129,8 +129,7 @@ class _LandingPagePharmacyState extends State { PharmacyPage(), PharmacyCategorisePage(), PharmacyProfilePage(), - CartOrderPage(), - + CartOrderPage(changeTab: _changeCurrentTab), ], ), bottomNavigationBar: BottomNavPharmacyBar( diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index 19acc5c5..6fde76ae 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -4,7 +4,6 @@ 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/gif_loader_dialog_utils.dart'; @@ -19,6 +18,8 @@ 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 { const CartOrderPage({Key key}) : super(key: key); @override @@ -26,7 +27,6 @@ class CartOrderPage extends StatefulWidget { } class _CartOrderPageState extends State { - bool isLoading = true; @override void initState() { @@ -34,7 +34,6 @@ class _CartOrderPageState extends State { getData(); } - @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); @@ -55,193 +54,191 @@ class _CartOrderPageState extends State { baseViewModel: model, backgroundColor: Colors.white, body: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) + 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( + height: height * 0.85, + width: double.infinity, + child: SingleChildScrollView( + child: Container( + margin: EdgeInsets.all(10), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, 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}'); - } - }); - })) + 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.subtotalWithVat).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, + ) ], ), ), - 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, + ), + ) + : 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, ), - Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", - fontSize: 14, - color: Colors.black, - fontWeight: FontWeight.bold, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text( + TranslationBase.of(context).noData, +// 'There is no data', + style: TextStyle(fontSize: 30), ), - ], - ), - 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) + model.cartResponse.shoppingCarts.length == 0) ? height * 0.15 : 0, color: Colors.white, @@ -251,13 +248,12 @@ class _CartOrderPageState extends State { ); } - void getData()async { - - await Provider.of(context, listen: false).getShoppingCart(); + void getData() async { + await Provider.of(context, listen: false) + .getShoppingCart(); setState(() { - isLoading= false; + isLoading = false; }); - } } @@ -279,148 +275,145 @@ class _OrderBottomWidgetState extends State { ProjectViewModel projectProvider = Provider.of(context); OrderPreviewViewModel cart = Provider.of(context); return !(cart.cartResponse.shoppingCarts == null || - cart.cartResponse.shoppingCarts.length == 0) + 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( + crossAxisAlignment: CrossAxisAlignment.start, 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, - ), - ), + const Divider( + color: Color(0xFFD6D6D6), + height: 1, + thickness: 1, + indent: 0, + endIndent: 0, ), - InkWell( - onTap: () => { - Navigator.push(context, - FadePage(page: PharmacyTermsConditions())) - }, - child: Container( - child: Icon( - Icons.info, - size: 25, - color: Color(0xff005aff), - ), + 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, + Container( + height: widget.height * 0.065, + margin: EdgeInsets.symmetric(vertical: 2), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container( - margin: EdgeInsets.symmetric( - horizontal: 0, vertical: 0), - child: Row( + 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.subtotalWithVat).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( - "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotalWithVat).toStringAsFixed(2)}", - fontSize: - projectProvider.isArabic ? 12 : 14, + "${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, 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), ), ], ), ), - 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-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/pharmacy_module_page.dart b/lib/pages/pharmacies/screens/pharmacy_module_page.dart index 2e71a0c3..5ffe875c 100644 --- a/lib/pages/pharmacies/screens/pharmacy_module_page.dart +++ b/lib/pages/pharmacies/screens/pharmacy_module_page.dart @@ -1,44 +1,15 @@ -import 'package:diplomaticquarterapp/config/size_config.dart'; -import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; -import 'package:diplomaticquarterapp/core/service/parmacyModule/order-preview-service.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BestSellerViewModel.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/BrandViewModel.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/LastVisitedViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/PrescriptionViewModel.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/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/landing/home_page.dart'; -import 'package:diplomaticquarterapp/pages/medical/prescriptions/prescriptions_home_page.dart'; -import 'package:diplomaticquarterapp/pages/offers_categorise_page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/product-brands.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/lacum-activitaion-vida-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/lakum-main-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/recommended-product-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/BannerPager.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductTileItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/BestSellerWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/GridViewButtons.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/PrescriptionsWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/RecentlyViewedWidget.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/home/ShopByBrandWidget.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/widgets/manufacturerItem.dart'; -import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; -import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/borderedButton.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'; -import 'package:rating_bar/rating_bar.dart'; -import '../../../locator.dart'; -import '../../final_products_page.dart'; class PharmacyPage extends StatefulWidget { @override 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..d936b51c 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 { 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 ee1bcd60..b9612925 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/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/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 4f457cad..8bad3e69 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -154,6 +154,7 @@ class ProductDetailService extends BaseService { super.error = error; }); } + Future deleteItemFromWishlist(itemID) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; @@ -163,9 +164,11 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _wishListProducts.add(Wishlist.fromJson(item)); }); + AppToast.showSuccessToast(message: 'You have removed a product from the Wishlist'); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; + AppToast.showErrorToast(message: error??Utils.generateContactAdminMessage()); }); } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index b3cc63d7..f80acf75 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -5,10 +5,11 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; 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'; @@ -29,8 +30,6 @@ import '../progress_indicator/app_loader_widget.dart'; import 'arrow_back.dart'; import 'network_base_view.dart'; import 'not_auh_page.dart'; -import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; VoidCallback _onCartClick; @@ -59,6 +58,8 @@ class AppScaffold extends StatelessWidget { final List imagesInfo; final bool isHelp; final bool isLocalLoader; + final Function backButtonTab; + AuthenticatedUserObject authenticatedUserObject = locator(); @@ -90,7 +91,9 @@ class AppScaffold extends StatelessWidget { this.showHomeAppBarIcon = true, this.imagesInfo, appBar, - this.customAppBar, this.isLocalLoader= false}); + this.customAppBar, + this.isLocalLoader = false, + this.backButtonTab}); AppScaffold setOnAppBarCartClick(VoidCallback onClick) { _onCartClick = onClick; @@ -115,6 +118,7 @@ class AppScaffold extends StatelessWidget { isOfferPackages: isOfferPackages, showOfferPackagesCart: showOfferPackagesCart, isShowDecPage: isShowDecPage, + backButtonTab: backButtonTab, ) : null, bottomSheet: bottomSheet, @@ -146,18 +150,18 @@ class AppScaffold extends StatelessWidget { } buildBodyWidget(context) { - return Stack( - children: [ - Center( - child:isLoading? CircularProgressIndicator( - backgroundColor: Colors.white, - valueColor: AlwaysStoppedAnimation( - Colors.grey[500], - ), - ):body), - - - isHelp == true ? RobotIcon() : Container()]); + return Stack(children: [ + Center( + child: isLoading + ? CircularProgressIndicator( + backgroundColor: Colors.white, + valueColor: AlwaysStoppedAnimation( + Colors.grey[500], + ), + ) + : body), + isHelp == true ? RobotIcon() : Container() + ]); } } @@ -174,6 +178,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { final bool showOfferPackagesCart; final bool isShowDecPage; + final Function backButtonTab; Function(String) badgeUpdater; AppBarWidget( @@ -184,6 +189,7 @@ class AppBarWidget extends StatefulWidget with PreferredSizeWidget { this.showPharmacyCart = true, this.isOfferPackages = false, this.showOfferPackagesCart = false, + this.backButtonTab, this.isShowDecPage = true}); @override @@ -210,6 +216,8 @@ class AppBarWidgetState extends State { Widget buildAppBar(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + return AppBar( elevation: 0, backgroundColor: widget.isPharmacy @@ -230,7 +238,9 @@ class AppBarWidgetState extends State { fontFamily: projectViewModel.isArabic ? 'Cairo' : 'WorkSans')), leading: Builder( builder: (BuildContext context) { - return ArrowBack(); + return ArrowBack( + onTap: widget.backButtonTab, + ); }, ), centerTitle: true, @@ -253,7 +263,7 @@ class AppBarWidgetState extends State { icon: Badge( position: BadgePosition.topStart(top: -15, start: -10), badgeContent: Text( - _badgeText, + orderPreviewViewModel.cartResponse.quantityCount.toString() /*_badgeText*/, style: TextStyle( fontSize: 9, color: Colors.white, @@ -385,10 +395,10 @@ class _RobotIcon extends State { bottom: -15); } - // setAnimation() async { - // /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || - // // var animation = - // // IS_TEXT_COMPLETED == ? true : false; +// setAnimation() async { +// /// await sharedPref.getBool(IS_ROBOT_VISIBLE) || +// // var animation = +// // IS_TEXT_COMPLETED == ? true : false; - // } +// } } diff --git a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart index 94e260d0..1b8eaefa 100644 --- a/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart +++ b/lib/widgets/pharmacy/bottom_nav_pharmacy_item.dart @@ -34,6 +34,9 @@ class BottomNavPharmacyItem extends StatelessWidget { @override Widget build(BuildContext context) { + OrderPreviewViewModel orderPreviewViewModel = Provider.of(context); + ProjectViewModel projectViewModel = Provider.of(context); + return Expanded( child: SizedBox( // height: 72.0, @@ -97,7 +100,7 @@ class BottomNavPharmacyItem extends StatelessWidget { ), ), ), - if(currentIndex == 3 &&Provider.of(context, listen: false).cartResponse.quantityCount !=0) + if(projectViewModel.isLogin && currentIndex == 3 && orderPreviewViewModel.cartResponse.quantityCount !=0) Positioned( top: 5, right: -3.5, child: Container( @@ -108,7 +111,7 @@ class BottomNavPharmacyItem extends StatelessWidget { ), padding: EdgeInsets.only(left: 5, right: 4.5), height: 18, - child: Center(child: Texts(Provider.of(context, listen: false).cartResponse.quantityCount.toString(), style: "caption", medium: true, color: Colors.white,)), + 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 b6f73823..78ea12b0 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';