From 378562b78110ab73331a8bdec5dde4507724aacc Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 7 Dec 2020 15:44:26 +0200 Subject: [PATCH] adding some changes in order pages like translate texts --- lib/config/localized_values.dart | 14 ++- .../pharmacies/screens/cart-order-page.dart | 108 +++++++++--------- .../screens/cart-order-preview.dart | 64 +++++++---- lib/uitl/translations_delegate_base.dart | 8 ++ 4 files changed, 114 insertions(+), 80 deletions(-) diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 15ae4181..c98fbb14 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -669,9 +669,16 @@ const Map localizedValues = { "shippedMethod": {"en": "SHIP BY:", "ar": " الشحن بواسطة:"}, "orderDetail": {"en": "Order Detail", "ar": " تفاصيل الطلب"}, "orderSummary": {"en": "Order Summary", "ar": " تفاصيل المنتج"}, - "subtotal": {"en": "Subtotal", "ar": " المجموع"}, + "subtotal": {"en": "Subtotal", "ar": " المجموع الفرعي"}, "shipping": {"en": "Shipping", "ar": " الشحن"}, + "shipBy": {"en": "SHIP BY:", "ar": "الشحن عن طريق:"}, + "lakumPoints": {"en": "Lakum Points", "ar": "نقاط لكم"}, + "use": {"en": "USE", "ar": "استخدم"}, + "proceedPay": {"en": "PROCEED TO PAY", "ar": "المتابعة للدفع"}, "vat": {"en": "VAT (15%)", "ar": "(15%) القيمة المضافة"}, + "inclusiveVat": {"en": "(inclusive VAT)", "ar": "(شامل الضريبة)"}, + "items": {"en": "item(s)", "ar": "عنصر"}, + "checkOut": {"en": "CHECK OUT", "ar": "الدفع"}, "sar": {"en": "SAR", "ar": " ر.س "}, "payOnline": {"en": "PAY ONLINE", "ar": "اتمام عملية الدفع "}, "cancelOrder": {"en": "CANCEL ORDER", "ar": "الغاء الطلب "}, @@ -1144,4 +1151,9 @@ const Map localizedValues = { "en": "Select Home Health Care Services", "ar": " حدد خدمات الرعاية الصحية المنزلية" }, + "pharmacyServiceTermsCondition": { + "en": "I agree with the terms of service and I adhere to them unconditionally", + "ar": " أوافق على شروط الخدمة وألتزم بها دون قيد أو شرط" + }, + }; diff --git a/lib/pages/pharmacies/screens/cart-order-page.dart b/lib/pages/pharmacies/screens/cart-order-page.dart index d8a274d7..c5576900 100644 --- a/lib/pages/pharmacies/screens/cart-order-page.dart +++ b/lib/pages/pharmacies/screens/cart-order-page.dart @@ -1,6 +1,7 @@ import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/ShoppingCartResponse.dart'; import 'package:diplomaticquarterapp/core/viewModels/pharmacyModule/OrderPreviewViewModel.dart'; +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/pages/base/base_view.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/cart-order-preview.dart'; import 'package:diplomaticquarterapp/pages/pharmacies/screens/pharmacy-terms-conditions-page.dart'; @@ -95,13 +96,13 @@ class CartOrderPage extends StatelessWidget { MainAxisAlignment.spaceBetween, children: [ Texts( - "Subtotal", + TranslationBase.of(context).subtotal, fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), Texts( - "SAR ${(cart.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -120,13 +121,13 @@ class CartOrderPage extends StatelessWidget { MainAxisAlignment.spaceBetween, children: [ Texts( - "VAT (15%)", + "${TranslationBase.of(context).vat}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), Texts( - "SAR ${(cart.subtotalVatAmount).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(cart.subtotalVatAmount).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -151,7 +152,7 @@ class CartOrderPage extends StatelessWidget { fontWeight: FontWeight.bold, ), Texts( - "SAR ${(cart.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, @@ -181,7 +182,9 @@ class CartOrderPage extends StatelessWidget { : Container(), bottomSheet: Container( height: !(model.cartResponse.shoppingCarts == null || - model.cartResponse.shoppingCarts.length == 0) ? height * 0.15 : 0, + model.cartResponse.shoppingCarts.length == 0) + ? height * 0.15 + : 0, color: Colors.white, child: OrderBottomWidget(model.addresses, height), ), @@ -206,6 +209,8 @@ class _OrderBottomWidgetState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); + return Container( margin: EdgeInsets.symmetric(horizontal: 10, vertical: 0), child: Consumer( @@ -238,7 +243,9 @@ class _OrderBottomWidgetState extends State { width: 25.0, height: widget.height * 0.070, decoration: new BoxDecoration( - color: !isAgree ? Color(0xffeeeeee) : Colors.green, + color: !isAgree + ? Color(0xffeeeeee) + : Colors.green, shape: BoxShape.circle, ), child: !isAgree @@ -258,7 +265,8 @@ class _OrderBottomWidgetState extends State { padding: EdgeInsets.symmetric(horizontal: 4), margin: const EdgeInsets.symmetric(vertical: 4), child: Texts( - "I agree with the terms of service and I adhere to them unconditionally", + TranslationBase.of(context) + .pharmacyServiceTermsCondition, fontSize: 13, color: Colors.grey.shade800, fontWeight: FontWeight.normal, @@ -267,10 +275,8 @@ class _OrderBottomWidgetState extends State { ), InkWell( onTap: () => { - Navigator.push( - context, - FadePage( - page: PharmacyTermsConditions())) + Navigator.push(context, + FadePage(page: PharmacyTermsConditions())) }, child: Container( child: Icon( @@ -290,39 +296,43 @@ class _OrderBottomWidgetState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - margin: EdgeInsets.symmetric( - horizontal: 0, vertical: 4), - child: Row( - children: [ - Texts( - "SAR ${(cart.subtotal).toStringAsFixed(2)}", - fontSize: 14, - fontWeight: FontWeight.bold, - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: 4), - child: Texts( - "(inclusive VAT)", - fontSize: 8, - color: Colors.grey, + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.symmetric( + horizontal: 0, vertical: 0), + child: Row( + children: [ + Texts( + "${TranslationBase.of(context).sar} ${(cart.subtotal).toStringAsFixed(2)}", + fontSize: + projectProvider.isArabic ? 12 : 14, fontWeight: FontWeight.bold, ), - ), - ], + Padding( + padding: const EdgeInsets.symmetric( + horizontal: 4), + child: Texts( + "${TranslationBase.of(context).inclusiveVat}", + fontSize: 8, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ), + ], + ), ), - ), - Texts( - "${cart.quantityCount} item(s)", - fontSize: 10, - color: Colors.grey, - fontWeight: FontWeight.bold, - ), - ], + Texts( + "${cart.quantityCount} ${TranslationBase.of(context).items}", + fontSize: 10, + color: Colors.grey, + fontWeight: FontWeight.bold, + ), + ], + ), ), RaisedButton( onPressed: isAgree @@ -335,7 +345,7 @@ class _OrderBottomWidgetState extends State { } : null, child: new Text( - "CHECK OUT", + "${TranslationBase.of(context).checkOut}", style: new TextStyle( color: isAgree ? Colors.white @@ -345,19 +355,9 @@ class _OrderBottomWidgetState extends State { color: Color(0xff005aff), disabledColor: Color(0xff005aff), ), - /* SecondaryButton( - label: "CHECK OUT", - color: Colors.blueAccent, - textColor: Colors.white, - onTap: (() { - Navigator.push( - context, FadePage(page: OrderPreviewPage(widget.addresses))); - }), - disabled: isAgree ? false : true, - )*/ ], ), - ) + ), ], ) : Container(), diff --git a/lib/pages/pharmacies/screens/cart-order-preview.dart b/lib/pages/pharmacies/screens/cart-order-preview.dart index aed2dbc5..39d06ea8 100644 --- a/lib/pages/pharmacies/screens/cart-order-preview.dart +++ b/lib/pages/pharmacies/screens/cart-order-preview.dart @@ -2,6 +2,7 @@ import 'package:diplomaticquarterapp/core/enum/viewstate.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/Addresses.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/payment-checkout-data.dart'; 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'; @@ -22,7 +23,8 @@ class OrderPreviewPage extends StatelessWidget { @override Widget build(BuildContext context) { - PreferredSizeWidget appBarWidget = AppBarWidget("Check out", null, true); + PreferredSizeWidget appBarWidget = + AppBarWidget("${TranslationBase.of(context).checkOut}", null, true); final mediaQuery = MediaQuery.of(context); final height = mediaQuery.size.height - appBarWidget.preferredSize.height - @@ -33,7 +35,7 @@ class OrderPreviewPage extends StatelessWidget { builder: (_, model, wi) => ChangeNotifierProvider.value( value: model.paymentCheckoutData, child: AppScaffold( - title: "Check out", + title: "${TranslationBase.of(context).checkOut}", isShowAppBar: true, isShowDecPage: false, appBarWidget: appBarWidget, @@ -114,13 +116,13 @@ class OrderPreviewPage extends StatelessWidget { MainAxisAlignment.spaceBetween, children: [ Texts( - "Subtotal", + "${TranslationBase.of(context).subtotal}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), Texts( - "SAR ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -139,13 +141,13 @@ class OrderPreviewPage extends StatelessWidget { MainAxisAlignment.spaceBetween, children: [ Texts( - "Shipping", + "${TranslationBase.of(context).shipping}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), Texts( - "SAR ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.totalAdditionalShippingCharge).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -164,13 +166,13 @@ class OrderPreviewPage extends StatelessWidget { MainAxisAlignment.spaceBetween, children: [ Texts( - "VAT (15%)", + "${TranslationBase.of(context).vat}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, ), Texts( - "SAR ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotalVatAmount).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.w500, @@ -195,7 +197,7 @@ class OrderPreviewPage extends StatelessWidget { fontWeight: FontWeight.bold, ), Texts( - "SAR ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", fontSize: 14, color: Colors.black, fontWeight: FontWeight.bold, @@ -215,7 +217,9 @@ class OrderPreviewPage extends StatelessWidget { ), ), bottomSheet: Container( - height: model.cartResponse.shoppingCarts != null ? height * 0.10 : 0, + height: model.cartResponse.shoppingCarts != null + ? height * 0.10 + : 0, color: Colors.white, child: PaymentBottomWidget(model), ), @@ -396,7 +400,7 @@ class _SelectAddressWidgetState extends State { padding: EdgeInsets.symmetric( vertical: 0, horizontal: 6), child: Texts( - "SHIP BY:", + "${TranslationBase.of(context).shipBy}", fontSize: 12, fontWeight: FontWeight.bold, color: Colors.black, @@ -562,6 +566,8 @@ class _LakumWidgetState extends State { @override Widget build(BuildContext context) { + ProjectViewModel projectProvider = Provider.of(context); + return Container( color: Colors.white, padding: EdgeInsets.symmetric(vertical: 12, horizontal: 12), @@ -579,7 +585,7 @@ class _LakumWidgetState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Texts( - "Lakum Points", + "${TranslationBase.of(context).lakumPoints}", fontSize: 12, fontWeight: FontWeight.bold, ), @@ -599,23 +605,27 @@ class _LakumWidgetState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ Texts( - "Riyal", + "${TranslationBase.of(context).riyal}", fontSize: 12, fontWeight: FontWeight.bold, ), Container( - margin: EdgeInsets.only(left: 4), + margin: projectProvider.isArabic ? EdgeInsets.only(right: 4) : EdgeInsets.only(left: 4), width: 60, - height: 40, + height: 50, child: TextField( decoration: InputDecoration( border: OutlineInputBorder( borderSide: BorderSide(color: Colors.black, width: 0.2), gapPadding: 0, - borderRadius: BorderRadius.only( - topLeft: Radius.circular(8), - bottomLeft: Radius.circular(8)), + borderRadius: projectProvider.isArabic + ? BorderRadius.only( + topRight: Radius.circular(8), + bottomRight: Radius.circular(8)) + : BorderRadius.only( + topLeft: Radius.circular(8), + bottomLeft: Radius.circular(8)), ), disabledBorder: OutlineInputBorder( borderSide: @@ -670,12 +680,16 @@ class _LakumWidgetState extends State { ), ), Container( - height: 40, + height: 50, padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12), decoration: new BoxDecoration( color: Color(0xff3666E0), shape: BoxShape.rectangle, - borderRadius: BorderRadius.only( + borderRadius: projectProvider.isArabic + ? BorderRadius.only( + topLeft: Radius.circular(6), + bottomLeft: Radius.circular(6)) + : BorderRadius.only( topRight: Radius.circular(6), bottomRight: Radius.circular(6)), border: Border.fromBorderSide(BorderSide( @@ -684,7 +698,7 @@ class _LakumWidgetState extends State { )), ), child: Texts( - "USE", + "${TranslationBase.of(context).use}", fontSize: 12, color: Colors.white, fontWeight: FontWeight.bold, @@ -727,7 +741,7 @@ class PaymentBottomWidget extends StatelessWidget { child: Row( children: [ Texts( - "SAR ${(model.cartResponse.subtotal).toStringAsFixed(2)}", + "${TranslationBase.of(context).sar} ${(model.cartResponse.subtotal).toStringAsFixed(2)}", fontSize: 14, fontWeight: FontWeight.bold, color: Color(0xff929295), @@ -736,7 +750,7 @@ class PaymentBottomWidget extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 4), child: Texts( - "(inclusive VAT)", + "${TranslationBase.of(context).inclusiveVat}", fontSize: 8, color: Color(0xff929295), fontWeight: FontWeight.w600, @@ -746,7 +760,7 @@ class PaymentBottomWidget extends StatelessWidget { ), ), Texts( - "${model.cartResponse.quantityCount} item(s)", + "${model.cartResponse.quantityCount} ${TranslationBase.of(context).items}", fontSize: 10, color: Colors.grey, fontWeight: FontWeight.bold, @@ -785,7 +799,7 @@ class PaymentBottomWidget extends StatelessWidget { child: Padding( padding: const EdgeInsets.symmetric(vertical: 16), child: new Text( - "PROCEED TO PAY", + "${TranslationBase.of(context).proceedPay}", style: new TextStyle( color: (paymentData.address != null && paymentData.paymentOption != null) diff --git a/lib/uitl/translations_delegate_base.dart b/lib/uitl/translations_delegate_base.dart index 6721824d..0bd2ce60 100644 --- a/lib/uitl/translations_delegate_base.dart +++ b/lib/uitl/translations_delegate_base.dart @@ -735,7 +735,14 @@ class TranslationBase { String get orderDetail => localizedValues['orderDetail'][locale.languageCode]; String get subtotal => localizedValues['subtotal'][locale.languageCode]; String get shipping => localizedValues['shipping'][locale.languageCode]; + String get shipBy => localizedValues['shipBy'][locale.languageCode]; + String get lakumPoints => localizedValues['lakumPoints'][locale.languageCode]; + String get use => localizedValues['use'][locale.languageCode]; + String get proceedPay => localizedValues['proceedPay'][locale.languageCode]; String get vat => localizedValues['vat'][locale.languageCode]; + String get inclusiveVat => localizedValues['inclusiveVat'][locale.languageCode]; + String get items => localizedValues['items'][locale.languageCode]; + String get checkOut => localizedValues['checkOut'][locale.languageCode]; String get total => localizedValues['total'][locale.languageCode]; String get sar => localizedValues['sar'][locale.languageCode]; String get payOnline => localizedValues['payOnline'][locale.languageCode]; @@ -1023,6 +1030,7 @@ class TranslationBase { String get riyal => localizedValues['riyal'][locale.languageCode]; String get termOfService => localizedValues['termOfService'][locale.languageCode]; String get shoppingCart => localizedValues['shoppingCart'][locale.languageCode]; + String get pharmacyServiceTermsCondition => localizedValues['pharmacyServiceTermsCondition'][locale.languageCode]; String get referralStatus => localizedValues['referralStatus'][locale.languageCode];