diff --git a/assets/images/new-design/tamara.png b/assets/images/new-design/tamara.png new file mode 100644 index 00000000..ab58e3ac Binary files /dev/null and b/assets/images/new-design/tamara.png differ diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 4e085e46..334d9646 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -1603,4 +1603,5 @@ const Map localizedValues = { "android-instructions-2": { "en": "Make sure that you have installed your watch related apps from Google PlayStore.", "ar": "تأكد من أنك قمت بتثبيت التطبيقات المتعلقة بالساعات من Google PlayStore." }, "android-instructions-3": { "en": "Make sure that your Smart Watch is connected with the WearOS app & your watch apps.", "ar": "تأكد من أن ساعتك الذكية متصلة بتطبيق WearOS وتطبيقات ساعتك." }, "android-instructions-4": { "en": "Make sure that your smart watch apps are linked/associated with Google Fit App.", "ar": "تأكد من أن تطبيقات ساعتك الذكية مرتبطة / مرتبطة بتطبيق Google Fit." }, "android-instructions-5": { "en": "Make sure that data like heart rate, steps, distance etc. are being shown on your watch app & on Google Fit app & both are in sync.", "ar": "تأكد من عرض بيانات مثل معدل ضربات القلب والخطوات والمسافة وما إلى ذلك على تطبيق الساعة وعلى تطبيق Google Fit وكلاهما في حالة مزامنة." }, + "tamaraInstPlan" : { "en": "Select the tamara installment plan", "ar": "حدد خطة تقسيط تمارة" }, }; diff --git a/lib/core/service/client/base_app_client.dart b/lib/core/service/client/base_app_client.dart index 5abbe81e..dbed0212 100644 --- a/lib/core/service/client/base_app_client.dart +++ b/lib/core/service/client/base_app_client.dart @@ -466,7 +466,7 @@ class BaseAppClient { simplePost( String fullUrl, { - Map body, Map headers, + Map body, Map headers, Function(dynamic response, int statusCode) onSuccess, Function(String error, int statusCode) onFailure, }) async { diff --git a/lib/core/service/packages_offers/PackagesOffersServices.dart b/lib/core/service/packages_offers/PackagesOffersServices.dart index 17abdc05..d05bc274 100644 --- a/lib/core/service/packages_offers/PackagesOffersServices.dart +++ b/lib/core/service/packages_offers/PackagesOffersServices.dart @@ -147,6 +147,18 @@ class OffersAndPackagesServices extends BaseService { var finished = 0; var totalCalls = 3; + + completedAll(){ + + finished++; + if(completion != null && finished == totalCalls) { + _hideLoading(context, showLoading); + completion(); + } + } + + _showLoading(context, showLoading); + final auth_token = await baseAppClient.generatePackagesToken(); if(auth_token == null){ throw 'Something went wrong while authentication, Please try again letter'; @@ -162,18 +174,6 @@ class OffersAndPackagesServices extends BaseService { } } - - completedAll(){ - - finished++; - if(completion != null && finished == totalCalls) { - _hideLoading(context, showLoading); - completion(); - } - } - - _showLoading(context, showLoading); - // Performing Parallel Request on same time // # 1 getBestSellers(request: OffersProductsRequestModel(), context: context, showLoading: false).then((value){ @@ -283,7 +283,7 @@ class OffersAndPackagesServices extends BaseService { var jsonResponse = json.decode(stringResponse); var jsonCartItem = jsonResponse["shopping_carts"][0]; response = ResponseModel(status: true, data: PackagesCartItemsResponseModel.fromJson(jsonCartItem), error: null); - cartItemCount = response.data.quantity.toString(); + cartItemCount = (jsonResponse['count'] ?? 0).toString(); }, onFailure: (String error, int statusCode){ _hideLoading(context, showLoading); @@ -334,19 +334,18 @@ class OffersAndPackagesServices extends BaseService { // -------------------- // Place Order // -------------------- - Future placeOrder({@required Map paymentParams, @required BuildContext context, bool showLoading = true}) async{ + Future placeOrder({@required Map paymentParams, @required BuildContext context, bool showLoading = true}) async{ Future errorThrow; - var jsonBody = { - "order": { - "customer_id" : customer.id, - "billing_address": { - "email": patientUser.emailAddress, - "phone_number": patientUser.mobileNumber - }, - } + Map jsonBody = { + "customer_id" : customer.id, + "billing_address": { + "email": patientUser.emailAddress, + "phone_number": patientUser.mobileNumber + }, }; jsonBody.addAll(paymentParams); + jsonBody = {'order' : jsonBody}; int order_id; _showLoading(context, showLoading); diff --git a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart index 53b4895c..d1219541 100644 --- a/lib/pages/packages_offers/OfferAndPackagesCartPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesCartPage.dart @@ -87,7 +87,7 @@ class _PackagesCartPageState extends State 'Failed to place order, please try again later'); } }).catchError((error) { - utils.Utils.showErrorToast(error); + utils.Utils.showErrorToast(error.toString()); }); } @@ -217,7 +217,7 @@ class _PackagesCartPageState extends State {@required int orderId, @required bool withStatus, dynamic data}) async { viewModel.service.getOrderById(orderId, context: context).then((value) { var heading = withStatus ? "Success" : "Failed"; - var title = "Your order has been placed successfully"; + var title = withStatus ? "Your order has been placed successfully" : "Failed to place your order"; var subTitle = "Order# ${value.data.customOrderNumber}"; Navigator.of(context).pushReplacement(MaterialPageRoute( builder: (context) => PackageOrderCompletedPage( @@ -231,7 +231,7 @@ class _PackagesCartPageState extends State // /* Payment Footer Widgets */ // --------------------------- String _selectedPaymentMethod; -Map _selectedPaymentParams; +Map _selectedPaymentParams; Widget _paymentOptions(BuildContext context, Function(String) onSelected, {PackagesViewModel viewModel}) { double height = 30; @@ -258,7 +258,7 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa Future selectTamaraPaymentOption() async{ final tamara_options = await viewModel.service.getTamaraOptions(context: context, showLoading: true); - final selected = await SingleSelectionDialog(tamara_options, title: 'Select the tamara installment plan').show(context); + final selected = await SingleSelectionDialog(tamara_options, icon: Image.asset('assets/images/new-design/tamara.png'), title: TranslationBase.of(context).tamaraInstPlan).show(context); return selected.name; } @@ -271,13 +271,16 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa mainAxisAlignment: MainAxisAlignment.center, children: [ InkWell( - child: buttonContent(_selectedPaymentMethod == "tamara", 'mada.png'), + child: buttonContent(_selectedPaymentMethod == "tamara", 'tamara.png'), onTap: () async{ final tamara_option = await selectTamaraPaymentOption(); _selectedPaymentParams = {"channel" : "Web", "payment_method_system_name" : "Payments.Tamara", "payment_option" : tamara_option}; onSelected("tamara"); }, ), + SizedBox( + width: 5, + ), InkWell( child: buttonContent(_selectedPaymentMethod == "mada", 'mada.png'), onTap: () { @@ -305,17 +308,17 @@ Widget _paymentOptions(BuildContext context, Function(String) onSelected, {Packa onSelected("mastercard"); }, ), - SizedBox( - width: 5, - ), - InkWell( - child: buttonContent( - _selectedPaymentMethod == "installment", 'installment.png'), - onTap: () { - _selectedPaymentParams = {"payment_method_system_name" : "Payments.PayFort", "payment_option" : "INSTALLMENT"}; - onSelected("installment"); - }, - ), + // SizedBox( + // width: 5, + // ), + // InkWell( + // child: buttonContent( + // _selectedPaymentMethod == "installment", 'installment.png'), + // onTap: () { + // _selectedPaymentParams = {"payment_method_system_name" : "Payments.PayFort", "payment_option" : "INSTALLMENT"}; + // onSelected("installment"); + // }, + // ), ], ), ), diff --git a/lib/pages/packages_offers/OfferAndPackagesPage.dart b/lib/pages/packages_offers/OfferAndPackagesPage.dart index 4005f835..dc5b6584 100644 --- a/lib/pages/packages_offers/OfferAndPackagesPage.dart +++ b/lib/pages/packages_offers/OfferAndPackagesPage.dart @@ -98,7 +98,7 @@ class _PackagesHomePageState extends State with AfterLayoutMix await viewModel.service.addProductToCart(request, context: context).then((response){ appScaffold.appBar.badgeUpdater(viewModel.service.cartItemCount); }).catchError((error) { - utils.Utils.showErrorToast(error); + utils.Utils.showErrorToast(error.toString()); }); } } diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 396afd00..aac73d71 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -2563,6 +2563,8 @@ class TranslationBase { String get androidInstructions3 => localizedValues["android-instructions-3"][locale.languageCode]; String get androidInstructions4 => localizedValues["android-instructions-4"][locale.languageCode]; + + String get tamaraInstPlan => localizedValues["tamaraInstPlan"][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/lib/widgets/dialogs/radio_selection_dialog.dart b/lib/widgets/dialogs/radio_selection_dialog.dart index 4cbfdcc4..7175d6dc 100644 --- a/lib/widgets/dialogs/radio_selection_dialog.dart +++ b/lib/widgets/dialogs/radio_selection_dialog.dart @@ -110,7 +110,7 @@ class RadioSelectionDialogState extends State { Expanded( child: DefaultButton( TranslationBase.of(context).save, - () { + (){ Navigator.pop(context); widget.onValueSelected(selectedIndex); }, diff --git a/lib/widgets/single_selection_dialog.dart b/lib/widgets/single_selection_dialog.dart index b8466b65..155f6394 100644 --- a/lib/widgets/single_selection_dialog.dart +++ b/lib/widgets/single_selection_dialog.dart @@ -13,8 +13,9 @@ import 'package:permission_handler/permission_handler.dart'; class SingleSelectionDialog extends StatefulWidget { final List items; final String title; + final Widget icon; - SingleSelectionDialog(this.items, {Widget icon, @required this.title}); + SingleSelectionDialog(this.items, {@required this.icon, @required this.title}); Future show(BuildContext context) async { return showDialog( @@ -32,6 +33,7 @@ class SingleSelectionDialog extends StatefulWidget { @override _SingleSelectionDialogState createState() => _SingleSelectionDialogState(); + } class _SingleSelectionDialogState extends State { @@ -51,11 +53,12 @@ class _SingleSelectionDialogState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ - Icon( - Icons.notifications_active, - color: Color(0xff2B353E), - size: 50, + + SizedBox( + height: 40, + child: widget.icon, ), + IconButton( icon: Icon(Icons.clear), color: Color(0xff2B353E), @@ -95,33 +98,33 @@ class _SingleSelectionDialogState extends State { } Widget optionList(List options){ - return ListView( - shrinkWrap: true, - children: List.generate(options.length, (index){ - - final opt = options[index]; - return Row( - children: [ - Radio( - value: index, - groupValue: i, - onChanged: (int value) { - setState(() { - i = value; - }); - }, - ), - Text( - opt.toString(), - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - letterSpacing: -0.48, + return ListView.builder( + shrinkWrap: true, + itemCount: options.length, + itemBuilder: (ctx,idx){ + final opt = options[idx]; + return Row( + children: [ + Radio( + value: idx, + groupValue: i, + onChanged: (int value) { + setState(() { + i = value; + }); + }, ), - ), - ], - ); - }), + Text( + opt.toString(), + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.48, + ), + ), + ], + ); + } ); } }