From 3a75781abb909914df35036a23ab8c63c7713c34 Mon Sep 17 00:00:00 2001 From: "Fatimah.Alshammari" Date: Sun, 20 Sep 2026 14:09:49 +0300 Subject: [PATCH] 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(),