From 1b187e6ee0bf0b244d7e0e2b15c963bb01230966 Mon Sep 17 00:00:00 2001 From: "Fatimah.Alshammari" Date: Wed, 16 Sep 2026 09:55:28 +0300 Subject: [PATCH 1/2] fix issues with changing lang --- assets/langs/ar-SA.json | 8 +++- assets/langs/en-US.json | 8 +++- lib/extensions/string_extensions.dart | 29 +++++++++---- lib/generated/locale_keys.g.dart | 5 +++ .../ads_duration_model.dart | 8 ++++ lib/models/general_models/widgets_models.dart | 4 +- .../branch_detail_model.dart | 3 ++ lib/models/services_models/service_model.dart | 4 ++ lib/repositories/branch_repo.dart | 2 +- lib/view_models/ad_view_model.dart | 8 +++- lib/view_models/appointments_view_model.dart | 9 +++- .../ad_review_containers.dart | 2 +- .../ads_detail_view/ads_detail_view.dart | 8 +++- .../ad_duration_selection_sheet.dart | 22 +++++++--- .../advertisement/select_ad_type_view.dart | 2 +- ...appointment_service_pick_bottom_sheet.dart | 41 +++++++++++++++++-- .../common_appointment_slider_widget.dart | 2 +- lib/widgets/dropdown/dropdow_field.dart | 10 +++-- 18 files changed, 145 insertions(+), 30 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index c01586e..69bce63 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -917,5 +917,11 @@ "pleaseSelectAccidentFree": "يرجى تحديد ما إذا كانت المركبة خالية من الحوادث", "pleaseSelectMileageIncrease": "يرجى تحديد ما إذا كان يمكن زيادة المسافة المقطوعة", "formatNeedsUpdate": "تنسيق الاعلان يحتاج الى تحديث", - "noAdsMatchesYourSearch" :"لا توجد اعلانات تطابق بحثك" + "noAdsMatchesYourSearch" :"لا توجد اعلانات تطابق بحثك", + "upgrade": "ترقية", + "downgrade": "تخفيض الباقة", + "current": "الحالية", + "adActiveDuration": "سيبقى إعلانك نشطًا لمدة {} يومًا، وبعد ذلك ستحتاج إلى تمديده ليبقى نشطًا.", + "discountOff": "خصم {}٪" + } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 5ecef33..592d394 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -915,5 +915,11 @@ "pleaseWait": "Please wait...", "numberOfShipping": "Number of Shipping", "formatNeedsUpdate": "Ad format needs to be updated.", - "noAdsMatchesYourSearch": "No Ads that matches your search" + "noAdsMatchesYourSearch": "No Ads that matches your search", + "upgrade": "Upgrade", + "downgrade": "Downgrade", + "current": "Current", + "adActiveDuration": "Your Ad will be active for {} Days and then you will need to extend it to keep it active.", + "discountOff": "{} % OFF" + } \ No newline at end of file diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index fd19104..09b6eec 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -1049,18 +1049,33 @@ extension SubscriptionTypeEnumToInt on SubscriptionTypeEnum { } } -extension SubscriptionTypeEnumToString on SubscriptionTypeEnum { +// extension SubscriptionTypeEnumToString on SubscriptionTypeEnum { +// String getStringSubscriptionTypeEnum() { +// switch (this) { +// case SubscriptionTypeEnum.current: +// return "Current"; +// case SubscriptionTypeEnum.upgrade: +// return "Upgrade"; +// case SubscriptionTypeEnum.downgrade: +// return "Downgrade"; +// +// default: +// return "Current"; +// } +// } +// } + +extension SubscriptionTypeEnumExtension on SubscriptionTypeEnum { String getStringSubscriptionTypeEnum() { switch (this) { case SubscriptionTypeEnum.current: - return "Current"; + return LocaleKeys.current.tr(); + case SubscriptionTypeEnum.upgrade: - return "Upgrade"; - case SubscriptionTypeEnum.downgrade: - return "Downgrade"; + return LocaleKeys.upgrade.tr(); - default: - return "Current"; + case SubscriptionTypeEnum.downgrade: + return LocaleKeys.downgrade.tr(); } } } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 2296673..66bab2e 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -899,5 +899,10 @@ abstract class LocaleKeys { static const pleaseSelectMileageIncrease = 'pleaseSelectMileageIncrease'; static const formatNeedsUpdate = 'formatNeedsUpdate'; static const noAdsMatchesYourSearch = 'noAdsMatchesYourSearch'; + static const upgrade = "upgrade"; + static const downgrade = "downgrade"; + static const current = "current"; + static const adActiveDuration = "adActiveDuration"; + static const discountOff = "discountOff"; } diff --git a/lib/models/advertisment_models/ads_duration_model.dart b/lib/models/advertisment_models/ads_duration_model.dart index c435569..eb9347d 100644 --- a/lib/models/advertisment_models/ads_duration_model.dart +++ b/lib/models/advertisment_models/ads_duration_model.dart @@ -7,6 +7,8 @@ class AdsDurationModel { bool? isActive; String? countryName; String? currency; + String? countryNameN; + String? currencyN; double? discountValue; double? discountPercent; double? priceAfterDiscount; @@ -22,6 +24,8 @@ class AdsDurationModel { this.isActive, this.countryName, this.currency, + this.countryNameN, + this.currencyN, this.discountValue, this.discountPercent, this.priceAfterDiscount, @@ -38,6 +42,8 @@ class AdsDurationModel { isActive = json['isActive']; countryName = json['countryName']; currency = json['currency']; + countryNameN = json['countryNameN']; + currencyN = json['currencyN']; discountValue = json['discountValue']; discountPercent = json['discountPercent']; priceAfterDiscount = json['priceAfterDiscount']; @@ -55,6 +61,8 @@ class AdsDurationModel { data['isActive'] = isActive; data['countryName'] = countryName; data['currency'] = currency; + data['countryNameN'] = countryNameN; + data['currencyN'] = currencyN; data['discountValue'] = discountValue; data['discountPercent'] = discountPercent; data['priceAfterDiscount'] = priceAfterDiscount; diff --git a/lib/models/general_models/widgets_models.dart b/lib/models/general_models/widgets_models.dart index e71290c..d988fd3 100644 --- a/lib/models/general_models/widgets_models.dart +++ b/lib/models/general_models/widgets_models.dart @@ -17,6 +17,7 @@ class SelectionModel { String errorValue; String itemPrice; String currency; + String currencyN; SelectionModel({ this.selectedOption = "", @@ -24,11 +25,12 @@ class SelectionModel { this.selectedId = 0, this.itemPrice = "", this.currency = "", + this.currencyN = "", }); @override String toString() { - return 'SelectionModel{selectedOption: $selectedOption, selectedId: $selectedId, errorValue: $errorValue, itemPrice: $itemPrice, currency: $currency}'; + return 'SelectionModel{selectedOption: $selectedOption, selectedId: $selectedId, errorValue: $errorValue, itemPrice: $itemPrice, currency: $currency, currencyN: $currencyN}'; } } diff --git a/lib/models/provider_branches_models/branch_detail_model.dart b/lib/models/provider_branches_models/branch_detail_model.dart index fe91223..11268fc 100644 --- a/lib/models/provider_branches_models/branch_detail_model.dart +++ b/lib/models/provider_branches_models/branch_detail_model.dart @@ -33,6 +33,7 @@ class BranchDetailModel { bool isExpanded = false; bool? isFavorite; String? cityNameN; + String? countryNameN; BranchDetailModel({ @@ -64,6 +65,7 @@ class BranchDetailModel { this.isFavorite, required this.isExpanded, this.cityNameN, + this.countryNameN, }); List populateBranchImages(value) { @@ -109,6 +111,7 @@ class BranchDetailModel { isExpanded = false; isFavorite = false; cityNameN = json["cityNameN"]; + countryNameN = json["countryNameN"]; } } diff --git a/lib/models/services_models/service_model.dart b/lib/models/services_models/service_model.dart index e6f34a9..472f167 100644 --- a/lib/models/services_models/service_model.dart +++ b/lib/models/services_models/service_model.dart @@ -7,6 +7,7 @@ class ServiceModel { final dynamic providerServiceDescription; final int? categoryId; final String? categoryName; + final String? categoryNameN; final int? serviceId; final String? serviceDescription; final String? serviceDescriptionN; @@ -32,6 +33,7 @@ class ServiceModel { this.providerServiceDescription, this.categoryId, this.categoryName, + this.categoryNameN, this.serviceId, this.serviceDescription, this.serviceDescriptionN, @@ -58,6 +60,7 @@ class ServiceModel { providerServiceDescription: json["providerServiceDescription"], categoryId: json["categoryID"], categoryName: json["categoryName"], + categoryNameN: json["categoryNameN"], serviceId: json["serviceID"], serviceDescription: json["serviceDescription"] ?? json["serviceName"], serviceDescriptionN: json["serviceDescriptionN"] ?? json["serviceNameN"], @@ -89,6 +92,7 @@ class ServiceModel { "providerServiceDescription": providerServiceDescription, "categoryID": categoryId, "categoryName": categoryName, + "categoryNameN": categoryNameN, "serviceID": serviceId, "serviceDescription": serviceDescription, "serviceDescriptionN": serviceDescriptionN, diff --git a/lib/repositories/branch_repo.dart b/lib/repositories/branch_repo.dart index 3f264db..7c4e2fc 100644 --- a/lib/repositories/branch_repo.dart +++ b/lib/repositories/branch_repo.dart @@ -517,7 +517,7 @@ class BranchRepoImp implements BranchRepo { } GenericRespModel adsGenericModel = await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.branchesAndServices, token: appState.getUser.data!.accessToken, queryParameters: postParams); - + print("branchesAndServices response ===== ${adsGenericModel.data}"); return ProviderProfileModel.fromJson(adsGenericModel.data); } diff --git a/lib/view_models/ad_view_model.dart b/lib/view_models/ad_view_model.dart index 3542a72..86f5806 100644 --- a/lib/view_models/ad_view_model.dart +++ b/lib/view_models/ad_view_model.dart @@ -1504,10 +1504,13 @@ class AdVM extends BaseVM { } void showSaveAsDraftConfirmationDialog(BuildContext context, {required VoidCallback onYes, required VoidCallback onNo}) { + final isArabic = AppState().isArabic(context); actionConfirmationBottomSheet( context: context, - title: "Save As Draft".toText(fontSize: 28, isBold: true, letterSpacing: -1.44), - subtitle: "Your ad will be saved as draft and you can continue later from where you left off. Do you want to save and go back?", + title:( isArabic ? "حفظ كمسودة" : "Save As Draft").toText(fontSize: 28, isBold: true, letterSpacing: -1.44), + subtitle: isArabic + ? "سيتم حفظ إعلانك كمسودة، ويمكنك المتابعة لاحقًا من حيث توقفت. هل تريد الحفظ والرجوع؟" + : "Your ad will be saved as draft and you can continue later from where you left off. Do you want to save and go back?", actionButtonYes: Expanded( child: ShowFillButton( maxHeight: 55, @@ -2887,6 +2890,7 @@ class AdVM extends BaseVM { selectedOption: "${vehicleAdsDurations[index].days} Days", itemPrice: vehicleAdsDurations[index].price!.toString(), currency: vehicleAdsDurations[index].currency!.toString(), + currencyN: vehicleAdsDurations[index].currencyN!.toString(), ), ); } diff --git a/lib/view_models/appointments_view_model.dart b/lib/view_models/appointments_view_model.dart index 4cff667..a71476c 100644 --- a/lib/view_models/appointments_view_model.dart +++ b/lib/view_models/appointments_view_model.dart @@ -251,6 +251,7 @@ class AppointmentsVM extends BaseVM { void updateProviderCategoryId(SelectionModel id) { branchSelectedCategoryId = id; getBranchServices(categoryId: branchSelectedCategoryId.selectedId); + print(branchSelectedCategoryId.selectedOption); notifyListeners(); } @@ -1078,8 +1079,14 @@ class AppointmentsVM extends BaseVM { void getBranchCategories() async { for (var value in selectedBranchModel!.branchServices!) { if (!isCategoryAlreadyPresent(value.categoryId!)) { - branchCategories.add(DropValue(value.categoryId!, value.categoryName!, "")); + branchCategories.add(DropValue(value.categoryId!, value.categoryName!, value.categoryNameN ?? "")); } + print("branch ===== $value"); + print("categoryId ===== ${value.categoryId}"); + print("categoryName ===== ${value.categoryName}"); + print("categoryNameN ===== ${value.categoryNameN}"); + print("serviceDescription ===== ${value.serviceDescription}"); + print("serviceDescriptionN ===== ${value.serviceDescriptionN}"); } notifyListeners(); } diff --git a/lib/views/advertisement/ad_creation_steps/ad_review_containers.dart b/lib/views/advertisement/ad_creation_steps/ad_review_containers.dart index 605dd4e..bcc4e2a 100644 --- a/lib/views/advertisement/ad_creation_steps/ad_review_containers.dart +++ b/lib/views/advertisement/ad_creation_steps/ad_review_containers.dart @@ -80,7 +80,7 @@ class VehicleDetailsReview extends StatelessWidget { 16.height, SingleDetailWidget(text: adVM.isAccidentFree ? LocaleKeys.yes.tr() : LocaleKeys.no.tr(), type: LocaleKeys.accidentFree.tr()), 16.height, - SingleDetailWidget(text: "${adVM.odometer} Km", type: LocaleKeys.odometer.tr()), + SingleDetailWidget(text: "${adVM.odometer} ${LocaleKeys.km.tr()}", type: LocaleKeys.odometer.tr()), 16.height, SingleDetailWidget(text: adVM.vehicleVin, type: LocaleKeys.vehicleVIN.tr()), 16.height, diff --git a/lib/views/advertisement/ads_detail_view/ads_detail_view.dart b/lib/views/advertisement/ads_detail_view/ads_detail_view.dart index 0fe45b6..3e9f7d2 100644 --- a/lib/views/advertisement/ads_detail_view/ads_detail_view.dart +++ b/lib/views/advertisement/ads_detail_view/ads_detail_view.dart @@ -93,6 +93,7 @@ class _AdsDetailViewState extends State { Widget buildVehicleDetailsWidget() { bool isArabic = AppState().isArabic(context); + print("====================== ${widget.adDetails.vehicle!.currency }"); return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -202,7 +203,12 @@ class _AdsDetailViewState extends State { crossAxisAlignment: CrossAxisAlignment.end, children: [ widget.adDetails.vehicle!.demandAmount!.toInt().toString().toText(fontSize: 30, height: 1.2, isBold: true), - (widget.adDetails.vehicle!.currency ?? LocaleKeys.sar.tr()).toText(fontSize: 15, color: MyColors.lightTextColor).paddingOnly(bottom: 5), + // (widget.adDetails.vehicle!.currency ?? LocaleKeys.sar.tr()).toText(fontSize: 15, color: MyColors.lightTextColor).paddingOnly(bottom: 5), + ( (isArabic ? widget.adDetails.vehicle!.currencyN : widget.adDetails.vehicle!.currency ) ?? '').toText( + fontSize: 15, + color: MyColors.lightTextColor, + ) + .paddingOnly(bottom: 5), ], ), if (widget.adDetails.adPostStatus == AdPostStatus.expired) ...[ diff --git a/lib/views/advertisement/bottom_sheets/ad_duration_selection_sheet.dart b/lib/views/advertisement/bottom_sheets/ad_duration_selection_sheet.dart index 394d147..ea931da 100644 --- a/lib/views/advertisement/bottom_sheets/ad_duration_selection_sheet.dart +++ b/lib/views/advertisement/bottom_sheets/ad_duration_selection_sheet.dart @@ -47,6 +47,7 @@ class AdDurationSelectionSheet extends StatelessWidget { shrinkWrap: true, itemCount: adVM.vehicleAdsDurations.length, itemBuilder: (BuildContext context, int index) { + bool isArabic = AppState().isArabic(context); AdsDurationModel adDuration = adVM.vehicleAdsDurations[index]; return SizedBox( width: double.infinity, @@ -61,10 +62,16 @@ class AdDurationSelectionSheet extends StatelessWidget { children: [ ("${adDuration.days} ${LocaleKeys.daysVar.tr()}").toString().toText(fontSize: 16, isBold: true), 4.height, - "Your Ad will be active for ${adDuration.days} Days and then you will need to extend it to keep it active. ".toText( + LocaleKeys.adActiveDuration + .tr(args: [adDuration.days.toString()]) + .toText( fontSize: 14, color: MyColors.lightTextColor, ), + // "Your Ad will be active for ${adDuration.days} Days and then you will need to extend it to keep it active. ".toText( + // fontSize: 14, + // color: MyColors.lightTextColor, + // ), 12.height, LocaleKeys.adCharges.tr().toText(fontSize: 14, color: MyColors.lightTextColor, isBold: true), if (adDuration.discountPercent != null && adDuration.discountPercent! > 0.0) ...[ @@ -83,18 +90,21 @@ class AdDurationSelectionSheet extends StatelessWidget { 2.width, Padding( padding: const EdgeInsets.only(bottom: 4), - child: (adDuration.currency ?? LocaleKeys.sar.tr()).toText(fontSize: 10, color: MyColors.lightTextColor, isBold: true), + child: (isArabic ? adDuration.currencyN : adDuration.currency)?.toText(fontSize: 10, color: MyColors.lightTextColor, isBold: true) ), 14.width, "${adDuration.priceAfterDiscount}".toText(fontSize: 20, isBold: true), 2.width, Padding( padding: const EdgeInsets.only(bottom: 4), - child: (adDuration.currency ?? LocaleKeys.sar.tr()).toText(fontSize: 10, color: MyColors.lightTextColor, isBold: true), + // child: (adDuration.currency ?? LocaleKeys.sar.tr()).toText(fontSize: 10, color: MyColors.lightTextColor, isBold: true), + child: (isArabic ? adDuration.currencyN.toString() : adDuration.currency.toString()).toText(fontSize: 10, color: MyColors.lightTextColor, isBold: true), ), ], ), - "${adDuration.discountPercent} % OFF".toText(color: MyColors.white, fontSize: 10).toContainer( + + //"${adDuration.discountPercent} % OFF" + LocaleKeys.discountOff.tr(args: [adDuration.discountPercent.toString()]).toText(color: MyColors.white, fontSize: 10).toContainer( marginAll: 5, paddingAll: 5, borderRadius: 4, @@ -110,7 +120,7 @@ class AdDurationSelectionSheet extends StatelessWidget { 2.width, Padding( padding: const EdgeInsets.only(bottom: 4), - child: (adDuration.currency ?? LocaleKeys.sar.tr()).toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), + child: (isArabic ? adDuration.currencyN.toString() : adDuration.currency.toString()).toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), ), ], ), @@ -142,7 +152,7 @@ class AdDurationSelectionSheet extends StatelessWidget { selectedId: adDuration.id ?? 0, selectedOption: ("${adDuration.days} ${LocaleKeys.daysVar.tr()}"), itemPrice: adDuration.priceAfterDiscount!.toString(), - currency: adDuration.currency!.toString(), + // currency: adDuration.currency!.toString(), ), ); }); diff --git a/lib/views/advertisement/select_ad_type_view.dart b/lib/views/advertisement/select_ad_type_view.dart index 2d68dcd..24c6eb2 100644 --- a/lib/views/advertisement/select_ad_type_view.dart +++ b/lib/views/advertisement/select_ad_type_view.dart @@ -152,7 +152,7 @@ class SelectAdTypeView extends StatelessWidget { 2.width, Padding( padding: const EdgeInsets.only(bottom: 4), - child: adVM.vehicleAdDurationId.currency.toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), + child: (isArabic ? adVM.vehicleAdDurationId.currencyN : adVM.vehicleAdDurationId.currency).toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), ), ], ), diff --git a/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart b/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart index 9fd67d6..8d50215 100644 --- a/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart +++ b/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart @@ -29,7 +29,9 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { @override Widget build(BuildContext context) { + bool isArabic = AppState().isArabic(context); AppointmentsVM appointmentsVM = context.watch(); + print("----------------- ${appointmentsVM.branchCategories.first}"); return SizedBox( height: MediaQuery.of(context).size.height * 0.85, child: Column( @@ -53,13 +55,46 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { children: [ Builder( builder: (context) { - return DropdownField( - (DropValue value) => appointmentsVM.updateProviderCategoryId(SelectionModel(selectedId: value.id, selectedOption: value.value, itemPrice: value.subValue)), + print("isArabic ===== $isArabic"); + + for (var item in appointmentsVM.branchCategories) { + print("id ===== ${item.id}"); + print("value English ===== ${item.value}"); + print("valueN Arabic ===== ${item.valueN}"); + print("subValue Price ===== ${item.subValue}"); + + print( + "Displayed ===== ${isArabic ? (item.valueN ?? item.value) : item.value}", + ); + } + for (var item in appointmentsVM.branchCategories) { + print('id: ${item.id}'); + print('value: ${item.value}'); + print('subValue: ${item.subValue}'); + print("valueN ${item.valueN}"); + } + // return DropdownField( + // (DropValue value) => appointmentsVM.updateProviderCategoryId(SelectionModel(selectedId: value.id, selectedOption: value.value, itemPrice: value.subValue)), + // list: appointmentsVM.branchCategories, + // hint: LocaleKeys.selectCategory.tr(), + // dropdownValue: appointmentsVM.branchSelectedCategoryId.selectedId != -1 + // ? DropValue(appointmentsVM.branchSelectedCategoryId.selectedId, appointmentsVM.branchSelectedCategoryId.selectedOption, "") + // : null, + // ); + return DropdownField((DropValue value) => appointmentsVM.updateProviderCategoryId( + SelectionModel( + selectedId: value.id, + selectedOption: value.value, + itemPrice: value.subValue, + ), + ), list: appointmentsVM.branchCategories, hint: LocaleKeys.selectCategory.tr(), dropdownValue: appointmentsVM.branchSelectedCategoryId.selectedId != -1 - ? DropValue(appointmentsVM.branchSelectedCategoryId.selectedId, appointmentsVM.branchSelectedCategoryId.selectedOption, "") + ? appointmentsVM.branchCategories.firstWhere( + (item) => item.id == appointmentsVM.branchSelectedCategoryId.selectedId,) : null, + isArabic: isArabic, ); }, ), diff --git a/lib/views/appointments/widgets/common_appointment_slider_widget.dart b/lib/views/appointments/widgets/common_appointment_slider_widget.dart index 0a29030..3ea047d 100644 --- a/lib/views/appointments/widgets/common_appointment_slider_widget.dart +++ b/lib/views/appointments/widgets/common_appointment_slider_widget.dart @@ -174,7 +174,7 @@ class AppointmentHomeTileWidget extends StatelessWidget { children: [ !isForProvider ? MyAssets.miniClock.buildSvg(height: 12) : const SizedBox(), 2.width, - "${isForProvider ? LocaleKeys.apptOn.tr() : ""} ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime()}" + "${isForProvider ? LocaleKeys.apptOn.tr() : ""} ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toLocalizedFormattedDateWithoutTime(context)}" .toText(color: MyColors.lightTextColor, fontSize: 12, letterSpacing: -0.48, height: 19 / 12), ], ), diff --git a/lib/widgets/dropdown/dropdow_field.dart b/lib/widgets/dropdown/dropdow_field.dart index 6d3ba97..9b3b809 100644 --- a/lib/widgets/dropdown/dropdow_field.dart +++ b/lib/widgets/dropdown/dropdow_field.dart @@ -12,14 +12,15 @@ class DropValue { String value; String subValue; bool? isEnabled; + String? valueN; - DropValue(this.id, this.value, this.subValue, {this.isEnabled = true}); + DropValue(this.id, this.value, this.subValue, {this.valueN, this.isEnabled = true}); bool operator ==(o) => o is DropValue && o.value == value && o.id == id; @override String toString() { - return 'DropValue{id: $id, value: $value, subValue: $subValue, isEnabled: $isEnabled}'; + return 'DropValue{id: $id, value: $value, subValue: $subValue, valueN: $valueN, isEnabled: $isEnabled}'; } } @@ -33,9 +34,12 @@ class DropdownField extends StatefulWidget { final bool showAppointmentPickerVariant; final TextStyle? textStyle; final bool isSelectAble; + final bool isArabic; + const DropdownField(this.onSelect, - {super.key, this.hint, this.list, this.dropdownValue, this.onTap, this.errorValue = "", this.showAppointmentPickerVariant = false, this.textStyle, this.isSelectAble = true}); + {super.key, this.hint, this.list, this.dropdownValue, this.onTap, this.errorValue = "", this.showAppointmentPickerVariant = false, this.textStyle, this.isSelectAble = true, + this.isArabic = false}); @override State createState() => _DropdownFieldState(); From 3a75781abb909914df35036a23ab8c63c7713c34 Mon Sep 17 00:00:00 2001 From: "Fatimah.Alshammari" Date: Sun, 20 Sep 2026 14:09:49 +0300 Subject: [PATCH 2/2] fix issues with changing lang --- assets/langs/ar-SA.json | 2 +- lib/generated/codegen_loader.g.dart | 20 ++++++++++++++--- lib/generated/locale_keys.g.dart | 10 ++++----- lib/view_models/service_view_model.dart | 1 + ...appointment_service_pick_bottom_sheet.dart | 22 ++++++++++++++----- lib/views/requests/create_request_page.dart | 19 ++++++++++++++-- lib/widgets/dropdown/dropdow_field.dart | 22 +++++++++++++++++-- 7 files changed, 78 insertions(+), 18 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 69bce63..db46675 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -922,6 +922,6 @@ "downgrade": "تخفيض الباقة", "current": "الحالية", "adActiveDuration": "سيبقى إعلانك نشطًا لمدة {} يومًا، وبعد ذلك ستحتاج إلى تمديده ليبقى نشطًا.", - "discountOff": "خصم {}٪" + "discountOff": "خصم {} ٪" } \ No newline at end of file diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index dd0545c..e93ff85 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -613,7 +613,7 @@ class CodegenLoader extends AssetLoader{ "requestAlreadyInProgress": "هذا الطلب قيد التقدم بالفعل.", "acceptOfferConfirmation": "هل تريد قبول هذا العرض؟", "acceptOfferConfirmationMessage": "سيتم قبول هذا العرض وستدفع المبلغ المطلوب للمشتري في وقت معين وإلا سيتم إلغاء هذا العرض.", - "noUpcomingAppointments": "لا مواعيد قادم..", + "noUpcomingAppointments": "لا توجد مواعيد قادمه..", "addNewAppointment": "إضافة موعد جديد", "myNearbyBranches": "فروعي القريبة", "myRecentBranches": "فروعي الأخيرة", @@ -931,7 +931,14 @@ class CodegenLoader extends AssetLoader{ "numberOfShipping": "عدد الشحنات", "loading": "جار التحميل...", "pleaseSelectAccidentFree": "يرجى تحديد ما إذا كانت المركبة خالية من الحوادث", - "pleaseSelectMileageIncrease": "يرجى تحديد ما إذا كان يمكن زيادة المسافة المقطوعة" + "pleaseSelectMileageIncrease": "يرجى تحديد ما إذا كان يمكن زيادة المسافة المقطوعة", + "formatNeedsUpdate": "تنسيق الاعلان يحتاج الى تحديث", + "noAdsMatchesYourSearch": "لا توجد اعلانات تطابق بحثك", + "upgrade": "ترقية", + "downgrade": "تخفيض الباقة", + "current": "الحالية", + "adActiveDuration": "سيبقى إعلانك نشطًا لمدة {} يومًا، وبعد ذلك ستحتاج إلى تمديده ليبقى نشطًا.", + "discountOff": "خصم {} ٪" }; static const Map _en_US = { "firstTimeLogIn": "First Time Log In", @@ -1848,7 +1855,14 @@ static const Map _en_US = { "androidApp": "Android", "iosApp": "iOS", "pleaseWait": "Please wait...", - "numberOfShipping": "Number of Shipping" + "numberOfShipping": "Number of Shipping", + "formatNeedsUpdate": "Ad format needs to be updated.", + "noAdsMatchesYourSearch": "No Ads that matches your search", + "upgrade": "Upgrade", + "downgrade": "Downgrade", + "current": "Current", + "adActiveDuration": "Your Ad will be active for {} Days and then you will need to extend it to keep it active.", + "discountOff": "{} % OFF" }; static const Map> mapLocales = {"ar_SA": _ar_SA, "en_US": _en_US}; } diff --git a/lib/generated/locale_keys.g.dart b/lib/generated/locale_keys.g.dart index 66bab2e..b7239fe 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -899,10 +899,10 @@ abstract class LocaleKeys { static const pleaseSelectMileageIncrease = 'pleaseSelectMileageIncrease'; static const formatNeedsUpdate = 'formatNeedsUpdate'; static const noAdsMatchesYourSearch = 'noAdsMatchesYourSearch'; - static const upgrade = "upgrade"; - static const downgrade = "downgrade"; - static const current = "current"; - static const adActiveDuration = "adActiveDuration"; - static const discountOff = "discountOff"; + static const upgrade = 'upgrade'; + static const downgrade = 'downgrade'; + static const current = 'current'; + static const adActiveDuration = 'adActiveDuration'; + static const discountOff = 'discountOff'; } diff --git a/lib/view_models/service_view_model.dart b/lib/view_models/service_view_model.dart index 836f739..d482db3 100644 --- a/lib/view_models/service_view_model.dart +++ b/lib/view_models/service_view_model.dart @@ -989,3 +989,4 @@ class ServiceVM extends BaseVM { } } } + diff --git a/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart b/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart index 8d50215..487da2f 100644 --- a/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart +++ b/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart @@ -81,20 +81,32 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { // ? DropValue(appointmentsVM.branchSelectedCategoryId.selectedId, appointmentsVM.branchSelectedCategoryId.selectedOption, "") // : null, // ); - return DropdownField((DropValue value) => appointmentsVM.updateProviderCategoryId( + return DropdownField( + (DropValue value) => appointmentsVM.updateProviderCategoryId( SelectionModel( selectedId: value.id, - selectedOption: value.value, - itemPrice: value.subValue, + selectedOption: isArabic + ? (value.subValue ?? value.value) + : value.value, ), ), list: appointmentsVM.branchCategories, hint: LocaleKeys.selectCategory.tr(), - dropdownValue: appointmentsVM.branchSelectedCategoryId.selectedId != -1 + dropdownValue: + appointmentsVM.branchSelectedCategoryId.selectedId != -1 && + appointmentsVM.branchCategories.any( + (item) => + item.id == + appointmentsVM.branchSelectedCategoryId.selectedId, + ) ? appointmentsVM.branchCategories.firstWhere( - (item) => item.id == appointmentsVM.branchSelectedCategoryId.selectedId,) + (item) => + item.id == + appointmentsVM.branchSelectedCategoryId.selectedId, + ) : null, isArabic: isArabic, + useSubValueForArabic: true, ); }, ), diff --git a/lib/views/requests/create_request_page.dart b/lib/views/requests/create_request_page.dart index 14cde30..8652789 100644 --- a/lib/views/requests/create_request_page.dart +++ b/lib/views/requests/create_request_page.dart @@ -69,14 +69,29 @@ class CreateRequestPage extends StatelessWidget { Builder(builder: (context) { List requestTypeDrop = []; for (var element in requestsVM.myRequestsTypeEnum) { - requestTypeDrop.add(DropValue(element.enumValue.toInt() ?? 0, element.enumValueStr ?? "", "")); + requestTypeDrop.add(DropValue(element.enumValue.toInt() ?? 0, element.enumValueStr ?? "", "", + valueN: element.enumValueStrN)); } + print("languge====== ${context.locale.languageCode}"); return DropdownField( - (DropValue value) => requestsVM.updateSelectionRequestTypeId(SelectionModel(selectedId: value.id, selectedOption: value.value)), + (DropValue value + ) { + print( + "========== REQUEST TYPE SELECTED =========="); + print("id: ${value.id}"); + print("value: ${value.value}"); + print("valueN: ${value.valueN}"); + print("subValue: ${value.subValue}"); + requestsVM.updateSelectionRequestTypeId( + SelectionModel(selectedId: value.id, + selectedOption: value.value)); + }, list: requestTypeDrop, dropdownValue: requestsVM.requestTypeId.selectedId != -1 ? DropValue(requestsVM.requestTypeId.selectedId, requestsVM.requestTypeId.selectedOption, "") : null, hint: LocaleKeys.requestType.tr(), errorValue: requestsVM.requestTypeId.errorValue, + isArabic: context.locale.languageCode == "ar", + useValueNForArabic: true, ); }), ], diff --git a/lib/widgets/dropdown/dropdow_field.dart b/lib/widgets/dropdown/dropdow_field.dart index 9b3b809..7bf7f65 100644 --- a/lib/widgets/dropdown/dropdow_field.dart +++ b/lib/widgets/dropdown/dropdow_field.dart @@ -35,11 +35,13 @@ class DropdownField extends StatefulWidget { final TextStyle? textStyle; final bool isSelectAble; final bool isArabic; + final bool useSubValueForArabic; + final bool useValueNForArabic; const DropdownField(this.onSelect, {super.key, this.hint, this.list, this.dropdownValue, this.onTap, this.errorValue = "", this.showAppointmentPickerVariant = false, this.textStyle, this.isSelectAble = true, - this.isArabic = false}); + this.isArabic = false , this.useSubValueForArabic = false, this.useValueNForArabic = false}); @override State createState() => _DropdownFieldState(); @@ -60,6 +62,11 @@ class _DropdownFieldState extends State { @override Widget build(BuildContext context) { dropdownValue = widget.dropdownValue; + + print("========== DROPDOWN VALUE =========="); + print("IsArabic: ${widget.isSelectAble}"); + print("listll: ${widget.list?.length}"); + print("list: ${widget.list}"); return Column( children: [ // Always show hint as label when provided @@ -126,7 +133,18 @@ class _DropdownFieldState extends State { return DropdownMenuItem( value: value, enabled: value.isEnabled ?? true, - child: value.value.toText(fontSize: 15, color: value.isEnabled == false ? MyColors.darkTextColor : null, fontWeight: MyFonts.Medium), + // child: value.value.toText(fontSize: 15, color: value.isEnabled == false ? MyColors.darkTextColor : null, fontWeight: MyFonts.Medium), + child: (widget.isArabic && widget.useValueNForArabic + ? (value.valueN ?? value.value) + : widget.isArabic && widget.useSubValueForArabic + ? value.subValue + : value.value) + .toText( + fontSize: 15, + color: value.isEnabled == false + ? MyColors.darkTextColor + : null, + ), ); }, ).toList(),