From b9a12341d5c3cc2d351b7b347e56201f0d2a7adc Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 10 Mar 2021 09:46:18 +0300 Subject: [PATCH] updates & fixes --- lib/config/localized_values.dart | 4 + lib/core/service/client/base_app_client.dart | 75 +-- lib/pages/landing/home_page.dart | 31 +- lib/pages/pharmacies/product-brands.dart | 2 + lib/pages/pharmacies/product_detail.dart | 460 ++++++++++-------- .../screens/cart-order-preview.dart | 10 +- lib/uitl/translations_delegate_base.dart | 1 + 7 files changed, 335 insertions(+), 248 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index f6257ae8..da5809e5 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1954,4 +1954,8 @@ const Map localizedValues = { }, "order-overview": {"en": "Order Overview", "ar": "ملخص الطلب"}, "shipping-address": {"en": "Delivery Address", "ar": "عنوان التوصيل"}, + "pharmacy-relogin": { + "en": "Your session has timed out, Please try again", + "ar": "انتهت مهلة جلسة الخاص بها. يرجى المحاولة مرة أخرى" + }, }; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index abfa7594..fab6d8fd 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -7,6 +7,8 @@ import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; import 'package:diplomaticquarterapp/pages/appUpdatePage/app_update_page.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; +import 'package:diplomaticquarterapp/uitl/app_toast.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/cupertino.dart'; @@ -293,7 +295,13 @@ class BaseAppClient { print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { - onFailure('Error While Fetching data', statusCode); + if (statusCode == 401) { + AppToast.showErrorToast( + message: TranslationBase.of(AppGlobal.context).pharmacyRelogin); + Navigator.of(AppGlobal.context).pushNamed(HOME); + } else { + onFailure('Error While Fetching data', statusCode); + } } else { var parsed = json.decode(response.body.toString()); onSuccess(parsed, statusCode); @@ -386,13 +394,12 @@ class BaseAppClient { return params; } - pharmacyPost(String endPoint, {Map body, - Function(dynamic response, int statusCode) onSuccess, - Function(String error, int statusCode) onFailure, - bool isAllowAny = false, - bool isExternal = false}) async { + Function(dynamic response, int statusCode) onSuccess, + Function(String error, int statusCode) onFailure, + bool isAllowAny = false, + bool isExternal = false}) async { String url; if (isExternal) { url = endPoint; @@ -404,13 +411,13 @@ class BaseAppClient { if (!isExternal) { String token = await sharedPref.getString(TOKEN); var languageID = - await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); + await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar'); var user = await sharedPref.getObject(USER_PROFILE); if (body.containsKey('SetupID')) { body['SetupID'] = body.containsKey('SetupID') ? body['SetupID'] != null - ? body['SetupID'] - : SETUP_ID + ? body['SetupID'] + : SETUP_ID : SETUP_ID; } @@ -422,17 +429,17 @@ class BaseAppClient { body['generalid'] = GENERAL_ID; body['PatientOutSA'] = body.containsKey('PatientOutSA') ? body['PatientOutSA'] != null - ? body['PatientOutSA'] - : PATIENT_OUT_SA + ? body['PatientOutSA'] + : PATIENT_OUT_SA : PATIENT_OUT_SA; if (body.containsKey('isDentalAllowedBackend')) { body['isDentalAllowedBackend'] = - body.containsKey('isDentalAllowedBackend') - ? body['isDentalAllowedBackend'] != null - ? body['isDentalAllowedBackend'] - : IS_DENTAL_ALLOWED_BACKEND - : IS_DENTAL_ALLOWED_BACKEND; + body.containsKey('isDentalAllowedBackend') + ? body['isDentalAllowedBackend'] != null + ? body['isDentalAllowedBackend'] + : IS_DENTAL_ALLOWED_BACKEND + : IS_DENTAL_ALLOWED_BACKEND; } body['DeviceTypeID'] = DeviceTypeID; @@ -440,18 +447,18 @@ class BaseAppClient { if (!body.containsKey('IsPublicRequest')) { body['PatientType'] = body.containsKey('PatientType') ? body['PatientType'] != null - ? body['PatientType'] - : user['PatientType'] != null - ? user['PatientType'] - : PATIENT_TYPE + ? body['PatientType'] + : user['PatientType'] != null + ? user['PatientType'] + : PATIENT_TYPE : PATIENT_TYPE; body['PatientTypeID'] = body.containsKey('PatientTypeID') ? body['PatientTypeID'] != null - ? body['PatientTypeID'] - : user['PatientType'] != null - ? user['PatientType'] - : PATIENT_TYPE_ID + ? body['PatientTypeID'] + : user['PatientType'] != null + ? user['PatientType'] + : PATIENT_TYPE_ID : PATIENT_TYPE_ID; if (user != null) { body['TokenID'] = token; @@ -469,13 +476,12 @@ class BaseAppClient { var ss = json.encode(body); if (await Utils.checkConnection()) { - final response = await http.post(url.trim(), - body: json.encode(body), - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', - }); + final response = + await http.post(url.trim(), body: json.encode(body), headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'Statictoken': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9', + }); final int statusCode = response.statusCode; print("statusCode :$statusCode"); if (statusCode < 200 || statusCode >= 400 || json == null) { @@ -515,12 +521,11 @@ class BaseAppClient { parsed['IsAuthenticated']) { if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) { - if(parsed['ErrorSearchMsg'] == null ){ + if (parsed['ErrorSearchMsg'] == null) { onFailure("Server Error found with no available message", statusCode); - }else { - onFailure(parsed['ErrorSearchMsg'], - statusCode); + } else { + onFailure(parsed['ErrorSearchMsg'], statusCode); } } else { onFailure( diff --git a/lib/pages/landing/home_page.dart b/lib/pages/landing/home_page.dart index 452c315c..c2f96194 100644 --- a/lib/pages/landing/home_page.dart +++ b/lib/pages/landing/home_page.dart @@ -1,6 +1,8 @@ import 'package:diplomaticquarterapp/config/size_config.dart'; import 'package:diplomaticquarterapp/core/viewModels/dashboard_view_model.dart'; +import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/ComprehensiveMedicalCheckup/cmc_page.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/HomeHealthCare/home_health_care_page.dart'; import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/all_habib_medical_service_page.dart'; @@ -11,6 +13,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/livecare/livecare_home.dart'; import 'package:diplomaticquarterapp/pages/paymentService/payment_service.dart'; import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; +import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; @@ -33,6 +36,9 @@ class HomePage extends StatefulWidget { } class _HomePageState extends State { + PharmacyModuleViewModel pharmacyModuleViewModel = + locator(); + @override Widget build(BuildContext context) { ProjectViewModel projectViewModel = Provider.of(context); @@ -503,8 +509,7 @@ class _HomePageState extends State { ), if (projectViewModel.havePrivilege(65)) DashboardItem( - onTap: () => Navigator.push( - context, FadePage(page: LandingPagePharmacy())), + onTap: () => getPharmacyToken(model), child: Center( child: Padding( padding: const EdgeInsets.all(15.0), @@ -799,10 +804,24 @@ class _HomePageState extends State { ); } - // openBrowser() { - // InAppBrowser browser = new InAppBrowser(); - // browser.openUrl(url: "https://uat.hmgwebservices.com/epharmacy/checkout/OpcCompleteRedirectionPaymentClientbyOrder?orderID=ca9dd276-0a20-4924-a768-fafa9a855ef1&&CustomerId=1367368"); - // } + getPharmacyToken(DashboardViewModel model) async { + if(!model.isLogin) { + Navigator.push(context, FadePage(page: LandingPagePharmacy())); + } else { + GifLoaderDialogUtils.showMyDialog(context); + await pharmacyModuleViewModel.generatePharmacyToken().then((value) async { + if (pharmacyModuleViewModel.error.isNotEmpty) { + await pharmacyModuleViewModel.createUser().then((value) { + GifLoaderDialogUtils.hideDialog(context); + Navigator.push(context, FadePage(page: LandingPagePharmacy())); + }); + } else { + GifLoaderDialogUtils.hideDialog(context); + Navigator.push(context, FadePage(page: LandingPagePharmacy())); + } + }); + } + } navigateToCovidDriveThru() { Navigator.push(context, FadePage(page: CovidDrivethruLocation())); diff --git a/lib/pages/pharmacies/product-brands.dart b/lib/pages/pharmacies/product-brands.dart index 945fbda1..e2fefab0 100644 --- a/lib/pages/pharmacies/product-brands.dart +++ b/lib/pages/pharmacies/product-brands.dart @@ -28,6 +28,7 @@ class _ProductBrandsPageState extends State { @override Widget build(BuildContext context) { return BaseView( + allowAny: true, onModelReady: (model) => model.getBrandsData(), builder: (_, model, wi) => AppScaffold( appBarTitle: 'Brands page', @@ -142,6 +143,7 @@ class _ProductBrandsPageState extends State { topBrand(BuildContext context) { return BaseView( + allowAny: true, onModelReady: (model) => model.getTopBrandsData(), builder: (_, model, wi) => GridView.count( crossAxisCount: 4, diff --git a/lib/pages/pharmacies/product_detail.dart b/lib/pages/pharmacies/product_detail.dart index c119f468..bd776355 100644 --- a/lib/pages/pharmacies/product_detail.dart +++ b/lib/pages/pharmacies/product_detail.dart @@ -1,23 +1,22 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart'; -import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/pharmacy_module_view_model.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/product_detail_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/login/welcome.dart'; +import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.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/widgets/data_display/text.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scafold_detail_page.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; -import 'package:diplomaticquarterapp/widgets/others/app_scafold_detail_page.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:provider/provider.dart'; import 'package:rating_bar/rating_bar.dart'; -import 'package:diplomaticquarterapp/uitl/app_toast.dart'; + import 'screens/cart-order-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/compare-list.dart'; int price = 0; var languageID; @@ -30,7 +29,9 @@ PharmacyProduct specificationData; class ProductDetailPage extends StatefulWidget { final PharmacyProduct product; + ProductDetailPage(this.product); + @override __ProductDetailPageState createState() => __ProductDetailPageState(); } @@ -42,8 +43,10 @@ class __ProductDetailPageState extends State { bool isAvailabilty = false; dynamic wishlistItems; var model; + // String ProductId="4561"; String productId = ""; + checkWishlist() async { GifLoaderDialogUtils.showMyDialog(context); ProductDetailViewModel x = new ProductDetailViewModel(); @@ -62,6 +65,7 @@ class __ProductDetailPageState extends State { GifLoaderDialogUtils.hideDialog(context); setState(() {}); } + void initState() { price = 1; specificationData = widget.product; @@ -613,21 +617,20 @@ class __ProductDetailPageState extends State { Container( width: 410, height: 50, - // margin: EdgeInsets.only(bottom: 5), + // margin: EdgeInsets.only(bottom: 5), color: Colors.white, child: Texts( TranslationBase.of(context).recommended, bold: true, ), ), - ], ), SingleChildScrollView( child: Container( color: Colors.white, child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, + // crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start, // mainAxisSize: MainAxisSize.min, children: [ @@ -636,208 +639,252 @@ class __ProductDetailPageState extends State { height: 210, margin: EdgeInsets.only(bottom: 75), padding: EdgeInsets.only(bottom: 5), - // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), + // margin: EdgeInsets.symmetric(horizontal: 6, vertical: 4), child: BaseView( onModelReady: (model) => - model.getRecommendedProducts(widget.product.id.toString()), - builder: (_, model, wi) => - Container( + model.getRecommendedProducts( + widget.product.id.toString()), + builder: (_, model, wi) => Container( child: // Text(model.recommendedProductList[0].id), - model.recommendedProductList.length != null - ? Expanded( - child: ListView.builder( - scrollDirection: Axis.horizontal, - shrinkWrap: true, - physics: ScrollPhysics(), - // physics: NeverScrollableScrollPhysics(), - itemCount: model.recommendedProductList.length, - itemBuilder: (context, index) { - return Card( - elevation: 2, - shape: RoundedRectangleBorder( - side: BorderSide( - color: Colors.grey[300], width: 2), - borderRadius: BorderRadius.circular(10)), - margin: EdgeInsets.symmetric( - horizontal: 8, - vertical: 0, - ), - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.all( - Radius.circular(15), - ), - ), - padding: EdgeInsets.symmetric(horizontal: 4), - width: MediaQuery.of(context).size.width / 3, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Stack(children: [ - Container( - child: Align( - alignment: Alignment.topRight, - child: //true - itemID.contains(model.recommendedProductList[index].id) - // !isInWishlist - ? IconButton( - icon: Icon(Icons - .favorite_border), - color: Colors.grey, - iconSize: 30, - onPressed: () { - setState(() { - addToWishlistFunction(itemID); - }); - }, - ) - : IconButton( - icon: Icon( - Icons.favorite), - color: Colors.red, - iconSize: 30, - onPressed: () { - setState(() { - deleteFromWishlistFunction(itemID); - }); - }, - ) -// + model.recommendedProductList.length != + null + ? Expanded( + child: ListView.builder( + scrollDirection: + Axis.horizontal, + shrinkWrap: true, + physics: ScrollPhysics(), + // physics: NeverScrollableScrollPhysics(), + itemCount: model + .recommendedProductList + .length, + itemBuilder: + (context, index) { + return Card( + elevation: 2, + shape: RoundedRectangleBorder( + side: BorderSide( + color: Colors + .grey[ + 300], + width: 2), + borderRadius: + BorderRadius + .circular( + 10)), + margin: EdgeInsets + .symmetric( + horizontal: 8, + vertical: 0, ), - ), - Container( - margin: EdgeInsets.fromLTRB( - 0, 16, 10, 16), - alignment: Alignment.center, + child: Container( + decoration: + BoxDecoration( + borderRadius: + BorderRadius + .all( + Radius.circular( + 15), + ), + ), + padding: EdgeInsets + .symmetric( + horizontal: + 4), + width: MediaQuery.of( + context) + .size + .width / + 3, + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Stack( + children: [ + Container( + child: Align( + alignment: Alignment.topRight, + child: //true + itemID.contains(model.recommendedProductList[index].id) + // !isInWishlist + ? IconButton( + icon: Icon(Icons.favorite_border), + color: Colors.grey, + iconSize: 30, + onPressed: () { + setState(() { + addToWishlistFunction(itemID); + }); + }, + ) + : IconButton( + icon: Icon(Icons.favorite), + color: Colors.red, + iconSize: 30, + onPressed: () { + setState(() { + deleteFromWishlistFunction(itemID); + }); + }, + ) +// + ), + ), + Container( + margin: EdgeInsets.fromLTRB( + 0, + 16, + 10, + 16), + alignment: + Alignment.center, // padding: EdgeInsets.only(left: 25, bottom: 20), - child: (model.recommendedProductList[index].images != null && - model.recommendedProductList[index].images.length > 0) - ? Image.network( - model.recommendedProductList[index].images[0].src.toString(), + child: (model.recommendedProductList[index].images != null && + model.recommendedProductList[index].images.length > 0) + ? Image.network( + model.recommendedProductList[index].images[0].src.toString(), // item.images[0].src, - fit: BoxFit.cover, - height: 60, - ) - : Image.asset( - "assets/images/no_image.png", - fit: BoxFit.cover, - height: 60, - ), - ), - Container( - width: model - .recommendedProductList[ - index] - .rxMessage != - null - ? MediaQuery.of(context) - .size - .width / - 5 - : 0, - padding: EdgeInsets.all(4), - decoration: BoxDecoration( - color: Color(0xffb23838), - borderRadius: BorderRadius.only( - topLeft: Radius.circular(6)), - ), - child: Texts( - model.recommendedProductList[index] - .rxMessage != - null - ? model - .recommendedProductList[ - index] - .rxMessage - : "", - color: Colors.white, - regular: true, - fontSize: 10, - fontWeight: FontWeight.w400, - ), - ), - ]), - Container( - margin: EdgeInsets.symmetric( - horizontal: 6, - vertical: 0, - ), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - languageID == "ar" - ? model.recommendedProductList[index].namen - : model.recommendedProductList[index].name, - style: TextStyle( - color: Colors.black, - fontSize: 13.0, + fit: BoxFit.cover, + height: 60, + ) + : Image.asset( + "assets/images/no_image.png", + fit: BoxFit.cover, + height: 60, + ), + ), + Container( + width: model.recommendedProductList[index].rxMessage != + null + ? MediaQuery.of(context).size.width / + 5 + : 0, + padding: + EdgeInsets.all(4), + decoration: + BoxDecoration( + color: + Color(0xffb23838), + borderRadius: + BorderRadius.only(topLeft: Radius.circular(6)), + ), + child: + Texts( + model.recommendedProductList[index].rxMessage != null + ? model.recommendedProductList[index].rxMessage + : "", + color: + Colors.white, + regular: + true, + fontSize: + 10, + fontWeight: + FontWeight.w400, + ), + ), + ]), + Container( + margin: EdgeInsets + .symmetric( + horizontal: + 6, + vertical: 0, + ), + child: Column( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: [ + Text( + languageID == + "ar" + ? model.recommendedProductList[index].namen + : model.recommendedProductList[index].name, + style: + TextStyle( + color: + Colors.black, + fontSize: + 13.0, // fontWeight: FontWeight.bold, - ), - ), - Padding( + ), + ), + Padding( // padding: const EdgeInsets.only(top: 15, bottom: 10), - padding: const EdgeInsets.only( - top: 10, bottom: 5), - child: Texts( - "SAR ${model.recommendedProductList[index].price}", - bold: true, - fontSize: 14, - ), - ), - ], - ), - ), - Row( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Container( - padding: - EdgeInsets.only(right: 10), + padding: const EdgeInsets.only( + top: + 10, + bottom: + 5), + child: + Texts( + "SAR ${model.recommendedProductList[index].price}", + bold: + true, + fontSize: + 14, + ), + ), + ], + ), + ), + Row( + crossAxisAlignment: + CrossAxisAlignment + .start, + children: < + Widget>[ + Container( + padding: + EdgeInsets.only(right: 10), // margin: EdgeInsets.only(left: 5), - child: Align( - alignment: Alignment.topLeft, - child: RatingBar.readOnly( - initialRating: model - .recommendedProductList[ - index] - .approvedRatingSum - .toDouble(), + child: + Align( + alignment: + Alignment.topLeft, + child: + RatingBar.readOnly( + initialRating: + model.recommendedProductList[index].approvedRatingSum.toDouble(), // initialRating: productRate, - size: 13.0, - filledColor: - Colors.yellow[700], - emptyColor: Colors.grey[500], - isHalfAllowed: true, - halfFilledIcon: - Icons.star_half, - filledIcon: Icons.star, - emptyIcon: Icons.star, - ), - ), - ), - Texts( - "(${model.recommendedProductList[index].approvedTotalReviews.toString()})", + size: + 13.0, + filledColor: + Colors.yellow[700], + emptyColor: + Colors.grey[500], + isHalfAllowed: + true, + halfFilledIcon: + Icons.star_half, + filledIcon: + Icons.star, + emptyIcon: + Icons.star, + ), + ), + ), + Texts( + "(${model.recommendedProductList[index].approvedTotalReviews.toString()})", // bold: true, - fontSize: 12, + fontSize: + 12, + ), + ]), + ], ), - ]), - ], - ), - ), - ); - }), - ) - : Container( + ), + ); + }), + ) + : Container( // child: Text("NO DATA"), - ), - ) - - ), + ), + )), ), ], ), @@ -1341,8 +1388,10 @@ class footerWidget extends StatefulWidget { final int minQuantity; final int quantityLimit; final PharmacyProduct item; + footerWidget(this.isAvailble, this.maxQuantity, this.minQuantity, this.quantityLimit, this.item); + @override _footerWidgetState createState() => _footerWidgetState(); } @@ -1350,6 +1399,7 @@ class footerWidget extends StatefulWidget { class _footerWidgetState extends State { double quantityUI = 70; bool showUI = false; + @override Widget build(BuildContext context) { return Container( @@ -1752,7 +1802,7 @@ class _footerWidgetState extends State { ) : InkWell( onTap: () { - addToCartFunction(price, widget.item.id); + addToCartFunction(price, widget.item.id, context); }, child: Container( alignment: Alignment.center, @@ -1792,11 +1842,10 @@ class _footerWidgetState extends State { : InkWell( onTap: () { print('buy now'); - addToCartFunction(price, widget.item.id); + addToCartFunction(price, widget.item.id, context); Navigator.push( context, - FadePage(page: - CartOrderPage()), + FadePage(page: CartOrderPage()), ); }, child: Container( @@ -1824,7 +1873,9 @@ class _footerWidgetState extends State { class productNameAndPrice extends StatefulWidget { BuildContext context; PharmacyProduct item; + productNameAndPrice(this.context, this.item); + @override _productNameAndPriceState createState() => _productNameAndPriceState(); } @@ -2014,9 +2065,12 @@ getSpecificationData(itemID) async { specificationData = await x.productSpecificationData(itemID); } -addToCartFunction(quantity, itemID) async { +addToCartFunction(quantity, itemID, BuildContext context) async { + GifLoaderDialogUtils.showMyDialog(context); ProductDetailViewModel x = new ProductDetailViewModel(); - await x.addToCartData(quantity, itemID); + await x.addToCartData(quantity, itemID).then((value) { + GifLoaderDialogUtils.hideDialog(context); + }); } notifyMeWhenAvailable(context, itemId) async { @@ -2071,7 +2125,7 @@ settingModalBottomSheet(context) { title: Text('Add to cart'), onTap: () => { if (price > 0) - {addToCartFunction(price, itemID)} + {addToCartFunction(price, itemID, context)} else { AppToast.showErrorToast( diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart index e0c062fa..7555587a 100644 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-order-preview.dart @@ -4,25 +4,25 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/address-select-page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/payment-method-select-page.dart'; -import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy_module_page.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/widgets/ProductOrderPreviewItem.dart'; import 'package:diplomaticquarterapp/pages/pharmacy/pharmacyAddresses/PharmacyAddresses.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/widgets/data_display/text.dart'; +import 'package:diplomaticquarterapp/widgets/in_app_browser/InAppBrowser.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:flutter/scheduler.dart'; class OrderPreviewPage extends StatelessWidget { final List addresses; OrderPreviewPage(this.addresses); + MyInAppBrowser browser; + @override Widget build(BuildContext context) { final mediaQuery = MediaQuery.of(context); @@ -783,7 +783,9 @@ class PaymentBottomWidget extends StatelessWidget { ? () async { await model.makeOrder(); if (model.state != ViewState.Idle) { - AppToast.showSuccessToast(message: "Order has been placed successfully!!"); + AppToast.showSuccessToast( + message: + "Order has been placed successfully!!"); } else { AppToast.showErrorToast(message: model.error); } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 47c78b79..f5ad16ab 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -1570,6 +1570,7 @@ class TranslationBase { String get shippingAddresss => localizedValues["shipping-address"][locale.languageCode]; String get covidAlert => localizedValues["covid-alert"][locale.languageCode]; + String get pharmacyRelogin => localizedValues["pharmacy-relogin"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate {