From 616748dc6f10369c2c1e996ce9c28216d36665ac Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Sun, 31 Oct 2021 10:41:27 +0200 Subject: [PATCH] fix proceed button --- lib/config/config.dart | 4 ++-- .../screens/cart-page/cart-order-preview.dart | 9 ++++++-- .../cart-page/select_address_widget.dart | 21 ++++++++----------- .../select_payment_option_widget.dart | 4 +++- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index bbbacaa4..8041ec47 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -14,8 +14,8 @@ const PACKAGES_PRODUCTS = '/api/products'; const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; -// const BASE_URL = 'https://hmgwebservices.com/'; +// const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; // Pharmacy UAT URLs // const BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart index 25c02dd0..4f5ab14e 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -63,11 +63,11 @@ class _OrderPreviewPageState extends State { color: Color(0xFFF1F1F1), child: Column( children: [ - SelectAddressWidget(model, widget.addresses), + SelectAddressWidget(model, widget.addresses,changeMainState), SizedBox( height: 10, ), - SelectPaymentOptionWidget(model), + SelectPaymentOptionWidget(model, changeMainState), SizedBox( height: 10, ), @@ -235,4 +235,9 @@ class _OrderPreviewPageState extends State { ), ); } + changeMainState(){ + setState(() { + + }); + } } diff --git a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart index bf958a36..d6182b9a 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -2,6 +2,7 @@ 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/service/AlHabibMedicalService/customer_addresses_service.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'; @@ -25,39 +26,35 @@ import 'package:provider/provider.dart'; class SelectAddressWidget extends StatefulWidget { final OrderPreviewViewModel model; final List addresses; + final Function changeMainState; - SelectAddressWidget(this.model, this.addresses); + SelectAddressWidget(this.model, this.addresses, this.changeMainState); @override _SelectAddressWidgetState createState() => _SelectAddressWidgetState(); } class _SelectAddressWidgetState extends State { - Addresses address; + AddressInfo address; _navigateToAddressPage() { Navigator.push(context, FadePage(page: PharmacyAddressesPage())) .then((result) { if (result != null) { address = result; - widget.model.paymentCheckoutData.address = address; + widget.model.paymentCheckoutData.address = + Addresses.fromJson(address.toJson()); widget.model.getInformationsByAddress(); + widget.changeMainState(); } - - /* 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; + address = AddressInfo.fromJson( + widget.model.paymentCheckoutData.address.toJson()); } super.initState(); } 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 index 9234bb38..7ccb12e5 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_payment_option_widget.dart @@ -24,8 +24,9 @@ import 'package:provider/provider.dart'; class SelectPaymentOptionWidget extends StatefulWidget { final OrderPreviewViewModel model; + final Function changeMainState; - SelectPaymentOptionWidget(this.model); + SelectPaymentOptionWidget(this.model, this.changeMainState); @override _SelectPaymentOptionWidgetState createState() => @@ -44,6 +45,7 @@ class _SelectPaymentOptionWidgetState extends State { widget.model.paymentCheckoutData.paymentOption = paymentOption; } + widget.changeMainState(); }) }); }