From f8883f5439692746a96a05922920f5030fb051db Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 9 Nov 2021 14:07:12 +0200 Subject: [PATCH 01/20] first step from fixing check out process --- lib/config/config.dart | 4 +- .../screens/cart-page/cart-order-page.dart | 94 ++++++++++--------- .../screens/cart-page/cart-order-preview.dart | 35 +++---- .../cart-page/select_address_widget.dart | 2 +- .../select_payment_option_widget.dart | 2 +- .../screens/order-preview-page.dart | 48 ---------- .../screens/payment-method-select-page.dart | 50 ++++++++-- .../pharmacyAddresses/PharmacyAddresses.dart | 28 +++++- 8 files changed, 138 insertions(+), 125 deletions(-) delete mode 100644 lib/pages/pharmacies/screens/order-preview-page.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 200e5776..694cb602 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -15,8 +15,8 @@ const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; const PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; -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-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index 9c6fa42e..3b7d080f 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderItem.dart'; +import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -22,7 +23,6 @@ import 'package:provider/provider.dart'; import 'cart-order-preview.dart'; class CartOrderPage extends StatefulWidget { - final Function(int) changeTab; const CartOrderPage({Key key, this.changeTab}) : super(key: key); @@ -38,7 +38,6 @@ class _CartOrderPageState extends State { void initState() { super.initState(); getData(); - } @override @@ -105,8 +104,8 @@ class _CartOrderPageState extends State { .shoppingCarts[index]) .then((value) { if (model.state != ViewState.Error) { - // appScaffold.appBar.badgeUpdater( - // '${value.quantityCount ?? 0}'); + // appScaffold.appBar.badgeUpdater( + // '${value.quantityCount ?? 0}'); } if (model.state == ViewState.ErrorLocal) { @@ -250,7 +249,7 @@ class _CartOrderPageState extends State { ? height * 0.15 : 0, color: Colors.white, - child: OrderBottomWidget(model.addresses, height), + child: OrderBottomWidget(model.addresses, height, model), ), ), ); @@ -268,8 +267,9 @@ class _CartOrderPageState extends State { class OrderBottomWidget extends StatefulWidget { final List addresses; final double height; + final OrderPreviewViewModel model; - OrderBottomWidget(this.addresses, this.height); + OrderBottomWidget(this.addresses, this.height, this.model); @override _OrderBottomWidgetState createState() => _OrderBottomWidgetState(); @@ -281,9 +281,10 @@ class _OrderBottomWidgetState extends State { @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) + OrderPreviewViewModel model = Provider.of(context); + + return !(model.cartResponse.shoppingCarts == null || + model.cartResponse.shoppingCarts.length == 0) ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -373,7 +374,7 @@ class _OrderBottomWidgetState extends State { child: Row( children: [ Texts( - "${TranslationBase.of(context).sar} ${(cart.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: projectProvider.isArabic ? 12 : 14, fontWeight: FontWeight.bold, ), @@ -391,7 +392,7 @@ class _OrderBottomWidgetState extends State { ), ), Texts( - "${cart.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", fontSize: 10, color: Colors.grey, fontWeight: FontWeight.bold, @@ -403,50 +404,36 @@ class _OrderBottomWidgetState extends State { onPressed: isAgree // && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { - if(cart.isCartItemsOutOfStock()){ - // Toast msg - AppToast.showErrorToast(message: TranslationBase.of(context).outOfStockMsg) - }else { - Navigator.push( - context, - FadePage( - page: - OrderPreviewPage(widget.addresses))) - } - } + if (model + .isCartItemsOutOfStock()) + { + // Toast msg + AppToast.showErrorToast( + message: TranslationBase.of(context) + .outOfStockMsg) + } + else + { + _navigateToAddressPage(model + .user.patientIdentificationNo) + // Navigator.push( + // context, + // FadePage( + // page: + // OrderPreviewPage(widget.addresses))) + } + } : null, child: new Text( "${TranslationBase.of(context).checkOut}", style: new TextStyle( color: - isAgree ? Colors.white : Colors.grey.shade300, + isAgree ? Colors.white : Colors.grey.shade300, fontSize: 14), ), color: Color(0xFF4CAF50), - disabledColor:Color(0xFF848484), -// disabledColor: Color(0xff005aff), + disabledColor: Color(0xFF848484), ) -// RaisedButton( -// onPressed: isAgree -//// && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 -// ? () => { -// Navigator.push( -// context, -// FadePage( -// page: -// OrderPreviewPage(widget.addresses))) -// } -// : null, -// child: new Text( -// "${TranslationBase.of(context).checkOut}", -// style: new TextStyle( -// color: -// isAgree ? Colors.white : Colors.grey.shade300, -// fontSize: 14), -// ), -// color: Color(0xff005aff), -// disabledColor: Color(0xff005aff), -// ) ], ), ), @@ -454,4 +441,19 @@ class _OrderBottomWidgetState extends State { ) : Container(); } + + _navigateToAddressPage(String identificationNo) { + Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))) + .then((result) async { + if (result != null) { + GifLoaderDialogUtils.showMyDialog(context); + var address = result; + widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson()); + await widget.model.getInformationsByAddress(identificationNo); + await widget.model.getShoppingCart(); + // widget.changeMainState(); + GifLoaderDialogUtils.hideDialog(context); + } + }); + } } 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 50cee7c3..40af2e02 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -15,8 +15,9 @@ import 'lakum_widget.dart'; class OrderPreviewPage extends StatefulWidget { final List addresses; + final OrderPreviewViewModel model; - OrderPreviewPage(this.addresses); + OrderPreviewPage({this.addresses, this.model}); @override _OrderPreviewPageState createState() => _OrderPreviewPageState(); @@ -43,7 +44,7 @@ class _OrderPreviewPageState extends State { Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; - OrderPreviewViewModel model = Provider.of(context); + // OrderPreviewViewModel widget.model = Provider.of(context); return AppScaffold( appBarTitle: "${TranslationBase.of(context).checkOut}", isShowAppBar: true, @@ -52,7 +53,7 @@ class _OrderPreviewPageState extends State { isLoading: isLoading, isLocalLoader: true, backgroundColor: Colors.white, - // baseViewModel: model, + // baseViewModel: widget.model, body: Container( color: Color(0xFFF1F1F1), height: height * 0.90, @@ -61,19 +62,19 @@ class _OrderPreviewPageState extends State { color: Color(0xFFF1F1F1), child: Column( children: [ - SelectAddressWidget(model, widget.addresses, changeMainState), + SelectAddressWidget(widget.model, widget.addresses, changeMainState), SizedBox( height: 10, ), - SelectPaymentOptionWidget(model, changeMainState), + SelectPaymentOptionWidget(widget.model, changeMainState), SizedBox( height: 10, ), - model.paymentCheckoutData.lacumInformation != null + widget.model.paymentCheckoutData.lacumInformation != null ? Container( child: Column( children: [ - LakumWidget(model), + LakumWidget(widget.model), SizedBox( height: 10, ), @@ -95,8 +96,8 @@ class _OrderPreviewPageState extends State { color: Colors.black, ), ...List.generate( - model.cartResponse.shoppingCarts != null ? model.cartResponse.shoppingCarts.length : 0, - (index) => ProductOrderPreviewItem(model.cartResponse.shoppingCarts[index]), + widget.model.cartResponse.shoppingCarts != null ? widget.model.cartResponse.shoppingCarts.length : 0, + (index) => ProductOrderPreviewItem(widget.model.cartResponse.shoppingCarts[index]), ), ], ), @@ -104,7 +105,7 @@ class _OrderPreviewPageState extends State { Container( width: double.infinity, padding: EdgeInsets.all(8), - child: model.cartResponse.subtotal != null + child: widget.model.cartResponse.subtotal != null ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -127,7 +128,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.w500, ), Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -151,7 +152,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.w500, ), Texts( - "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.totalAdditionalShippingCharge).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -175,7 +176,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.w500, ), Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -199,7 +200,7 @@ class _OrderPreviewPageState extends State { fontWeight: FontWeight.bold, ), Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, @@ -214,7 +215,7 @@ class _OrderPreviewPageState extends State { : Container(), ), SizedBox( - height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, + height: widget.model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, ) ], ), @@ -222,9 +223,9 @@ class _OrderPreviewPageState extends State { ), ), bottomSheet: Container( - height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, + height: widget.model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, color: Colors.white, - child: PaymentBottomWidget(model), + child: PaymentBottomWidget(widget.model), ), ); } 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 e03a4b35..4228af0a 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -24,7 +24,7 @@ class _SelectAddressWidgetState extends State { AddressInfo address; _navigateToAddressPage(String identificationNo) { - Navigator.push(context, FadePage(page: PharmacyAddressesPage())).then((result) async { + Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))).then((result) async { if (result != null) { GifLoaderDialogUtils.showMyDialog(context); address = result; 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 825e2577..66e1b16b 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 @@ -20,7 +20,7 @@ class _SelectPaymentOptionWidgetState extends State { PaymentOption paymentOption; _navigateToPaymentOption() { - Navigator.push(context, FadePage(page: PaymentMethodSelectPage())) + Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.model,))) .then((result) => { setState(() { if (result != null) { diff --git a/lib/pages/pharmacies/screens/order-preview-page.dart b/lib/pages/pharmacies/screens/order-preview-page.dart deleted file mode 100644 index 6b5f4f51..00000000 --- a/lib/pages/pharmacies/screens/order-preview-page.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; -import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; -import 'package:diplomaticquarterapp/widgets/buttons/GestureIconButton.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; -import 'package:flutter/material.dart'; - -class OrderPreviewPage extends StatelessWidget { - @override - Widget build(BuildContext context) { - return BaseView( - builder: (_, model, wi) => AppScaffold( - title: TranslationBase.of(context).shoppingCart, - isShowAppBar: true, - isShowDecPage: false, - baseViewModel: model, - backgroundColor: Colors.white, - body: Container( - 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.shade800,), - onTap: () => {}, - ), - const Divider( - color: Colors.grey, - height: 20, - thickness: 1, - indent: 0, - endIndent: 0, - ), - - ], - ), - ), - ), - ), - ), - ); - } -} - diff --git a/lib/pages/pharmacies/screens/payment-method-select-page.dart b/lib/pages/pharmacies/screens/payment-method-select-page.dart index 92065102..719fd45d 100644 --- a/lib/pages/pharmacies/screens/payment-method-select-page.dart +++ b/lib/pages/pharmacies/screens/payment-method-select-page.dart @@ -6,11 +6,19 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; +import 'cart-page/cart-order-preview.dart'; + class PaymentMethodSelectPage extends StatefulWidget { + final OrderPreviewViewModel model; + + const PaymentMethodSelectPage({Key key, this.model}) : super(key: key); + @override - _PaymentMethodSelectPageState createState() => _PaymentMethodSelectPageState(); + _PaymentMethodSelectPageState createState() => + _PaymentMethodSelectPageState(); } class _PaymentMethodSelectPageState extends State { @@ -79,7 +87,8 @@ class _PaymentMethodSelectPageState extends State { PaymentOption.installments, () => { setState(() { - selectedPaymentOption = PaymentOption.installments; + selectedPaymentOption = + PaymentOption.installments; }) }), if (Platform.isIOS) @@ -103,7 +112,21 @@ class _PaymentMethodSelectPageState extends State { padding: EdgeInsets.symmetric(horizontal: 16, vertical: 20), child: DefaultButton( TranslationBase.of(context).next, - selectedPaymentOption != null ? () => {Navigator.pop(context, selectedPaymentOption)} : null, + selectedPaymentOption != null + ? () { + + + widget.model.paymentCheckoutData.paymentOption = + selectedPaymentOption; + // Navigator.pop(context, selectedPaymentOption); + + Navigator.push( + context, + FadePage( + page: + OrderPreviewPage(model: widget.model,),),); + } + : null, color: Color(0xff5AB154), ), ), @@ -117,12 +140,14 @@ class PaymentMethodCard extends StatelessWidget { final PaymentOption paymentOption; final Function selectMethod; - PaymentMethodCard(this.cardWidth, this.selectedPaymentOption, this.paymentOption, this.selectMethod); + PaymentMethodCard(this.cardWidth, this.selectedPaymentOption, + this.paymentOption, this.selectMethod); @override Widget build(BuildContext context) { bool isSelected = false; - if (selectedPaymentOption != null && selectedPaymentOption == paymentOption) { + if (selectedPaymentOption != null && + selectedPaymentOption == paymentOption) { isSelected = true; } @@ -136,7 +161,9 @@ class PaymentMethodCard extends StatelessWidget { color: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), - side: isSelected ? BorderSide(color: Colors.green, width: 2.0) : BorderSide(color: Colors.transparent, width: 0.0), + side: isSelected + ? BorderSide(color: Colors.green, width: 2.0) + : BorderSide(color: Colors.transparent, width: 0.0), ), child: Padding( padding: const EdgeInsets.all(12.0), @@ -145,7 +172,13 @@ class PaymentMethodCard extends StatelessWidget { Container( width: 24, height: 24, - decoration: containerColorRadiusBorderWidth(isSelected ? CustomColors.accentColor : Colors.transparent, 100, Colors.grey, 0.5), + decoration: containerColorRadiusBorderWidth( + isSelected + ? CustomColors.accentColor + : Colors.transparent, + 100, + Colors.grey, + 0.5), ), mWidth(12), Container( @@ -157,7 +190,8 @@ class PaymentMethodCard extends StatelessWidget { if (isSelected) Container( decoration: containerRadius(CustomColors.green, 200), - padding: EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12), + padding: + EdgeInsets.only(top: 6, bottom: 6, left: 12, right: 12), child: Text( TranslationBase.of(context).paymentSelected, style: TextStyle( diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index b763e960..9fd40f2b 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -1,7 +1,9 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.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/PharmacyAddressesViewModel.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/AddAddress.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -13,7 +15,12 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +///TODO Elham* split this to tow files class PharmacyAddressesPage extends StatefulWidget { + + final OrderPreviewViewModel orderPreviewViewModel; + + const PharmacyAddressesPage({Key key, this.orderPreviewViewModel}) : super(key: key); @override _PharmacyAddressesState createState() => _PharmacyAddressesState(); } @@ -53,10 +60,13 @@ class _PharmacyAddressesState extends State { () { setState(() { model.setSelectedAddressIndex(index); + //TODO Elham* + widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[index].toJson()); }); }, model.selectedAddressIndex == index, (address) { + navigateToAddressPage(context, model, address); }), ), @@ -109,8 +119,8 @@ class _PharmacyAddressesState extends State { vPadding: 8, handler: () { model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]); - Navigator.pop(context, model.addresses[model.selectedAddressIndex]); - }, + _navigateToPaymentOption(); + }, ), ), ], @@ -119,6 +129,20 @@ class _PharmacyAddressesState extends State { ), ); } + + _navigateToPaymentOption() { + Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.orderPreviewViewModel,))) + .then((result) => { + setState(() { + if (result != null) { + var paymentOption = result; + widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = + paymentOption; + } + // widget.changeMainState(); + }) + }); + } } class AddressItemWidget extends StatelessWidget { From df9e58402d9d1904227559d4eefebb51a6848c84 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Tue, 9 Nov 2021 15:12:07 +0200 Subject: [PATCH 02/20] first step from update design --- .../screens/cart-page/cart-order-preview.dart | 4 +- .../cart-page/select_address_widget.dart | 12 +- .../select_payment_option_widget.dart | 12 +- .../screens/payment-method-select-page.dart | 66 ++++------- .../pharmacyAddresses/PharmacyAddresses.dart | 105 ++++++++++++------ 5 files changed, 109 insertions(+), 90 deletions(-) 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 40af2e02..cc2e1edc 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-preview.dart @@ -62,11 +62,11 @@ class _OrderPreviewPageState extends State { color: Color(0xFFF1F1F1), child: Column( children: [ - SelectAddressWidget(widget.model, widget.addresses, changeMainState), + SelectAddressWidget(widget.model, widget.addresses, changeMainState, isUpdating: true,), SizedBox( height: 10, ), - SelectPaymentOptionWidget(widget.model, changeMainState), + SelectPaymentOptionWidget(widget.model, changeMainState,isUpdating: true,), SizedBox( height: 10, ), 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 4228af0a..a1634e21 100644 --- a/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart +++ b/lib/pages/pharmacies/screens/cart-page/select_address_widget.dart @@ -13,8 +13,10 @@ class SelectAddressWidget extends StatefulWidget { final OrderPreviewViewModel model; final List addresses; final Function changeMainState; + final bool isUpdating; - SelectAddressWidget(this.model, this.addresses, this.changeMainState); + SelectAddressWidget(this.model, this.addresses, this.changeMainState, + {this.isUpdating = false}); @override _SelectAddressWidgetState createState() => _SelectAddressWidgetState(); @@ -24,7 +26,7 @@ class _SelectAddressWidgetState extends State { AddressInfo address; _navigateToAddressPage(String identificationNo) { - Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))).then((result) async { + Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,isUpdate: widget.isUpdating,changeMainState: widget.changeMainState,))).then((result) async { if (result != null) { GifLoaderDialogUtils.showMyDialog(context); address = result; @@ -39,15 +41,15 @@ class _SelectAddressWidgetState extends State { @override void initState() { - if (widget.model.paymentCheckoutData.address != null) { - address = AddressInfo.fromJson(widget.model.paymentCheckoutData.address.toJson()); - } super.initState(); } @override Widget build(BuildContext context) { OrderPreviewViewModel model = Provider.of(context); + if (widget.model.paymentCheckoutData.address != null) { + address = AddressInfo.fromJson(widget.model.paymentCheckoutData.address.toJson()); + } return Container( color: Colors.white, child: address == null 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 66e1b16b..67692c5d 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 @@ -9,8 +9,10 @@ import 'package:flutter/material.dart'; class SelectPaymentOptionWidget extends StatefulWidget { final OrderPreviewViewModel model; final Function changeMainState; + final bool isUpdating; - SelectPaymentOptionWidget(this.model, this.changeMainState); + + SelectPaymentOptionWidget(this.model, this.changeMainState, {this.isUpdating = false}); @override _SelectPaymentOptionWidgetState createState() => _SelectPaymentOptionWidgetState(); @@ -20,7 +22,7 @@ class _SelectPaymentOptionWidgetState extends State { PaymentOption paymentOption; _navigateToPaymentOption() { - Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.model,))) + Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.model,changeMainState:widget.changeMainState,isUpdating: widget.isUpdating,))) .then((result) => { setState(() { if (result != null) { @@ -35,14 +37,14 @@ class _SelectPaymentOptionWidgetState extends State { @override void initState() { - if (widget.model.paymentCheckoutData.paymentOption != null) { - paymentOption = widget.model.paymentCheckoutData.paymentOption; - } super.initState(); } @override Widget build(BuildContext context) { + if (widget.model.paymentCheckoutData.paymentOption != null) { + paymentOption = widget.model.paymentCheckoutData.paymentOption; + } return Container( color: Colors.white, child: paymentOption == null diff --git a/lib/pages/pharmacies/screens/payment-method-select-page.dart b/lib/pages/pharmacies/screens/payment-method-select-page.dart index 719fd45d..978afae3 100644 --- a/lib/pages/pharmacies/screens/payment-method-select-page.dart +++ b/lib/pages/pharmacies/screens/payment-method-select-page.dart @@ -13,8 +13,12 @@ import 'cart-page/cart-order-preview.dart'; class PaymentMethodSelectPage extends StatefulWidget { final OrderPreviewViewModel model; + final bool isUpdating; + final Function changeMainState; - const PaymentMethodSelectPage({Key key, this.model}) : super(key: key); + const PaymentMethodSelectPage( + {Key key, this.model, this.isUpdating = false, this.changeMainState}) + : super(key: key); @override _PaymentMethodSelectPageState createState() => @@ -114,17 +118,23 @@ class _PaymentMethodSelectPageState extends State { TranslationBase.of(context).next, selectedPaymentOption != null ? () { - - - widget.model.paymentCheckoutData.paymentOption = - selectedPaymentOption; + widget.model.paymentCheckoutData.paymentOption = + selectedPaymentOption; + if (widget.isUpdating) { + widget.changeMainState(); + Navigator.pop(context); + return; + } else { + Navigator.push( + context, + FadePage( + page: OrderPreviewPage( + model: widget.model, + ), + ), + ); + } // Navigator.pop(context, selectedPaymentOption); - - Navigator.push( - context, - FadePage( - page: - OrderPreviewPage(model: widget.model,),),); } : null, color: Color(0xff5AB154), @@ -204,40 +214,6 @@ class PaymentMethodCard extends StatelessWidget { ), ), ), - // Container( - // margin: EdgeInsets.symmetric(horizontal: 2, vertical: 0), - // child: Stack( - // children: [ - // Container( - // padding: EdgeInsets.symmetric(horizontal: 8, vertical: 8), - // margin: EdgeInsets.symmetric(horizontal: 14, vertical: 8), - // decoration: new BoxDecoration( - // color: Colors.grey.shade100, - // shape: BoxShape.rectangle, - // borderRadius: BorderRadius.circular(8), - // border: Border.fromBorderSide(BorderSide( - // color: isSelected ? Color(0xff20BC11) : Colors.grey.shade300, - // width: 0.8, - // )), - // ), - // width: cardWidth, - // child: Image.asset( - // getPaymentOptionImage(paymentOption), - // fit: BoxFit.cover, - // ), - // ), - // if (isSelected) - // Positioned( - // right: 1, - // child: Icon( - // Icons.check_circle, - // color: Color(0xff20BC11), - // size: 30, - // ), - // ), - // ], - // ), - // ), ), ); } diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 9fd40f2b..338fe87e 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -17,16 +17,22 @@ import 'package:flutter/material.dart'; ///TODO Elham* split this to tow files class PharmacyAddressesPage extends StatefulWidget { - final OrderPreviewViewModel orderPreviewViewModel; + final Function changeMainState; + + final bool isUpdate; + + const PharmacyAddressesPage( + {Key key, this.orderPreviewViewModel, this.isUpdate = false, this.changeMainState}) + : super(key: key); - const PharmacyAddressesPage({Key key, this.orderPreviewViewModel}) : super(key: key); @override _PharmacyAddressesState createState() => _PharmacyAddressesState(); } class _PharmacyAddressesState extends State { - void navigateToAddressPage(BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) { + void navigateToAddressPage( + BuildContext ctx, PharmacyAddressesViewModel model, AddressInfo address) { Navigator.push( ctx, FadePage( @@ -61,12 +67,14 @@ class _PharmacyAddressesState extends State { setState(() { model.setSelectedAddressIndex(index); //TODO Elham* - widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[index].toJson()); + widget.orderPreviewViewModel.paymentCheckoutData + .address = + Addresses.fromJson( + model.addresses[index].toJson()); }); }, model.selectedAddressIndex == index, (address) { - navigateToAddressPage(context, model, address); }), ), @@ -88,8 +96,9 @@ class _PharmacyAddressesState extends State { }, ), ), - SizedBox(height: height * 0.10,) - + SizedBox( + height: height * 0.10, + ) ], ), ), @@ -118,9 +127,10 @@ class _PharmacyAddressesState extends State { fontSize: 14, vPadding: 8, handler: () { - model.saveSelectedAddressLocally(model.addresses[model.selectedAddressIndex]); - _navigateToPaymentOption(); - }, + model.saveSelectedAddressLocally( + model.addresses[model.selectedAddressIndex]); + _navigateToPaymentOption(model); + }, ), ), ], @@ -130,18 +140,31 @@ class _PharmacyAddressesState extends State { ); } - _navigateToPaymentOption() { - Navigator.push(context, FadePage(page: PaymentMethodSelectPage(model: widget.orderPreviewViewModel,))) - .then((result) => { - setState(() { - if (result != null) { - var paymentOption = result; - widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = - paymentOption; - } - // widget.changeMainState(); - }) - }); + _navigateToPaymentOption(model) { + if(widget.isUpdate) { + print("sfsf"); + + widget.orderPreviewViewModel.paymentCheckoutData.address = Addresses.fromJson(model.addresses[model.selectedAddressIndex].toJson()); + widget.changeMainState(); + Navigator.pop(context); + + return; + } + Navigator.push( + context, + FadePage( + page: PaymentMethodSelectPage( + model: widget.orderPreviewViewModel, + ))).then((result) => { + setState(() { + if (result != null) { + var paymentOption = result; + widget.orderPreviewViewModel.paymentCheckoutData.paymentOption = + paymentOption; + } + // widget.changeMainState(); + }) + }); } } @@ -152,7 +175,8 @@ class AddressItemWidget extends StatelessWidget { final bool isSelected; final Function(AddressInfo) onTabEditAddress; - AddressItemWidget(this.model, this.address, this.selectAddress, this.isSelected, this.onTabEditAddress); + AddressItemWidget(this.model, this.address, this.selectAddress, + this.isSelected, this.onTabEditAddress); @override Widget build(BuildContext context) { @@ -178,13 +202,18 @@ class AddressItemWidget extends StatelessWidget { decoration: new BoxDecoration( color: !isSelected ? Colors.white : Colors.green, shape: BoxShape.circle, - border: Border.all(color: Colors.grey, style: BorderStyle.solid, width: 1.0), + border: Border.all( + color: Colors.grey, + style: BorderStyle.solid, + width: 1.0), ), child: Padding( padding: const EdgeInsets.all(0.0), child: Icon( Icons.check, - color: isSelected ? Colors.white : Colors.transparent, + color: isSelected + ? Colors.white + : Colors.transparent, size: 25, ), ), @@ -197,7 +226,8 @@ class AddressItemWidget extends StatelessWidget { Expanded( child: Container( child: Container( - margin: EdgeInsets.symmetric(vertical: 12, horizontal: 12), + margin: + EdgeInsets.symmetric(vertical: 12, horizontal: 12), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -260,7 +290,8 @@ class AddressItemWidget extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), + padding: + const EdgeInsets.symmetric(horizontal: 8), child: SizedBox( child: Container( width: 1, @@ -278,13 +309,21 @@ class AddressItemWidget extends StatelessWidget { ConfirmDialog dialog = new ConfirmDialog( context: context, title: "Are you sure want to delete", - confirmMessage: "${address.address1} ${address.address2}", - okText: TranslationBase.of(context).delete, - cancelText: TranslationBase.of(context).cancel_nocaps, + confirmMessage: + "${address.address1} ${address.address2}", + okText: + TranslationBase.of(context).delete, + cancelText: TranslationBase.of(context) + .cancel_nocaps, okFunction: () => { - model.deleteAddresses(address).then((_) { - ConfirmDialog.closeAlertDialog(context); - AppToast.showErrorToast(message: "Address has been deleted"); + model + .deleteAddresses(address) + .then((_) { + ConfirmDialog.closeAlertDialog( + context); + AppToast.showErrorToast( + message: + "Address has been deleted"); }) }, cancelFunction: () => {}); From 1d1708bdcc6f40ed9ae80a7ca04a6d7462f445de Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Tue, 9 Nov 2021 16:32:55 +0300 Subject: [PATCH 03/20] Health Calculator 4.0 --- lib/config/localized_values.dart | 40 ++ .../bmr_calculator/bmr_calculator.dart | 33 +- .../bmr_calculator/bmr_result_page.dart | 6 +- .../health_calculator/body_fat/body_fat.dart | 18 +- .../calorie_calculator.dart | 8 +- .../calorie_result_page.dart | 6 +- .../delivery_due/delivery_due.dart | 181 ++++---- .../delivery_due_result_page.dart | 196 ++++---- .../ideal_body/ideal_body.dart | 20 +- .../ideal_body/ideal_body_result_page.dart | 22 +- .../ovulation_period/ovulation_period.dart | 436 +++++++----------- .../ovulation_result_page.dart | 204 ++++---- lib/uitl/translations_delegate_base.dart | 43 ++ 13 files changed, 637 insertions(+), 576 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 3985f3fc..392d143a 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1635,4 +1635,44 @@ const Map localizedValues = { "waist": {"en": "Waist", "ar": "وسط"}, "hip": {"en": "Hip", "ar": "ورك او نتوء"}, "carbsProtin": {"en": "Carbs, Protein and Fat", "ar": "الكربوهيدرات والبروتينات والدهون"}, + "usefulInfo": {"en": "Useful Information", "ar": "Useful Information"}, + "babyAge": {"en": "Baby Age", "ar": "عمر الطفل الآن:"}, + "babyAgeAvail": {"en": "baby age is not available", "ar": "عمر الطفل غير متوفر"}, + "deliveryDue": {"en": "The delivery due date is estimated to be on the", "ar": "من المقدر أن يكون تاريخ استحقاق التسليم في"}, + + "almostInactive": {"en": "Almost Inactive(Little or no exercises)", "ar": "شبه غير نشط (تمارين قليلة أو معدومة)"}, + "lightActive1": {"en": "Lighty Active (1-3) days per week", "ar": "Lighty Active (1-3) أيام في الأسبوع"}, + "veryActive": {"en": "very Active(6-7) days per week", "ar": "نشط جدا (6-7) أيام في الأسبوع"}, + "superActive": {"en": "Super Active(very hard exercises)", "ar": "سوبر نشط (تمارين صعبة للغاية)"}, + + "dailyIntake": {"en": "Daily intake is", "ar": "المدخول اليومي"}, + "calculateAmount": {"en": "Calculates the amount of energy that the person’s body expends in a day", "ar": "تحسب كمية الطاقة التي يبذلها جسم الشخص في اليوم"}, + "bodyWillBurn": {"en": "This means the body will burn", "ar": "هذا يعني أن الجسم سوف يحترق"}, + "caloriesEachDay": {"en": "calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is", "ar": "السعرات الحرارية في كل يوم ، إذا لم تمارس أي نشاط طوال اليوم .. ملاحظة: متطلبات السعرات الحرارية اليومية هي"}, + "maintainWeight": {"en": "calories, to maintain the current weight.", "ar": "السعرات الحرارية للحفاظ على الوزن الحالي."}, + + "mediumFinger": {"en": "Medium(fingers touch)", "ar": "متوسطة (لمسة الأصابع)"}, + "smallFinger": {"en": "Small(fingers overlap)", "ar": "صغير (أصابع متداخلة)"}, + "largeFinger": {"en": "Large(fingers don\'n touch)", "ar": "كبير (لا تلمس الأصابع)"}, + "idealBodyWeight": {"en": "Calculates the ideal body weight based on height, Weight, and Body Size", "ar": "يحسب وزن الجسم المثالي بناءً على الطول والوزن وحجم الجسم"}, + "bodyFrameSize": {"en": "Body Frame Size", "ar": "حجم إطار الجسم"}, + + "idealWeightRange": {"en": "Ideal weight range is", "ar": "نطاق الوزن المثالي هو"}, + "currentWeightPerfect": {"en": "Congratulations! The current weight is perfect and considered healthy", "ar": "تهانينا! الوزن الحالي مثالي ويعتبر صحي"}, + "littleBitWeightMore": {"en": "This means that the weight is a little bit more than ideal weight by", "ar": "هذا يعني أن الوزن أكثر قليلاً من الوزن المثالي به"}, + "consultWithDoctor": {"en": "May wish to consult with the doctor for medical help. Click to view our list of Doctors", "ar": "قد ترغب في استشارة الطبيب للحصول على مساعدة طبية. انقر لعرض قائمة الأطباء لدينا"}, + "excessiveObesity": {"en": "Means that you suffer from excessive obesity by", "ar": "يعني أنك تعاني من السمنة المفرطة بها"}, + "mayWish": {"en": "May wish to consult with the doctor for medical help. Click to view our list of\n Doctors", "ar": "قد ترغب في استشارة الطبيب للحصول على مساعدة طبية. انقر لعرض قائمة الأطباء \ n الخاصة بنا"}, + + "essential": {"en": "The category falls under essential", "ar": "الفئة تندرج تحت الأساسية"}, + "athlete": {"en": "The category falls under athlete", "ar": "فئة تندرج تحت رياضي"}, + "fitness": {"en": "The category falls under fitness", "ar": "الفئة تندرج تحت اللياقة البدنية"}, + "acceptable": {"en": "The category falls under acceptable", "ar": "الفئة تندرج تحت مقبول"}, + "underObese": {"en": "The category falls under obese", "ar": "تندرج الفئة تحت السمنة"}, + "crossedLimits": {"en": "Please check the value you have entered, since the body fat percentage has crosed the limits.", "ar": "يرجى التحقق من القيمة التي أدخلتها ، لأن نسبة الدهون في الجسم تجاوزت الحدود."}, + "lowLimits": {"en": "Please check the value you have entered, since the body fat percentage cannot be this low.", "ar": "يرجى التحقق من القيمة التي أدخلتها ، حيث لا يمكن أن تكون نسبة الدهون في الجسم منخفضة."}, + "estimates": {"en": "Estimates the total body fat based on\nthe size", "ar": "تقدير إجمالي الدهون في الجسم بناءً على \ n الحجم"}, + + }; + diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart index 3512b4de..e2010445 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart @@ -49,7 +49,7 @@ class _BmrCalculatorState extends State { // int height = 0; // int weight = 0; double bmrResult = 0; - String dropdownValue = 'Lighty Active (1-3) days per week'; + String dropdownValue = null; double calories = 0; void updateColor(int type) { @@ -122,14 +122,14 @@ class _BmrCalculatorState extends State { bmrResult = bmrResult.roundToDouble(); } - void calculateCalories() { - if (dropdownValue == "Almost Inactive(Little or no exercises)") { + void calculateCalories(BuildContext context) { + if (dropdownValue == TranslationBase.of(context).almostInactive) { calories = bmrResult * 1.2; - } else if (dropdownValue == "Lighty Active (1-3) days per week") { + } else if (dropdownValue == TranslationBase.of(context).lightActive1) { calories = bmrResult * 1.375; - } else if (dropdownValue == "very Active(6-7) days per week") { + } else if (dropdownValue == TranslationBase.of(context).veryActive) { calories = bmrResult * 1.55; - } else if (dropdownValue == "Super Active(very hard exercises)") { + } else if (dropdownValue == TranslationBase.of(context).superActive) { calories = bmrResult * 1.725; } else if (dropdownValue == "") { calories = bmrResult * 10.725; @@ -138,6 +138,7 @@ class _BmrCalculatorState extends State { @override Widget build(BuildContext context) { + if (dropdownValue == null) dropdownValue = TranslationBase.of(context).lightActive1; ProjectViewModel projectViewModel = Provider.of(context); _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; @@ -171,7 +172,7 @@ class _BmrCalculatorState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Calculates the amount of energy that the person’s body expends in a day', + TranslationBase.of(context).calculateAmount, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -372,10 +373,10 @@ class _BmrCalculatorState extends State { }); }, items: [ - 'Almost Inactive(Little or no exercises)', - 'Lighty Active (1-3) days per week', - 'very Active(6-7) days per week', - 'Super Active(very hard exercises)' + TranslationBase.of(context).almostInactive, + TranslationBase.of(context).lightActive1, + TranslationBase.of(context).veryActive, + TranslationBase.of(context).superActive ].map>((String value) { return DropdownMenuItem( value: value, @@ -412,16 +413,16 @@ class _BmrCalculatorState extends State { onTap: () { setState(() { calculateBmr(); - calculateCalories(); + calculateCalories(context); { Navigator.push( context, FadePage( page: BmrResultPage( - bmrResult: bmrResult, - calories: calories, - )), + bmrResult: bmrResult, + calories: calories, + )), ); } }); @@ -661,5 +662,3 @@ class CommonDropDownView extends StatelessWidget { ); } } - - diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart index 53426f94..4ef6ad08 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_result_page.dart @@ -37,7 +37,7 @@ class BmrResultPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Calories", + TranslationBase.of(context).calories, style: TextStyle( fontSize: 19, letterSpacing: -1.34, @@ -65,7 +65,7 @@ class BmrResultPage extends StatelessWidget { height: 5.0, ), Text( - 'Calories', + TranslationBase.of(context).calories, style: TextStyle( fontSize: 18, letterSpacing: -1.08, @@ -80,7 +80,7 @@ class BmrResultPage extends StatelessWidget { ), mHeight(20), Text( - 'This means the body will burn ( ${bmrResult.toStringAsFixed(1)} ) calories each day, if engaged in no activity for the entire day.. Note: Daily calorie requirement is ( ${calories.toStringAsFixed(1)} ) calories, to maintain the current weight.', + TranslationBase.of(context).bodyWillBurn+' ( ${bmrResult.toStringAsFixed(1)} )'+TranslationBase.of(context).caloriesEachDay+'( ${calories.toStringAsFixed(1)} ) '+TranslationBase.of(context).maintainWeight, style: TextStyle( fontSize: 14, letterSpacing: -0.56, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart index 1442afbd..5cdd8e3b 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart @@ -180,22 +180,22 @@ class _BodyFatState extends State { } } - void showTextResult() { + void showTextResult(BuildContext context) { if (isMale == false) { if (bodyFat > 9 && bodyFat <= 13) { - textResult = 'The category falls under essential'; + textResult = TranslationBase.of(context).essential; } else if (bodyFat > 13 && bodyFat <= 20) { - textResult = 'The category falls under athlete'; + textResult = TranslationBase.of(context).athlete; } else if (bodyFat > 20 && bodyFat <= 24) { - textResult = 'The category falls under fitness'; + textResult =TranslationBase.of(context).fitness; } else if (bodyFat > 24 && bodyFat <= 31) { - textResult = 'The category falls under acceptable'; + textResult =TranslationBase.of(context).acceptable; } else if (bodyFat > 31 && bodyFat <= 60) { - textResult = 'The category falls under obese'; + textResult =TranslationBase.of(context).underObese; } else if (bodyFat > 60) { - textResult = 'Please check the value you have entered, since the body fat percentage has crosed the limits.'; + textResult =TranslationBase.of(context).crossedLimits; } else if (bodyFat <= 9) { - textResult = 'Please check the value you have entered, since the body fat percentage cannot be this low.'; + textResult =TranslationBase.of(context).lowLimits; } } else { if (bodyFat > 5 && fat <= 13) { @@ -464,7 +464,7 @@ class _BodyFatState extends State { onTap: () { setState(() { calculateBodyFat(); - showTextResult(); + showTextResult(context); { Navigator.push( diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart index 74db1a30..f1db7e82 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart @@ -305,10 +305,10 @@ class _CalorieCalculatorState extends State { }); }, items: [ - 'Almost Inactive(Little or no exercises)', - 'Lighty Active (1-3) days per week', - 'very Active(6-7) days per week', - 'Super Active(very hard exercises)' + TranslationBase.of(context).almostInactive, + TranslationBase.of(context).lightActive, + TranslationBase.of(context).lightActive1, + TranslationBase.of(context).superActive, ].map>((String value) { return DropdownMenuItem( value: value, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart index dc27e051..68bd2d2c 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_result_page.dart @@ -37,7 +37,7 @@ class CalorieResultPage extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Calories", + TranslationBase.of(context).calories, style: TextStyle( fontSize: 19, letterSpacing: -1.34, @@ -65,7 +65,7 @@ class CalorieResultPage extends StatelessWidget { height: 5.0, ), Text( - 'Calories', + TranslationBase.of(context).calories, style: TextStyle( fontSize: 18, letterSpacing: -1.08, @@ -80,7 +80,7 @@ class CalorieResultPage extends StatelessWidget { ), mHeight(20), Text( - 'Daily intake is ${calorie.toStringAsFixed(1)} calories', + TranslationBase.of(context).dailyIntake+' ${calorie.toStringAsFixed(1)} '+TranslationBase.of(context).calories, style: TextStyle( fontSize: 14, letterSpacing: -0.56, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due.dart b/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due.dart index 1ada0ca1..b8528ea6 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due.dart @@ -1,6 +1,8 @@ +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -44,103 +46,114 @@ class _DeliveryDueState extends State { showNewAppBarTitle: true, isShowDecPage: false, appBarTitle: TranslationBase.of(context).pregnancyTitle, - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 35.0, vertical: 20.0), - child: SingleChildScrollView( - child: Container( - child: Column( - children: [ - Texts( - TranslationBase.of(context).pregnancyDesc, - ), - Divider( - //height: 2, - thickness: 2, - ), - Column( + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 21.0, vertical: 21.0), + child: Column( children: [ - Texts( - TranslationBase.of(context).pregnancyDateLabel, + Text( + TranslationBase.of(context).pregnancyDesc, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + ), ), - InkWell( - onTap: () { - DatePicker.showDatePicker( - context, - showTitleActions: true, - minTime: DateTime(DateTime.now().year - 1, 1, 1), - maxTime: DateTime.now(), - onConfirm: (date) { - print('confirm $date'); - setState(() { - bloodSugarDate = date; - dateFrom = date.add(Duration(days: 10)); + Divider( + //height: 2, + thickness: 1, + ), + Column( + children: [ + Text( + TranslationBase.of(context).pregnancyDateLabel, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + ), + ), + InkWell( + onTap: () { + DatePicker.showDatePicker( + context, + showTitleActions: true, + minTime: DateTime(DateTime.now().year - 1, 1, 1), + maxTime: DateTime.now(), + onConfirm: (date) { + print('confirm $date'); + setState(() { + bloodSugarDate = date; + dateFrom = date.add(Duration(days: 10)); - dateTo = date.add(Duration(days: 20)); - conceivedDate = date.add(Duration(days: 14)); - deliveryDue = date.add(Duration(days: 280)); - firstTrimester = date.add(Duration(days: 85)); - secondTrimester = date.add(Duration(days: 190)); - thirdTrimester = date.add(Duration(days: 280)); - }); + dateTo = date.add(Duration(days: 20)); + conceivedDate = date.add(Duration(days: 14)); + deliveryDue = date.add(Duration(days: 280)); + firstTrimester = date.add(Duration(days: 85)); + secondTrimester = date.add(Duration(days: 190)); + thirdTrimester = date.add(Duration(days: 280)); + }); + }, + currentTime: DateTime.now(), + ); }, - currentTime: DateTime.now(), - ); - }, - child: Container( - padding: EdgeInsets.all(12), - margin: EdgeInsets.only(top: 15.0), - width: double.infinity, - height: 65, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( + child: Container( + padding: EdgeInsets.all(12), + margin: EdgeInsets.only(top: 15.0), + width: double.infinity, + height: 65, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Icon(Icons.date_range), - Texts(TranslationBase.of(context).date), + Row( + children: [ + Icon(Icons.date_range), + Texts(TranslationBase.of(context).date), + ], + ), + Texts(getDate()), ], ), - Texts(getDate()), - ], + ), ), - ), + ], ), + ], ), - SizedBox( - height: 280.0, - ), - Container( - height: 50.0, - width: 350.0, - child: DefaultButton( - TranslationBase.of(context).calculate, - () { - setState(() { - { - Navigator.push( - context, - FadePage( - page: DeliveryDueResult( - conceivedDate: conceivedDate, - dateFrom: dateFrom, - dateTo: dateTo, - deliveryDue: deliveryDue, - firstTrimester: firstTrimester, - secondTrimester: secondTrimester, - thirdTrimester: thirdTrimester, - )), - ); - } - }); - }, - ), - ), - ], + ), + ), + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, + onTap: () { + setState(() { + { + Navigator.push( + context, + FadePage( + page: DeliveryDueResult( + conceivedDate: conceivedDate, + dateFrom: dateFrom, + dateTo: dateTo, + deliveryDue: deliveryDue, + firstTrimester: firstTrimester, + secondTrimester: secondTrimester, + thirdTrimester: thirdTrimester, + )), + ); + } + }); + }, ), ), - ), + ], ), ); } diff --git a/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due_result_page.dart index b546426b..f7431d1a 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/delivery_due/delivery_due_result_page.dart @@ -1,9 +1,12 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -29,78 +32,102 @@ class DeliveryDueResult extends StatelessWidget { showNewAppBarTitle: true, isShowDecPage: false, appBarTitle: TranslationBase.of(context).pregnancyTitle, - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 12.0), - child: SingleChildScrollView( - child: Container( - height: 750.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Texts( - TranslationBase.of(context).ovulationPeriod, - fontWeight: FontWeight.w400, - ), - Texts( - TranslationBase.of(context).from, - fontWeight: FontWeight.w400, - ), - Texts(DateFormat.yMMMEd().format(dateFrom), fontWeight: FontWeight.w800, fontSize: 21.0, color: Color(0xffC5272D)), - Texts( - TranslationBase.of(context).to, - fontWeight: FontWeight.w400, - ), - Texts(DateFormat.yMMMEd().format(dateTo), fontWeight: FontWeight.w800, fontSize: 21.0, color: Color(0xffC5272D)), - Texts( - TranslationBase.of(context).conceive, - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(conceivedDate), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - TranslationBase.of(context).firstTri, - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(firstTrimester), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - TranslationBase.of(context).secondTri, - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(secondTrimester), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - TranslationBase.of(context).thirdTri, - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(thirdTrimester), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Container( - width: 350, - child: DefaultButton( - TranslationBase.of(context).seeDoctorsList, - () { - getDoctorsList(context); - }, - ), - ), - ], + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.symmetric(horizontal: 21.0, vertical: 21.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Text( + TranslationBase.of(context).pregnancyTitle, + style: TextStyle( + fontSize: 19, + letterSpacing: -1.14, + fontWeight: FontWeight.w600, + ), + ), + Text( + TranslationBase.of(context).ovulationPeriod, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + fontWeight: FontWeight.w600, + color: CustomColors.textColor, + ), + ), + mHeight(20), + showItem(TranslationBase.of(context).from, DateFormat.yMMMEd().format(dateFrom), titleColor: CustomColors.accentColor), + mHeight(12), + showItem(TranslationBase.of(context).to, DateFormat.yMMMEd().format(dateTo), titleColor: CustomColors.accentColor), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).conceive, DateFormat.yMMMEd().format(conceivedDate)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).firstTri, DateFormat.yMMMEd().format(firstTrimester)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).secondTri, DateFormat.yMMMEd().format(secondTrimester)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).thirdTri, DateFormat.yMMMEd().format(thirdTrimester)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + ], + ).withBorderedContainer, + ), ), ), - ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).seeDoctorsList, + color: CustomColors.accentColor, + onTap: () { + getDoctorsList(context); + }, + ), + ), + ], + ), + ); + } + + Widget showItem(String title, String value, {Color titleColor}) { + return Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + color: titleColor ?? Colors.black, + fontWeight: FontWeight.w500, + // fontWeight: FontWeight.w600, + ), + ), + Text( + value, + style: TextStyle( + fontSize: 18, + letterSpacing: -1.08, + fontWeight: FontWeight.w600, + ), + ), + ], ), ); } @@ -145,20 +172,11 @@ class DeliveryDueResult extends StatelessWidget { if (doctorByHospital.length != 0) { _patientDoctorAppointmentListHospital[_patientDoctorAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element); } else { - _patientDoctorAppointmentListHospital - .add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: "0", patientDoctorAppointment: element)); + _patientDoctorAppointmentListHospital.add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: "0", patientDoctorAppointment: element)); } }); - Navigator.push( - context, - FadePage( - page: SearchResults( - isLiveCareAppointment: false, - doctorsList: doctorsList, - patientDoctorAppointmentListHospital: - _patientDoctorAppointmentListHospital))); - + Navigator.push(context, FadePage(page: SearchResults(isLiveCareAppointment: false, doctorsList: doctorsList, patientDoctorAppointmentListHospital: _patientDoctorAppointmentListHospital))); } } }).catchError((err) { @@ -167,3 +185,19 @@ class DeliveryDueResult extends StatelessWidget { }); } } + +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); +} diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart index e414f028..265bb412 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart @@ -34,7 +34,7 @@ class _IdealBodyState extends State { double overWeightBy; int weight = 0; double idealWeight = 0; - String dropdownValue = 'Medium(fingers touch)'; + String dropdownValue = null; double calories = 0; String textResult = ''; double maxIdealWeight; @@ -58,11 +58,11 @@ class _IdealBodyState extends State { heightInches = int.parse(_heightController.text) * .39370078740157477; heightFeet = heightInches / 12; idealWeight = (50 + 2.3 * (heightInches - 60)); - if (dropdownValue == 'Small(fingers overlap)') { + if (dropdownValue == TranslationBase.of(context).smallFinger) { idealWeight = idealWeight - 10; - } else if (dropdownValue == 'Medium(fingers touch)') { + } else if (dropdownValue == TranslationBase.of(context).mediumFinger) { idealWeight = idealWeight; - } else if (dropdownValue == 'Large(fingers don\'n touch)') { + } else if (dropdownValue == TranslationBase.of(context).largeFinger) { idealWeight = idealWeight + 10; } @@ -75,6 +75,8 @@ class _IdealBodyState extends State { @override Widget build(BuildContext context) { + if(dropdownValue==null) + dropdownValue=TranslationBase.of(context).mediumFinger; _weightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).kg), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).lb), value: false)]; _heightPopupList = [PopupMenuItem(child: Text(TranslationBase.of(context).cm), value: true), PopupMenuItem(child: Text(TranslationBase.of(context).ft), value: false)]; @@ -103,7 +105,7 @@ class _IdealBodyState extends State { child: Column( children: [ Text( - 'Calculates the ideal body weight based on height, Weight, and Body Size', + TranslationBase.of(context).idealBodyWeight, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -186,7 +188,7 @@ class _IdealBodyState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Body Frame Size", + TranslationBase.of(context).bodyFrameSize, style: TextStyle( fontSize: 11, letterSpacing: -0.44, @@ -213,9 +215,9 @@ class _IdealBodyState extends State { }); }, items: [ - 'Small(fingers overlap)', - 'Medium(fingers touch)', - 'Large(fingers don\'n touch)', + TranslationBase.of(context).smallFinger, + TranslationBase.of(context).mediumFinger, + TranslationBase.of(context).largeFinger, ].map>((String value) { return DropdownMenuItem( value: value, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart index 6eec6dd8..a29d4bf0 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body_result_page.dart @@ -40,7 +40,7 @@ class IdealBodyResult extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Ideal weight range is', + TranslationBase.of(context).idealWeightRange, style: TextStyle( fontSize: 19, letterSpacing: -1.34, @@ -60,7 +60,7 @@ class IdealBodyResult extends StatelessWidget { Padding( padding: EdgeInsets.only(top: 8.0, left: 4.0), child: Text( - 'Kg', + " "+TranslationBase.of(context).kg+" ", style: TextStyle(color: Colors.red), ), ), @@ -80,7 +80,7 @@ class IdealBodyResult extends StatelessWidget { Padding( padding: EdgeInsets.only(top: 8.0, left: 4.0), child: Text( - 'Kg', + " "+TranslationBase.of(context).kg+" ", style: TextStyle(color: Colors.red), ), ), @@ -93,7 +93,7 @@ class IdealBodyResult extends StatelessWidget { ? Column( children: [ Texts( - 'Congratulations! The current weight is perfect and considered healthy', + TranslationBase.of(context).currentWeightPerfect, fontSize: 20.0, ), ], @@ -101,9 +101,9 @@ class IdealBodyResult extends StatelessWidget { : overWeightBy > 10 && overWeightBy < 17 ? Column( children: [ - Texts('This means that the weight is a little bit more than ideal weight by'), + Texts(TranslationBase.of(context).littleBitWeightMore), Texts(overWeightBy.toStringAsFixed(1)), - Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'), + Texts(TranslationBase.of(context).consultWithDoctor), ], ) : overWeightBy >= 18 @@ -112,7 +112,7 @@ class IdealBodyResult extends StatelessWidget { child: Column( children: [ Texts( - 'Means that you suffer from excessive obesity by', + TranslationBase.of(context).excessiveObesity, ), SizedBox( height: 12.0, @@ -128,7 +128,7 @@ class IdealBodyResult extends StatelessWidget { SizedBox( height: 12.0, ), - Texts('May wish to consult with the doctor for medical help. Click to view our list of\n Doctors'), + Texts(TranslationBase.of(context).mayWish), ], ), ) @@ -139,7 +139,7 @@ class IdealBodyResult extends StatelessWidget { Padding( padding: const EdgeInsets.all(8.0), child: Texts( - 'Under Weight', + TranslationBase.of(context).underWeight, fontSize: 18.0, ), ), @@ -161,7 +161,7 @@ class IdealBodyResult extends StatelessWidget { child: Column( children: [ Text( - 'under wheight', + TranslationBase.of(context).underWeight, style: TextStyle( fontSize: 17, fontWeight: FontWeight.bold, @@ -182,7 +182,7 @@ class IdealBodyResult extends StatelessWidget { SizedBox( height: 12.0, ), - Texts('May wish to consult with the doctor for medical help. Click to view our list of Doctors'), + Texts(TranslationBase.of(context).mayWish), ], ), ), diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart index 86699ed4..69894df3 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_period.dart @@ -1,6 +1,8 @@ +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -20,8 +22,9 @@ class _OvulationPeriodState extends State { DateTime bloodSugarDate = DateTime.now(); DateTime timeSugarDate = DateTime.now(); DateTime selectedDateTime = DateTime.now(); - int cycleLength = 0; - int lutealPhaseLength = 0; + + // int cycleLength = 0; + // int lutealPhaseLength = 0; String selectedDate; var dateFrom = DateTime.now(); var babyAgeWeeks; @@ -33,6 +36,9 @@ class _OvulationPeriodState extends State { var newFormat = DateFormat("yy-MM-dd"); String updatedDt; + TextEditingController cycleLengthController = new TextEditingController(); + TextEditingController lutelLengthController = new TextEditingController(); + String getTime() { return " ${timeSugarDate.hour}:${timeSugarDate.minute}"; } @@ -64,286 +70,176 @@ class _OvulationPeriodState extends State { showNewAppBarTitle: true, isShowDecPage: false, appBarTitle: TranslationBase.of(context).ovulation, - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 25.0, vertical: 15.0), - child: SingleChildScrollView( - child: Container( - height: 700.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts(TranslationBase.of(context).ovulationDesc), - SizedBox( - height: 12.0, - ), - Divider( - //height: 2, - thickness: 2, - ), - SizedBox( - height: 12.0, - ), - InkWell( - onTap: () { - DatePicker.showDatePicker( - context, - showTitleActions: true, - minTime: DateTime(DateTime.now().year - 1, 1, 1), - maxTime: DateTime.now(), - onConfirm: (date) { - print('confirm $date'); - setState(() { - selectedDateTime = date; - }); - }, - currentTime: DateTime.now(), - ); - }, - child: Container( - padding: EdgeInsets.all(12), - width: double.infinity, - height: 65, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Texts(TranslationBase.of(context).date), - Texts(getDate()), - ], - ), - ), - ), - SizedBox( - height: 5.0, - ), - Texts( - TranslationBase.of(context).cycleLabel, - fontWeight: FontWeight.w400, - ), - SizedBox( - height: 5.0, - ), - Row( + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, + Text( + TranslationBase.of(context).ovulationDesc, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.54, + color: Colors.black, + fontWeight: FontWeight.w600, ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(cycleLength.toString()), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (cycleLength < 45) cycleLength++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (cycleLength > 0) cycleLength--; - }); - }, - ), - ], - ), - ), - ], - ), - ), - ), - ), - Expanded( - child: Slider( - value: cycleLength.toDouble(), - min: 0, - max: 45, - onChanged: (double newValue) { - setState(() { - cycleLength = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], + ), + SizedBox( + height: 12.0, + ), + InkWell( + onTap: () { + DatePicker.showDatePicker( + context, + showTitleActions: true, + minTime: DateTime(DateTime.now().year - 1, 1, 1), + maxTime: DateTime.now(), + onConfirm: (date) { + print('confirm $date'); + setState(() { + selectedDateTime = date; + }); + }, + currentTime: DateTime.now(), + ); + }, + child: Container( + padding: EdgeInsets.all(12), + width: double.infinity, + height: 65, + decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: Colors.white), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Texts(TranslationBase.of(context).date), + Texts(getDate()), + ], + ), ), ), + SizedBox( + height: 12.0, + ), + inputWidget(TranslationBase.of(context).cycleLabel, "0", cycleLengthController), + SizedBox( + height: 12.0, + ), + inputWidget(TranslationBase.of(context).lutealLabel, "0", lutelLengthController), ], ), - Texts( - TranslationBase.of(context).lutealLabel, - fontWeight: FontWeight.w400, - ), - SizedBox( - height: 5.0, - ), - Row( - children: [ - Container( - width: 340.0, - height: 60.0, - decoration: BoxDecoration( - color: Colors.white, + ), + ), + ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).calculate, + color: CustomColors.accentColor, + onTap: () { + calculateBabyInformation(); + Navigator.push( + context, + FadePage( + page: OvulationResult( + conceivedDate: conceivedDate, + dateFrom: dateFrom, + dateTo: dateTo, + deliveryDue: deliveryDue, + babyAge: babyAgeWeeks, + babyAgeDays: babyAgeDays, + ), + ), + ); + }, + ), + ), + ], + ), + ); + } + + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + controller: _controller, + onChanged: (value) => {}, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, ), - child: Row( - children: [ - Padding( - padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 8.0), - child: Center( - child: Container( - width: 60.0, - foregroundDecoration: BoxDecoration( - borderRadius: BorderRadius.circular(5.0), - border: Border.all( - color: Colors.blueGrey, - width: 2.0, - ), - ), - child: Row( - children: [ - Expanded( - child: Center( - child: Text(lutealPhaseLength.toString()), - ), - ), - Container( - height: 38.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - width: 0.5, - ), - ), - ), - child: InkWell( - child: Icon( - Icons.arrow_drop_up, - size: 18.0, - ), - onTap: () { - setState(() { - if (lutealPhaseLength < 15) lutealPhaseLength++; - }); - }, - ), - ), - InkWell( - child: Icon( - Icons.arrow_drop_down, - size: 18.0, - ), - onTap: () { - setState(() { - if (lutealPhaseLength > 0) lutealPhaseLength--; - }); - }, - ), - ], - ), - ), - ], - ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + prefixIcon: prefix == null + ? null + : Text( + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, ), ), - ), - Expanded( - child: Slider( - value: lutealPhaseLength.toDouble(), - min: 0, - max: 15, - onChanged: (double newValue) { - setState(() { - lutealPhaseLength = newValue.round(); - }); - }, - activeColor: Color(0xffC5272D), - inactiveColor: Color(0xffF3C5C6), - ), - ), - ], - ), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, ), - ], - ), - SizedBox( - height: 220.0, - ), - Container( - height: 50.0, - width: 350.0, - child: DefaultButton( - TranslationBase.of(context).calculate, - () { - calculateBabyInformation(); - Navigator.push( - context, - FadePage( - page: OvulationResult( - conceivedDate: conceivedDate, - dateFrom: dateFrom, - dateTo: dateTo, - deliveryDue: deliveryDue, - babyAge: babyAgeWeeks, - babyAgeDays: babyAgeDays, - )), - ); - }, ), - ), - ], + ], + ), ), - ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], ), ), ); diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart index bc345711..67ec7dea 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ovulation_period/ovulation_result_page.dart @@ -1,9 +1,12 @@ import 'package:diplomaticquarterapp/core/service/AlHabibMedicalService/health-calculator/bariatrics-service.dart'; import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart'; import 'package:diplomaticquarterapp/pages/BookAppointment/SearchResults.dart'; +import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; +import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; @@ -26,6 +29,7 @@ class OvulationResult extends StatelessWidget { this.babyAge, this.babyAgeDays, }); + //var newFormat = DateFormat("yy-MM-dd"); @override @@ -35,81 +39,105 @@ class OvulationResult extends StatelessWidget { showNewAppBarTitle: true, isShowDecPage: false, appBarTitle: TranslationBase.of(context).ovulation, - body: Padding( - padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 15.0), - child: SingleChildScrollView( - child: Container( - height: 750.0, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Texts( - 'The next ovulation period is estimated to be:', - fontWeight: FontWeight.w400, - ), - Texts( - 'From:', - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(dateFrom), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - 'To:', - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(dateTo), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - 'Useful Information:', - color: Color(0xffC5272D), - ), - Texts( - 'You have conceived on:', - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(conceivedDate), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - 'The baby\'s age right now:', - fontWeight: FontWeight.w400, - ), - Texts( - babyAge <= 0 ? "baby age is not available" : babyAge.toString() + " Weeks", - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Texts( - 'The delivery due date is estimated to be on the: ', - fontWeight: FontWeight.w400, - ), - Texts( - DateFormat.yMMMEd().format(deliveryDue), - fontWeight: FontWeight.w800, - fontSize: 21.0, - ), - Container( - width: 350, - child: DefaultButton( - TranslationBase.of(context).seeDoctorsList, - () { - getDoctorsList(context); - }, - ), - ), - ], + body: Column( + children: [ + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: const EdgeInsets.all(21), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + TranslationBase.of(context).ovulation, + style: TextStyle( + fontSize: 19, + letterSpacing: -1.14, + fontWeight: FontWeight.w600, + ), + ), + mHeight(20), + Text( + TranslationBase.of(context).ovulationPeriod, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + fontWeight: FontWeight.w600, + color: CustomColors.textColor, + ), + ), + mHeight(20), + showItem(TranslationBase.of(context).from, DateFormat.yMMMEd().format(dateFrom), titleColor: CustomColors.accentColor), + mHeight(12), + showItem(TranslationBase.of(context).to, DateFormat.yMMMEd().format(dateTo), titleColor: CustomColors.accentColor), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + Text( + TranslationBase.of(context).useFullInfo, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + color: CustomColors.accentColor, + fontWeight: FontWeight.w500, + ), + ), + mHeight(12), + showItem(TranslationBase.of(context).conceive, DateFormat.yMMMEd().format(conceivedDate)), + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), + showItem(TranslationBase.of(context).babyAge, babyAge <= 0 ? TranslationBase.of(context).babyAgeAvail : babyAge.toString() + TranslationBase.of(context).week), + + mHeight(12), + mDivider(CustomColors.devider), + mHeight(12), showItem(TranslationBase.of(context).deliveryDue, DateFormat.yMMMEd().format(deliveryDue)), + ], + ).withBorderedContainer, + ), ), ), - ), + Container( + margin: EdgeInsets.symmetric(horizontal: 16.0, vertical: 16.0), + color: Colors.white, + child: SecondaryButton( + label: TranslationBase.of(context).viewDocList, + color: CustomColors.accentColor, + onTap: () { + getDoctorsList(context); + }, + ), + ), + ], + ), + ); + } + + Widget showItem(String title, String value, {Color titleColor}) { + return Container( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + title, + style: TextStyle( + fontSize: 14, + letterSpacing: -0.56, + color: titleColor ?? Colors.black, + fontWeight: FontWeight.w500, + // fontWeight: FontWeight.w600, + ), + ), + Text( + value, + style: TextStyle( + fontSize: 18, + letterSpacing: -1.08, + fontWeight: FontWeight.w600, + ), + ), + ], ), ); } @@ -148,26 +176,17 @@ class OvulationResult extends StatelessWidget { List doctorByHospital = _patientDoctorAppointmentListHospital .where( (elementClinic) => elementClinic.filterName == element.projectName, - ) + ) .toList(); if (doctorByHospital.length != 0) { _patientDoctorAppointmentListHospital[_patientDoctorAppointmentListHospital.indexOf(doctorByHospital[0])].patientDoctorAppointmentList.add(element); } else { - _patientDoctorAppointmentListHospital - .add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: "0", patientDoctorAppointment: element)); + _patientDoctorAppointmentListHospital.add(PatientDoctorAppointmentList(filterName: element.projectName, distanceInKMs: "0", patientDoctorAppointment: element)); } }); - Navigator.push( - context, - FadePage( - page: SearchResults( - isLiveCareAppointment: false, - doctorsList: doctorsList, - patientDoctorAppointmentListHospital: - _patientDoctorAppointmentListHospital))); - + Navigator.push(context, FadePage(page: SearchResults(isLiveCareAppointment: false, doctorsList: doctorsList, patientDoctorAppointmentListHospital: _patientDoctorAppointmentListHospital))); } } }).catchError((err) { @@ -175,5 +194,20 @@ class OvulationResult extends StatelessWidget { print(err); }); } +} +extension BorderedContainer on Widget { + Widget get withBorderedContainer => Container( + padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: this, + ); } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 6d454d05..0491cfd4 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2622,6 +2622,49 @@ class TranslationBase { String get waist => localizedValues["waist"][locale.languageCode]; String get hip => localizedValues["hip"][locale.languageCode]; String get carbsProtin => localizedValues["carbsProtin"][locale.languageCode]; + + String get useFullInfo => localizedValues["usefulInfo"][locale.languageCode]; + String get babyAge => localizedValues["babyAge"][locale.languageCode]; + String get babyAgeAvail => localizedValues["babyAgeAvail"][locale.languageCode]; + String get deliveryDue => localizedValues["deliveryDue"][locale.languageCode]; + + String get almostInactive => localizedValues["almostInactive"][locale.languageCode]; + String get lightActive1 => localizedValues["lightActive1"][locale.languageCode]; + String get veryActive => localizedValues["veryActive"][locale.languageCode]; + String get superActive => localizedValues["superActive"][locale.languageCode]; + + + String get dailyIntake => localizedValues["dailyIntake"][locale.languageCode]; + String get calculateAmount => localizedValues["calculateAmount"][locale.languageCode]; + String get bodyWillBurn => localizedValues["bodyWillBurn"][locale.languageCode]; + String get caloriesEachDay => localizedValues["caloriesEachDay"][locale.languageCode]; + String get maintainWeight => localizedValues["maintainWeight"][locale.languageCode]; + + String get mediumFinger => localizedValues["mediumFinger"][locale.languageCode]; + String get smallFinger => localizedValues["smallFinger"][locale.languageCode]; + String get largeFinger => localizedValues["largeFinger"][locale.languageCode]; + String get idealBodyWeight => localizedValues["idealBodyWeight"][locale.languageCode]; + String get bodyFrameSize => localizedValues["bodyFrameSize"][locale.languageCode]; + + String get idealWeightRange => localizedValues["idealWeightRange"][locale.languageCode]; + String get currentWeightPerfect => localizedValues["currentWeightPerfect"][locale.languageCode]; + String get littleBitWeightMore => localizedValues["littleBitWeightMore"][locale.languageCode]; + String get consultWithDoctor => localizedValues["consultWithDoctor"][locale.languageCode]; + String get excessiveObesity => localizedValues["excessiveObesity"][locale.languageCode]; + String get mayWish => localizedValues["mayWish"][locale.languageCode]; + + String get essential => localizedValues["essential"][locale.languageCode]; + String get athlete => localizedValues["athlete"][locale.languageCode]; + String get fitness => localizedValues["fitness"][locale.languageCode]; + String get acceptable => localizedValues["acceptable"][locale.languageCode]; + String get underObese => localizedValues["underObese"][locale.languageCode]; + String get crossedLimits => localizedValues["crossedLimits"][locale.languageCode]; + String get lowLimits => localizedValues["lowLimits"][locale.languageCode]; + String get estimates => localizedValues["estimates"][locale.languageCode]; + + + + } class TranslationBaseDelegate extends LocalizationsDelegate { From 590b7953566af1c08bbc1ad79f0ded341104e823 Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Tue, 9 Nov 2021 16:38:14 +0300 Subject: [PATCH 04/20] Health Calculator 4.0 marge --- lib/config/localized_values.dart | 6 ++---- lib/uitl/translations_delegate_base.dart | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 84ed8f54..4a8ee340 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1690,10 +1690,7 @@ const Map localizedValues = { "bodyFrameMedium": {"en": "Medium (fingers touch)", "ar": "متوسط (الأصابع تتلامس)"}, "bodyFrameLarge": {"en": "Large (fingers don't touch)", "ar": "عريض (الأصابع لا تتلامس)"}, "bodyFatDesc": {"en": "Estimates the total body fat based on the size", "ar": "حساب الدهون في الجسم بناءاً على الحجم"}, - "essential":{"en":"The category falls under Essential Fat.","ar":"تندرج تحت فئة دهون أساسية"}, - "athlete":{"en":" The category falls under Athlete.","ar":"تندرج تحت فئة دهون جسم رياضي"}, - "fitness":{"en":" The category falls under Fitness.","ar":"تندرج تحت فئة دهون جسم صحي"}, - "acceptable":{"en":"The category falls under Acceptable","ar":"تندرج تحت فئة دهون مقبولة"}, + "obeseBodyFat":{"en":"The category falls under Obese.","ar":"تندرج تحت فئة دهون جسم سمين"}, "invalid":{"en":"Invalid input for calculation.","ar":"البيانات المدخلة غير صالحة للحساب"}, "more":{"en":"Please check the value you have entered, since the body fat percentage has crossed the limits.","ar":"يرجى التحقق من القيمة التي أدخلتها ، نظرًا لأن نسبة الدهون في الجسم قد تجاوزت الحدود"}, @@ -1707,4 +1704,5 @@ const Map localizedValues = { "dietModerate":{"en":"Moderate Carb","ar":"حمية معتدلة الكربوهيدرات"}, "dietUSDA":{"en":"USDA Guidelines","ar":"ارشادات وزارة الزراعة الأمريكية"}, "dietZone":{"en":"Zone Diet","ar":"حمية زون"}, + }; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 7b1a3071..80425967 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2721,14 +2721,11 @@ class TranslationBase { String get excessiveObesity => localizedValues["excessiveObesity"][locale.languageCode]; String get mayWish => localizedValues["mayWish"][locale.languageCode]; - String get essential => localizedValues["essential"][locale.languageCode]; - String get athlete => localizedValues["athlete"][locale.languageCode]; - String get fitness => localizedValues["fitness"][locale.languageCode]; - String get acceptable => localizedValues["acceptable"][locale.languageCode]; String get underObese => localizedValues["underObese"][locale.languageCode]; String get crossedLimits => localizedValues["crossedLimits"][locale.languageCode]; String get lowLimits => localizedValues["lowLimits"][locale.languageCode]; String get estimates => localizedValues["estimates"][locale.languageCode]; + String get submitReview => localizedValues["submitReview"][locale.languageCode]; From 14b85cc407081bda4bb91cca14dc1590983c9190 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 17:21:58 +0300 Subject: [PATCH 05/20] Family files API changes --- .../send_activation_request.dart | 11 +- .../DrawerPages/family/add-family-member.dart | 170 +++--- .../DrawerPages/family/add-family_type.dart | 6 +- lib/pages/DrawerPages/family/my-family.dart | 498 ++++++++---------- .../family_files/family_files_provider.dart | 10 +- 5 files changed, 319 insertions(+), 376 deletions(-) diff --git a/lib/models/Authentication/send_activation_request.dart b/lib/models/Authentication/send_activation_request.dart index e9512102..867d2d95 100644 --- a/lib/models/Authentication/send_activation_request.dart +++ b/lib/models/Authentication/send_activation_request.dart @@ -25,6 +25,9 @@ class SendActivationRequest { String dob; int isHijri; String healthId; + int responseID; + int status; + SendActivationRequest( {this.patientMobileNumber, this.mobileNo, @@ -51,7 +54,9 @@ class SendActivationRequest { this.sMSSignature, this.dob, this.isHijri, - this.healthId}); + this.healthId, + this.responseID, + this.status}); SendActivationRequest.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; @@ -80,6 +85,8 @@ class SendActivationRequest { dob = json['DOB']; isHijri = json['IsHijri']; healthId = json['HealthId']; + responseID = json['ReponseID']; + status = json['Status']; } Map toJson() { @@ -110,6 +117,8 @@ class SendActivationRequest { data['DOB'] = dob; data['IsHijri'] = isHijri; data['HealthId'] = healthId; + data['ResponseID'] = responseID; + data['Status'] = status; return data; } } diff --git a/lib/pages/DrawerPages/family/add-family-member.dart b/lib/pages/DrawerPages/family/add-family-member.dart index 9fb20630..6d9064d7 100644 --- a/lib/pages/DrawerPages/family/add-family-member.dart +++ b/lib/pages/DrawerPages/family/add-family-member.dart @@ -1,7 +1,6 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/model/family-file/add_family_file_request.dart'; -import 'package:diplomaticquarterapp/core/model/family-file/insert_share_file_request.dart'; import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/services/family_files/family_files_provider.dart'; @@ -17,7 +16,6 @@ import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/otp/sms-popup.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; -import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -41,6 +39,7 @@ class _AddMember extends State { var familyFileProvider = FamilyFilesProvider(); var patientShareRequestID; + var patientShareResponseID; @override void initState() { @@ -50,67 +49,71 @@ class _AddMember extends State { @override Widget build(BuildContext context) { return AppScaffold( - appBarTitle: TranslationBase.of(context).myFamilyFiles, - isShowAppBar: true, - showNewAppBar: true, - showNewAppBarTitle: true, - body: isLoading == true - ? AppCircularProgressIndicator() - : SingleChildScrollView( - child: Container( - padding: EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30), + appBarTitle: TranslationBase.of(context).myFamilyFiles, + isShowAppBar: true, + showNewAppBar: true, + showNewAppBarTitle: true, + body: isLoading == true + ? AppCircularProgressIndicator() + : SingleChildScrollView( + child: Container( + padding: EdgeInsets.all(21.0), height: SizeConfig.realScreenHeight * .9, width: SizeConfig.realScreenWidth, - child: Column(children: [ - Expanded( - flex: 2, - child: AppText( - TranslationBase.of(context).enterNationalId, - fontSize: SizeConfig.textMultiplier * 3.5, - textAlign: TextAlign.left, - )), - Expanded( - flex: 4, - child: Column( - // mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - PhoneNumberSelectorWidget(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), - //MobileNo(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), - // Container( - // child: TextFields( - // controller: nationalIDorFile, - // onChanged: (value) => {validateForm()}, - // prefixIcon: Icon(loginType == 1 ? Icons.chrome_reader_mode : Icons.receipt, color: Colors.red), - // padding: EdgeInsets.only(top: 20, bottom: 20, left: 10, right: 10), - // hintText: loginType == 1 ? TranslationBase.of(context).nationalID : TranslationBase.of(context).fileNo, - // )) - SizedBox( - height: 12, - ), - inputWidget(loginType == 1 ? TranslationBase.of(context).nationalIdNumber : TranslationBase.of(context).medicalFileNumber, "Xxxxxxxxx", nationalIDorFile), - ], - ), - ), - Expanded( - flex: 3, + child: Column( + children: [ + Expanded( + flex: 1, + child: Text( + loginType == 1 ? TranslationBase.of(context).enterNationalId : TranslationBase.of(context).enterFile, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), + )), + Expanded( + flex: 4, child: Column( - mainAxisAlignment: MainAxisAlignment.end, children: [ - Row( - children: [ - Expanded( - child: DefaultButton( - TranslationBase.of(context).add, - () => {this.addMember()}, - color: isButtonDisabled == true ? Colors.grey : CustomColors.accentColor, - textColor: Colors.white, - )) - ], + PhoneNumberSelectorWidget(onNumberChange: (value) => {mobileNo = value, validateForm()}, onCountryChange: (value) => countryCode = value), + SizedBox( + height: 12, ), + inputWidget(loginType == 1 ? TranslationBase.of(context).nationalIdNumber : TranslationBase.of(context).medicalFileNumber, "Xxxxxxxxx", nationalIDorFile), ], - )) - ]), - ))); + ), + ), + // Expanded( + // flex: 3, + // child: Column( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Row( + // children: [ + // Expanded( + // child: DefaultButton( + // TranslationBase.of(context).add, + // () => {this.addMember()}, + // color: isButtonDisabled == true ? Colors.grey : CustomColors.accentColor, + // textColor: Colors.white, + // ), + // ) + // ], + // ), + // ], + // ), + // ) + ], + ), + ), + ), + bottomSheet: Container( + color: Colors.white, + padding: EdgeInsets.all(21.0), + child: DefaultButton( + TranslationBase.of(context).add, + () => {this.addMember()}, + color: isButtonDisabled == true ? Colors.grey : CustomColors.accentColor, + textColor: Colors.white, + )), + ); } void validateForm() { @@ -158,31 +161,30 @@ class _AddMember extends State { } insertFamilyData(addMemberResult) { - var request = InsertSharePatientFileReq(); - request.responseID = addMemberResult['ShareFamilyFileObj']['ReponseID']; - request.shareFamilyPatientName = addMemberResult['ShareFamilyFileObj']['SharedPatientName']; - request.status = 2; - if (request.patientOutSA == 1) { - request.regionID = 2; - } else { - request.regionID = 1; - } - loading(true); - familyFileProvider.insertNewMember(request).then((value) => sendActivationCode(value)).catchError((err){ - loading(false); - AppToast.showErrorToast(message: err); - }); + sendActivationCode(addMemberResult); + // var request = InsertSharePatientFileReq(); + // request.responseID = addMemberResult['ShareFamilyFileObj']['ReponseID']; + // request.shareFamilyPatientName = addMemberResult['ShareFamilyFileObj']['SharedPatientName']; + // request.status = 2; + // if (request.patientOutSA == 1) { + // request.regionID = 2; + // } else { + // request.regionID = 1; + // } + // loading(true); + // familyFileProvider.insertNewMember(request).then((value) => sendActivationCode(value)).catchError((err) { + // loading(false); + // AppToast.showErrorToast(message: err); + // }); } sendActivationCode(result) { // var request = this.getCommonRequest(); loading(true); - patientShareRequestID = result['PatientShareRequestID']; - familyFileProvider.sendActivationCode(mobileNo, countryCode, nationalIDorFile.text).then((result) => { - if (result != null && result['isSMSSent'] == true) {this.startSMSService(1, result)} - // {loading(false), this.startSMSService(type)} - // else - // {loading(false)} + patientShareResponseID = result['ShareFamilyFileObj']['ReponseID']; + familyFileProvider.sendActivationCode(mobileNo, countryCode, nationalIDorFile.text, patientShareResponseID).then((res) => { + patientShareRequestID = res['PatientShareRequestID'], + if (res != null && res['isSMSSent'] == true) {this.startSMSService(1, res)} }); } @@ -207,7 +209,7 @@ class _AddMember extends State { checkActivationCode(value, result) { Navigator.pop(context); GifLoaderDialogUtils.showMyDialog(context); - familyFileProvider.checkActivationCode(result['LogInTokenID'], value, nationalIDorFile.text, mobileNo).then((result) { + familyFileProvider.checkActivationCode(result['LogInTokenID'], value, nationalIDorFile.text, mobileNo, patientShareRequestID, patientShareResponseID).then((result) { SMSOTP.hideSMSBox(context); handleFamilyRequests(this.patientShareRequestID, 3); }).catchError((err) { @@ -219,12 +221,12 @@ class _AddMember extends State { } handleFamilyRequests(id, stauts) { - familyFileProvider.acceptAndRejectRecievedRequests(id, stauts).then((result) => { - sharedPref.remove(FAMILY_FILE), - Navigator.of(context).pushNamed( - MY_FAMILIY, - ) - }); + // familyFileProvider.acceptAndRejectRecievedRequests(id, stauts).then((result) => { + sharedPref.remove(FAMILY_FILE); + Navigator.of(context).pushNamed( + MY_FAMILIY, + ); + // }); } loading(flag) { diff --git a/lib/pages/DrawerPages/family/add-family_type.dart b/lib/pages/DrawerPages/family/add-family_type.dart index 533669c7..60e396c6 100644 --- a/lib/pages/DrawerPages/family/add-family_type.dart +++ b/lib/pages/DrawerPages/family/add-family_type.dart @@ -26,11 +26,11 @@ class AddFamilyMemberType extends StatelessWidget { padding: EdgeInsets.zero, physics: BouncingScrollPhysics(), children: [ - SizedBox(height: 12), + SizedBox(height: 21), HabibLogoWidget(), - SizedBox(height: 50), + SizedBox(height: 21), Text( - TranslationBase.of(context).logintypeRadio, + TranslationBase.of(context).registerInfoFamily, style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xff2B353E), letterSpacing: -0.64, height: 23 / 16), ), GridView( diff --git a/lib/pages/DrawerPages/family/my-family.dart b/lib/pages/DrawerPages/family/my-family.dart index 1d2b470b..f3658fae 100644 --- a/lib/pages/DrawerPages/family/my-family.dart +++ b/lib/pages/DrawerPages/family/my-family.dart @@ -27,7 +27,6 @@ import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/defaultButton.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart'; -import 'package:diplomaticquarterapp/widgets/dialogs/confirm_dialog.dart'; import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; @@ -159,113 +158,115 @@ class _MyFamily extends State with TickerProviderStateMixin { if (snapshot.hasError) return Padding(padding: EdgeInsets.all(10), child: Text(TranslationBase.of(context).noDataAvailable)); else - return ListView.separated( - itemBuilder: (context, index) { - if (snapshot.data.getAllSharedRecordsByStatusList[index].status == 3) - return Container( - margin: EdgeInsets.all(5), - decoration: cardRadius( - 15, - elevation: 0, - color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0xffFDA4B0) : Color(0xff6EA8FF), - ), - child: Container( - // height: 130,0xffFDA4B0 - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.all(10), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Texts( - snapshot.data.getAllSharedRecordsByStatusList[index].patientName.toLowerCase().capitalizeFirstofEach, - fontSize: 18, - fontWeight: FontWeight.bold, - color: Colors.white, - ), - Texts(TranslationBase.of(context).fileNumber + ': ' + snapshot.data.getAllSharedRecordsByStatusList[index].responseID.toString(), - fontSize: 12, color: Colors.white), - Texts( - snapshot.data.getAllSharedRecordsByStatusList[index].age.toString() + - ' ' + - TranslationBase.of(context).years + - ', ' + - snapshot.data.getAllSharedRecordsByStatusList[index].genderDescription, - fontSize: 12, - color: Colors.white), - ], - ), - Column( + return checkActive(snapshot.data.getAllSharedRecordsByStatusList) > 0 + ? ListView.separated( + itemBuilder: (context, index) { + if (snapshot.data.getAllSharedRecordsByStatusList[index].status == 3) + return Container( + margin: EdgeInsets.all(5), + decoration: cardRadius( + 15, + elevation: 0, + color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0xffFDA4B0) : Color(0xff6EA8FF), + ), + child: Container( + // height: 130,0xffFDA4B0 + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.all(10), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - SizedBox(height: 10), - InkWell( - onTap: () { - switchUser(snapshot.data.getAllSharedRecordsByStatusList[index], context); - }, - child: Container( - decoration: BoxDecoration(color: Colors.black.withOpacity(0.1), borderRadius: BorderRadius.circular(20)), - padding: EdgeInsets.fromLTRB(15, 10, 15, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset("assets/images/new-design/switch.svg", - height: 22, color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white), - SizedBox( - width: 5, - ), - // CupertinoSwitch( - // value: isSwitchUser, - // onChanged: (value) { - // setState(() { - // isSwitchUser = value; - // }); - // if (isSwitchUser == true) switchUser(snapshot.data.getAllSharedRecordsByStatusList[index], context); - // }, - // ), - Texts(TranslationBase.of(context).switchUser, - color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white, - fontSize: 12, - fontWeight: FontWeight.w600) - ], - ))), - SizedBox( - height: 10, + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Texts( + snapshot.data.getAllSharedRecordsByStatusList[index].patientName.toLowerCase().capitalizeFirstofEach, + fontSize: 18, + fontWeight: FontWeight.bold, + color: Colors.white, + ), + Texts(TranslationBase.of(context).fileNumber + ': ' + snapshot.data.getAllSharedRecordsByStatusList[index].responseID.toString(), + fontSize: 12, color: Colors.white), + Texts( + snapshot.data.getAllSharedRecordsByStatusList[index].age.toString() + + ' ' + + TranslationBase.of(context).years + + ', ' + + snapshot.data.getAllSharedRecordsByStatusList[index].genderDescription, + fontSize: 12, + color: Colors.white), + ], + ), + Column( + children: [ + SizedBox(height: 10), + InkWell( + onTap: () { + switchUser(snapshot.data.getAllSharedRecordsByStatusList[index], context); + }, + child: Container( + decoration: BoxDecoration(color: Colors.black.withOpacity(0.1), borderRadius: BorderRadius.circular(20)), + padding: EdgeInsets.fromLTRB(15, 10, 15, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset("assets/images/new-design/switch.svg", + height: 22, color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white), + SizedBox( + width: 5, + ), + // CupertinoSwitch( + // value: isSwitchUser, + // onChanged: (value) { + // setState(() { + // isSwitchUser = value; + // }); + // if (isSwitchUser == true) switchUser(snapshot.data.getAllSharedRecordsByStatusList[index], context); + // }, + // ), + Texts(TranslationBase.of(context).switchUser, + color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white, + fontSize: 12, + fontWeight: FontWeight.w600) + ], + ))), + SizedBox( + height: 10, + ), + InkWell( + onTap: () { + deleteFamily(snapshot.data.getAllSharedRecordsByStatusList[index], context); + }, + child: Container( + decoration: BoxDecoration(color: Colors.black.withOpacity(0.1), borderRadius: BorderRadius.circular(20)), + padding: EdgeInsets.fromLTRB(15, 10, 15, 10), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SvgPicture.asset("assets/images/new-design/delete.svg", + height: 22, color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white), + SizedBox( + width: 5, + ), + Texts(TranslationBase.of(context).delete, + color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white, + fontSize: 12, + fontWeight: FontWeight.w600), + ], + ))), + SizedBox(height: 10), + ], ), - InkWell( - onTap: () { - deleteFamily(snapshot.data.getAllSharedRecordsByStatusList[index], context); - }, - child: Container( - decoration: BoxDecoration(color: Colors.black.withOpacity(0.1), borderRadius: BorderRadius.circular(20)), - padding: EdgeInsets.fromLTRB(15, 10, 15, 10), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SvgPicture.asset("assets/images/new-design/delete.svg", - height: 22, color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white), - SizedBox( - width: 5, - ), - Texts(TranslationBase.of(context).delete, - color: snapshot.data.getAllSharedRecordsByStatusList[index].gender == 2 ? Color(0Xff5A282E) : Colors.white, - fontSize: 12, - fontWeight: FontWeight.w600), - ], - ))), - SizedBox(height: 10), ], - ), - ], - ))); - else if (checkActive(snapshot.data.getAllSharedRecordsByStatusList) == 0) - return getNoDataWidget(context); - else - return SizedBox(height: 0); - }, - separatorBuilder: (context, index) => SizedBox(height: 0), - itemCount: snapshot.data.getAllSharedRecordsByStatusList.length); + ))); + // else if (checkActive(snapshot.data.getAllSharedRecordsByStatusList) == 0) + // return getNoDataWidget(context); + else + return SizedBox(height: 0); + }, + separatorBuilder: (context, index) => SizedBox(height: 0), + itemCount: snapshot.data.getAllSharedRecordsByStatusList.length) + : getNoDataWidget(context); } }, ), @@ -290,176 +291,98 @@ class _MyFamily extends State with TickerProviderStateMixin { child: Column( children: [ FractionallySizedBox( - widthFactor: 1.0, - child: AppExpandableNotifier( - title: TranslationBase.of(context).userViewRequest, - bodyWidget: FutureBuilder( - future: getUserViewRequest(), // async work - builder: (BuildContext context, AsyncSnapshot snapshot) { - switch (snapshot.connectionState) { - case ConnectionState.waiting: - return SizedBox(); + widthFactor: 1.0, + child: AppExpandableNotifier( + title: TranslationBase.of(context).userViewRequest, + bodyWidget: FutureBuilder( + future: getUserViewRequest(), // async work + builder: (BuildContext context, AsyncSnapshot snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return SizedBox(); - default: - if (snapshot.hasError) - return Padding(padding: EdgeInsets.all(10), child: Text(TranslationBase.of(context).noDataAvailable)); - else - return ListView.separated( - shrinkWrap: true, - physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.only(bottom: 14, top: 14, left: 21, right: 21), - itemBuilder: (context, _index) { - return Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(10.0), - ), - border: Border.all(width: 1, color: Color(0xffEFEFEF)), - boxShadow: [ - BoxShadow( - color: Color(0xff000000).withOpacity(.05), - //spreadRadius: 5, - blurRadius: 27, - offset: Offset(0, -3), - ), - ], - color: Colors.white), - child: Column( - children: [ - Column(children: [ - Padding( - padding: EdgeInsets.all(10), - child: Row(children: [ - Expanded(flex: 3, child: AppText(TranslationBase.of(context).name, fontWeight: FontWeight.w600)), - Expanded(flex: 1, child: AppText(TranslationBase.of(context).allow, fontWeight: FontWeight.w600)), - Expanded(flex: 1, child: AppText(TranslationBase.of(context).reject, fontWeight: FontWeight.w600)), - ])), - Padding( - padding: const EdgeInsets.only(left: 10.0, right: 10.0), - child: Divider(color: Colors.black, height: 1.5, thickness: 1.5), - ), - Column( - children: familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList.map((result) { - return Container( - padding: EdgeInsets.all(10), - child: Row( - children: [ - Expanded( - flex: 3, - child: Texts( - result.patientName, - fontWeight: FontWeight.w600, - fontSize: 12, - )), - Expanded( - flex: 1, - child: IconButton( - icon: SvgPicture.asset("assets/images/new-design/allow.svg", height: 22), - onPressed: () { - acceptRemoveRequest(result.iD, 3, context); - }, - )), - Expanded( - flex: 1, - child: IconButton( - icon: SvgPicture.asset("assets/images/new-design/reject.svg", height: 22), - color: Colors.white, - onPressed: () { - acceptRemoveRequest(result.iD, 4, context); - }, - )) - ], - )); - }).toList()) - ]) - ], - )); - }, - separatorBuilder: (context, index) => SizedBox(height: 14), - itemCount: 1); - } - }, - ))), - - // RoundedContainer( - // child: ExpansionTile( - // title: Text( - // TranslationBase.of(context).userViewRequest, - // style: TextStyle(fontSize: 16.0, fontWeight: FontWeight.bold, color: Colors.black), - // ), - // children: [ - // FutureBuilder( - // future: getUserViewRequest(), // async work - // builder: (BuildContext context, AsyncSnapshot snapshot) { - // switch (snapshot.connectionState) { - // case ConnectionState.waiting: - // return Padding(padding: EdgeInsets.only(top: 50), child: Text('Loading....')); - // default: - // if (snapshot.hasError) - // return Padding(padding: EdgeInsets.all(10), child: Text(TranslationBase.of(context).noDataAvailable)); - // else - // return Container( - // padding: EdgeInsets.all(15), - // child: Card( - // elevation: 3, - // shape: cardRadius(8), - // child: Column( - // children: [ - // Column(children: [ - // Padding( - // padding: EdgeInsets.all(10), - // child: Row(children: [ - // Expanded(flex: 3, child: AppText(TranslationBase.of(context).name, fontWeight: FontWeight.w600)), - // Expanded(flex: 1, child: AppText(TranslationBase.of(context).allow, fontWeight: FontWeight.w600)), - // Expanded(flex: 1, child: AppText(TranslationBase.of(context).reject, fontWeight: FontWeight.w600)), - // ])), - // Divider(color: Colors.black, height: 1.5, thickness: 1.5), - // Column( - // children: familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList.map((result) { - // return Container( - // padding: EdgeInsets.all(10), - // child: Row( - // children: [ - // Expanded( - // flex: 3, - // child: Texts( - // result.patientName, - // fontWeight: FontWeight.w600, - // fontSize: 12, - // )), - // Expanded( - // flex: 1, - // child: IconButton( - // icon: Icon( - // Icons.check_circle, - // color: Color(0xff349745), - // ), - // onPressed: () { - // acceptRemoveRequest(result.iD, 3, context); - // }, - // )), - // Expanded( - // flex: 1, - // child: IconButton( - // icon: Icon( - // Icons.close, - // color: Colors.red[900], - // ), - // onPressed: () { - // acceptRemoveRequest(result.iD, 4, context); - // }, - // )) - // ], - // )); - // }).toList()) - // ]) - // ], - // ))); - // } - // }) - // ], - // ), - // ), + default: + if (snapshot.hasError) + return Padding(padding: EdgeInsets.all(10), child: Text(TranslationBase.of(context).noDataAvailable)); + else + return ListView.separated( + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + padding: EdgeInsets.only(bottom: 14, top: 14, left: 21, right: 21), + itemBuilder: (context, _index) { + return Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.all( + Radius.circular(10.0), + ), + border: Border.all(width: 1, color: Color(0xffEFEFEF)), + boxShadow: [ + BoxShadow( + color: Color(0xff000000).withOpacity(.05), + //spreadRadius: 5, + blurRadius: 27, + offset: Offset(0, -3), + ), + ], + color: Colors.white), + child: Column( + children: [ + Column(children: [ + Padding( + padding: EdgeInsets.all(10), + child: Row(children: [ + Expanded(flex: 3, child: AppText(TranslationBase.of(context).name, fontWeight: FontWeight.w600)), + Expanded(flex: 1, child: AppText(TranslationBase.of(context).allow, fontWeight: FontWeight.w600)), + Expanded(flex: 1, child: AppText(TranslationBase.of(context).reject, fontWeight: FontWeight.w600)), + ])), + Padding( + padding: const EdgeInsets.only(left: 10.0, right: 10.0), + child: Divider(color: Colors.black, height: 1.5, thickness: 1.5), + ), + Column( + children: familyFileProvider.allSharedRecordsByStatusResponse.getAllSharedRecordsByStatusList.map((result) { + return Container( + padding: EdgeInsets.all(10), + child: Row( + children: [ + Expanded( + flex: 3, + child: Texts( + result.patientName, + fontWeight: FontWeight.w600, + fontSize: 12, + )), + Expanded( + flex: 1, + child: IconButton( + icon: SvgPicture.asset("assets/images/new-design/allow.svg", height: 22), + onPressed: () { + acceptRemoveRequest(result.iD, 3, context); + }, + )), + Expanded( + flex: 1, + child: IconButton( + icon: SvgPicture.asset("assets/images/new-design/reject.svg", height: 22), + color: Colors.white, + onPressed: () { + acceptRemoveRequest(result.iD, 4, context); + }, + )) + ], + )); + }).toList()) + ]) + ], + )); + }, + separatorBuilder: (context, index) => SizedBox(height: 14), + itemCount: 1); + } + }, + ), + ), + ), SizedBox(height: 15), FractionallySizedBox( widthFactor: 1.0, @@ -521,18 +444,21 @@ class _MyFamily extends State with TickerProviderStateMixin { fontSize: 12, )), Expanded( - flex: 1, - child: Card( - // shape: cardRadius(10), - color: result.status == 3 ? Color(0xff349745) : Color(0xffD02127), - child: Padding( - padding: EdgeInsets.all(5), - child: AppText( - result.statusDescription, - color: Colors.white, - textAlign: TextAlign.center, - fontSize: 12, - )))), + flex: 1, + child: Card( + // shape: cardRadius(10), + color: result.status == 3 ? Color(0xff349745) : Color(0xffD02127), + child: Padding( + padding: EdgeInsets.all(5), + child: AppText( + result.statusDescription != null ? result.statusDescription : "", + color: Colors.white, + textAlign: TextAlign.center, + fontSize: 12, + ), + ), + ), + ), ], )); }).toList(), diff --git a/lib/services/family_files/family_files_provider.dart b/lib/services/family_files/family_files_provider.dart index ef7ad14d..cc151c7b 100644 --- a/lib/services/family_files/family_files_provider.dart +++ b/lib/services/family_files/family_files_provider.dart @@ -140,7 +140,7 @@ class FamilyFilesProvider with ChangeNotifier { } } - Future sendActivationCode(cellNumber, zipCode, patientIdentificationID) async { + Future sendActivationCode(cellNumber, zipCode, patientIdentificationID, responseID) async { try { dynamic localRes; var request = SendActivationRequest(); @@ -151,6 +151,8 @@ class FamilyFilesProvider with ChangeNotifier { request.loginType = request.searchType = 1; request.oTPSendType = 1; request.isRegister = false; + request.responseID = responseID; + request.status = 2; await new BaseAppClient().post(SEND_FAMILY_FILE_ACTIVATION, onSuccess: (dynamic response, int statusCode) { localRes = response; }, onFailure: (String error, int statusCode) { @@ -166,7 +168,7 @@ class FamilyFilesProvider with ChangeNotifier { } //TODO - Future checkActivationCode(loginTokenID, activationCode, indentification, mobileNo) async { + Future checkActivationCode(loginTokenID, activationCode, indentification, mobileNo, requestID, responseID) async { try { dynamic localRes; Map request = {}; @@ -175,6 +177,10 @@ class FamilyFilesProvider with ChangeNotifier { request['PatientIdentificationID'] = indentification; request['LogInTokenID'] = loginTokenID; request['activationCode'] = activationCode; + request['PatientShareRequestID'] = requestID; + request['ResponseID'] = responseID; + request['Status'] = 3; + // this.authService.authenticateRequest(request); await new BaseAppClient().post(CHECK_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) { localRes = response; From 338c646a438424a850ab1783807c88e1ab6a4217 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 17:32:30 +0300 Subject: [PATCH 06/20] updates --- .../health_calculator/body_fat/body_fat.dart | 100 ++++++++---------- lib/uitl/translations_delegate_base.dart | 28 ++++- 2 files changed, 69 insertions(+), 59 deletions(-) diff --git a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart index 5cdd8e3b..6aab447a 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/body_fat/body_fat.dart @@ -4,7 +4,6 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart'; -import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; @@ -23,7 +22,6 @@ class BodyFat extends StatefulWidget { } class _BodyFatState extends State { - final GlobalKey clinicDropdownKey = GlobalKey(); bool _isHeightCM = true; bool _isNeckKG = true; @@ -34,7 +32,6 @@ class _BodyFatState extends State { double _waistValue = 0; double _hipValue = 0; - TextEditingController _heightController = new TextEditingController(); TextEditingController _neckController = TextEditingController(); TextEditingController _waistController = TextEditingController(); @@ -45,12 +42,12 @@ class _BodyFatState extends State { List _waistPopupList = List(); List _hipPopupList = List(); - - bool isMale = false; + // bool isHeightCm = true; Color maleCard = activeCardColorGender; Color femaleCard = inactiveCardColorGender; + // Color neckCmCard = activeCardColor; // Color neckFtCard = inactiveCardColor; Color waistCmCard = activeCardColor; @@ -59,6 +56,7 @@ class _BodyFatState extends State { Color hipFtCard = inactiveCardColor; Color cmCard = activeCardColor; Color ftCard = inactiveCardColor; + // int neck = 10; // int heightCm = 0; // int heightFt = 0; @@ -67,6 +65,7 @@ class _BodyFatState extends State { double minRange; double maxRange; double overWeightBy; + // int waist = 5; double bodyFat = 0; double fat = 0; @@ -74,8 +73,6 @@ class _BodyFatState extends State { double calories = 0; String textResult = ''; - - @override void initState() { _neckController.text = _neckValue.toString(); @@ -105,8 +102,6 @@ class _BodyFatState extends State { } } - - void updateColorWaist(int type) { //MG/DLT card if (type == 1) { @@ -187,29 +182,29 @@ class _BodyFatState extends State { } else if (bodyFat > 13 && bodyFat <= 20) { textResult = TranslationBase.of(context).athlete; } else if (bodyFat > 20 && bodyFat <= 24) { - textResult =TranslationBase.of(context).fitness; + textResult = TranslationBase.of(context).fitness; } else if (bodyFat > 24 && bodyFat <= 31) { - textResult =TranslationBase.of(context).acceptable; + textResult = TranslationBase.of(context).acceptable; } else if (bodyFat > 31 && bodyFat <= 60) { - textResult =TranslationBase.of(context).underObese; + textResult = TranslationBase.of(context).underObese; } else if (bodyFat > 60) { - textResult =TranslationBase.of(context).crossedLimits; + textResult = TranslationBase.of(context).crossedLimits; } else if (bodyFat <= 9) { - textResult =TranslationBase.of(context).lowLimits; + textResult = TranslationBase.of(context).lowLimits; } } else { if (bodyFat > 5 && fat <= 13) { - textResult = 'The category falls under essential'; + textResult = TranslationBase.of(context).essential; } else if (bodyFat > 13 && bodyFat <= 17) { - textResult = 'The category falls under athlete'; + textResult = TranslationBase.of(context).athlete; } else if (bodyFat > 17 && bodyFat <= 24) { - textResult = 'The category falls under fitness'; + textResult = TranslationBase.of(context).fitness; } else if (bodyFat > 24 && bodyFat <= 45) { - textResult = 'The category falls under obese'; + textResult = TranslationBase.of(context).underObese; } else if (bodyFat > 45) { - textResult = 'Please check the value you have entered, since the body fat percentage has crosed the limits.'; + textResult = TranslationBase.of(context).crossedLimits; } else if (bodyFat <= 5) { - textResult = 'Please check the value you have entered, since the body fat percentage cannot be this low.'; + textResult = TranslationBase.of(context).lowLimits; } } } @@ -242,12 +237,12 @@ class _BodyFatState extends State { Expanded( child: SingleChildScrollView( child: Container( - padding: EdgeInsets.all(20), + padding: EdgeInsets.all(20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Estimates the total body fat based on\nthe size', + TranslationBase.of(context).bodyFatDesc, style: TextStyle( fontSize: 14, fontWeight: FontWeight.w600, @@ -354,14 +349,14 @@ class _BodyFatState extends State { 1, 270, _heightValue, - (text) { + (text) { _heightController.text = text; }, - (value) { + (value) { _heightValue = value; }, _isHeightCM ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isHeightCM != value) { setState(() { _isHeightCM = value; @@ -379,14 +374,14 @@ class _BodyFatState extends State { 1, 270, _neckValue, - (text) { - _neckController.text = text; + (text) { + _neckController.text = text; }, - (value) { - _neckValue = value; + (value) { + _neckValue = value; }, _isNeckKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isNeckKG != value) { setState(() { _isNeckKG = value; @@ -395,7 +390,6 @@ class _BodyFatState extends State { }, _neckPopupList, ), - SizedBox( height: 12.0, ), @@ -405,14 +399,14 @@ class _BodyFatState extends State { 1, 270, _waistValue, - (text) { - _waistController.text = text; + (text) { + _waistController.text = text; }, - (value) { + (value) { _waistValue = value; }, _isWaistKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isWaistKG != value) { setState(() { _isWaistKG = value; @@ -430,14 +424,14 @@ class _BodyFatState extends State { 1, 270, _hipValue, - (text) { + (text) { _hipController.text = text; }, - (value) { + (value) { _hipValue = value; }, _isHipKG ? TranslationBase.of(context).cm : TranslationBase.of(context).ft, - (value) { + (value) { if (_isHipKG != value) { setState(() { _isHipKG = value; @@ -446,7 +440,6 @@ class _BodyFatState extends State { }, _hipPopupList, ), - SizedBox( height: 12.0, ), @@ -471,10 +464,10 @@ class _BodyFatState extends State { context, FadePage( page: FatResult( - bodyFat: bodyFat, - fat: fat, - textResult: textResult, - )), + bodyFat: bodyFat, + fat: fat, + textResult: textResult, + )), ); } }); @@ -485,6 +478,7 @@ class _BodyFatState extends State { ), ); } + Widget inputWidget(String _labelText, String _hintText, TextEditingController _controller, {String prefix, bool isEnable = true, bool hasSelection = false}) { return Container( padding: EdgeInsets.only(left: 16, right: 16, bottom: 15, top: 15), @@ -542,15 +536,15 @@ class _BodyFatState extends State { prefixIcon: prefix == null ? null : Text( - "+" + prefix, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontWeight: FontWeight.w500, - color: Color(0xff2E303A), - letterSpacing: -0.56, - ), - ), + "+" + prefix, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w500, + color: Color(0xff2E303A), + letterSpacing: -0.56, + ), + ), contentPadding: EdgeInsets.zero, border: InputBorder.none, focusedBorder: InputBorder.none, @@ -691,5 +685,3 @@ class CommonDropDownView extends StatelessWidget { ); } } - - diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 80425967..d1bc500d 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2692,44 +2692,62 @@ class TranslationBase { String get dietZone => localizedValues["dietZone"][locale.languageCode]; String get useFullInfo => localizedValues["usefulInfo"][locale.languageCode]; + String get babyAge => localizedValues["babyAge"][locale.languageCode]; + String get babyAgeAvail => localizedValues["babyAgeAvail"][locale.languageCode]; + String get deliveryDue => localizedValues["deliveryDue"][locale.languageCode]; String get almostInactive => localizedValues["almostInactive"][locale.languageCode]; + String get lightActive1 => localizedValues["lightActive1"][locale.languageCode]; + String get veryActive => localizedValues["veryActive"][locale.languageCode]; - String get superActive => localizedValues["superActive"][locale.languageCode]; + String get superActive => localizedValues["superActive"][locale.languageCode]; String get dailyIntake => localizedValues["dailyIntake"][locale.languageCode]; + String get calculateAmount => localizedValues["calculateAmount"][locale.languageCode]; + String get bodyWillBurn => localizedValues["bodyWillBurn"][locale.languageCode]; + String get caloriesEachDay => localizedValues["caloriesEachDay"][locale.languageCode]; + String get maintainWeight => localizedValues["maintainWeight"][locale.languageCode]; String get mediumFinger => localizedValues["mediumFinger"][locale.languageCode]; + String get smallFinger => localizedValues["smallFinger"][locale.languageCode]; + String get largeFinger => localizedValues["largeFinger"][locale.languageCode]; + String get idealBodyWeight => localizedValues["idealBodyWeight"][locale.languageCode]; + String get bodyFrameSize => localizedValues["bodyFrameSize"][locale.languageCode]; String get idealWeightRange => localizedValues["idealWeightRange"][locale.languageCode]; + String get currentWeightPerfect => localizedValues["currentWeightPerfect"][locale.languageCode]; + String get littleBitWeightMore => localizedValues["littleBitWeightMore"][locale.languageCode]; + String get consultWithDoctor => localizedValues["consultWithDoctor"][locale.languageCode]; + String get excessiveObesity => localizedValues["excessiveObesity"][locale.languageCode]; + String get mayWish => localizedValues["mayWish"][locale.languageCode]; String get underObese => localizedValues["underObese"][locale.languageCode]; - String get crossedLimits => localizedValues["crossedLimits"][locale.languageCode]; - String get lowLimits => localizedValues["lowLimits"][locale.languageCode]; - String get estimates => localizedValues["estimates"][locale.languageCode]; - String get submitReview => localizedValues["submitReview"][locale.languageCode]; + String get crossedLimits => localizedValues["crossedLimits"][locale.languageCode]; + String get lowLimits => localizedValues["lowLimits"][locale.languageCode]; + String get estimates => localizedValues["estimates"][locale.languageCode]; + String get submitReview => localizedValues["submitReview"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { From 11d37d26e53b658f6128cf42e0e5f6aac50b562e Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 17:59:36 +0300 Subject: [PATCH 07/20] Product Detail page fix --- .../product-details/product-detail.dart | 394 +++++++++--------- .../product-name-and-price.dart | 2 +- .../product_detail_service.dart | 10 +- 3 files changed, 205 insertions(+), 201 deletions(-) diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 015df6ed..2676280f 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -1,4 +1,5 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; +import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; @@ -11,6 +12,7 @@ import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; import 'availability_info.dart'; @@ -87,8 +89,8 @@ class __ProductDetailPageState extends State { Widget build(BuildContext context) { return BaseView( allowAny: true, - onModelReady: (model) { - model.getProductReviewsData(widget.product.id); + onModelReady: (model) async { + await model.getProductReviewsData(widget.product.id).then((value) {}); }, builder: (_, model, wi) => AppScaffold( appBarTitle: TranslationBase.of(context).productDetails, @@ -108,215 +110,219 @@ class __ProductDetailPageState extends State { isInWishList: isInWishList, addToCartFunction: addToCartFunction, ), - body: SingleChildScrollView( - child: Column( - children: [ - Container( - width: double.infinity, - color: Colors.white, + body: model.state == ViewState.Idle + ? SingleChildScrollView( child: Column( children: [ - if (widget.product.images.isNotEmpty) - Container( - height: MediaQuery.of(context).size.height * .40, - child: Image.network( - widget.product.images[0].src.trim(), - fit: BoxFit.contain, - ), + Container( + width: double.infinity, + color: Colors.white, + child: Column( + children: [ + if (widget.product.images.isNotEmpty) + Container( + height: MediaQuery.of(context).size.height * .40, + child: Image.network( + widget.product.images[0].src.trim(), + fit: BoxFit.contain, + ), + ), + if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) + ], ), - if (widget.product.discountDescription != null) DiscountDescription(product: widget.product) - ], - ), - ), - SizedBox( - height: 4, - ), - Container( - color: Colors.white, - child: ProductNameAndPrice( - context, - widget.product, - customerId: customerId, - addToWishlistFunction: (item) { - addToWishlistFunction(itemID: item, model: model); - setState(() {}); - }, - deleteFromWishlistFunction: (item) { - deleteFromWishlistFunction(itemID: item, model: model); - setState(() {}); - }, - notifyMeWhenAvailable: (context, itemId) { - notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model); - }, - isInWishList: isInWishList, - isStockAvailable: model.isStockAvailable, - ), - ), - SizedBox( - height: 6, - ), - Container( - color: Colors.white, - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + ), + SizedBox( + height: 4, + ), Container( - padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), - child: Texts( - TranslationBase.of(context).specification, - fontSize: 15, - fontWeight: FontWeight.bold, + color: Colors.white, + child: ProductNameAndPrice( + context, + widget.product, + customerId: customerId, + addToWishlistFunction: (item) { + addToWishlistFunction(itemID: item, model: model); + setState(() {}); + }, + deleteFromWishlistFunction: (item) { + deleteFromWishlistFunction(itemID: item, model: model); + setState(() {}); + }, + notifyMeWhenAvailable: (context, itemId) { + notifyMeWhenAvailable(itemId: itemId, customerId: customerId, model: model); + }, + isInWishList: isInWishList, + isStockAvailable: model.isStockAvailable, ), - width: double.infinity, ), - // Divider(color: Colors.grey), - ], - ), - ), - SizedBox( - height: 6, - ), - Container( - // width: 500, - margin: EdgeInsets.only(bottom: 6), - color: Colors.white, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Column( - children: [ - FlatButton( - onPressed: () { - setState(() { - isDetails = true; - isReviews = false; - isAvailability = false; - }); - }, - child: Text( - TranslationBase.of(context).details, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - ), - color: Colors.white, + SizedBox( + height: 6, + ), + Container( + color: Colors.white, + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.symmetric(vertical: 15, horizontal: 10), + child: Texts( + TranslationBase.of(context).specification, + fontSize: 15, + fontWeight: FontWeight.bold, ), - CustomDivider( - color: isDetails ? Colors.green : Colors.transparent, - ) - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () async { - if (widget.product.approvedTotalReviews > 0) { - GifLoaderDialogUtils.showMyDialog(context); - await model.getProductReviewsData(widget.product.id); - GifLoaderDialogUtils.hideDialog(context); - } else { - model.clearReview(); - } - setState(() { - isDetails = false; - isReviews = true; - isAvailability = false; - }); - }, - child: Text( - TranslationBase.of(context).reviews, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + width: double.infinity, + ), + // Divider(color: Colors.grey), + ], + ), + ), + SizedBox( + height: 6, + ), + Container( + // width: 500, + margin: EdgeInsets.only(bottom: 6), + color: Colors.white, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Column( + children: [ + FlatButton( + onPressed: () { + setState(() { + isDetails = true; + isReviews = false; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).details, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isDetails ? Colors.green : Colors.transparent, + ) + ], ), - color: Colors.white, - ), - CustomDivider( - color: isReviews ? Colors.green : Colors.transparent, - ), - ], - ), - SizedBox( - width: 20, - ), - Column( - children: [ - FlatButton( - onPressed: () async { - GifLoaderDialogUtils.showMyDialog(context); - await model.getProductLocationData(); - GifLoaderDialogUtils.hideDialog(context); + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () async { + if (widget.product.approvedTotalReviews > 0) { + GifLoaderDialogUtils.showMyDialog(context); + await model.getProductReviewsData(widget.product.id); + GifLoaderDialogUtils.hideDialog(context); + } else { + model.clearReview(); + } + setState(() { + isDetails = false; + isReviews = true; + isAvailability = false; + }); + }, + child: Text( + TranslationBase.of(context).reviews, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isReviews ? Colors.green : Colors.transparent, + ), + ], + ), + SizedBox( + width: 20, + ), + Column( + children: [ + FlatButton( + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + await model.getProductLocationData(); + GifLoaderDialogUtils.hideDialog(context); - setState(() { - isDetails = false; - isReviews = false; - isAvailability = true; - }); - }, - child: Text( - TranslationBase.of(context).availability, - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + setState(() { + isDetails = false; + isReviews = false; + isAvailability = true; + }); + }, + child: Text( + TranslationBase.of(context).availability, + style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + ), + color: Colors.white, + ), + CustomDivider( + color: isAvailability ? Colors.green : Colors.transparent, + ), + ], ), - color: Colors.white, - ), - CustomDivider( - color: isAvailability ? Colors.green : Colors.transparent, - ), - ], - ), - ], + ], + ), + SizedBox( + height: 10, + ), + isDetails + ? DetailsInfo( + product: widget.product, + ) + : isReviews + ? ReviewsInfo( + product: widget.product, + previousModel: model, + ) + : isAvailability + ? AvailabilityInfo( + previousModel: model, + ) + : Container(), + ], + ), ), SizedBox( height: 10, ), - isDetails - ? DetailsInfo( - product: widget.product, - ) - : isReviews - ? ReviewsInfo( - product: widget.product, - previousModel: model, - ) - : isAvailability - ? AvailabilityInfo( - previousModel: model, - ) - : Container(), + RecommendedProducts( + product: widget.product, + productDetailViewModel: model, + addToWishlistFunction: (itemID) async { + await addToWishlistFunction(itemID: itemID, model: model); + }, + deleteFromWishlistFunction: (itemID) async { + await deleteFromWishlistFunction(itemID: itemID, model: model); + }, + ) ], ), - ), - SizedBox( - height: 10, - ), - RecommendedProducts( - product: widget.product, - productDetailViewModel: model, - addToWishlistFunction: (itemID) async { - await addToWishlistFunction(itemID: itemID, model: model); - }, - deleteFromWishlistFunction: (itemID) async { - await deleteFromWishlistFunction(itemID: itemID, model: model); - }, ) - ], - ), - ), - bottomSheet: FooterWidget( - model.isStockAvailable, - widget.product.orderMaximumQuantity, - widget.product.orderMinimumQuantity, - model.stockQuantity, - widget.product, - quantity: quantity, - isOverQuantity: isOverQuantity, - addToCartFunction: addToCartFunction, - addToShoppingCartFunction: addToShoppingCartFunction, - model: model, - ), + : AppCircularProgressIndicator(), + bottomSheet: model.state == ViewState.Idle + ? FooterWidget( + model.isStockAvailable, + widget.product.orderMaximumQuantity, + widget.product.orderMinimumQuantity, + model.stockQuantity, + widget.product, + quantity: quantity, + isOverQuantity: isOverQuantity, + addToCartFunction: addToCartFunction, + addToShoppingCartFunction: addToShoppingCartFunction, + model: model, + ) + : SizedBox(), )); } diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index 9401f3e0..e214d70e 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -24,7 +24,7 @@ class ProductNameAndPrice extends StatefulWidget { AuthenticatedUserObject authenticatedUserObject = locator(); ProductNameAndPrice(this.context, this.item, - {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, @required this.isStockAvailable}); + {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable = false}); @override _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 23379914..795530ff 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -2,15 +2,11 @@ import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/models/pharmacy/Wishlist.dart'; -import 'package:diplomaticquarterapp/models/pharmacy/addToCartModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; -import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; -import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; -import 'package:diplomaticquarterapp/uitl/utils.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCart.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; class ProductDetailService extends BaseService { bool isLogin = false; @@ -57,7 +53,9 @@ class ProductDetailService extends BaseService { }); _stockQuantity = response['products'][0]['stock_quantity']; _stockAvailability = response['products'][0]['stock_availability']; - _isStockAvailable = response['products'][0]['IsStockAvailable']; + + // _isStockAvailable = response['products'][0]['IsStockAvailable']; + _isStockAvailable = _stockAvailability == "In stock" ? true : false; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; From 70304427f95c18e633969633f622c6aae5335c62 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Tue, 9 Nov 2021 18:31:53 +0300 Subject: [PATCH 08/20] Doc specialty fix --- lib/config/config.dart | 9 +++++++-- lib/pages/BookAppointment/widgets/DoctorView.dart | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 200e5776..280b6255 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -15,8 +15,8 @@ const PACKAGES_CUSTOMER = '/api/customers'; const PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; const PACKAGES_ORDERS = '/api/orders'; const PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; -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/'; @@ -26,6 +26,11 @@ const BASE_URL = 'https://uat.hmgwebservices.com/'; const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapi/api/'; const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapi/api/'; +// // Pharmacy Pre-Production URLs +// const BASE_PHARMACY_URL = 'https://mdlaboratories.com/exacartapitest/api/'; +// const PHARMACY_BASE_URL = 'https://mdlaboratories.com/exacartapitest/api/'; + + // RC API URL const RC_BASE_URL = 'https://livecare.hmg.com/'; diff --git a/lib/pages/BookAppointment/widgets/DoctorView.dart b/lib/pages/BookAppointment/widgets/DoctorView.dart index 794ece31..1e2e48df 100644 --- a/lib/pages/BookAppointment/widgets/DoctorView.dart +++ b/lib/pages/BookAppointment/widgets/DoctorView.dart @@ -78,7 +78,8 @@ class DoctorView extends StatelessWidget { if (doctor.projectName != null) MyRichText(TranslationBase.of(context).branch, doctor.projectName, projectViewModel.isArabic), if (doctor.speciality != null) Text( - getDoctorSpeciality(this.doctor.speciality).trim(), + this.doctor.speciality[0].trim(), + // getDoctorSpeciality(this.doctor.speciality).trim(), style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 18 / 12), ), if (doctor.nearestFreeSlot != null) From 62d904aa68f380b38c12b94cf5f69e7388708e83 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Tue, 9 Nov 2021 19:22:24 +0300 Subject: [PATCH 09/20] fixed issues --- lib/pages/final_products_page.dart | 11 ++- lib/pages/offers_categorise_page.dart | 22 ++--- lib/pages/parent_categorise_page.dart | 90 +++++-------------- .../pharmacies/widgets/ProductTileItem.dart | 35 ++++++-- .../widgets/home/PrescriptionsWidget.dart | 2 +- lib/pages/pharmacy_categorise.dart | 3 +- lib/pages/sub_categorise_page.dart | 16 +++- 7 files changed, 77 insertions(+), 102 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index ea5ee011..63e684fe 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; @@ -15,6 +16,7 @@ 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 'base/base_view.dart'; @@ -58,6 +60,7 @@ class _FinalProductsPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) { if (widget.productType == 1) { @@ -259,8 +262,8 @@ class _FinalProductsPageState extends State { ), ), ), - Texts( - model.finalProducts[index].name, + Texts(projectViewModel.isArabic ? model.finalProducts[index].namen : model.finalProducts[index].name, +// model.finalProducts[index].name, regular: true, fontSize: 12, fontWeight: FontWeight.w400, @@ -414,8 +417,8 @@ class _FinalProductsPageState extends State { ), Container( width: MediaQuery.of(context).size.width * 0.64, - child: Texts( - model.finalProducts[index].name, + child: Texts(projectViewModel.isArabic ? model.finalProducts[index].namen : model.finalProducts[index].name, +// model.finalProducts[index].name, regular: true, fontSize: 13.2, fontWeight: FontWeight.w500, diff --git a/lib/pages/offers_categorise_page.dart b/lib/pages/offers_categorise_page.dart index 263aef5c..a9e9622a 100644 --- a/lib/pages/offers_categorise_page.dart +++ b/lib/pages/offers_categorise_page.dart @@ -28,6 +28,7 @@ class _OffersCategorisePageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getOffersCategorise(), @@ -99,9 +100,8 @@ class _OffersCategorisePageState extends State { .height * 0.09, child: Center( - child: Texts( - model.categorise[index] - .name, + child: Texts(projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, +// model.categorise[index].name, fontWeight: FontWeight.w600, fontSize: 13.8, @@ -117,8 +117,8 @@ class _OffersCategorisePageState extends State { String ids = model.categorise[index].id; - categoriseName = model - .categorise[index].name; + categoriseName = projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name; + //model.categorise[index].name; }), ], ), @@ -403,11 +403,8 @@ class _OffersCategorisePageState extends State { ), ), ), - Texts( - model - .products[ - index] - .name, + Texts( projectViewModel.isArabic ? model.products[index].namen : model.products[index].name, + // model.products[index].name, regular: true, fontSize: 12.58, fontWeight: @@ -649,9 +646,8 @@ class _OffersCategorisePageState extends State { SizedBox( height: 4.0, ), - Texts( - model.products[index] - .name, + Texts( projectViewModel.isArabic ? model.products[index].namen : model.products[index].name, + // model.products[index].name, regular: true, fontSize: 14.0, fontWeight: diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index d8c2279c..ecf33158 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -116,12 +116,12 @@ class _ParentCategorisePageState extends State { Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: EdgeInsets.all(10.0), - child: InkWell( + InkWell( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: EdgeInsets.all(10.0), child: Container( child: Texts( TranslationBase.of(context).viewCategorise, @@ -129,70 +129,19 @@ class _ParentCategorisePageState extends State { fontWeight: FontWeight.w300, ), ), - onTap: () { - Navigator.push( - context, - FadePage( - page: SubCategoriseModalsheet( -// id: model.categorise[0].id, -// titleName: model.categorise[0].name, - )), - ); -// showModalBottomSheet( -// isScrollControlled: true, -// context: context, -// builder: (BuildContext context) { -// return Container( -// // height: MediaQuery.of(context) -// // .size -// // .height * -// // 0.89, -// color: Colors.white, -// child: Center( -// child: ListView.builder( -// scrollDirection: Axis.vertical, -// itemCount: model.categoriseParent.length, -// itemBuilder: (BuildContext context, int index) { -// return Container( -// child: Padding( -// padding: EdgeInsets.all(4.0), -// child: InkWell( -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// Texts(projectViewModel.isArabic -// ? model.categoriseParent[index].namen -// : model.categoriseParent[index].name), -// Divider( -// thickness: 0.6, -// color: Colors.black12, -// ) -// ], -// ), -// onTap: () { -// Navigator.push( -// context, -// FadePage( -// page: SubCategorisePage( -// title: model.categoriseParent[index].name, -// id: model.categoriseParent[index].id, -// parentId: id, -// )), -// ); -// }, -// ), -// ), -// ); -// }), -// ), -// ); -// }, -// ); - }, ), - ), Icon(Icons.arrow_forward) - ], + ], + ), + onTap: () { + Navigator.push( + context, + FadePage( + page: SubCategoriseModalsheet( + // id: model.categorise[0].id, + // titleName: model.categorise[0].name, + )), + );} ), Divider( thickness: 1.0, @@ -256,7 +205,8 @@ class _ParentCategorisePageState extends State { context, FadePage( page: SubCategorisePage( - title: model.categoriseParent[index].name, + title: projectViewModel.isArabic ? model.categoriseParent[index].namen : model.categoriseParent[index].name, +// title: model.categoriseParent[index].name, id: model.categoriseParent[index].id, parentId: id, )), @@ -289,7 +239,7 @@ class _ParentCategorisePageState extends State { width: 10.0, ), Texts( - 'Refine', + TranslationBase.of(context).refine, fontWeight: FontWeight.w600, ), ], diff --git a/lib/pages/pharmacies/widgets/ProductTileItem.dart b/lib/pages/pharmacies/widgets/ProductTileItem.dart index 278fc6aa..cb8560c4 100644 --- a/lib/pages/pharmacies/widgets/ProductTileItem.dart +++ b/lib/pages/pharmacies/widgets/ProductTileItem.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/widgets/others/StarRating.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'; class ProductTileItem extends StatelessWidget { final AppSharedPreferences sharedPref = AppSharedPreferences(); @@ -178,15 +179,31 @@ class ProductTileItem extends StatelessWidget { ), Row( children: [ - Expanded( - child: StarRating( - totalAverage: item.approvedTotalReviews > 0 - ? (item.approvedRatingSum.toDouble() / - item.approvedTotalReviews.toDouble()) - .toDouble() - : 0, - forceStars: true), - ), + // Expanded( + RatingBar.readOnly( + initialRating: item.approvedRatingSum.toDouble(), + size: 15.0, + filledColor: Colors.yellow[700], + emptyColor: Colors.grey[500], + isHalfAllowed: true, + halfFilledIcon: Icons.star_half, + filledIcon: Icons.star, + emptyIcon: Icons.star, + ), + Texts( + "(${item.approvedTotalReviews})", + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) +// StarRating( +// totalAverage: item.approvedTotalReviews > 0 +// ? (item.approvedRatingSum.toDouble() / +// item.approvedTotalReviews.toDouble()) +// .toDouble() +// : 0, +// forceStars: true), + // ), ], ), ], diff --git a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart index 61177d1f..1e993694 100644 --- a/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart +++ b/lib/pages/pharmacies/widgets/home/PrescriptionsWidget.dart @@ -36,7 +36,7 @@ class PrescriptionsWidget extends StatelessWidget { ViewAllHomeWidget(TranslationBase.of(context).myPrescription, HomePrescriptionsPage()), Container( margin: EdgeInsets.only(right: 10.0, left: 10.0), - height: MediaQuery.of(context).size.height * 0.19, + height: MediaQuery.of(context).size.height * 0.30, child: ListView.builder( scrollDirection: Axis.horizontal, shrinkWrap: true, diff --git a/lib/pages/pharmacy_categorise.dart b/lib/pages/pharmacy_categorise.dart index 8a965b6e..9ed1070f 100644 --- a/lib/pages/pharmacy_categorise.dart +++ b/lib/pages/pharmacy_categorise.dart @@ -80,7 +80,8 @@ class _PharmacyCategorisePageState extends State { page: model.categorise[index].id != '12' ? ParentCategorisePage( id: model.categorise[index].id, - titleName: model.categorise[index].name, + titleName: projectViewModel.isArabic ? model.categorise[index].namen : model.categorise[index].name, + // titleName: model.categorise[index].name, ) : FinalProductsPage( id: model.categorise[index].id, diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 9d2a1f6b..22b9151d 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacy/categorise_parent_model import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; @@ -17,6 +18,7 @@ import 'package:diplomaticquarterapp/widgets/others/entity_checkbox_list.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 'base/base_view.dart'; @@ -59,6 +61,7 @@ class _SubCategorisePageState extends State { Widget build(BuildContext context) { TextEditingController minField = TextEditingController(); TextEditingController maxField = TextEditingController(); + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) => model.getSubCategorise(i: id), builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( @@ -136,7 +139,9 @@ class _SubCategorisePageState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts(model.subCategorise[index].name), + Texts(projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, +// model.subCategorise[index].name + ), Divider( thickness: 0.6, color: Colors.black12, @@ -208,7 +213,8 @@ class _SubCategorisePageState extends State { height: MediaQuery.of(context).size.height * 0.10, child: Center( child: Texts( - model.subCategorise[index].name, + //projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, + model.subCategorise[index].name, fontSize: 14, fontWeight: FontWeight.w600, maxLines: 2, @@ -627,7 +633,8 @@ class _SubCategorisePageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - model.subProducts[index].name, + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, +// model.subProducts[index].name, regular: true, fontSize: 12, fontWeight: FontWeight.w400, @@ -757,7 +764,8 @@ class _SubCategorisePageState extends State { Container( width: MediaQuery.of(context).size.width * 0.65, child: Texts( - model.subProducts[index].name, + projectViewModel.isArabic ? model.subProducts[index].namen : model.subProducts[index].name, + // model.subProducts[index].name, regular: true, fontSize: 13.2, fontWeight: FontWeight.w500, From b7dc6ee4b12a761f1617364a9c6243fe6e7226d3 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 08:27:07 +0200 Subject: [PATCH 10/20] change model --- .../screens/cart-page/cart-order-page.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index 3b7d080f..eb9bf6d7 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -281,10 +281,9 @@ class _OrderBottomWidgetState extends State { @override Widget build(BuildContext context) { ProjectViewModel projectProvider = Provider.of(context); - OrderPreviewViewModel model = Provider.of(context); - return !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) + return !(widget.model.cartResponse.shoppingCarts == null || + widget.model.cartResponse.shoppingCarts.length == 0) ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -374,7 +373,7 @@ class _OrderBottomWidgetState extends State { child: Row( children: [ Texts( - "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(widget.model.cartResponse.subtotalWithVat).toStringAsFixed(2)}", fontSize: projectProvider.isArabic ? 12 : 14, fontWeight: FontWeight.bold, ), @@ -392,7 +391,7 @@ class _OrderBottomWidgetState extends State { ), ), Texts( - "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", + "${widget.model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", fontSize: 10, color: Colors.grey, fontWeight: FontWeight.bold, @@ -404,7 +403,7 @@ class _OrderBottomWidgetState extends State { onPressed: isAgree // && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { - if (model + if (widget.model .isCartItemsOutOfStock()) { // Toast msg @@ -414,7 +413,7 @@ class _OrderBottomWidgetState extends State { } else { - _navigateToAddressPage(model + _navigateToAddressPage(widget.model .user.patientIdentificationNo) // Navigator.push( // context, From 2c3c270c43ca6ace1f1177f3bb9a808692e9ba4f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 08:39:45 +0200 Subject: [PATCH 11/20] finish steps inside payment --- .../pharmacyAddresses/PharmacyAddresses.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart index 338fe87e..85bc7cb8 100644 --- a/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart +++ b/lib/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart @@ -48,7 +48,7 @@ class _PharmacyAddressesState extends State { return BaseView( onModelReady: (model) => model.getAddressesList(), builder: (_, model, wi) => AppScaffold( - appBarTitle: TranslationBase.of(context).changeAddress, + appBarTitle: widget.isUpdate?TranslationBase.of(context).changeAddress:"Add Address", isShowAppBar: true, isPharmacy: true, baseViewModel: model, @@ -66,11 +66,6 @@ class _PharmacyAddressesState extends State { () { setState(() { model.setSelectedAddressIndex(index); - //TODO Elham* - widget.orderPreviewViewModel.paymentCheckoutData - .address = - Addresses.fromJson( - model.addresses[index].toJson()); }); }, model.selectedAddressIndex == index, @@ -127,6 +122,11 @@ class _PharmacyAddressesState extends State { fontSize: 14, vPadding: 8, handler: () { + //TODO Elham* + widget.orderPreviewViewModel.paymentCheckoutData + .address = + Addresses.fromJson( + model.addresses[model.selectedAddressIndex].toJson()); model.saveSelectedAddressLocally( model.addresses[model.selectedAddressIndex]); _navigateToPaymentOption(model); From c4e185ea60003f35265b64ead1e1fcb9f6fe8457 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 10 Nov 2021 09:40:12 +0300 Subject: [PATCH 12/20] fixed issues --- lib/config/localized_values.dart | 10 ++++++++ .../product_detail_view_model.dart | 16 ++++++------ lib/pages/final_products_page.dart | 2 +- lib/pages/parent_categorise_page.dart | 12 ++++----- .../pharmacies/ProductCheckTypeWidget.dart | 2 +- lib/pages/pharmacies/compare-list.dart | 19 ++++++++++---- .../product-details/product-detail.dart | 12 ++++----- .../product-name-and-price.dart | 10 ++++---- .../shared/product_details_app_bar.dart | 6 +++-- .../screens/recommended-product-page.dart | 4 +-- lib/pages/sub_categorise_page.dart | 10 ++++---- .../product_detail_service.dart | 25 +++++++++++++------ lib/uitl/translations_delegate_base.dart | 20 +++++++++++++++ lib/widgets/pharmacy/product_tile.dart | 2 +- 14 files changed, 100 insertions(+), 50 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 4a8ee340..7be2decb 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -630,6 +630,16 @@ const Map localizedValues = { "years-old": {"en": "years old", "ar": "سنة"}, "drag-point": {"en": "Drag point to change your age", "ar": "اسحب لتغيير عمرك"}, "refine": {"en": "Refine", "ar": "تصفية"}, + "max": {"en": "Max", "ar": "اعلى"}, + "addToCompareMsg": {"en": "You have added a product to the Compare list", "ar": "تمت الاضافه لقائمة المقارنه"}, + "itInListMsg": {"en": "Item is already in the list", "ar": "المنتج موجود في القائمه"}, + "compareListFull": {"en": "Your compare list is full", "ar": "قائمة المقارنة ممتلئه"}, + "addQuantity": {"en": "You should add quantity", "ar": "اختر الكمية"}, + "addToCartMsg": {"en": "You have added a product to the cart", "ar": "تمت اضافة المنتج بنجاح"}, + "addToWishlistMsg": {"en": "You have added a product to the Wishlist", "ar": "تمت الاضافة لقائمة الرغبات"}, + "notifyMeMsg": {"en": "You will be notified when product available", "ar": "سيتم اخبارك في حال توفر المنتج"}, + "removeFromWishlistMsg": {"en": "You have removed a product from the Wishlist", "ar": "تمت ازالة المنتج بنجاح"}, + "min": {"en": "Min", "ar": "اقل"}, "reset": {"en": "Reset", "ar": "اعادة تعيين"}, "apply": {"en": "Apply", "ar": "تطبيق"}, "viewCategorise": {"en": "View All Categories", "ar": "عرض جميع الفئات"}, diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 2ae935dd..6eb1f4b9 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -55,10 +55,10 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future notifyMe(customerId, itemID) async { + Future notifyMe(customerId, itemID, context) async { hasError = false; setState(ViewState.BusyLocal); - await _productDetailService.notifyMe(customerId, itemID); + await _productDetailService.notifyMe(customerId, itemID, context); if (_productDetailService.hasError) { error = _productDetailService.error; setState(ViewState.ErrorLocal); @@ -66,10 +66,10 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future addToCartData(quantity, itemID) async { + Future addToCartData(quantity, itemID, context) async { hasError = false; setState(ViewState.BusyLocal); - var resp = await _productDetailService.addToCart(quantity, itemID); + var resp = await _productDetailService.addToCart(quantity, itemID, context); ShoppingCartResponse object = _handleGetShoppingCartResponse(resp); if (_productDetailService.hasError) { error = _productDetailService.error; @@ -103,11 +103,11 @@ class ProductDetailViewModel extends BaseViewModel { return cartResponse; } - Future addToWishlistData(itemID) async { + Future addToWishlistData(itemID, context) async { hasError = false; setState(ViewState.BusyLocal); GifLoaderDialogUtils.showMyDialog(locator().navigatorKey.currentContext); - await _productDetailService.addToWishlist(itemID); + await _productDetailService.addToWishlist(itemID, context); GifLoaderDialogUtils.hideDialog(locator().navigatorKey.currentContext); if (_productDetailService.hasError) { @@ -128,11 +128,11 @@ class ProductDetailViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future deleteWishlistData(itemID) async { + Future deleteWishlistData(itemID, context) async { hasError = false; setState(ViewState.BusyLocal); GifLoaderDialogUtils.showMyDialog(locator().navigatorKey.currentContext); - await _productDetailService.deleteItemFromWishlist(itemID); + await _productDetailService.deleteItemFromWishlist(itemID, context); GifLoaderDialogUtils.hideDialog(locator().navigatorKey.currentContext); if (_productDetailService.hasError) { diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 63e684fe..519c8c4d 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -530,6 +530,6 @@ class _FinalProductsPageState extends State { addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index ecf33158..1c52b7a5 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -368,7 +368,7 @@ class _ParentCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Min'), + Texts(TranslationBase.of(context).min), Container( color: Colors.white, width: 200, @@ -385,7 +385,7 @@ class _ParentCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Max'), + Texts(TranslationBase.of(context).max), Container( color: Colors.white, width: 200, @@ -588,7 +588,7 @@ class _ParentCategorisePageState extends State { bottom: 5.0, ), child: Texts( - 'offer'.toUpperCase(), + TranslationBase.of(context).offers.toUpperCase(), color: Colors.red, fontSize: 13.0, fontWeight: FontWeight.w900, @@ -876,8 +876,8 @@ class _ParentCategorisePageState extends State { ), Padding( padding: const EdgeInsets.all(8.0), - child: Text( - 'There is no data', + child: Text(TranslationBase.of(context).noData, + // 'There is no data', style: TextStyle(fontSize: 30), ), ) @@ -895,7 +895,7 @@ class _ParentCategorisePageState extends State { addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } bool isEntityListSelected(CategoriseParentModel masterKey) { diff --git a/lib/pages/pharmacies/ProductCheckTypeWidget.dart b/lib/pages/pharmacies/ProductCheckTypeWidget.dart index 2b88d30a..46c5e7a3 100644 --- a/lib/pages/pharmacies/ProductCheckTypeWidget.dart +++ b/lib/pages/pharmacies/ProductCheckTypeWidget.dart @@ -48,7 +48,7 @@ class _ProductCheckTypeWidgetState extends State { deleteWishListItem(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); GifLoaderDialogUtils.showMyDialog(context); - await x.deleteWishlistData(itemID); + await x.deleteWishlistData(itemID, context); await widget.model.getWishlistData(isLocalLoader: true); GifLoaderDialogUtils.hideDialog(context); } diff --git a/lib/pages/pharmacies/compare-list.dart b/lib/pages/pharmacies/compare-list.dart index c4da5ba2..afa5382f 100644 --- a/lib/pages/pharmacies/compare-list.dart +++ b/lib/pages/pharmacies/compare-list.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/material.dart'; class CompareList with ChangeNotifier { @@ -7,20 +8,28 @@ class CompareList with ChangeNotifier { List get productListItems => _product; - void addItem(data) { + void addItem(data, context) { if (_product.length == 0) { _product.add(data); - AppToast.showSuccessToast(message: 'You have added a product to the Compare list'); + AppToast.showSuccessToast(message:TranslationBase.of(context).addToCompareMsg + // 'You have added a product to the Compare list' + ); } else { for (int i = 0; i < _product.length; i++) { if (_product.length <= 4 && _product[i].id != data.id) { _product.add(data); - AppToast.showSuccessToast(message: 'You have added a product to the Compare list'); + AppToast.showSuccessToast(message:TranslationBase.of(context).addToCompareMsg + // 'You have added a product to the Compare list' + ); break; } else if(_product[i].id == data.id){ - AppToast.showErrorToast(message: 'the item is already in the list'); + AppToast.showErrorToast(message:TranslationBase.of(context).itInListMsg + // 'the item is already in the list' + ); } else if(_product.length == 4){ - AppToast.showErrorToast(message: 'your compare list is full'); + AppToast.showErrorToast(message: TranslationBase.of(context).compareListFull + // 'your compare list is full' + ); } } } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 2676280f..3c44463e 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -328,19 +328,19 @@ class __ProductDetailPageState extends State { addToShoppingCartFunction({quantity, itemID, ProductDetailViewModel model}) async { GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); + await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = true; - await model.addToWishlistData(itemID); + await model.addToWishlistData(itemID, context); setState(() {}); } deleteFromWishlistFunction({itemID, ProductDetailViewModel model}) async { isInWishList = false; - await model.deleteWishlistData(itemID); + await model.deleteWishlistData(itemID, context); setState(() {}); } @@ -350,11 +350,11 @@ class __ProductDetailPageState extends State { ProductDetailViewModel model, }) async { GifLoaderDialogUtils.showMyDialog(context); - await model.addToCartData(quantity, itemID); + await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); } } -notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model}) async { - await model.notifyMe(customerId, itemId); +notifyMeWhenAvailable({itemId, customerId, ProductDetailViewModel model, context}) async { + await model.notifyMe(customerId, itemId, context); } diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index e214d70e..a70d9fc2 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -128,11 +128,11 @@ class _ProductNameAndPriceState extends State { SizedBox( width: 10, ), - Texts( - "${widget.item.approvedRatingSum}", - fontWeight: FontWeight.bold, - fontSize: 12, - ), +// Texts( +// "${widget.item.approvedRatingSum}", +// fontWeight: FontWeight.bold, +// fontSize: 12, +// ), SizedBox( width: 30, ), 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 1626e24f..944e065c 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 @@ -157,7 +157,9 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { Navigator.of(context).pop(); } } else { - AppToast.showErrorToast(message: "you should add quantity"); + AppToast.showErrorToast(message: TranslationBase.of(context).addQuantity + // "you should add quantity" + ); } }), ListTile( @@ -184,7 +186,7 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { ), onTap: () { Provider.of(context, listen: false) - .addItem(specificationData); + .addItem(specificationData,context); Navigator.of(context).pop(); }, ), diff --git a/lib/pages/pharmacies/screens/recommended-product-page.dart b/lib/pages/pharmacies/screens/recommended-product-page.dart index 4ea089fa..b04201e5 100644 --- a/lib/pages/pharmacies/screens/recommended-product-page.dart +++ b/lib/pages/pharmacies/screens/recommended-product-page.dart @@ -534,13 +534,13 @@ class _RecommendedProductPageState extends State addToWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlist = true; - await x.addToWishlistData(itemID); + await x.addToWishlistData(itemID, context); } deleteFromWishlistFunction(itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); isInWishlist = false; - await x.addToWishlistData(itemID); + await x.addToWishlistData(itemID, context); } } diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 22b9151d..01b061b6 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -213,8 +213,8 @@ class _SubCategorisePageState extends State { height: MediaQuery.of(context).size.height * 0.10, child: Center( child: Texts( - //projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, - model.subCategorise[index].name, + projectViewModel.isArabic ? model.subCategorise[index].namen : model.subCategorise[index].name, + // model.subCategorise[index].name, fontSize: 14, fontWeight: FontWeight.w600, maxLines: 2, @@ -386,7 +386,7 @@ class _SubCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Min'), + Texts(TranslationBase.of(context).min), Container( color: Colors.white, width: 200, @@ -403,7 +403,7 @@ class _SubCategorisePageState extends State { Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - Texts('Max'), + Texts(TranslationBase.of(context).max), Container( color: Colors.white, width: 200, @@ -897,6 +897,6 @@ class _SubCategorisePageState extends State { addToCartFunction(quantity, itemID) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } } diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 795530ff..7a50a37c 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -6,6 +6,7 @@ import 'package:diplomaticquarterapp/models/pharmacy/locationModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/productDetailModel.dart'; import 'package:diplomaticquarterapp/models/pharmacy/specification.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; class ProductDetailService extends BaseService { @@ -91,7 +92,7 @@ class ProductDetailService extends BaseService { }, body: request); } - Future addToCart(quantity, itemID) async { + Future addToCart(quantity, itemID, context) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; Map request; @@ -106,7 +107,9 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _addToCartModel.add(Wishlist.fromJson(item)); }); - AppToast.showSuccessToast(message: 'You have added a product to the cart'); + AppToast.showSuccessToast(message: TranslationBase.of(context).addToCartMsg + // 'You have added a product to the cart' + ); localRes = response; }, onFailure: (String error, int statusCode) { hasError = true; @@ -117,10 +120,12 @@ class ProductDetailService extends BaseService { return Future.value(localRes); } - Future notifyMe(customerId, itemID) async { + Future notifyMe(customerId, itemID, context) async { hasError = false; await baseAppClient.getPharmacy(SUBSCRIBE_PRODUCT + "SinceId=$customerId&ProductId=$itemID", onSuccess: (dynamic response, int statusCode) { - AppToast.showSuccessToast(message: 'You will be notified when product available'); + AppToast.showSuccessToast(message: TranslationBase.of(context).notifyMeMsg + //'You will be notified when product available' + ); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -128,7 +133,7 @@ class ProductDetailService extends BaseService { }); } - Future addToWishlist(itemID) async { + Future addToWishlist(itemID, context) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; Map request; @@ -141,7 +146,9 @@ class ProductDetailService extends BaseService { response['shopping_carts'].forEach((item) { _wishListProducts.add(Wishlist.fromJson(item)); }); - AppToast.showSuccessToast(message: 'You have added a product to the Wishlist'); + AppToast.showSuccessToast(message: TranslationBase.of(context).addToWishlistMsg + // 'You have added a product to the Wishlist' + ); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -163,7 +170,7 @@ class ProductDetailService extends BaseService { }); } - Future deleteItemFromWishlist(itemID) async { + Future deleteItemFromWishlist(itemID, context) async { var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID); hasError = false; await baseAppClient.getPharmacy(DELETE_WISHLIST + customerId + "+&product_id=" + itemID + "&cart_type=Wishlist", onSuccess: (dynamic response, int statusCode) { @@ -171,7 +178,9 @@ 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'); + AppToast.showSuccessToast(message: TranslationBase.of(context).removeFromWishlistMsg + // 'You have removed a product from the Wishlist' + ); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index d1bc500d..63d1719f 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1206,6 +1206,26 @@ class TranslationBase { String get refine => localizedValues['refine'][locale.languageCode]; + String get max => localizedValues['max'][locale.languageCode]; + + String get min => localizedValues['min'][locale.languageCode]; + + String get addToCompareMsg => localizedValues['addToCompareMsg'][locale.languageCode]; + + String get itInListMsg => localizedValues['itInListMsg'][locale.languageCode]; + + String get compareListFull => localizedValues['compareListFull'][locale.languageCode]; + + String get addQuantity => localizedValues['addQuantity'][locale.languageCode]; + + String get addToCartMsg => localizedValues['addToCartMsg'][locale.languageCode]; + + String get addToWishlistMsg => localizedValues['addToWishlistMsg'][locale.languageCode]; + + String get notifyMeMsg => localizedValues['notifyMeMsg'][locale.languageCode]; + + String get removeFromWishlistMsg => localizedValues['removeFromWishlistMsg'][locale.languageCode]; + String get apply => localizedValues['apply'][locale.languageCode]; String get reset => localizedValues['reset'][locale.languageCode]; diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index c63410ba..70a727bf 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -295,6 +295,6 @@ class productTile extends StatelessWidget { addToCartFunction(quantity, itemID, BuildContext context) async { ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID, context); } } From 3ec2f990b1dc0a4f9349653a97e992032daa4c20 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 10 Nov 2021 09:48:05 +0300 Subject: [PATCH 13/20] product detail page updates --- .../viewModels/pharmacyModule/product_detail_view_model.dart | 2 ++ lib/pages/landing/landing_page.dart | 4 ++-- .../pharmacies/screens/product-details/product-detail.dart | 4 ++++ .../screens/product-details/product-name-and-price.dart | 5 +++-- lib/services/pharmacy_services/product_detail_service.dart | 5 ++++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart index 2ae935dd..980c62c2 100644 --- a/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart +++ b/lib/core/viewModels/pharmacyModule/product_detail_view_model.dart @@ -31,6 +31,8 @@ class ProductDetailViewModel extends BaseViewModel { String get stockAvailability => _productDetailService.stockAvailability; + String get stockAvailabilityn => _productDetailService.stockAvailabilityn; + bool get isStockAvailable => _productDetailService.isStockAvailable; Future getProductReviewsData(productID) async { diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index cb26c8b7..2bca7a9e 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -241,14 +241,14 @@ class _LandingPageState extends State with WidgetsBindingObserver { pageController = PageController(keepPage: true); _firebaseMessaging.setAutoInitEnabled(true); - signalRUtil = new SignalRUtil(hubName: "https://VCallApi.hmg.com/WebRTCHub?source=mobile&username=2001273", context: context); + // signalRUtil = new SignalRUtil(hubName: "https://VCallApi.hmg.com/WebRTCHub?source=mobile&username=2001273", context: context); locationUtils = new LocationUtils(isShowConfirmDialog: false, context: context); WidgetsBinding.instance.addPostFrameCallback((_) { if (projectViewModel.isLogin && !projectViewModel.isLoginChild) { familyFileProvider.getSharedRecordByStatus(); } - if (!signalRUtil.getConnectionState()) signalRUtil.startSignalRConnection(); + // if (!signalRUtil.getConnectionState()) signalRUtil.startSignalRConnection(); }); // HMG (Guest/Internet) Wifi Access [Zohaib Kambrani] //for now commented to reduce this call will enable it when needed diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index 2676280f..b1e6aff9 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.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/pharmacies/screens/product-details/product-name-and-price.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart'; @@ -14,6 +15,7 @@ import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'availability_info.dart'; import 'details_info.dart'; @@ -87,6 +89,7 @@ class __ProductDetailPageState extends State { } Widget build(BuildContext context) { + ProjectViewModel projectViewModel = Provider.of(context); return BaseView( allowAny: true, onModelReady: (model) async { @@ -153,6 +156,7 @@ class __ProductDetailPageState extends State { }, isInWishList: isInWishList, isStockAvailable: model.isStockAvailable, + stockAvailability: projectViewModel.isArabic ? model.stockAvailabilityn : model.stockAvailability, ), ), SizedBox( diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index e214d70e..708e5df8 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -20,11 +20,12 @@ class ProductNameAndPrice extends StatefulWidget { final Function addToWishlistFunction; final Function deleteFromWishlistFunction; final bool isStockAvailable; + final String stockAvailability; AuthenticatedUserObject authenticatedUserObject = locator(); ProductNameAndPrice(this.context, this.item, - {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable = false}); + {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable, this.stockAvailability}); @override _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); @@ -48,7 +49,7 @@ class _ProductNameAndPriceState extends State { children: [ Texts(widget.item.price.toString() + " " + TranslationBase.of(context).sar, fontWeight: FontWeight.bold, fontSize: 20), Texts( - projectViewModel.isArabic ? widget.item.stockAvailabilityn : widget.item.stockAvailability, + widget.stockAvailability, fontWeight: FontWeight.bold, fontSize: 15, color: widget.isStockAvailable ? Colors.green : Colors.red, diff --git a/lib/services/pharmacy_services/product_detail_service.dart b/lib/services/pharmacy_services/product_detail_service.dart index 795530ff..29b7e943 100644 --- a/lib/services/pharmacy_services/product_detail_service.dart +++ b/lib/services/pharmacy_services/product_detail_service.dart @@ -16,8 +16,10 @@ class ProductDetailService extends BaseService { num get stockQuantity => _stockQuantity; String _stockAvailability; + String _stockAvailabilityn; String get stockAvailability => _stockAvailability; + String get stockAvailabilityn => _stockAvailabilityn; bool _isStockAvailable; @@ -45,7 +47,7 @@ class ProductDetailService extends BaseService { Future getProductReviews(productID) async { hasError = false; - await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL + productID + "?fields=reviews,stock_quantity,stock_availability,IsStockAvailable", onSuccess: (dynamic response, int statusCode) { + await baseAppClient.getPharmacy(GET_PRODUCT_DETAIL + productID + "?fields=reviews,stock_quantity,stock_availability,stock_availabilityn,IsStockAvailable", onSuccess: (dynamic response, int statusCode) { _productDetailList.clear(); response['products'].forEach((item) { _productDetailList.add(ProductDetail.fromJson(item)); @@ -53,6 +55,7 @@ class ProductDetailService extends BaseService { }); _stockQuantity = response['products'][0]['stock_quantity']; _stockAvailability = response['products'][0]['stock_availability']; + _stockAvailabilityn = response['products'][0]['stock_availabilityn']; // _isStockAvailable = response['products'][0]['IsStockAvailable']; _isStockAvailable = _stockAvailability == "In stock" ? true : false; From 96ec3f29261ddfdedb6eaed6f9354d091c983127 Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 10 Nov 2021 09:56:14 +0300 Subject: [PATCH 14/20] fix issues --- lib/pages/parent_categorise_page.dart | 41 ++++++++++++++++++++------- lib/pages/sub_categorise_page.dart | 33 +++++++++++++++++---- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 1c52b7a5..34567267 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -69,6 +69,7 @@ class _ParentCategorisePageState extends State { TextEditingController minField = TextEditingController(); TextEditingController maxField = TextEditingController(); ProjectViewModel projectViewModel = Provider.of(context); + ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getCategoriseParent(i: id), allowAny: true, @@ -615,13 +616,23 @@ class _ParentCategorisePageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ), + child:model.parentProducts[index].rxMessage != null ? + Texts(projectProvider.isArabic + ? model.parentProducts[index].rxMessagen + : model.parentProducts[index].rxMessage, + color: Colors.white, + regular: true, + fontSize: 10, + fontWeight: FontWeight.w400, + ) + : Texts(""), +// Texts( +// model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), ), ], ), @@ -752,13 +763,23 @@ class _ParentCategorisePageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", + child: model.parentProducts[index].rxMessage != null ? + Texts(projectProvider.isArabic + ? model.parentProducts[index].rxMessagen + : model.parentProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w400, - ), + ) + : Texts(""), +// Texts( +// model.parentProducts[index].rxMessage != null ? model.parentProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), ), ], ), diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 01b061b6..178b511b 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -62,6 +62,7 @@ class _SubCategorisePageState extends State { TextEditingController minField = TextEditingController(); TextEditingController maxField = TextEditingController(); ProjectViewModel projectViewModel = Provider.of(context); + ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.getSubCategorise(i: id), builder: (BuildContext context, PharmacyCategoriseViewModel model, Widget child) => PharmacyAppScaffold( @@ -614,13 +615,23 @@ class _SubCategorisePageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", + child:model.subProducts[index].rxMessage != null ? + Texts(projectProvider.isArabic + ? model.subProducts[index].rxMessagen + : model.subProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w400, - ), + ) + : Texts(""), +// Texts( +// model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), ), ], ), @@ -736,13 +747,23 @@ class _SubCategorisePageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", + child: model.subProducts[index].rxMessage != null ? + Texts(projectProvider.isArabic + ? model.subProducts[index].rxMessagen + : model.subProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w400, - ), + ) + : Texts(""), +// Texts( +// model.subProducts[index].rxMessage != null ? model.subProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), ), ], ), From 8a168386daf03c2fa5dc97a457dda4a3181ff6da Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 09:15:25 +0200 Subject: [PATCH 15/20] fix black screen which is appear in cart page --- .../screens/cart-page/cart-order-page.dart | 412 +++++++++--------- 1 file changed, 210 insertions(+), 202 deletions(-) diff --git a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart index eb9bf6d7..03799638 100644 --- a/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-page/cart-order-page.dart @@ -46,212 +46,216 @@ class _CartOrderPageState extends State { OrderPreviewViewModel model = Provider.of(context); final height = mediaQuery.size.height - 60 - mediaQuery.padding.top; - AppScaffold appScaffold; - return NetworkBaseView( - isLoading: isLoading, - isLocalLoader: true, - child: appScaffold = AppScaffold( - appBarTitle: TranslationBase.of(context).shoppingCart, - isShowAppBar: true, - isPharmacy: true, - showHomeAppBarIcon: false, - isShowDecPage: false, - isMainPharmacyPages: true, - showPharmacyCart: false, - baseViewModel: model, - backgroundColor: Colors.white, - body: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) + return AppScaffold( + appBarTitle: TranslationBase.of(context).shoppingCart, + isShowAppBar: true, + isPharmacy: true, + showHomeAppBarIcon: false, + isShowDecPage: false, + isMainPharmacyPages: true, + showPharmacyCart: false, + baseViewModel: model, + backgroundColor: Colors.white, + body: NetworkBaseView( + isLoading: isLoading, + isLocalLoader: true, + child: !(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), + 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( - 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.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.png", - width: mediaQuery.size.width - 20, - height: 30.0, - fit: BoxFit.scaleDown, - ), - SizedBox( - height: 120, - ) + ...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}'); + } + }); + })) ], ), ), - ), - ) - : 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, + 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, ), - ), - Padding( - padding: const EdgeInsets.all(8.0), - child: Text( - TranslationBase.of(context).noData, -// 'There is no data', - style: TextStyle(fontSize: 30), + 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.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, ), ), - bottomSheet: Container( - height: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) - ? height * 0.15 - : 0, - color: Colors.white, - child: OrderBottomWidget(model.addresses, height, model), + 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, model), + ), ); } @@ -283,7 +287,7 @@ class _OrderBottomWidgetState extends State { ProjectViewModel projectProvider = Provider.of(context); return !(widget.model.cartResponse.shoppingCarts == null || - widget.model.cartResponse.shoppingCarts.length == 0) + widget.model.cartResponse.shoppingCarts.length == 0) ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -403,8 +407,7 @@ class _OrderBottomWidgetState extends State { onPressed: isAgree // && cart.cartResponse.shoppingCarts[1].product.stockQuantity ==0 ? () => { - if (widget.model - .isCartItemsOutOfStock()) + if (widget.model.isCartItemsOutOfStock()) { // Toast msg AppToast.showErrorToast( @@ -413,8 +416,8 @@ class _OrderBottomWidgetState extends State { } else { - _navigateToAddressPage(widget.model - .user.patientIdentificationNo) + _navigateToAddressPage(widget + .model.user.patientIdentificationNo) // Navigator.push( // context, // FadePage( @@ -442,12 +445,17 @@ class _OrderBottomWidgetState extends State { } _navigateToAddressPage(String identificationNo) { - Navigator.push(context, FadePage(page: PharmacyAddressesPage(orderPreviewViewModel: widget.model,))) - .then((result) async { + Navigator.push( + context, + FadePage( + page: PharmacyAddressesPage( + orderPreviewViewModel: widget.model, + ))).then((result) async { if (result != null) { GifLoaderDialogUtils.showMyDialog(context); var address = result; - widget.model.paymentCheckoutData.address = Addresses.fromJson(address.toJson()); + widget.model.paymentCheckoutData.address = + Addresses.fromJson(address.toJson()); await widget.model.getInformationsByAddress(identificationNo); await widget.model.getShoppingCart(); // widget.changeMainState(); From dc3d3bc7726cdfe5a0a4ea37ec6e174e12b4dfd7 Mon Sep 17 00:00:00 2001 From: devmirza121 Date: Wed, 10 Nov 2021 10:16:04 +0300 Subject: [PATCH 16/20] Health Calculator 5.0 --- lib/config/localized_values.dart | 7 +++- .../bmr_calculator/bmr_calculator.dart | 2 +- .../calorie_calculator.dart | 1 + .../health_calculator/carbs/carbs.dart | 2 +- .../carbs/carbs_result_page.dart | 32 +++++++++---------- .../ideal_body/ideal_body.dart | 2 +- lib/uitl/translations_delegate_base.dart | 5 +++ 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 4a8ee340..46f60222 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1636,7 +1636,7 @@ const Map localizedValues = { "waist": {"en": "Waist", "ar": "وسط"}, "hip": {"en": "Hip", "ar": "ورك او نتوء"}, "carbsProtin": {"en": "Carbs, Protein and Fat", "ar": "الكربوهيدرات والبروتينات والدهون"}, - "usefulInfo": {"en": "Useful Information", "ar": "Useful Information"}, + "usefulInfo": {"en": "Useful Information", "ar": "معلومات مفيدة"}, "babyAge": {"en": "Baby Age", "ar": "عمر الطفل الآن:"}, "babyAgeAvail": {"en": "baby age is not available", "ar": "عمر الطفل غير متوفر"}, "deliveryDue": {"en": "The delivery due date is estimated to be on the", "ar": "من المقدر أن يكون تاريخ استحقاق التسليم في"}, @@ -1705,4 +1705,9 @@ const Map localizedValues = { "dietUSDA":{"en":"USDA Guidelines","ar":"ارشادات وزارة الزراعة الأمريكية"}, "dietZone":{"en":"Zone Diet","ar":"حمية زون"}, + "Protein": {"en": "Protein", "ar": "بروتين"}, + "Cals": {"en": "Cals", "ar": "كالس"}, + "gramsPerDay": {"en": "Grams Per Day", "ar": "غرام في اليوم"}, + "gr": {"en": "gr", "ar": "غرام"}, + "gramsPerMeal": {"en": "Grams Per Meal", "ar": "عدد الجرامات لكل وجبة"}, }; diff --git a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart index e2010445..62020a62 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/bmr_calculator/bmr_calculator.dart @@ -357,7 +357,7 @@ class _BmrCalculatorState extends State { height: 18, child: DropdownButtonHideUnderline( child: DropdownButton( - value: dropdownValue, + value: dropdownValue, key: clinicDropdownKey, icon: Icon(Icons.arrow_downward), iconSize: 0, elevation: 16, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart index f1db7e82..b7e00652 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/calorie_calculator/calorie_calculator.dart @@ -290,6 +290,7 @@ class _CalorieCalculatorState extends State { child: DropdownButtonHideUnderline( child: DropdownButton( value: dropdownValue, + key: clinicDropdownKey, icon: Icon(Icons.arrow_downward), iconSize: 0, elevation: 16, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart index 31990a6b..9f2c6842 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart @@ -171,7 +171,7 @@ class _CarbsState extends State { height: 18, child: DropdownButtonHideUnderline( child: DropdownButton( - value: dropdownValue, + value: dropdownValue, key: clinicDropdownKey, icon: Icon(Icons.arrow_downward), iconSize: 0, elevation: 16, diff --git a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart index 43019deb..44363734 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/carbs/carbs_result_page.dart @@ -91,10 +91,10 @@ class CarbsResult extends StatelessWidget { tableRow.add( TableRow( children: [ - Utils.tableColumnTitle("Description"), - Utils.tableColumnTitle("Protein"), - Utils.tableColumnTitle("Carbohydrate"), - Utils.tableColumnTitle("Fat"), + Utils.tableColumnTitle(TranslationBase.of(context).description), + Utils.tableColumnTitle(TranslationBase.of(context).Protein), + Utils.tableColumnTitle(TranslationBase.of(context).carbohydrate), + Utils.tableColumnTitle(TranslationBase.of(context).fat), ], ), ); @@ -102,10 +102,10 @@ class CarbsResult extends StatelessWidget { tableRow.add( TableRow( children: [ - Utils.tableColumnValue("Calories Per Day", isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(pCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(cCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(cCal.ceil().toString() + ' Cals', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(TranslationBase.of(context).calDay, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(pCal.ceil().toString() + ' '+TranslationBase.of(context).Cals, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCal.ceil().toString() + ' '+TranslationBase.of(context).Cals, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCal.ceil().toString() + ' '+TranslationBase.of(context).Cals, isCapitable: false, mProjectViewModel: projectViewModel), ], ), ); @@ -113,20 +113,20 @@ class CarbsResult extends StatelessWidget { tableRow.add( TableRow( children: [ - Utils.tableColumnValue("Grams Per Day", isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(pCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(cCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(fCalGram.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(TranslationBase.of(context).gramsPerDay, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(pCalGram.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCalGram.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(fCalGram.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), ], ), ); tableRow.add( TableRow( children: [ - Utils.tableColumnValue('Grams Per Meal', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(pCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(cCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), - Utils.tableColumnValue(fCalMeal.ceil().toString() + ' gr', isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(TranslationBase.of(context).gramsPerMeal, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(pCalMeal.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(cCalMeal.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), + Utils.tableColumnValue(fCalMeal.ceil().toString() + ' '+TranslationBase.of(context).gr, isCapitable: false, mProjectViewModel: projectViewModel), ], ), ); diff --git a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart index 265bb412..a594846e 100644 --- a/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart +++ b/lib/pages/AlHabibMedicalService/health_calculator/ideal_body/ideal_body.dart @@ -200,7 +200,7 @@ class _IdealBodyState extends State { child: DropdownButtonHideUnderline( child: DropdownButton( value: dropdownValue, - icon: Icon(Icons.arrow_downward), + icon: Icon(Icons.arrow_downward), key: clinicDropdownKey, iconSize: 0, elevation: 16, isExpanded: true, diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 80425967..3c878c19 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2727,6 +2727,11 @@ class TranslationBase { String get estimates => localizedValues["estimates"][locale.languageCode]; String get submitReview => localizedValues["submitReview"][locale.languageCode]; + String get Protein => localizedValues["Protein"][locale.languageCode]; + String get Cals => localizedValues["Cals"][locale.languageCode]; + String get gramsPerDay => localizedValues["gramsPerDay"][locale.languageCode]; + String get gr => localizedValues["gr"][locale.languageCode]; + String get gramsPerMeal => localizedValues["gramsPerMeal"][locale.languageCode]; From d1e0b6ccd95cf01375f588b6dced6612b9f42e7c Mon Sep 17 00:00:00 2001 From: Fatimah Alshammari Date: Wed, 10 Nov 2021 11:42:22 +0300 Subject: [PATCH 17/20] fix issue --- lib/pages/final_products_page.dart | 18 ++++- lib/pages/offers_categorise_page.dart | 78 +++++++++++--------- lib/pages/pharmacies/search_brands_page.dart | 12 ++- lib/pages/search_products_page.dart | 41 ++++++---- lib/pages/sub_categorise_page.dart | 2 +- 5 files changed, 93 insertions(+), 58 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index 519c8c4d..f65665b5 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -60,6 +60,7 @@ class _FinalProductsPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context); return BaseView( onModelReady: (model) { @@ -228,7 +229,7 @@ class _FinalProductsPageState extends State { ), child: model.finalProducts[index].rxMessage != null ? Texts( - languageID == 'ar' ? model.finalProducts[index].rxMessagen : model.finalProducts[index].rxMessage, + projectProvider.isArabic ? model.finalProducts[index].rxMessagen : model.finalProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, @@ -390,13 +391,22 @@ class _FinalProductsPageState extends State { color: Color(0xffb23838), borderRadius: BorderRadius.only(topLeft: Radius.circular(6)), ), - child: Texts( - model.finalProducts[index].rxMessage != null ? model.finalProducts[index].rxMessage : "", + child:model.finalProducts[index].rxMessage != null + ? Texts( + projectProvider.isArabic ? model.finalProducts[index].rxMessagen : model.finalProducts[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w600, - ), + ) + : Texts(""), +// Texts( +// model.finalProducts[index].rxMessage != null ? model.finalProducts[index].rxMessage : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w600, +// ), ), ], ), diff --git a/lib/pages/offers_categorise_page.dart b/lib/pages/offers_categorise_page.dart index a9e9622a..a4708830 100644 --- a/lib/pages/offers_categorise_page.dart +++ b/lib/pages/offers_categorise_page.dart @@ -275,7 +275,7 @@ class _OffersCategorisePageState extends State { bottom: 5.0, ), child: Texts( - 'offer' + TranslationBase.of(context).offers .toUpperCase(), color: Colors .red, @@ -338,25 +338,28 @@ class _OffersCategorisePageState extends State { .circular( 6)), ), - child: Texts( - model - .products[ - index] - .rxMessage != - null - ? model - .products[ - index] - .rxMessage - : "", - color: - Colors.white, + child: model.products[index].rxMessage != null + ? Texts( + projectProvider.isArabic + ? model.products[index].rxMessagen + : model.products[index].rxMessage, + color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, - ), + fontWeight: FontWeight.w400, + ): Texts("") +// Texts( +// model.products[index].rxMessage != null ? +// model.products[index].rxMessage +// : "", +// color: +// Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: +// FontWeight +// .w400, +// ), ), ], ), @@ -508,7 +511,7 @@ class _OffersCategorisePageState extends State { child: Center( child: Texts( - 'offer' + TranslationBase.of(context).offers .toUpperCase(), color: Colors .red, @@ -576,25 +579,28 @@ class _OffersCategorisePageState extends State { .circular( 6)), ), - child: Texts( - model - .products[ - index] - .rxMessage != - null - ? model - .products[ - index] - .rxMessage - : "", - color: - Colors.white, + child: model.products[index].rxMessage != null + ? Texts( + projectProvider.isArabic + ? model.products[index].rxMessagen + : model.products[index].rxMessage, + color: Colors.white, regular: true, fontSize: 10, - fontWeight: - FontWeight - .w400, - ), + fontWeight: FontWeight.w400, + ): Texts("") +// Texts( +// model.products[index].rxMessage != null +// ? model.products[index].rxMessage +// : "", +// color: +// Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: +// FontWeight +// .w400, +// ), ), ], ), diff --git a/lib/pages/pharmacies/search_brands_page.dart b/lib/pages/pharmacies/search_brands_page.dart index db9dbcb6..7ffe8d26 100644 --- a/lib/pages/pharmacies/search_brands_page.dart +++ b/lib/pages/pharmacies/search_brands_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/brand_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -9,6 +10,7 @@ import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_pharmacy_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; class SearchBrandsPage extends StatefulWidget { @override @@ -22,6 +24,7 @@ class _SearchBrandsPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.searchProducts(), builder: (BuildContext context, model, Widget child) => @@ -60,7 +63,7 @@ class _SearchBrandsPageState extends State { RegExp regExp = RegExp(r'([A-Za-z0-9 a space])'); if (value.isEmpty) { TranslationBase.of(context).pleaseEnterProductName; - }else if (regExp.hasMatch(value)){ + }else if (!regExp.hasMatch(value)){ AppToast.showErrorToast(message: TranslationBase.of(context).noArabicLetters); } return null; @@ -112,7 +115,7 @@ class _SearchBrandsPageState extends State { model.searchList.length == 0 ? Container( child: Text( - 'no data' + model.searchList.length.toString()), + TranslationBase.of(context).noData + model.searchList.length.toString()), ) : Expanded( child: Container( @@ -128,8 +131,9 @@ class _SearchBrandsPageState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Container( - child: Text( - model.searchList[index].name, + child: Text( projectProvider.isArabic + ? model.searchList[index].namen + :model.searchList[index].name, style: TextStyle(fontSize: 20), ), ), diff --git a/lib/pages/search_products_page.dart b/lib/pages/search_products_page.dart index b7f08378..8ec9f014 100644 --- a/lib/pages/search_products_page.dart +++ b/lib/pages/search_products_page.dart @@ -1,5 +1,6 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacy_categorise_view_model.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/product_detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; @@ -13,6 +14,7 @@ import 'package:diplomaticquarterapp/widgets/others/network_base_view.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; import 'base/base_view.dart'; @@ -28,6 +30,7 @@ class _SearchProductsPageState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); return BaseView( onModelReady: (model) => model.clearSearchList(), builder: (BuildContext context, PharmacyCategoriseViewModel model, @@ -67,7 +70,7 @@ class _SearchProductsPageState extends State { if (value.isEmpty) { TranslationBase.of(context) .pleaseEnterProductName; - } else if (regExp.hasMatch(value)) { + } else if (!regExp.hasMatch(value)) { AppToast.showErrorToast( message: TranslationBase.of(context) .noArabicLetters); @@ -220,19 +223,29 @@ class _SearchProductsPageState extends State { Radius.circular( 6)), ), - child: Texts( - model.searchList[index] - .rxMessage != - null - ? model - .searchList[index] - .rxMessage - : "", + child: model.searchList[index].rxMessage != null + ? Texts( + projectProvider.isArabic + ? model.searchList[index].rxMessagen + : model.searchList[index].rxMessage, color: Colors.white, regular: true, fontSize: 10, fontWeight: FontWeight.w400, - ), + ): Texts(""), +// Texts( +// model.searchList[index] +// .rxMessage != +// null +// ? model +// .searchList[index] +// .rxMessage +// : "", +// color: Colors.white, +// regular: true, +// fontSize: 10, +// fontWeight: FontWeight.w400, +// ), ), ], ), @@ -245,9 +258,11 @@ class _SearchProductsPageState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ - Texts( - model - .searchList[index].name, + Texts(projectProvider.isArabic + ? model.searchList[index].namen + :model.searchList[index].name, + + // model.searchList[index].name, regular: true, fontSize: 12, fontWeight: FontWeight.w400, diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index 178b511b..d5309383 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -884,7 +884,7 @@ class _SubCategorisePageState extends State { Padding( padding: const EdgeInsets.all(8.0), child: Text( - 'There is no data', + TranslationBase.of(context).noData, style: TextStyle(fontSize: 30), ), ) From 65aac99806e03753eec4aa8e5d1e26cd1d60c43f Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 10:44:00 +0200 Subject: [PATCH 18/20] fix Availabilty part --- .../product-details/footor/footer-widget.dart | 8 +------- .../screens/product-details/product-detail.dart | 16 +++++++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) 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 72399498..644ab693 100644 --- a/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart +++ b/lib/pages/pharmacies/screens/product-details/footor/footer-widget.dart @@ -209,13 +209,7 @@ class _FooterWidgetState extends State { ); } else { await widget.addToShoppingCartFunction(quantity: widget.quantity, itemID: widget.item.id, model: widget.model); - // Navigator.of(context).pushNamed( - // CART_ORDER_PAGE, - // ); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); + } }, fontWeight: FontWeight.w600, diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index b1e6aff9..6a8ac3ea 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-name-and-price.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/recommended_products.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/reviews_info.dart'; @@ -14,6 +15,7 @@ import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -113,8 +115,7 @@ class __ProductDetailPageState extends State { isInWishList: isInWishList, addToCartFunction: addToCartFunction, ), - body: model.state == ViewState.Idle - ? SingleChildScrollView( + body: SingleChildScrollView( child: Column( children: [ Container( @@ -311,9 +312,9 @@ class __ProductDetailPageState extends State { ) ], ), - ) - : AppCircularProgressIndicator(), - bottomSheet: model.state == ViewState.Idle + ), + // : AppCircularProgressIndicator(), + bottomSheet: model.state == ViewState.Idle || model.state == ViewState.ErrorLocal ? FooterWidget( model.isStockAvailable, widget.product.orderMaximumQuantity, @@ -334,6 +335,11 @@ class __ProductDetailPageState extends State { GifLoaderDialogUtils.showMyDialog(context); await model.addToCartData(quantity, itemID); GifLoaderDialogUtils.hideDialog(context); + if(model.state != ViewState.ErrorLocal) + Navigator.push( + context, + FadePage(page: CartOrderPage()), + ); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { From 05e4e7be45d8a56795db3b783ae5130b7212adc2 Mon Sep 17 00:00:00 2001 From: Elham Rababh Date: Wed, 10 Nov 2021 12:27:50 +0200 Subject: [PATCH 19/20] fix bottom bar in cart page --- lib/pages/final_products_page.dart | 7 +- lib/pages/parent_categorise_page.dart | 3 +- .../product-details/product-detail.dart | 6 +- .../shared/product_details_app_bar.dart | 13 +- lib/pages/sub_categorise_page.dart | 4 +- lib/uitl/utils.dart | 252 ++++++++++++++---- lib/widgets/others/app_scaffold_widget.dart | 4 +- lib/widgets/pharmacy/product_tile.dart | 6 +- 8 files changed, 220 insertions(+), 75 deletions(-) diff --git a/lib/pages/final_products_page.dart b/lib/pages/final_products_page.dart index f65665b5..91e953ad 100644 --- a/lib/pages/final_products_page.dart +++ b/lib/pages/final_products_page.dart @@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart' as utils ; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -21,6 +22,7 @@ import 'package:rating_bar/rating_bar.dart'; import 'base/base_view.dart'; + dynamic languageID; class FinalProductsPage extends StatefulWidget { @@ -487,7 +489,10 @@ class _FinalProductsPageState extends State { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, model.finalProducts[index].id); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); + // Navigator.push(context, FadePage(page: CartOrderPage())); + utils.Utils.navigateToCartPage(); + + } else { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } diff --git a/lib/pages/parent_categorise_page.dart b/lib/pages/parent_categorise_page.dart index 34567267..65d9ea1c 100644 --- a/lib/pages/parent_categorise_page.dart +++ b/lib/pages/parent_categorise_page.dart @@ -12,6 +12,7 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -859,7 +860,7 @@ class _ParentCategorisePageState extends State { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, model.parentProducts[index].id); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); + Utils.navigateToCartPage(); } else { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } diff --git a/lib/pages/pharmacies/screens/product-details/product-detail.dart b/lib/pages/pharmacies/screens/product-details/product-detail.dart index baa92648..c4c1b26c 100644 --- a/lib/pages/pharmacies/screens/product-details/product-detail.dart +++ b/lib/pages/pharmacies/screens/product-details/product-detail.dart @@ -12,6 +12,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/sh import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; @@ -336,10 +337,7 @@ class __ProductDetailPageState extends State { await model.addToCartData(quantity, itemID, context); GifLoaderDialogUtils.hideDialog(context); if(model.state != ViewState.ErrorLocal) - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); + Utils.navigateToCartPage(); } addToWishlistFunction({itemID, ProductDetailViewModel model}) async { diff --git a/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart b/lib/pages/pharmacies/screens/product-details/shared/product_details_app_bar.dart index 944e065c..f58438cf 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 @@ -2,9 +2,11 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart' import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-order-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/product-details/product-detail.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:flutter/material.dart'; @@ -74,10 +76,13 @@ class ProductAppBar extends StatelessWidget with PreferredSizeWidget { icon: Icons.shopping_cart, color: Colors.grey[800], onPress: () { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => CartOrderPage()), - ); + + Navigator.pushAndRemoveUntil( + locator().navigatorKey.currentContext, MaterialPageRoute(builder: (context) => LandingPagePharmacy(currentTab: 3)), (Route r) => false); + // Navigator.push( + // context, + // MaterialPageRoute(builder: (context) => CartOrderPage()), + // ); }), if (Provider.of(context, listen: false) diff --git a/lib/pages/sub_categorise_page.dart b/lib/pages/sub_categorise_page.dart index d5309383..92b20476 100644 --- a/lib/pages/sub_categorise_page.dart +++ b/lib/pages/sub_categorise_page.dart @@ -10,6 +10,7 @@ import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/StarRating.dart'; @@ -845,8 +846,7 @@ class _SubCategorisePageState extends State { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, model.subProducts[index].id); GifLoaderDialogUtils.hideDialog(context); - Navigator.push(context, FadePage(page: CartOrderPage())); - } else { + Utils.navigateToCartPage(); } else { AppToast.showErrorToast(message: TranslationBase.of(context).needPrescription); } }), diff --git a/lib/uitl/utils.dart b/lib/uitl/utils.dart index d23b91b2..f20f4243 100644 --- a/lib/uitl/utils.dart +++ b/lib/uitl/utils.dart @@ -16,6 +16,7 @@ import 'package:diplomaticquarterapp/pages/MyAppointments/MyAppointments.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_approval_screen.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_card_screen.dart'; import 'package:diplomaticquarterapp/pages/insurance/insurance_update_screen.dart'; +import 'package:diplomaticquarterapp/pages/landing/landing_page_pharmcy.dart'; import 'package:diplomaticquarterapp/pages/medical/active_medications/ActiveMedicationsPage.dart'; import 'package:diplomaticquarterapp/pages/medical/allergies_page.dart'; import 'package:diplomaticquarterapp/pages/medical/ask_doctor/ask_doctor_home_page.dart'; @@ -44,13 +45,14 @@ import 'package:provider/provider.dart'; import 'package:url_launcher/url_launcher.dart'; import '../Constants.dart'; +import '../locator.dart'; import 'app_shared_preferences.dart'; import 'app_toast.dart'; import 'gif_loader_dialog_utils.dart'; +import 'navigation_service.dart'; AppSharedPreferences sharedPref = new AppSharedPreferences(); - class Utils { // static ProgressDialog pr; @@ -66,8 +68,10 @@ class Utils { /// Check The Internet Connection static Future checkConnection() async { - ConnectivityResult connectivityResult = await (Connectivity().checkConnectivity()); - if ((connectivityResult == ConnectivityResult.mobile) || (connectivityResult == ConnectivityResult.wifi)) { + ConnectivityResult connectivityResult = + await (Connectivity().checkConnectivity()); + if ((connectivityResult == ConnectivityResult.mobile) || + (connectivityResult == ConnectivityResult.wifi)) { return true; } else { return false; @@ -131,11 +135,19 @@ class Utils { } static String getAppointmentTransID(int projectID, int clinicID, int appoNo) { - return projectID.toString() + '-' + clinicID.toString() + '-' + appoNo.toString(); + return projectID.toString() + + '-' + + clinicID.toString() + + '-' + + appoNo.toString(); } static String getAdvancePaymentTransID(int projectID, int fileNumber) { - return projectID.toString() + '-' + fileNumber.toString() + '-' + DateTime.now().millisecondsSinceEpoch.toString(); + return projectID.toString() + + '-' + + fileNumber.toString() + + '-' + + DateTime.now().millisecondsSinceEpoch.toString(); } bool validateIDBox(String value, type) { @@ -195,14 +207,22 @@ class Utils { } static validEmail(email) { - return RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email); + return RegExp( + r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+") + .hasMatch(email); } - static List myMedicalList({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count}) { + static List myMedicalList( + {ProjectViewModel projectViewModel, + BuildContext context, + bool isLogin, + count}) { List medical = List(); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(5) ? Navigator.push(context, FadePage(page: MyAppointments())) : null, + onTap: () => projectViewModel.havePrivilege(5) + ? Navigator.push(context, FadePage(page: MyAppointments())) + : null, child: isLogin ? Stack(children: [ Container( @@ -229,7 +249,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -247,7 +271,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -274,7 +302,9 @@ class Utils { } medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(7) ? Navigator.push(context, FadePage(page: RadiologyHomePage())) : null, + onTap: () => projectViewModel.havePrivilege(7) + ? Navigator.push(context, FadePage(page: RadiologyHomePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).radiology, imagePath: 'radiology.svg', @@ -284,7 +314,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(12) ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) : null, + onTap: () => projectViewModel.havePrivilege(12) + ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).medicines, imagePath: 'medicine_prescription.svg', @@ -310,7 +342,8 @@ class Utils { medical.add(InkWell( onTap: () { - if (projectViewModel.havePrivilege(48)) Navigator.push(context, FadePage(page: ActiveMedicationsPage())); + if (projectViewModel.havePrivilege(48)) + Navigator.push(context, FadePage(page: ActiveMedicationsPage())); }, child: MedicalProfileItem( title: TranslationBase.of(context).myMedical, @@ -329,12 +362,17 @@ class Utils { ), ) : null, - child: - MedicalProfileItem(title: TranslationBase.of(context).myDoctor, imagePath: 'my_doc.svg', subTitle: TranslationBase.of(context).myDoctorSubtitle, isEnable: projectViewModel.havePrivilege(6)), + child: MedicalProfileItem( + title: TranslationBase.of(context).myDoctor, + imagePath: 'my_doc.svg', + subTitle: TranslationBase.of(context).myDoctorSubtitle, + isEnable: projectViewModel.havePrivilege(6)), )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(14) ? Navigator.push(context, FadePage(page: MyInvoices())) : null, + onTap: () => projectViewModel.havePrivilege(14) + ? Navigator.push(context, FadePage(page: MyInvoices())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).invoicesList, imagePath: 'invoice_list.svg', @@ -344,7 +382,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(14) ? Navigator.push(context, FadePage(page: EyeMeasurementsPage())) : null, + onTap: () => projectViewModel.havePrivilege(14) + ? Navigator.push(context, FadePage(page: EyeMeasurementsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).eye, imagePath: 'eye_measurement.svg', @@ -354,7 +394,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(22) ? Navigator.push(context, FadePage(page: InsuranceCard())) : null, + onTap: () => projectViewModel.havePrivilege(22) + ? Navigator.push(context, FadePage(page: InsuranceCard())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).insurance, imagePath: 'insurance_card.svg', @@ -375,7 +417,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(18) ? Navigator.push(context, FadePage(page: InsuranceApproval())) : null, + onTap: () => projectViewModel.havePrivilege(18) + ? Navigator.push(context, FadePage(page: InsuranceApproval())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).insuranceApproval, imagePath: 'insurance_approval.svg', @@ -385,7 +429,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(23) ? Navigator.push(context, FadePage(page: AllergiesPage())) : null, + onTap: () => projectViewModel.havePrivilege(23) + ? Navigator.push(context, FadePage(page: AllergiesPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).allergies, imagePath: 'allergies_diagnosed.svg', @@ -395,7 +441,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(26) ? Navigator.push(context, FadePage(page: MyVaccines())) : null, + onTap: () => projectViewModel.havePrivilege(26) + ? Navigator.push(context, FadePage(page: MyVaccines())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).myVaccines, imagePath: 'vaccine_list.svg', @@ -405,7 +453,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(20) ? Navigator.push(context, FadePage(page: HomeReportPage())) : null, + onTap: () => projectViewModel.havePrivilege(20) + ? Navigator.push(context, FadePage(page: HomeReportPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).medical, imagePath: 'medical_report.svg', @@ -415,7 +465,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(19) ? Navigator.push(context, FadePage(page: MonthlyReportsPage())) : null, + onTap: () => projectViewModel.havePrivilege(19) + ? Navigator.push(context, FadePage(page: MonthlyReportsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).monthly, imagePath: 'monthly_report.svg', @@ -425,7 +477,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(16) ? Navigator.push(context, FadePage(page: PatientSickLeavePage())) : null, + onTap: () => projectViewModel.havePrivilege(16) + ? Navigator.push(context, FadePage(page: PatientSickLeavePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).sick, imagePath: 'sick_leave.svg', @@ -435,7 +489,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(47) ? Navigator.push(context, FadePage(page: MyBalancePage())) : null, + onTap: () => projectViewModel.havePrivilege(47) + ? Navigator.push(context, FadePage(page: MyBalancePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).myBalance, imagePath: 'balance_credit.svg', @@ -452,7 +508,9 @@ class Utils { // )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(24) ? Navigator.push(context, FadePage(page: MyTrackers())) : null, + onTap: () => projectViewModel.havePrivilege(24) + ? Navigator.push(context, FadePage(page: MyTrackers())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).myTrackers, imagePath: 'tracker.svg', @@ -462,7 +520,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(30) ? Navigator.push(context, FadePage(page: SmartWatchInstructions())) : null, + onTap: () => projectViewModel.havePrivilege(30) + ? Navigator.push(context, FadePage(page: SmartWatchInstructions())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).smartWatchesSubtitle, imagePath: 'smart_watch.svg', @@ -472,9 +532,14 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(28) ? Navigator.push(context, FadePage(page: AskDoctorHomPage())) : null, + onTap: () => projectViewModel.havePrivilege(28) + ? Navigator.push(context, FadePage(page: AskDoctorHomPage())) + : null, child: MedicalProfileItem( - title: TranslationBase.of(context).askYourSubtitle, imagePath: 'ask_doctor.svg', subTitle: TranslationBase.of(context).askYour, isEnable: projectViewModel.havePrivilege(28)), + title: TranslationBase.of(context).askYourSubtitle, + imagePath: 'ask_doctor.svg', + subTitle: TranslationBase.of(context).askYour, + isEnable: projectViewModel.havePrivilege(28)), )); if (projectViewModel.havePrivilege(32) || true) { @@ -484,13 +549,18 @@ class Utils { if (projectViewModel.isLogin && userData_ != null) { String patientID = userData_.patientID.toString(); GifLoaderDialogUtils.showMyDialog(context); - projectViewModel.platformBridge().connectHMGInternetWifi(patientID).then((value) => {GifLoaderDialogUtils.hideDialog(context)}).catchError((err) { + projectViewModel + .platformBridge() + .connectHMGInternetWifi(patientID) + .then((value) => {GifLoaderDialogUtils.hideDialog(context)}) + .catchError((err) { print(err.toString()); }); } else { AlertDialogBox( context: context, - confirmMessage: "Please login with your account first to use this feature", + confirmMessage: + "Please login with your account first to use this feature", okText: "OK", okFunction: () { AlertDialogBox.closeAlertDialog(context); @@ -507,7 +577,9 @@ class Utils { } medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(40) ? launch('whatsapp://send?phone=18885521858&text=') : null, + onTap: () => projectViewModel.havePrivilege(40) + ? launch('whatsapp://send?phone=18885521858&text=') + : null, child: MedicalProfileItem( title: TranslationBase.of(context).chatbot, imagePath: 'chatbot.svg', @@ -519,13 +591,17 @@ class Utils { return medical; } - - - static List myMedicalListHomePage({ProjectViewModel projectViewModel, BuildContext context, bool isLogin, count}) { + static List myMedicalListHomePage( + {ProjectViewModel projectViewModel, + BuildContext context, + bool isLogin, + count}) { List medical = List(); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(5) ? Navigator.push(context, FadePage(page: MyAppointments())) : null, + onTap: () => projectViewModel.havePrivilege(5) + ? Navigator.push(context, FadePage(page: MyAppointments())) + : null, child: isLogin ? Stack(children: [ MedicalProfileItem( @@ -548,7 +624,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -566,7 +646,11 @@ class Utils { borderRadius: BorderRadius.circular(8), badgeContent: Container( padding: EdgeInsets.all(2.0), - child: Text(count.toString(), style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 12.0)), + child: Text(count.toString(), + style: TextStyle( + color: Colors.white, + fontWeight: FontWeight.bold, + fontSize: 12.0)), ), ), ) @@ -593,7 +677,9 @@ class Utils { } medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(7) ? Navigator.push(context, FadePage(page: RadiologyHomePage())) : null, + onTap: () => projectViewModel.havePrivilege(7) + ? Navigator.push(context, FadePage(page: RadiologyHomePage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).radiology, imagePath: 'radiology.svg', @@ -603,7 +689,9 @@ class Utils { )); medical.add(InkWell( - onTap: () => projectViewModel.havePrivilege(12) ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) : null, + onTap: () => projectViewModel.havePrivilege(12) + ? Navigator.push(context, FadePage(page: HomePrescriptionsPage())) + : null, child: MedicalProfileItem( title: TranslationBase.of(context).medicines, imagePath: 'medicine_prescription.svg', @@ -621,19 +709,24 @@ class Utils { ), ) : null, - child: - MedicalProfileItem(title: TranslationBase.of(context).myDoctor, imagePath: 'my_doc.svg', subTitle: TranslationBase.of(context).myDoctorSubtitle, isEnable: projectViewModel.havePrivilege(6)), + child: MedicalProfileItem( + title: TranslationBase.of(context).myDoctor, + imagePath: 'my_doc.svg', + subTitle: TranslationBase.of(context).myDoctorSubtitle, + isEnable: projectViewModel.havePrivilege(6)), )); return medical; } - static Widget loadNetworkImage({@required String url, BoxFit fitting = BoxFit.cover}) { + static Widget loadNetworkImage( + {@required String url, BoxFit fitting = BoxFit.cover}) { return CachedNetworkImage( placeholderFadeInDuration: Duration(milliseconds: 250), fit: fitting, imageUrl: url, - placeholder: (context, url) => Container(child: Center(child: CircularProgressIndicator())), + placeholder: (context, url) => + Container(child: Center(child: CircularProgressIndicator())), errorWidget: (context, url, error) { return Icon( Icons.error, @@ -650,6 +743,14 @@ class Utils { return route.runtimeType == equalsTo; } + static navigateToCartPage() { + Navigator.pushAndRemoveUntil( + locator().navigatorKey.currentContext, + MaterialPageRoute( + builder: (context) => LandingPagePharmacy(currentTab: 3)), + (Route r) => false); + } + static Widget tableColumnTitle(String text, {bool showDivider = true}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -658,7 +759,12 @@ class Utils { SizedBox(height: 6), Text( text, - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff2E303A), letterSpacing: -0.48, height: 18 / 12), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff2E303A), + letterSpacing: -0.48, + height: 18 / 12), ), SizedBox(height: 5), if (showDivider) @@ -671,16 +777,27 @@ class Utils { ); } - static Widget tableColumnValue(String text, {bool isLast = false, bool isCapitable = true, ProjectViewModel mProjectViewModel}) { - ProjectViewModel projectViewModel = mProjectViewModel ?? Provider.of(AppGlobal.context); + static Widget tableColumnValue(String text, + {bool isLast = false, + bool isCapitable = true, + ProjectViewModel mProjectViewModel}) { + ProjectViewModel projectViewModel = + mProjectViewModel ?? Provider.of(AppGlobal.context); return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ SizedBox(height: 12), Text( - isCapitable && !projectViewModel.isArabic ? text.toLowerCase().capitalizeFirstofEach : text, - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xff575757), letterSpacing: -0.4, height: 16 / 10), + isCapitable && !projectViewModel.isArabic + ? text.toLowerCase().capitalizeFirstofEach + : text, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xff575757), + letterSpacing: -0.4, + height: 16 / 10), ), SizedBox(height: 12), if (!isLast) @@ -693,7 +810,8 @@ class Utils { ); } - static Widget tableColumnValueWithUnderLine(String text, {bool isLast = false, bool isCapitable = true}) { + static Widget tableColumnValueWithUnderLine(String text, + {bool isLast = false, bool isCapitable = true}) { return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, @@ -704,7 +822,13 @@ class Utils { isCapitable ? text.toLowerCase().capitalizeFirstofEach : text, maxLines: 1, minFontSize: 6, - style: TextStyle(decoration: TextDecoration.underline, fontSize: 12, fontWeight: FontWeight.w600, color: Color(0xffD02127), letterSpacing: -0.48, height: 18 / 12), + style: TextStyle( + decoration: TextDecoration.underline, + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xffD02127), + letterSpacing: -0.48, + height: 18 / 12), ), SizedBox(height: 10), if (!isLast) @@ -718,7 +842,13 @@ class Utils { } } -Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, double spreadRadius = 2, double blurRadius = 7, Offset offset = const Offset(2, 2), @required Widget child}) { +Widget applyShadow( + {Color color = Colors.grey, + double shadowOpacity = 0.5, + double spreadRadius = 2, + double blurRadius = 7, + Offset offset = const Offset(2, 2), + @required Widget child}) { return Container( decoration: BoxDecoration( boxShadow: [ @@ -735,7 +865,8 @@ Widget applyShadow({Color color = Colors.grey, double shadowOpacity = 0.5, doubl } Future userData() async { - var userData = AuthenticatedUser.fromJson(await AppSharedPreferences().getObject(MAIN_USER)); + var userData = AuthenticatedUser.fromJson( + await AppSharedPreferences().getObject(MAIN_USER)); return userData; } @@ -749,9 +880,12 @@ extension IndexedIterable on Iterable { openAppStore({String androidPackageName, String iOSAppID}) async { if (Platform.isAndroid) { - assert(!(androidPackageName == null), "Should have valid value in androidPackageName parameter"); - if ((await FlutterHmsGmsAvailability.isGmsAvailable)) launch("market://details?id=com.ejada.hmg"); - if ((await FlutterHmsGmsAvailability.isHmsAvailable)) launch("appmarket://details?id=com.ejada.hmg"); + assert(!(androidPackageName == null), + "Should have valid value in androidPackageName parameter"); + if ((await FlutterHmsGmsAvailability.isGmsAvailable)) + launch("market://details?id=com.ejada.hmg"); + if ((await FlutterHmsGmsAvailability.isHmsAvailable)) + launch("appmarket://details?id=com.ejada.hmg"); } else if (Platform.isIOS) { assert((iOSAppID == null), "Should have valid value in iOSAppID parameter"); launch("https://itunes.apple.com/kr/app/apple-store/$iOSAppID)"); @@ -777,7 +911,11 @@ String labelFrom({@required String className}) { extension StringExtension on String { String capitalize() { - return this.splitMapJoin(RegExp(r'\w+'), onMatch: (m) => '${m.group(0)}'.substring(0, 1).toUpperCase() + '${m.group(0)}'.substring(1).toLowerCase(), onNonMatch: (n) => ' '); + return this.splitMapJoin(RegExp(r'\w+'), + onMatch: (m) => + '${m.group(0)}'.substring(0, 1).toUpperCase() + + '${m.group(0)}'.substring(1).toLowerCase(), + onNonMatch: (n) => ' '); } } diff --git a/lib/widgets/others/app_scaffold_widget.dart b/lib/widgets/others/app_scaffold_widget.dart index 8772a60e..0dc0f318 100644 --- a/lib/widgets/others/app_scaffold_widget.dart +++ b/lib/widgets/others/app_scaffold_widget.dart @@ -21,6 +21,7 @@ import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/navigation_service.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/uitl/utils_new.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/pharmacy/bottom_nav_pharmacy_bar.dart'; @@ -494,8 +495,7 @@ class AppBarWidgetState extends State { icon: Badge(badgeContent: Text(orderPreviewViewModel.cartResponse.quantityCount.toString()), child: Icon(Icons.shopping_cart)), color: Colors.white, onPressed: () { - // Navigator.of(context).popUntil(ModalRoute.withName('/')); - Navigator.of(context).popAndPushNamed(CART_ORDER_PAGE); + Utils.navigateToCartPage(); }) : Container(), (widget.isOfferPackages && widget.showOfferPackagesCart) diff --git a/lib/widgets/pharmacy/product_tile.dart b/lib/widgets/pharmacy/product_tile.dart index 70a727bf..b7293ce1 100644 --- a/lib/widgets/pharmacy/product_tile.dart +++ b/lib/widgets/pharmacy/product_tile.dart @@ -4,6 +4,7 @@ import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-page/cart-ord import 'package:diplomaticquarterapp/pages/pharmacy/order/ProductReview.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; @@ -165,10 +166,7 @@ class productTile extends StatelessWidget { GifLoaderDialogUtils.showMyDialog(context); await addToCartFunction(1, productID, context); GifLoaderDialogUtils.hideDialog(context); - Navigator.push( - context, - FadePage(page: CartOrderPage()), - ); + Utils.navigateToCartPage(); }, ), ], From 289e74fd0ad384411c703de5f6ba911925d1f0b6 Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 10 Nov 2021 16:02:41 +0300 Subject: [PATCH 20/20] fixes --- lib/core/service/medical/prescriptions_service.dart | 3 +-- lib/pages/BookAppointment/BookConfirm.dart | 1 + .../screens/product-details/product-name-and-price.dart | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/core/service/medical/prescriptions_service.dart b/lib/core/service/medical/prescriptions_service.dart index 4349f218..0a7d9e68 100644 --- a/lib/core/service/medical/prescriptions_service.dart +++ b/lib/core/service/medical/prescriptions_service.dart @@ -225,13 +225,12 @@ class PrescriptionsService extends BaseService { }, body: _requestPrescriptionReportEnh.toJson()); } - Future updatePressOrderRC({@required int presOrderID, @required String patientID}) async { + Future updatePressOrderRC({@required int presOrderID}) async { hasError = false; Map body = Map(); body['Id'] = presOrderID; body['StatusId'] = 6; body['ClickButton'] = 14; - body['PatientID'] = patientID; await baseAppClient.post(UPDATE_PRESCRIPTION_ORDER_RC, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; diff --git a/lib/pages/BookAppointment/BookConfirm.dart b/lib/pages/BookAppointment/BookConfirm.dart index 585e862d..bdf387d6 100644 --- a/lib/pages/BookAppointment/BookConfirm.dart +++ b/lib/pages/BookAppointment/BookConfirm.dart @@ -88,6 +88,7 @@ class _BookConfirmState extends State { null, widget.doctor.noOfPatientsRate, "", + ), isNeedToShowButton: false, ), diff --git a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart index 78a9a88e..0f25b236 100644 --- a/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart +++ b/lib/pages/pharmacies/screens/product-details/product-name-and-price.dart @@ -25,7 +25,7 @@ class ProductNameAndPrice extends StatefulWidget { AuthenticatedUserObject authenticatedUserObject = locator(); ProductNameAndPrice(this.context, this.item, - {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable, this.stockAvailability}); + {this.customerId, this.isInWishList, this.notifyMeWhenAvailable, this.addToWishlistFunction, this.deleteFromWishlistFunction, this.isStockAvailable = true, this.stockAvailability}); @override _ProductNameAndPriceState createState() => _ProductNameAndPriceState(); @@ -56,7 +56,7 @@ class _ProductNameAndPriceState extends State { ), // SizedBox(width: 20), if (widget.authenticatedUserObject.isLogin) - widget.isStockAvailable && widget.customerId != null + !widget.isStockAvailable && widget.customerId != null ? InkWell( onTap: () => widget.notifyMeWhenAvailable(context, widget.item.id), child: Row(children: [