diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 3567120..eb03dca 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -132,14 +132,14 @@ "insert_otp_code": "ادخل الرمز", "type_code": "الرجاء كتابة الرمز الذي أرسلناه إلى", "resend_code": "أعد إرسال الرمز", - "check_code": "التحقق من الشفرة", + "check_code": "التحقق من الرمز", "time_will_expire": "إعادة إرسال الرمز بتنسيق", "sec": "ثانية", "providers": "الموفرون", - "appointments": "تعيينات", + "appointments": "المواعيد", "home": "بيت", "ads": "إعلانات", - "settings": "إعدادات", + "settings": "الإعدادات", "view_all": "مشاهدة الكل", "my_active_Ads": "إعلاناتي النشطة", "recommended_ads": "الإعلانات الموصى بها", @@ -212,8 +212,8 @@ "noItemSelectedYet": "لم يتم تحديد أي عنصر بعد", "totalAdditionalAmount": "إجمالي المبلغ الإضافي", "sar": "ريال سعودي", - "cancel": "يلغي", - "add": "يضيف", + "cancel": "الغاء", + "add": "اضافه", "itemsAddedSuccessfully": "تمت إضافة العناصر بنجاح", "pleaseSelectItems": "يرجى اختيار العناصر", "totalAmount": "المبلغ الإجمالي", @@ -226,10 +226,10 @@ "typeHere": "اكتب هنا...", "pleaseSelectReason": "يرجى تحديد السبب", "noAppointmentFound": "لم يتم العثور على مواعيد", - "slotsOverview": "نظرة عامة على الفتحات", + "slotsOverview": "نظرة عامة على الحجوزات", "empty": "فارغ", "occupied": "محجوز", - "totalSlots": "إجمالي الفتحات", + "totalSlots": "إجمالي الحجوزات", "selectAppointments": "اختيار المواعيد", "appointmentMergeSuccessfully": "دمج المواعيد تم بنجاح", "updateAppointment": "تحديث الموعد", @@ -238,11 +238,11 @@ "appointmentisCompleted": "تم اكتمال الموعد", "workStart": "بدء العمل", "payNow": "ادفع الآن", - "arrived": "وصل", + "arrived": "تم الوصول", "payLater": "ادفع لاحقًا", "complete": "اكتمل", "makeAnOffer": "قدم عرضًا", - "provideOffer": "تقديم العرض", + "provideOffer": "تقديم عرض", "enterAmount": "أدخل المبلغ", "submit": "إرسال", "viewChat": "عرض الدردشة", @@ -406,7 +406,7 @@ "passwordIsStrong": "كلمة المرور الخاصة بك قوية", "passwordVeryStrong": "كلمة المرور الخاصة بك قوية جدًا", "selectDuration": "اختر المدة", - "daysVar": "الأيام", + "daysVar": "يوم", "adCharges": "رسوم الإعلان", "select": "اختر", "deleteAdConfirmation": "هل تريد حذف الإعلان؟", @@ -655,7 +655,7 @@ "servicesNotAvailableHomeLocation": "بعض الخدمات غير متوفرة في الموقع المنزلي.", "additionalChargesNotice": "هذه الرسوم إضافية على رسوم الخدمة الفعلية. قد تختلف الرسوم للعناصر الثقيلة.", "selectServiceLocation": "اختر موقع الخدمة", - "apptOn": "التعيين في", + "apptOn": "الموعد في", "merged": "مُدمج", "date": "التاريخ", "selectAll": "اختر الكل", @@ -817,13 +817,74 @@ "specialRequestsChats": "دردشات الطلبات الخاصة", "selectDeliveryOption": "اختر خيار التوصيل", "deliveryOptions": "خيارات التوصيل", - "selfPickup": "الالتقاط الذاتي", + "selfPickup": "استلام ذاتي", "updateYourLocationInfo": "قم بتحديث معلومات موقعك", "initiateSelfPickup": "بدء الاستلام الذاتي", - "selfPickupStatus": "حالة الالتقاط الذاتي", + "selfPickupStatus": "حالة الاستلام الذاتي", "myDraftAds": "مسودتي للإعلانات", "scheduleDeletedSuccessfully": "تم حذف الجدول بنجاح", "addValidAddress": "رجى إضافة عنوان صالح", - "termsPrivacyPolicy": "الشروط وسياسة الخصوصية" + "termsPrivacyPolicy": "الشروط وسياسة الخصوصية", + "pendingApproval": "قيد الموافقة", + "inReview": "قيد المراجعة", + "rejected": "مرفوض", + "deactivated": "معطل", + "blocked": "محظور", + "allRequests": "جميع الطلبات", + "pending": "قيد الانتظار", + "preparingToCollect": "جاري التحضير للاستلام", + "readyToCollect": "جاهز للاستلام", + "collected": "تم الاستلام", + "initiated": "تم البدء", + "inTransit": "قيد النقل", + "outForDelivery": "قيد التسليم", + "delivered": "تم التسليم", + "negotiate": "تفاوض", + "accepted": "مقبول", + "cancelled": "ملغى", + "loginToAnotherAccount": "تسجيل الدخول إلى حساب آخر", + "silver": "فضي", + "phoneWithoutCountryCode": "رقم الهاتف بدون رمز الدوله", + "sunday": "الأحد", + "monday": "الإثنين", + "tuesday": "الثلاثاء", + "wednesday": "الأربعاء", + "thursday": "الخميس", + "friday": "الجمعة", + "saturday": "السبت", + "adsWith": "الإعلانات:", + "usersWith": "المستخدمون:", + "branchesWith": "الفروع:", + "subscribed": "مشترك", + "expires": "تنتهي", + "renew": "تجديد", + "km": "كم", + "items": "عناصر", + "no_items": "لا توجد عناصر", + "allAds": "جميع الاعلانات", + "reserveCancel": "الغاء الحجز", + "pendingForReview": "قيد المراجعة", + "pendingForPayment": "قيد الدفع", + "rejected_n": "مرفوض", + "canceled": "ملغى", + "pendingForPost": "قيد النشر", + "active_n": "نشط", + "expired_n": "منتهي الصلاحية", + "sold_n": "مباع", + "reserved_n": "محجوز", + "buyingService": "خدمة الشراء", + "deActive": "غير نشط", + "pendingForActive": "قيد التفعيل", + "updateItem": "تحديث العنصر", + "createItem": "إنشاء عنصر", + "pleaseAddAtLeastOneItemImage": "يرجى إضافة صورة واحدة على الأقل للعنصر", + "pleaseAddValidItemName": "يرجى إضافة اسم عنصر صحيح", + "pleaseAddValidItemDescription": "يرجى إضافة وصف عنصر صحيح", + "pleaseAddValidItemPrice": "يرجى إضافة سعر عنصر صحيح", + "remaining": "متبقي", + "month": "شهر", + "currentPackage": "الحزمة الحالية", + "forVar": "لمدة", + "branch": "الفرع" } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 0e72d6e..07b3fbd 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -822,5 +822,66 @@ "myDraftAds": "My Draft Ads", "scheduleDeletedSuccessfully": "The schedule has been deleted successfully", "addValidAddress": "Please add a valid address", - "termsPrivacyPolicy": "Terms & Privacy Policy" + "termsPrivacyPolicy": "Terms & Privacy Policy", + "pendingApproval": "Pending Approval", + "inReview": "In Review", + "rejected": "Rejected", + "deactivated": "Deactivated", + "blocked": "Blocked", + "allRequests": "All Requests", + "pending": "Pending", + "preparingToCollect": "Preparing To Collect", + "readyToCollect": "Ready To Collect", + "collected": "Collected", + "initiated": "Initiated", + "inTransit": "In Transit", + "outForDelivery": "Out For De,livery", + "negotiate": "Negotiate", + "accepted": "Accepted", + "cancelled": "Cancelled", + "delivered": "Delivered", + "loginToAnotherAccount": "Login To Another Account", + "silver": "Silver", + "phoneWithoutCountryCode": "Phone without country code", + "sunday": "Sunday", + "monday": "Monday", + "tuesday": "Tuesday", + "wednesday": "Wednesday", + "thursday": "Thursday", + "friday": "Friday", + "saturday": "Saturday", + "adsWith": "Ads:", + "usersWith": "Users:", + "branchesWith": "Branches:", + "subscribed": "Subscribed", + "expires": "Expires", + "renew": "Renew", + "km": "km", + "items": "items", + "no_items": "No items", + "allAds": "All Ads", + "reserveCancel": "Reserve Cancel", + "pendingForReview": "Pending For Review", + "pendingForPayment": "Pending For Payment", + "rejected_n": "Rejected", + "canceled": "Cancelled", + "pendingForPost": "Pending For Post", + "active_n": "Active", + "expired_n": "Expired", + "sold_n": "Sold", + "reserved_n": "Reserved", + "buyingService": "Buying Service", + "deActive": "De Active", + "pendingForActive": "Pending For Active", + "updateItem": "Update Item", + "createItem": "Create Item", + "pleaseAddAtLeastOneItemImage": "Please add at least one item image", + "pleaseAddValidItemName": "Please add valid item name", + "pleaseAddValidItemDescription": "Please add valid item description", + "pleaseAddValidItemPrice": "Please add valid item price", + "remaining": "remaining", + "month": "Month", + "currentPackage": "Current Package", + "forVar": "for", + "branch": "branch" } \ No newline at end of file diff --git a/lib/classes/app_state.dart b/lib/classes/app_state.dart index ce1bf3f..4785d36 100644 --- a/lib/classes/app_state.dart +++ b/lib/classes/app_state.dart @@ -1,3 +1,4 @@ +import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:mc_common_app/models/general_models/post_params_model.dart'; import 'package:mc_common_app/models/subscriptions_models/provider_subscription_model.dart'; @@ -35,6 +36,9 @@ class AppState { _deviceType = value; } + bool isArabic(BuildContext context) => + Localizations.localeOf(context).languageCode == 'ar'; + AppType currentAppType = AppType.provider; UserType userType = UserType.customer; @@ -66,7 +70,8 @@ class AppState { List? _providerSubscription; - List get getproviderSubscription => _providerSubscription ?? [Subscription(name: "")]; + List get getproviderSubscription => + _providerSubscription ?? [Subscription(name: "")]; set setproviderSubscription(List? value) { _providerSubscription = value; @@ -74,7 +79,8 @@ class AppState { DropValue? _userRegisterCountrySelection; - DropValue get getUserRegisterCountrySelection => _userRegisterCountrySelection!; + DropValue get getUserRegisterCountrySelection => + _userRegisterCountrySelection!; set setUserRegisterCountrySelection(DropValue value) { _userRegisterCountrySelection = value; @@ -87,6 +93,4 @@ class AppState { set setIsViewOnly(bool value) { _isViewOnly = value; } - - } diff --git a/lib/extensions/string_extensions.dart b/lib/extensions/string_extensions.dart index ddfee55..2d2048f 100644 --- a/lib/extensions/string_extensions.dart +++ b/lib/extensions/string_extensions.dart @@ -8,6 +8,8 @@ import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/utils/date_helper.dart'; import 'package:mc_common_app/utils/enums.dart'; +import 'package:easy_localization/easy_localization.dart'; +import 'package:mc_common_app/generated/locale_keys.g.dart'; extension EmailValidator on String { Widget toText( @@ -1075,13 +1077,13 @@ extension RequestDeliveryOptionEnumTosTRINGExt on RequestDeliveryOptionEnum { String getStringFromRequestDeliveryOptionEnum() { switch (this) { case RequestDeliveryOptionEnum.delivery: - return "Delivery"; + return LocaleKeys.delivery.tr(); case RequestDeliveryOptionEnum.selfPickup: - return "Self Pickup"; + return LocaleKeys.selfPickup.tr(); case RequestDeliveryOptionEnum.both: - return "Delivery, Self Pickup"; + return "${LocaleKeys.delivery.tr()}, ${LocaleKeys.selfPickup.tr()}"; default: - return "Self Pickup"; + return LocaleKeys.selfPickup.tr(); } } } diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 48bdef2..420938e 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -148,14 +148,14 @@ class CodegenLoader extends AssetLoader{ "insert_otp_code": "ادخل الرمز", "type_code": "الرجاء كتابة الرمز الذي أرسلناه إلى", "resend_code": "أعد إرسال الرمز", - "check_code": "التحقق من الشفرة", + "check_code": "التحقق من الرمز", "time_will_expire": "إعادة إرسال الرمز بتنسيق", "sec": "ثانية", "providers": "الموفرون", - "appointments": "تعيينات", + "appointments": "المواعيد", "home": "بيت", "ads": "إعلانات", - "settings": "إعدادات", + "settings": "الإعدادات", "view_all": "مشاهدة الكل", "my_active_Ads": "إعلاناتي النشطة", "recommended_ads": "الإعلانات الموصى بها", @@ -228,8 +228,8 @@ class CodegenLoader extends AssetLoader{ "noItemSelectedYet": "لم يتم تحديد أي عنصر بعد", "totalAdditionalAmount": "إجمالي المبلغ الإضافي", "sar": "ريال سعودي", - "cancel": "يلغي", - "add": "يضيف", + "cancel": "الغاء", + "add": "اضافه", "itemsAddedSuccessfully": "تمت إضافة العناصر بنجاح", "pleaseSelectItems": "يرجى اختيار العناصر", "totalAmount": "المبلغ الإجمالي", @@ -242,10 +242,10 @@ class CodegenLoader extends AssetLoader{ "typeHere": "اكتب هنا...", "pleaseSelectReason": "يرجى تحديد السبب", "noAppointmentFound": "لم يتم العثور على مواعيد", - "slotsOverview": "نظرة عامة على الفتحات", + "slotsOverview": "نظرة عامة على الحجوزات", "empty": "فارغ", "occupied": "محجوز", - "totalSlots": "إجمالي الفتحات", + "totalSlots": "إجمالي الحجوزات", "selectAppointments": "اختيار المواعيد", "appointmentMergeSuccessfully": "دمج المواعيد تم بنجاح", "updateAppointment": "تحديث الموعد", @@ -254,11 +254,11 @@ class CodegenLoader extends AssetLoader{ "appointmentisCompleted": "تم اكتمال الموعد", "workStart": "بدء العمل", "payNow": "ادفع الآن", - "arrived": "وصل", + "arrived": "تم الوصول", "payLater": "ادفع لاحقًا", "complete": "اكتمل", "makeAnOffer": "قدم عرضًا", - "provideOffer": "تقديم العرض", + "provideOffer": "تقديم عرض", "enterAmount": "أدخل المبلغ", "submit": "إرسال", "viewChat": "عرض الدردشة", @@ -422,7 +422,7 @@ class CodegenLoader extends AssetLoader{ "passwordIsStrong": "كلمة المرور الخاصة بك قوية", "passwordVeryStrong": "كلمة المرور الخاصة بك قوية جدًا", "selectDuration": "اختر المدة", - "daysVar": "الأيام", + "daysVar": "يوم", "adCharges": "رسوم الإعلان", "select": "اختر", "deleteAdConfirmation": "هل تريد حذف الإعلان؟", @@ -671,7 +671,7 @@ class CodegenLoader extends AssetLoader{ "servicesNotAvailableHomeLocation": "بعض الخدمات غير متوفرة في الموقع المنزلي.", "additionalChargesNotice": "هذه الرسوم إضافية على رسوم الخدمة الفعلية. قد تختلف الرسوم للعناصر الثقيلة.", "selectServiceLocation": "اختر موقع الخدمة", - "apptOn": "التعيين في", + "apptOn": "الموعد في", "merged": "مُدمج", "date": "التاريخ", "selectAll": "اختر الكل", @@ -833,14 +833,75 @@ class CodegenLoader extends AssetLoader{ "specialRequestsChats": "دردشات الطلبات الخاصة", "selectDeliveryOption": "اختر خيار التوصيل", "deliveryOptions": "خيارات التوصيل", - "selfPickup": "الالتقاط الذاتي", + "selfPickup": "الاستلام الذاتي", "updateYourLocationInfo": "قم بتحديث معلومات موقعك", "initiateSelfPickup": "بدء الاستلام الذاتي", - "selfPickupStatus": "حالة الالتقاط الذاتي", + "selfPickupStatus": "حالة الاستلام الذاتي", "myDraftAds": "مسودتي للإعلانات", "scheduleDeletedSuccessfully": "تم حذف الجدول بنجاح", "addValidAddress": "رجى إضافة عنوان صالح", - "termsPrivacyPolicy": "الشروط وسياسة الخصوصية" + "termsPrivacyPolicy": "الشروط وسياسة الخصوصية", + "pendingApproval": "قيد الموافقة", + "inReview": "قيد المراجعة", + "rejected": "مرفوض", + "deactivated": "معطل", + "blocked": "محظور", + "allRequests": "جميع الطلبات", + "pending": "قيد الانتظار", + "preparingToCollect": "جاري التحضير للاستلام", + "readyToCollect": "جاهز للاستلام", + "collected": "تم الاستلام", + "initiated": "تم البدء", + "inTransit": "قيد النقل", + "outForDelivery": "قيد التسليم", + "delivered": "تم التسليم", + "negotiate": "تفاوض", + "accepted": "مقبول", + "cancelled": "ملغى", + "loginToAnotherAccount": "تسجيل الدخول إلى حساب آخر", + "silver": "فضي", + "phoneWithoutCountryCode": "رقم الهاتف بدون رمز الدوله", + "sunday": "الأحد", + "monday": "الإثنين", + "tuesday": "الثلاثاء", + "wednesday": "الأربعاء", + "thursday": "الخميس", + "friday": "الجمعة", + "saturday": "السبت", + "adsWith": "الإعلانات:", + "usersWith": "المستخدمون:", + "branchesWith": "الفروع:", + "subscribed": "مشترك", + "expires": "تنتهي", + "renew": "تجديد", + "km": "كم", + "items": "عناصر", + "no_items": "لا توجد عناصر", + "allAds": "جميع الاعلانات", + "reserveCancel": "الغاء الحجز", + "pendingForReview": "قيد المراجعة", + "pendingForPayment": "قيد الدفع", + "rejected_n": "مرفوض", + "canceled": "ملغى", + "pendingForPost": "قيد النشر", + "active_n": "نشط", + "expired_n": "منتهي الصلاحية", + "sold_n": "مباع", + "reserved_n": "محجوز", + "buyingService": "خدمة الشراء", + "deActive": "غير نشط", + "pendingForActive": "قيد التفعيل", + "updateItem": "تحديث العنصر", + "createItem": "إنشاء عنصر", + "pleaseAddAtLeastOneItemImage": "يرجى إضافة صورة واحدة على الأقل للعنصر", + "pleaseAddValidItemName": "يرجى إضافة اسم عنصر صحيح", + "pleaseAddValidItemDescription": "يرجى إضافة وصف عنصر صحيح", + "pleaseAddValidItemPrice": "يرجى إضافة سعر عنصر صحيح", + "remaining": "متبقي", + "month": "شهر", + "currentPackage": "الحزمة الحالية", + "forVar": "لمدة", + "branch": "الفرع" }; static const Map _en_US = { "firstTimeLogIn": "First Time Log In", @@ -1666,7 +1727,69 @@ static const Map _en_US = { "myDraftAds": "My Draft Ads", "scheduleDeletedSuccessfully": "The schedule has been deleted successfully", "addValidAddress": "Please add a valid address", - "termsPrivacyPolicy": "Terms & Privacy Policy" + "termsPrivacyPolicy": "Terms & Privacy Policy", + "pendingApproval": "Pending Approval", + "inReview": "In Review", + "rejected": "Rejected", + "deactivated": "Deactivated", + "blocked": "Blocked", + "allRequests": "All Requests", + "pending": "Pending", + "preparingToCollect": "Preparing To Collect", + "readyToCollect": "Ready To Collect", + "collected": "Collected", + "initiated": "Initiated", + "inTransit": "In Transit", + "outForDelivery": "Out For De,livery", + "negotiate": "Negotiate", + "accepted": "Accepted", + "cancelled": "Cancelled", + "delivered": "Delivered", + "loginToAnotherAccount": "Login To Another Account", + "silver": "Silver", + "phoneWithoutCountryCode": "Phone without country code", + "sunday": "Sunday", + "monday": "Monday", + "tuesday": "Tuesday", + "wednesday": "Wednesday", + "thursday": "Thursday", + "friday": "Friday", + "saturday": "Saturday", + "adsWith": "Ads:", + "usersWith": "Users:", + "branchesWith": "Branches:", + "subscribed": "Subscribed", + "expires": "Expires", + "renew": "Renew", + "km": "km", + "items": "items", + "no_items": "No items", + "All Ads":"All Ads", + "reserveCancel": " Reserve Cancel", + "pendingForReview": "Pending For Review", + "pendingForPayment": "Pending For Payment", + "rejected_n": "Rejected", + "canceled": "Canceled", + "pendingForPost": "Pending For Post", + "active_n": "Active", + "expired_n": "Expired", + "sold_n": "Sold", + "reserved_n": "Reserved", + "buyingService": "Buying Service", + "deActive": "De Active", + "pendingForActive": "Pending For Active", + "updateItem": "Update Item", + "createItem": "Create Item", + "pleaseAddAtLeastOneItemImage": "Please add at least one item image", + "pleaseAddValidItemName": "Please add valid item name", + "pleaseAddValidItemDescription": "Please add valid item description", + "pleaseAddValidItemPrice": "Please add valid item price", + "remaining": "remaining", + "month": "Month", + "currentPackage": "Current Package", + "forVar": "for", + "branch": "branch", + }; 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 ae088cf..3ed6164 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -806,5 +806,80 @@ abstract class LocaleKeys { static const scheduleDeletedSuccessfully = 'scheduleDeletedSuccessfully'; static const addValidAddress = 'addValidAddress'; static const termsPrivacyPolicy = 'termsPrivacyPolicy'; + static const pendingApproval = 'pendingApproval'; + static const inReview = 'inReview'; + static const rejected = 'rejected'; + static const deactivated = 'deactivated'; + static const blocked = 'blocked'; + static const allRequests = 'allRequests'; + static const pending = 'pending'; + static const preparingToCollect = 'preparingToCollect'; + static const readyToCollect = 'readyToCollect'; + static const collected = 'collected'; + static const initiated = 'initiated'; + static const inTransit = 'inTransit'; + static const outForDelivery = 'outForDelivery'; + static const delivered = 'delivered'; + static const negotiate = 'negotiate'; + static const accepted = 'accepted'; + static const cancelled = 'cancelled'; + static const loginToAnotherAccount = 'loginToAnotherAccount'; + static const silver = 'silver'; + static const phoneWithoutCountryCode = 'phoneWithoutCountryCode'; + static const sunday = 'sunday'; + static const monday = 'monday'; + static const tuesday = 'tuesday'; + static const wednesday = 'wednesday'; + static const thursday = 'thursday'; + static const friday = 'friday'; + static const saturday = 'saturday'; + static const adsWith = 'adsWith'; + static const usersWith = 'usersWith'; + static const branchesWith = 'branchesWith'; + static const subscribed = 'subscribed'; + static const renew = 'renew'; + static const km = 'km'; + static const items = 'items'; + static const no_items = 'no_items'; + static const allAds = 'allAds'; + static const reserveCancel = 'reserveCancel'; + static const pendingForReview = 'pendingForReview'; + static const pendingForPayment = 'pendingForPayment'; + static const rejected_n = 'rejected_n'; + static const cancelled_n = 'cancelled_n'; + static const pendingForPost = 'pendingForPost'; + static const active_n = 'active_n'; + static const expired_n = 'expired_n'; + static const sold_n = 'sold_n'; + static const reserved_n = 'reserved_n'; + static const buyingService = 'buyingService'; + static const deActive = 'deActive'; + static const pendingForActive = 'pendingForActive'; + static const updateItem = 'updateItem'; + static const createItem = 'createItem'; + static const pleaseAddAtLeastOneItemImage = 'pleaseAddAtLeastOneItemImage'; + static const pleaseAddValidItemName = 'pleaseAddValidItemName'; + static const pleaseAddValidItemDescription = 'pleaseAddValidItemDescription'; + static const pleaseAddValidItemPrice = 'pleaseAddValidItemPrice'; + static const remaining = 'remaining'; + static const month = 'month'; + static const currentPackage = 'currentPackage'; + static const forVar = 'forVar'; + static const branch = 'branch'; + + + + + + + + + + + + + + + } diff --git a/lib/models/advertisment_models/ad_details_model.dart b/lib/models/advertisment_models/ad_details_model.dart index 03f340d..8cafcf9 100644 --- a/lib/models/advertisment_models/ad_details_model.dart +++ b/lib/models/advertisment_models/ad_details_model.dart @@ -347,6 +347,7 @@ class Mileage { class ModelYear { int? id; String? label; + String? labelN; ModelYear({this.id, this.label}); diff --git a/lib/models/general_models/enums_model.dart b/lib/models/general_models/enums_model.dart index 77a58df..e46372f 100644 --- a/lib/models/general_models/enums_model.dart +++ b/lib/models/general_models/enums_model.dart @@ -2,6 +2,7 @@ class EnumsModel { int id; int enumTypeId; String enumValueStr; + String enumValueStrN; String enumValueStrDes; int enumValue; bool isActive; @@ -10,6 +11,7 @@ class EnumsModel { required this.id, required this.enumTypeId, required this.enumValueStr, + required this.enumValueStrN, required this.enumValueStrDes, required this.enumValue, required this.isActive, @@ -19,6 +21,7 @@ class EnumsModel { id: json["id"], enumTypeId: json["enumTypeID"], enumValueStr: json["enumValueStr"], + enumValueStrN: json["enumValueStrN"], enumValueStrDes: json["enumValueStrDes"] ?? json["enumValueStr"], enumValue: json["enumValue"], isActive: json["isActive"], @@ -26,6 +29,7 @@ class EnumsModel { @override String toString() { - return 'EnumsModel{id: $id, enumTypeId: $enumTypeId, enumValueStr: $enumValueStr,enumValueStrDes: $enumValueStrDes, enumValue: $enumValue, isActive: $isActive}'; + return 'EnumsModel{id: $id, enumTypeId: $enumTypeId, enumValueStr: $enumValueStr,enumValueStrDes: $enumValueStrDes, enumValue: $enumValue, isActive: $isActive,' + 'enumValueStrN: $enumValueStrN}'; } } diff --git a/lib/models/general_models/widgets_models.dart b/lib/models/general_models/widgets_models.dart index ae5e061..0463729 100644 --- a/lib/models/general_models/widgets_models.dart +++ b/lib/models/general_models/widgets_models.dart @@ -1,10 +1,12 @@ class FilterListModel { String title; + String? titleN; String iconUrl; int id; bool isSelected; - FilterListModel({required this.id, required this.isSelected, this.iconUrl = "", required this.title}); + FilterListModel( + {required this.id, required this.isSelected, this.iconUrl = "", required this.title, this.titleN}); } class SelectionModel { diff --git a/lib/models/setting_utils_models/faqs_model.dart b/lib/models/setting_utils_models/faqs_model.dart index 6ee0944..8d8a3f8 100644 --- a/lib/models/setting_utils_models/faqs_model.dart +++ b/lib/models/setting_utils_models/faqs_model.dart @@ -6,8 +6,11 @@ class FAQsModel { bool? isActive; int? channel; bool? isCollapsed; + String? questionN; + String? answerN; - FAQsModel({this.id, this.question, this.answer, this.sequenceNo, this.isActive, this.channel, this.isCollapsed}); + FAQsModel({this.id, this.question, this.answer, this.sequenceNo, this.isActive, this.channel, this.isCollapsed, + this.questionN, this.answerN, }); FAQsModel.fromJson(Map json) { id = json['id']; @@ -17,6 +20,8 @@ class FAQsModel { isActive = json['isActive']; channel = json['channel']; isCollapsed = false; + questionN = json['questionN']; + answerN = json['answerN']; } Map toJson() { @@ -27,6 +32,8 @@ class FAQsModel { data['sequenceNo'] = sequenceNo; data['isActive'] = isActive; data['channel'] = channel; + data['questionN'] = questionN; + data['answerN'] = answerN; return data; } } diff --git a/lib/repositories/appointment_repo.dart b/lib/repositories/appointment_repo.dart index 4a4d4ef..e5b2808 100644 --- a/lib/repositories/appointment_repo.dart +++ b/lib/repositories/appointment_repo.dart @@ -304,6 +304,8 @@ class AppointmentRepoImp implements AppointmentRepo { queryParameters: params, ApiConsts.customersAppointmentGetByFilters, ); + print("genericRespModel.data ......."); + print(genericRespModel.data); List appointmentList = List.generate(genericRespModel.data.length, (index) => AppointmentListModel.fromJson(genericRespModel.data[index])); return appointmentList; } diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 5e9d335..ca9d93f 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -305,56 +305,55 @@ class Utils { static String getNameByRequestOfferStatusEnum(RequestOfferStatusEnum requestOfferStatusEnum) { switch (requestOfferStatusEnum) { case RequestOfferStatusEnum.offer: - return "Offer"; + return LocaleKeys.offer.tr(); case RequestOfferStatusEnum.negotiate: - return "Negotiate"; + return LocaleKeys.negotiate.tr(); case RequestOfferStatusEnum.accepted: - return "Accepted"; + return LocaleKeys.accepted.tr(); case RequestOfferStatusEnum.rejected: - return "Rejected"; + return LocaleKeys.rejected.tr(); case RequestOfferStatusEnum.cancel: - return "Cancelled"; + return LocaleKeys.cancelled.tr(); } } static String getNameByShippingRequestStatusEnum(ShippingRequestStatusEnum shippingRequestStatusEnum) { switch (shippingRequestStatusEnum) { case ShippingRequestStatusEnum.allRequests: - return "All Requests"; + return LocaleKeys.allRequests.tr(); case ShippingRequestStatusEnum.initiated: - return "Initiated"; + return LocaleKeys.initiated.tr(); case ShippingRequestStatusEnum.inTransit: - return "In Transit"; + return LocaleKeys.inTransit.tr(); case ShippingRequestStatusEnum.outForDelivery: - return "Out For Delivery"; + return LocaleKeys.outForDelivery.tr(); case ShippingRequestStatusEnum.delivered: - return "Delivered"; + return LocaleKeys.delivered.tr(); case ShippingRequestStatusEnum.pending: - return "Pending"; + return LocaleKeys.pending.tr(); } } static String getNameBySelfPickupRequestStatusEnum(SelfPickupRequestStatusEnum selfPickupRequestStatusEnum) { switch (selfPickupRequestStatusEnum) { case SelfPickupRequestStatusEnum.allRequests: - return "All Requests"; + return LocaleKeys.allRequests.tr(); case SelfPickupRequestStatusEnum.pending: - return "Pending"; + return LocaleKeys.pending.tr(); case SelfPickupRequestStatusEnum.preparingToCollect: - return "Preparing To Collect"; + return LocaleKeys.preparingToCollect.tr(); case SelfPickupRequestStatusEnum.readyToCollect: - return "Ready To Collect"; - + return LocaleKeys.readyToCollect.tr(); case SelfPickupRequestStatusEnum.collected: - return "Collected"; + return LocaleKeys.collected.tr(); } } @@ -424,24 +423,44 @@ class Utils { static String getChipStatusTextByBranchStatus(BranchStatusEnum branchStatusEnum) { switch (branchStatusEnum) { case BranchStatusEnum.pending: - return "Pending Approval"; + return LocaleKeys.pendingApproval.tr(); case BranchStatusEnum.review: - return "In Review"; + return LocaleKeys.inReview.tr(); case BranchStatusEnum.rejected: - return "Rejected"; + return LocaleKeys.rejected.tr(); case BranchStatusEnum.deactivated: - return "Deactivated"; + return LocaleKeys.deactivated.tr(); case BranchStatusEnum.blocked: - return "Blocked"; + return LocaleKeys.blocked.tr(); case BranchStatusEnum.approvedOrActive: - return "Active"; + return LocaleKeys.active.tr(); } - } + // static String getChipStatusTextByBranchStatus(BranchStatusEnum branchStatusEnum) { + // switch (branchStatusEnum) { + // case BranchStatusEnum.pending: + // return "Pending Approval"; + // + // case BranchStatusEnum.review: + // return "In Review"; + // + // case BranchStatusEnum.rejected: + // return "Rejected"; + // + // case BranchStatusEnum.deactivated: + // return "Deactivated"; + // + // case BranchStatusEnum.blocked: + // return "Blocked"; + // + // case BranchStatusEnum.approvedOrActive: + // return "Active"; + // } + } static statusContainerChip({ required String text, diff --git a/lib/view_models/ad_view_model.dart b/lib/view_models/ad_view_model.dart index 5e8e536..06479de 100644 --- a/lib/view_models/ad_view_model.dart +++ b/lib/view_models/ad_view_model.dart @@ -2602,7 +2602,7 @@ class AdVM extends BaseVM { autoFillSelectedVehicleType(); autoFillSelectedVehicleAdsDuration(); if (isForDraft) { - autoFillSelectedVehicleAdsDetails(); + autoFillSelectedVehicleAdsDetails(context); } navigateWithName(context, AppRoutes.selectAdTypeView, arguments: [AppState().currentAppType == AppType.provider, isFromExtendAd, previousDetails.id]); } @@ -2679,7 +2679,7 @@ class AdVM extends BaseVM { notifyListeners(); } - void autoFillSelectedVehicleAdsDetails() async { + void autoFillSelectedVehicleAdsDetails(BuildContext context) async { if (vehicleBrands.isEmpty) { await getVehicleBrandsByVehicleTypeId(); } @@ -2688,18 +2688,18 @@ class AdVM extends BaseVM { if (index != -1) { await updateSelectionVehicleBrandId(SelectionModel(selectedId: vehicleBrands[index].id!, selectedOption: vehicleBrands[index].vehicleBrandDescription ?? "")); } - + bool isArabic = AppState().isArabic(context); updateSelectionVehicleModelId(SelectionModel(selectedId: previousAdDetails!.vehicle!.model!.id!, selectedOption: previousAdDetails!.vehicle!.model!.label ?? "")); updateSelectionVehicleModelYearId(SelectionModel(selectedId: previousAdDetails!.vehicle!.modelyear!.id!, selectedOption: previousAdDetails!.vehicle!.modelyear!.label ?? "")); - updateSelectionVehicleColorId(SelectionModel(selectedId: previousAdDetails!.vehicle!.color!.id!, selectedOption: previousAdDetails!.vehicle!.color!.label ?? "")); - updateSelectionVehicleConditionId(SelectionModel(selectedId: previousAdDetails!.vehicle!.condition!.id!, selectedOption: previousAdDetails!.vehicle!.condition!.label ?? "")); - updateSelectionVehicleCategoryId(SelectionModel(selectedId: previousAdDetails!.vehicle!.category!.id!, selectedOption: previousAdDetails!.vehicle!.category!.label ?? "")); + updateSelectionVehicleColorId(SelectionModel(selectedId: previousAdDetails!.vehicle!.color!.id!, selectedOption: isArabic ? previousAdDetails!.vehicle!.color!.labelN.toString() : previousAdDetails!.vehicle!.color!.label ?? "")); + updateSelectionVehicleConditionId(SelectionModel(selectedId: previousAdDetails!.vehicle!.condition!.id!, selectedOption: isArabic ? previousAdDetails!.vehicle!.condition!.labelN.toString() :previousAdDetails!.vehicle!.condition!.label ?? "")); + updateSelectionVehicleCategoryId(SelectionModel(selectedId: previousAdDetails!.vehicle!.category!.id!, selectedOption: isArabic ? previousAdDetails!.vehicle!.category!.labelN.toString() :previousAdDetails!.vehicle!.category!.label ?? "")); updateSelectionVehicleMileageId(SelectionModel( selectedId: previousAdDetails!.vehicle!.mileage!.id!, selectedOption: "${previousAdDetails!.vehicle!.mileage!.mileageStart} - ${previousAdDetails!.vehicle!.mileage!.mileageEnd}", )); - updateSelectionVehicleTransmissionId(SelectionModel(selectedId: previousAdDetails!.vehicle!.transmission!.id!, selectedOption: previousAdDetails!.vehicle!.transmission!.label ?? "")); - updateSelectionVehicleSellerTypeId(SelectionModel(selectedId: previousAdDetails!.vehicle!.sellertype!.id!, selectedOption: previousAdDetails!.vehicle!.sellertype!.label ?? "")); + updateSelectionVehicleTransmissionId(SelectionModel(selectedId: previousAdDetails!.vehicle!.transmission!.id!, selectedOption:isArabic ? previousAdDetails!.vehicle!.transmission!.labelN.toString() : previousAdDetails!.vehicle!.transmission!.label ?? "")); + updateSelectionVehicleSellerTypeId(SelectionModel(selectedId: previousAdDetails!.vehicle!.sellertype!.id!, selectedOption: isArabic ? previousAdDetails!.vehicle!.sellertype!.labelN.toString() :previousAdDetails!.vehicle!.sellertype!.label ?? "")); int indexCountry = vehicleCountries.indexWhere((element) => element.id == previousAdDetails!.vehicle!.countryID); if (indexCountry != -1) { updateSelectionVehicleCountryId(SelectionModel(selectedId: vehicleCountries[indexCountry].id!, selectedOption: vehicleCountries[indexCountry].countryName ?? "")); diff --git a/lib/view_models/appointments_view_model.dart b/lib/view_models/appointments_view_model.dart index b67ca43..fd88b0a 100644 --- a/lib/view_models/appointments_view_model.dart +++ b/lib/view_models/appointments_view_model.dart @@ -52,7 +52,8 @@ class AppointmentsVM extends BaseVM { final BranchRepo branchRepo; final AppointmentRepo appointmentRepo; - AppointmentsVM({required this.commonServices, required this.appointmentRepo, required this.commonRepo, required this.branchRepo}); + AppointmentsVM( + {required this.commonServices, required this.appointmentRepo, required this.commonRepo, required this.branchRepo}); bool isUpcomingEnabled = true; bool isFetchingLists = false; @@ -79,7 +80,8 @@ class AppointmentsVM extends BaseVM { List allSelectedItemsInAppointments = []; bool ifItemAlreadySelected(int id) { - int indexFound = allSelectedItemsInAppointments.indexWhere((element) => element.id == id); + int indexFound = allSelectedItemsInAppointments.indexWhere(( + element) => element.id == id); log("already selected at: $indexFound"); if (indexFound != -1) { return true; @@ -89,7 +91,8 @@ class AppointmentsVM extends BaseVM { Future onItemsSelectedInService() async { if (currentServiceSelection != null) { - int index = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!); + int index = servicesInCurrentAppointment.indexWhere((element) => + element.serviceId == currentServiceSelection!.serviceId!); if (index == -1) { double totalPrice = 0.0; @@ -106,9 +109,12 @@ class AppointmentsVM extends BaseVM { } } - Future onPayNowPressedForAppointment({required BuildContext context, required int appointmentID}) async { - context.read().updateAppointmentIdsForPayment(ids: [appointmentID]); - navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.partialAppointment); + Future onPayNowPressedForAppointment( + {required BuildContext context, required int appointmentID}) async { + context.read().updateAppointmentIdsForPayment( + ids: [appointmentID]); + navigateWithName(context, AppRoutes.paymentMethodsView, + arguments: PaymentTypes.partialAppointment); } Future onBookAppointmentPressed(BuildContext context) async { @@ -116,7 +122,8 @@ class AppointmentsVM extends BaseVM { bool isSuccess = false; List appointmentIdsList = []; try { - GenericRespModel genericRespModel = await appointmentRepo.createServiceAppointment( + GenericRespModel genericRespModel = await appointmentRepo + .createServiceAppointment( schedules: serviceAppointmentScheduleList, serviceProviderID: selectedBranchModel!.serviceProviderId ?? 0, ); @@ -141,13 +148,16 @@ class AppointmentsVM extends BaseVM { } context.read().onNavbarTapped(1); - applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: AppointmentStatusEnum.booked); + applyFilterOnAppointmentsVMForCustomers( + appointmentStatusEnum: AppointmentStatusEnum.booked); Utils.hideLoading(context); resetAfterBookingAppointment(); if (isSuccess) { if (amountToPayForAppointment > 0) { - context.read().updateAppointmentIdsForPayment(ids: appointmentIdsList); - navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.appointment); + context.read().updateAppointmentIdsForPayment( + ids: appointmentIdsList); + navigateWithName(context, AppRoutes.paymentMethodsView, + arguments: PaymentTypes.appointment); } else { Utils.showToast(LocaleKeys.appointmentBookedSuccessfully.tr()); navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard); @@ -158,9 +168,12 @@ class AppointmentsVM extends BaseVM { } } - Future onConfirmAppointmentPressed({required BuildContext context, required appointmentId}) async { - context.read().updateAppointmentIdsForPayment(ids: [appointmentId]); - navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.appointment); + Future onConfirmAppointmentPressed( + {required BuildContext context, required appointmentId}) async { + context.read().updateAppointmentIdsForPayment( + ids: [appointmentId]); + navigateWithName(context, AppRoutes.paymentMethodsView, + arguments: PaymentTypes.appointment); } OfferRequestCommentModel selectedCancelAppointmentReason = OfferRequestCommentModel( @@ -211,23 +224,28 @@ class AppointmentsVM extends BaseVM { } } - Future onCancelAppointmentPressed({required BuildContext context, required AppointmentListModel appointmentListModel}) async { + Future onCancelAppointmentPressed( + {required BuildContext context, required AppointmentListModel appointmentListModel}) async { Utils.showLoading(context); try { - GenericRespModel genericRespModel = await appointmentRepo.cancelOrRescheduleServiceAppointment( + GenericRespModel genericRespModel = await appointmentRepo + .cancelOrRescheduleServiceAppointment( serviceAppointmentID: appointmentListModel.id ?? 0, serviceSlotID: appointmentListModel.serviceSlotID ?? 0, appointmentScheduleAction: 2, // 1 for Reschedule and 2 for Cancel ); - if (genericRespModel.messageStatus == 2 || genericRespModel.data == null) { + if (genericRespModel.messageStatus == 2 || + genericRespModel.data == null) { Utils.hideLoading(context); Utils.showToast(genericRespModel.message.toString()); return; } - if (genericRespModel.messageStatus == 1 && AppState().currentAppType == AppType.customer) { + if (genericRespModel.messageStatus == 1 && + AppState().currentAppType == AppType.customer) { context.read().onNavbarTapped(1); - applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: AppointmentStatusEnum.cancelled); + applyFilterOnAppointmentsVMForCustomers( + appointmentStatusEnum: AppointmentStatusEnum.cancelled); Utils.showToast(genericRespModel.message.toString()); Utils.hideLoading(context); navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard); @@ -246,7 +264,8 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel branchSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel branchSelectedCategoryId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); void updateProviderCategoryId(SelectionModel id) { branchSelectedCategoryId = id; @@ -274,7 +293,8 @@ class AppointmentsVM extends BaseVM { service.servicelocationInfo.latitude = value.latitude; service.servicelocationInfo.longitude = value.longitude; service.servicelocationInfo.distanceToBranch = value.distanceToBranch; - service.servicelocationInfo.homeChargesInCurrentService = double.parse(service.rangePricePerKm ?? "0.0"); + service.servicelocationInfo.homeChargesInCurrentService = + double.parse(service.rangePricePerKm ?? "0.0"); } } @@ -283,7 +303,9 @@ class AppointmentsVM extends BaseVM { void updateBranchServiceId(SelectionModel id) async { branchSelectedServiceId = id; - currentServiceSelection = branchServices.firstWhere((element) => element.serviceProviderServiceId == id.selectedId); + currentServiceSelection = branchServices.firstWhere((element) => + element + .serviceProviderServiceId == id.selectedId); if (currentServiceSelection == null) { return; } @@ -293,13 +315,15 @@ class AppointmentsVM extends BaseVM { return; } if (currentLocationInfoModel != null) { - currentLocationInfoModel!.homeChargesInCurrentService = double.parse(currentServiceSelection!.rangePricePerKm ?? "0.0"); + currentLocationInfoModel!.homeChargesInCurrentService = + double.parse(currentServiceSelection!.rangePricePerKm ?? "0.0"); currentServiceSelection!.servicelocationInfo = CurrentLocationInfoModel( address: currentLocationInfoModel!.address, latitude: currentLocationInfoModel!.latitude, longitude: currentLocationInfoModel!.longitude, distanceToBranch: currentLocationInfoModel!.distanceToBranch, - homeChargesInCurrentService: double.parse(currentServiceSelection!.rangePricePerKm ?? "0.0"), + homeChargesInCurrentService: double.parse( + currentServiceSelection!.rangePricePerKm ?? "0.0"), ); } @@ -307,8 +331,11 @@ class AppointmentsVM extends BaseVM { } void removeServiceInCurrentAppointment(int index) { - int serviceId = servicesInCurrentAppointment.elementAt(index).serviceProviderServiceId ?? -1; - allSelectedItemsInAppointments.removeWhere((element) => element.serviceProviderServiceId == serviceId); + int serviceId = servicesInCurrentAppointment + .elementAt(index) + .serviceProviderServiceId ?? -1; + allSelectedItemsInAppointments.removeWhere((element) => + element.serviceProviderServiceId == serviceId); servicesInCurrentAppointment[index].serviceItems!.clear(); servicesInCurrentAppointment.removeAt(index); notifyListeners(); @@ -316,9 +343,11 @@ class AppointmentsVM extends BaseVM { resetCategorySelectionBottomSheet() { selectedSubServicesCounter = 0; - branchSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + branchSelectedCategoryId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); isHomeTapped = false; - branchSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + branchSelectedServiceId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); currentServiceSelection = null; } @@ -334,7 +363,8 @@ class AppointmentsVM extends BaseVM { servicesInCurrentAppointment.clear(); servicesInCurrentAppointment = []; currentLocationInfoModel = null; - log("here servicesInCurrentAppointment: ${servicesInCurrentAppointment.length}"); + log("here servicesInCurrentAppointment: ${servicesInCurrentAppointment + .length}"); } List myAppointmentsEnum = []; @@ -342,83 +372,111 @@ class AppointmentsVM extends BaseVM { Future populateAppointmentsFilterList() async { if (appointmentsFilterOptions.isNotEmpty) return; - myAppointmentsEnum = await commonRepo.getEnumTypeValues(enumTypeID: AppEnums.appointmentsFilterEnumId); // 13 is to get Appointments Filter Enums + myAppointmentsEnum = await commonRepo.getEnumTypeValues(enumTypeID: AppEnums + .appointmentsFilterEnumId); // 13 is to get Appointments Filter Enums for (int i = 0; i < myAppointmentsEnum.length; i++) { - appointmentsFilterOptions.add(FilterListModel(title: myAppointmentsEnum[i].enumValueStr, isSelected: false, id: myAppointmentsEnum[i].enumValue)); + appointmentsFilterOptions.add(FilterListModel( + title: myAppointmentsEnum[i].enumValueStr, + titleN: myAppointmentsEnum[i].enumValueStrN, + isSelected: false, + id: myAppointmentsEnum[i].enumValue)); } - appointmentsFilterOptions.insert(0, FilterListModel(title: "All Appointments", isSelected: true, id: 0)); + appointmentsFilterOptions.insert( + 0, FilterListModel(title: "All Appointments",titleN: "جميع الفروع", isSelected: true, id: 0)); notifyListeners(); } bool isAppointmentLoading = false; - applyFilterOnAppointmentsVMForProviders({int? branchID, required AppointmentStatusEnum appointmentStatusEnum, bool isNeedCustomerFilter = false, bool shouldPopulateUpcoming = false}) async { + applyFilterOnAppointmentsVMForProviders( + {int? branchID, required AppointmentStatusEnum appointmentStatusEnum, bool isNeedCustomerFilter = false, bool shouldPopulateUpcoming = false}) async { if (appointmentsFilterOptions.isEmpty) return; for (var value in appointmentsFilterOptions) { value.isSelected = false; } - int index = appointmentsFilterOptions.indexWhere((element) => element.id == appointmentStatusEnum.getIdFromAppointmentStatusEnum()); + int index = appointmentsFilterOptions.indexWhere((element) => + element.id == appointmentStatusEnum.getIdFromAppointmentStatusEnum()); appointmentsFilterOptions[index].isSelected = true; isAppointmentLoading = true; notifyListeners(); - myFilteredAppointmentsForProvider = await getAppointmentsBasedOnFiltersForProviders(branchID: branchID ?? selectedBranchIdForAppointments, appointmentStatus: appointmentStatusEnum); + myFilteredAppointmentsForProvider = + await getAppointmentsBasedOnFiltersForProviders( + branchID: branchID ?? selectedBranchIdForAppointments, + appointmentStatus: appointmentStatusEnum); isAppointmentLoading = false; if (shouldPopulateUpcoming) { myUpComingAppointments = myFilteredAppointmentsForProvider .where((element) => - (element.appointmentStatusEnum == AppointmentStatusEnum.booked || element.appointmentStatusEnum == AppointmentStatusEnum.confirmed) && - (DateHelper.parseStringToDate(element.appointmentDate!).isAfter(DateTime.now()))) + (element.appointmentStatusEnum == AppointmentStatusEnum.booked || + element.appointmentStatusEnum == AppointmentStatusEnum.confirmed) && + (DateHelper.parseStringToDate(element.appointmentDate!).isAfter( + DateTime.now()))) .toList(); log("myUpComingAppointments: ${myUpComingAppointments.length}"); } if (isNeedCustomerFilter) { - log("myFilteredAppointmentsForProvider: ${myFilteredAppointmentsForProvider.length}"); + log( + "myFilteredAppointmentsForProvider: ${myFilteredAppointmentsForProvider + .length}"); - myFilteredAppointmentsForProvider = findAppointmentsBasedOnCustomers(myFilteredAppointmentsForProvider); + myFilteredAppointmentsForProvider = + findAppointmentsBasedOnCustomers(myFilteredAppointmentsForProvider); } notifyListeners(); } - applyFilterOnAppointmentsVMForCustomers({required AppointmentStatusEnum appointmentStatusEnum, bool shouldPopulateUpcoming = false}) async { + applyFilterOnAppointmentsVMForCustomers( + {required AppointmentStatusEnum appointmentStatusEnum, bool shouldPopulateUpcoming = false}) async { log("appointmentsFilterOptions: ${appointmentsFilterOptions.isEmpty}"); if (appointmentsFilterOptions.isEmpty) return; for (var value in appointmentsFilterOptions) { value.isSelected = false; } - int index = appointmentsFilterOptions.indexWhere((element) => element.id == appointmentStatusEnum.getIdFromAppointmentStatusEnum()); + int index = appointmentsFilterOptions.indexWhere((element) => + element.id == appointmentStatusEnum.getIdFromAppointmentStatusEnum()); appointmentsFilterOptions[index].isSelected = true; isAppointmentLoading = true; notifyListeners(); - myFilteredAppointmentsForCustomers = await getAppointmentsBasedOnFiltersForCustomer(appointmentStatusEnum: appointmentStatusEnum); + myFilteredAppointmentsForCustomers = + await getAppointmentsBasedOnFiltersForCustomer( + appointmentStatusEnum: appointmentStatusEnum); isAppointmentLoading = false; if (shouldPopulateUpcoming) { myUpComingAppointments = myFilteredAppointmentsForCustomers .where((element) => - (element.appointmentStatusEnum == AppointmentStatusEnum.booked || element.appointmentStatusEnum == AppointmentStatusEnum.confirmed) && - (DateHelper.parseStringToDate(element.appointmentDate!).isAfter(DateTime.now()))) + (element.appointmentStatusEnum == AppointmentStatusEnum.booked || + element.appointmentStatusEnum == AppointmentStatusEnum.confirmed) && + (DateHelper.parseStringToDate(element.appointmentDate!).isAfter( + DateTime.now()))) .toList(); } notifyListeners(); } - List findAppointmentsBasedOnCustomers(List appointments) { + List findAppointmentsBasedOnCustomers( + List appointments) { Set uniqueCustomerIDs = {}; for (var item in appointments) { uniqueCustomerIDs.add(item.customerID ?? 0); } List groupedList = uniqueCustomerIDs.map((id) { - List list = appointments.where((item) => item.customerID == id).toList(); - list.sort((a, b) => DateHelper.parseStringToDate(DateHelper.formatDateT(b.appointmentDate!)) - .millisecondsSinceEpoch - .compareTo(DateHelper.parseStringToDate(DateHelper.formatDateT(a.appointmentDate!)).millisecondsSinceEpoch)); + List list = appointments.where((item) => + item.customerID == id).toList(); + list.sort((a, b) => + DateHelper + .parseStringToDate(DateHelper.formatDateT(b.appointmentDate!)) + .millisecondsSinceEpoch + .compareTo(DateHelper + .parseStringToDate(DateHelper.formatDateT(a.appointmentDate!)) + .millisecondsSinceEpoch)); AppointmentListModel model = list.first; model.customerAppointmentList = list; return model; @@ -435,7 +493,10 @@ class AppointmentsVM extends BaseVM { isSlotsLoading = true; notifyListeners(); try { - GenericRespModel genericRespModel = await appointmentRepo.getAppointmentSlots(branchID: branchID, fromDate: selectedDateForAppointments, toDate: selectedDateForAppointments); + GenericRespModel genericRespModel = await appointmentRepo + .getAppointmentSlots(branchID: branchID, + fromDate: selectedDateForAppointments, + toDate: selectedDateForAppointments); if (genericRespModel.messageStatus == 1) { appointmentSlots = AppointmentSlots.fromJson(genericRespModel.data); } else { @@ -450,10 +511,13 @@ class AppointmentsVM extends BaseVM { } } - Future updateAppointmentStatus({required int appointmentId, required AppointmentStatusEnum appointmentStatusEnum, bool isNeedToRebuild = false}) async { + Future updateAppointmentStatus( + {required int appointmentId, required AppointmentStatusEnum appointmentStatusEnum, bool isNeedToRebuild = false}) async { if (isNeedToRebuild) setState(ViewState.busy); try { - GenericRespModel genericRespModel = await appointmentRepo.updateAppointmentStatus(appointmentId: appointmentId, appointmentStatusEnum: appointmentStatusEnum); + GenericRespModel genericRespModel = await appointmentRepo + .updateAppointmentStatus(appointmentId: appointmentId, + appointmentStatusEnum: appointmentStatusEnum); if (genericRespModel.messageStatus == 1) { Utils.showToast(LocaleKeys.appointmentStatusUpdated.tr()); @@ -468,10 +532,12 @@ class AppointmentsVM extends BaseVM { } } - Future updateAppointmentPaymentStatus(Map map, {bool isNeedToRebuild = false}) async { + Future updateAppointmentPaymentStatus(Map map, + {bool isNeedToRebuild = false}) async { if (isNeedToRebuild) setState(ViewState.busy); try { - GenericRespModel genericRespModel = await appointmentRepo.updateAppointmentPaymentStatus(map); + GenericRespModel genericRespModel = await appointmentRepo + .updateAppointmentPaymentStatus(map); if (genericRespModel.messageStatus == 1) { Utils.showToast(LocaleKeys.paymentStatusUpdated.tr()); @@ -487,16 +553,22 @@ class AppointmentsVM extends BaseVM { } bool isShowMergeButton() { - if (myFilteredAppointmentsForProvider[selectedAppointmentIndex].customerAppointmentList == null) { + if (myFilteredAppointmentsForProvider[selectedAppointmentIndex] + .customerAppointmentList == null) { return false; } - return myFilteredAppointmentsForProvider[selectedAppointmentIndex].customerAppointmentList!.every((appointment) => appointment.appointmentStatusEnum == AppointmentStatusEnum.confirmed) && - myFilteredAppointmentsForProvider[selectedAppointmentIndex].customerAppointmentList!.length > 1; + return myFilteredAppointmentsForProvider[selectedAppointmentIndex] + .customerAppointmentList!.every((appointment) => + appointment.appointmentStatusEnum == AppointmentStatusEnum.confirmed) && + myFilteredAppointmentsForProvider[selectedAppointmentIndex] + .customerAppointmentList!.length > 1; } - Future createMergeAppointment(Map map, {bool isNeedToRebuild = false}) async { + Future createMergeAppointment(Map map, + {bool isNeedToRebuild = false}) async { if (isNeedToRebuild) setState(ViewState.busy); - GenericRespModel genericRespModel = await appointmentRepo.createMergeAppointment(map); + GenericRespModel genericRespModel = await appointmentRepo + .createMergeAppointment(map); return genericRespModel; } @@ -504,10 +576,14 @@ class AppointmentsVM extends BaseVM { bool inNeedToEnableMergeButton = false; void updateCheckBoxInMergeRequest(int currentIndex) { - myFilteredAppointmentsForProvider[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected = - !(myFilteredAppointmentsForProvider[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false); - - int count = countSelected(myFilteredAppointmentsForProvider[selectedAppointmentIndex].customerAppointmentList ?? []); + myFilteredAppointmentsForProvider[selectedAppointmentIndex] + .customerAppointmentList![currentIndex].isSelected = + !(myFilteredAppointmentsForProvider[selectedAppointmentIndex] + .customerAppointmentList?[currentIndex].isSelected ?? false); + + int count = countSelected( + myFilteredAppointmentsForProvider[selectedAppointmentIndex] + .customerAppointmentList ?? []); if (count > 1) { inNeedToEnableMergeButton = true; } else { @@ -517,35 +593,52 @@ class AppointmentsVM extends BaseVM { } int countSelected(List appointments) { - return appointments.where((appointment) => appointment.isSelected == true).toList().length; + return appointments + .where((appointment) => appointment.isSelected == true) + .toList() + .length; } - updateSelectedAppointmentDate({required int dateIndex, required int scheduleIndex}) { - for (var element in serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList!) { + updateSelectedAppointmentDate( + {required int dateIndex, required int scheduleIndex}) { + for (var element in serviceAppointmentScheduleList[scheduleIndex] + .customTimeDateSlotList!) { element.date!.isSelected = false; } - serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].date!.isSelected = true; + serviceAppointmentScheduleList[scheduleIndex] + .customTimeDateSlotList![dateIndex].date!.isSelected = true; serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex = dateIndex; final date = TimeSlotModel( - date: serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].date!.date, - slotId: serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].date!.slotId, + date: serviceAppointmentScheduleList[scheduleIndex] + .customTimeDateSlotList![dateIndex].date!.date, + slotId: serviceAppointmentScheduleList[scheduleIndex] + .customTimeDateSlotList![dateIndex].date!.slotId, isSelected: true, slot: "", ); - serviceAppointmentScheduleList[scheduleIndex].selectedCustomTimeDateSlotModel = CustomTimeDateSlotModel(date: date); + serviceAppointmentScheduleList[scheduleIndex] + .selectedCustomTimeDateSlotModel = CustomTimeDateSlotModel(date: date); notifyListeners(); } - updateSelectedAppointmentSlotByDate({required int scheduleIndex, required int slotIndex}) { - for (var element in serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList!) { + updateSelectedAppointmentSlotByDate( + {required int scheduleIndex, required int slotIndex}) { + for (var element in serviceAppointmentScheduleList[scheduleIndex] + .customTimeDateSlotList!) { for (var element in element.availableSlots!) { element.isSelected = false; } } - int dateIndex = serviceAppointmentScheduleList[scheduleIndex].selectedDateIndex!; - serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].availableSlots![slotIndex].isSelected = true; - serviceAppointmentScheduleList[scheduleIndex].selectedCustomTimeDateSlotModel!.availableSlots = serviceAppointmentScheduleList[scheduleIndex].customTimeDateSlotList![dateIndex].availableSlots!; + int dateIndex = serviceAppointmentScheduleList[scheduleIndex] + .selectedDateIndex!; + serviceAppointmentScheduleList[scheduleIndex] + .customTimeDateSlotList![dateIndex].availableSlots![slotIndex] + .isSelected = true; + serviceAppointmentScheduleList[scheduleIndex] + .selectedCustomTimeDateSlotModel!.availableSlots = + serviceAppointmentScheduleList[scheduleIndex] + .customTimeDateSlotList![dateIndex].availableSlots!; notifyListeners(); } @@ -559,7 +652,8 @@ class AppointmentsVM extends BaseVM { int selectedSubServicesCounter = 0; void onItemUpdateOrSelected(int index, bool selected, int itemId) { - int serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!); + int serviceIndex = servicesInCurrentAppointment.indexWhere(( + element) => element.serviceId == currentServiceSelection!.serviceId!); serviceItemsFromApi[index].isUpdateOrSelected = selected; serviceItemsFromApi[index].isHomeSelected = isHomeTapped; @@ -576,18 +670,27 @@ class AppointmentsVM extends BaseVM { if (serviceIndex != -1) { // servicesInCurrentAppointment[serviceIndex].serviceItems!.add(serviceItemsFromApi[index]); servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = - servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0"); + servicesInCurrentAppointment[serviceIndex] + .currentTotalServicePrice + + double.parse((serviceItemsFromApi[index].price) ?? "0.0"); } } } else { selectedSubServicesCounter = selectedSubServicesCounter - 1; - currentServiceSelection!.serviceItems!.removeWhere((element) => element.id == itemId); - allSelectedItemsInAppointments.removeWhere((element) => element.id == itemId); + currentServiceSelection!.serviceItems!.removeWhere((element) => + element.id == itemId); + allSelectedItemsInAppointments.removeWhere((element) => + element.id == itemId); if (serviceIndex != -1) { servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = - servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0"); - if (servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice < 0.0) { - servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice * -1; + servicesInCurrentAppointment[serviceIndex] + .currentTotalServicePrice - + double.parse((serviceItemsFromApi[index].price) ?? "0.0"); + if (servicesInCurrentAppointment[serviceIndex] + .currentTotalServicePrice < 0.0) { + servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = + servicesInCurrentAppointment[serviceIndex] + .currentTotalServicePrice * -1; } // servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId); } @@ -603,14 +706,16 @@ class AppointmentsVM extends BaseVM { } branchesCategoriesFilterOptions[index].isSelected = true; - await getBranchesBasedOnCategoryFilters(serviceId: branchesCategoriesFilterOptions[index].id); + await getBranchesBasedOnCategoryFilters( + serviceId: branchesCategoriesFilterOptions[index].id); notifyListeners(); } Future> getServiceItems({required int serviceId}) async { setState(ViewState.busy); serviceItemsFromApi.clear(); - serviceItemsFromApi = await branchRepo.getServiceItems(serviceId: serviceId); + serviceItemsFromApi = + await branchRepo.getServiceItems(serviceId: serviceId); selectedSubServicesCounter = 0; for (var item in serviceItemsFromApi) { if (ifItemAlreadySelected(item.id!)) { @@ -625,7 +730,8 @@ class AppointmentsVM extends BaseVM { String pickHomeLocationError = ""; String selectSubServicesError = ""; - SelectionModel branchSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel branchSelectedServiceId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); void updatePickHomeLocationError(String value) { pickHomeLocationError = value; @@ -638,7 +744,8 @@ class AppointmentsVM extends BaseVM { } if (isHomeTapped) { - if (currentLocationInfoModel == null || currentLocationInfoModel!.address == "") { + if (currentLocationInfoModel == null || + currentLocationInfoModel!.address == "") { updatePickHomeLocationError(GlobalConsts.homeLocationEmptyError); return false; } @@ -665,7 +772,8 @@ class AppointmentsVM extends BaseVM { return totalPrice.toString(); } - void openTheAddServiceBottomSheet(BuildContext context, AppointmentsVM appointmentsVM) { + void openTheAddServiceBottomSheet(BuildContext context, + AppointmentsVM appointmentsVM) { showModalBottomSheet( context: context, isScrollControlled: true, @@ -676,16 +784,22 @@ class AppointmentsVM extends BaseVM { ); } - void priceBreakDownClicked(BuildContext context, ServiceModel selectedService) { + void priceBreakDownClicked(BuildContext context, + ServiceModel selectedService) { showModalBottomSheet( context: context, isScrollControlled: true, enableDrag: true, builder: (BuildContext context) { - double totalKms = double.parse(selectedService.servicelocationInfo.distanceToBranch.toStringAsFixed(2)); - double pricePerKm = double.parse(selectedService.servicelocationInfo.homeChargesInCurrentService.toStringAsFixed(2)); + double totalKms = double.parse( + selectedService.servicelocationInfo.distanceToBranch + .toStringAsFixed(2)); + double pricePerKm = double.parse( + selectedService.servicelocationInfo.homeChargesInCurrentService + .toStringAsFixed(2)); return InfoBottomSheet( - title: LocaleKeys.chargesBreakdown.tr().toText(fontSize: 24, isBold: true), + title: LocaleKeys.chargesBreakdown.tr().toText( + fontSize: 24, isBold: true), description: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -693,36 +807,49 @@ class AppointmentsVM extends BaseVM { Column( children: List.generate( selectedService.serviceItems!.length, - (index) => Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - "${selectedService.serviceItems![index].name}".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), - "${selectedService.serviceItems![index].price} ${LocaleKeys.sar.tr()}".toText(fontSize: 12, isBold: true), - ], - ), + (index) => + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + "${selectedService.serviceItems![index].name}" + .toText(fontSize: 12, + color: MyColors.lightTextColor, + isBold: true), + "${selectedService.serviceItems![index] + .price} ${LocaleKeys.sar.tr()}".toText( + fontSize: 12, isBold: true), + ], + ), ), ), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - "${selectedService.currentTotalServicePrice} ${LocaleKeys.sar.tr()}".toText(fontSize: 16, isBold: true), + "${selectedService.currentTotalServicePrice} ${LocaleKeys + .sar.tr()}".toText(fontSize: 16, isBold: true), ], ), if (selectedService.isHomeSelected) ...[ 20.height, - LocaleKeys.homeLocation.tr().toText(fontSize: 16, isBold: true), + LocaleKeys.homeLocation.tr().toText( + fontSize: 16, isBold: true), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - "${totalKms}km ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), - "$pricePerKm x $totalKms".toText(fontSize: 12, isBold: true), + "${totalKms}km ".toText(fontSize: 12, + color: MyColors.lightTextColor, + isBold: true), + "$pricePerKm x $totalKms".toText( + fontSize: 12, isBold: true), ], ), 8.height, Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - "${((pricePerKm) * totalKms).toStringAsFixed(2)} ${LocaleKeys.sar.tr()}".toText(fontSize: 16, isBold: true), + "${((pricePerKm) * totalKms).toStringAsFixed( + 2)} ${LocaleKeys.sar.tr()}".toText( + fontSize: 16, isBold: true), ], ), ], @@ -730,14 +857,21 @@ class AppointmentsVM extends BaseVM { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - LocaleKeys.totalAmount.tr().toText(fontSize: 16, isBold: true), + LocaleKeys.totalAmount.tr().toText( + fontSize: 16, isBold: true), Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ - (selectedService.isHomeSelected ? ((selectedService.currentTotalServicePrice) + (pricePerKm * totalKms)).toStringAsFixed(2) : "${selectedService.currentTotalServicePrice}") + (selectedService.isHomeSelected + ? ((selectedService.currentTotalServicePrice) + + (pricePerKm * totalKms)).toStringAsFixed(2) + : "${selectedService.currentTotalServicePrice}") .toText(fontSize: 29, isBold: true), 2.width, - LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5), + LocaleKeys.sar.tr().toText( + color: MyColors.lightTextColor, + fontSize: 16, + isBold: true).paddingOnly(bottom: 5), ], ) ], @@ -757,7 +891,8 @@ class AppointmentsVM extends BaseVM { isValidated = false; break; } - if (schedule.selectedCustomTimeDateSlotModel!.date == null || !schedule.selectedCustomTimeDateSlotModel!.date!.isSelected) { + if (schedule.selectedCustomTimeDateSlotModel!.date == null || + !schedule.selectedCustomTimeDateSlotModel!.date!.isSelected) { isValidated = false; break; } else { @@ -765,7 +900,8 @@ class AppointmentsVM extends BaseVM { isValidated = false; break; } else { - TimeSlotModel slot = schedule.selectedCustomTimeDateSlotModel!.availableSlots!.firstWhere((element) => element.isSelected); + TimeSlotModel slot = schedule.selectedCustomTimeDateSlotModel! + .availableSlots!.firstWhere((element) => element.isSelected); if (slot.date.isNotEmpty) { isValidated = true; break; @@ -797,7 +933,8 @@ class AppointmentsVM extends BaseVM { } } - serviceAppointmentScheduleList = await appointmentRepo.mergeServiceIntoAvailableSchedules( + serviceAppointmentScheduleList = + await appointmentRepo.mergeServiceIntoAvailableSchedules( serviceItemIdsForHome: serviceItemIdsForHome, serviceItemIdsForWorkshop: serviceItemIdsForWorkshop, ); @@ -810,30 +947,44 @@ class AppointmentsVM extends BaseVM { totalAmount = 0.0; amountToPayForAppointment = 0.0; for (var schedule in serviceAppointmentScheduleList) { - amountToPayForAppointment = amountToPayForAppointment + (schedule.amountToPay ?? 0.0); + amountToPayForAppointment = + amountToPayForAppointment + (schedule.amountToPay ?? 0.0); totalAmount = totalAmount + (schedule.amountTotal ?? 0.0); for (var service in schedule.servicesListInAppointment!) { - int index = servicesInCurrentAppointment.indexWhere((element) => element.serviceProviderServiceId == service.serviceProviderServiceId); + int index = servicesInCurrentAppointment.indexWhere((element) => + element.serviceProviderServiceId == service.serviceProviderServiceId); if (index != -1) { if (servicesInCurrentAppointment[index].isHomeSelected) { - service.servicelocationInfo = servicesInCurrentAppointment[index].servicelocationInfo; - schedule.locationInfoModel = servicesInCurrentAppointment[index].servicelocationInfo; + service.servicelocationInfo = + servicesInCurrentAppointment[index].servicelocationInfo; + schedule.locationInfoModel = + servicesInCurrentAppointment[index].servicelocationInfo; totalAmount = - totalAmount + ((servicesInCurrentAppointment[index].servicelocationInfo.distanceToBranch) * servicesInCurrentAppointment[index].servicelocationInfo.homeChargesInCurrentService); + totalAmount + + ((servicesInCurrentAppointment[index].servicelocationInfo + .distanceToBranch) * + servicesInCurrentAppointment[index].servicelocationInfo + .homeChargesInCurrentService); schedule.totalLocationCharges = schedule.totalLocationCharges! + - (servicesInCurrentAppointment[index].servicelocationInfo.distanceToBranch * servicesInCurrentAppointment[index].servicelocationInfo.homeChargesInCurrentService); + (servicesInCurrentAppointment[index].servicelocationInfo + .distanceToBranch * + servicesInCurrentAppointment[index].servicelocationInfo + .homeChargesInCurrentService); } } } } Utils.hideLoading(context); - navigateWithName(context, AppRoutes.bookAppointmenSchedulesView, arguments: ScreenArgumentsForAppointmentDetailPage(routeFlag: 1, appointmentId: 0)); // 1 For Creating an Appointment + navigateWithName(context, AppRoutes.bookAppointmenSchedulesView, + arguments: ScreenArgumentsForAppointmentDetailPage( + routeFlag: 1, appointmentId: 0)); // 1 For Creating an Appointment notifyListeners(); } - Future onRescheduleAppointmentPressed({required BuildContext context, required AppointmentListModel appointmentListModel}) async { + Future onRescheduleAppointmentPressed( + {required BuildContext context, required AppointmentListModel appointmentListModel}) async { Utils.showLoading(context); List serviceItemIdsForHome = []; @@ -850,7 +1001,8 @@ class AppointmentsVM extends BaseVM { } } - serviceAppointmentScheduleList = await appointmentRepo.mergeServiceIntoAvailableSchedules( + serviceAppointmentScheduleList = + await appointmentRepo.mergeServiceIntoAvailableSchedules( serviceItemIdsForHome: serviceItemIdsForHome, serviceItemIdsForWorkshop: serviceItemIdsForWorkshop, ); @@ -865,22 +1017,26 @@ class AppointmentsVM extends BaseVM { navigateWithName( context, AppRoutes.bookAppointmenSchedulesView, - arguments: ScreenArgumentsForAppointmentDetailPage(routeFlag: 2, appointmentId: appointmentListModel.id ?? 0), + arguments: ScreenArgumentsForAppointmentDetailPage( + routeFlag: 2, appointmentId: appointmentListModel.id ?? 0), ); // 2 For Rescheduling an Appointment notifyListeners(); } - Future onRescheduleAppointmentConfirmPressed({required BuildContext context, required int appointmentId, required int selectedSlotId}) async { + Future onRescheduleAppointmentConfirmPressed( + {required BuildContext context, required int appointmentId, required int selectedSlotId}) async { Utils.showLoading(context); try { - GenericRespModel genericRespModel = await appointmentRepo.cancelOrRescheduleServiceAppointment( + GenericRespModel genericRespModel = await appointmentRepo + .cancelOrRescheduleServiceAppointment( serviceAppointmentID: appointmentId, serviceSlotID: selectedSlotId, appointmentScheduleAction: 1, // 1 for Reschedule and 2 for Cancel ); - if (genericRespModel.messageStatus == 2 || genericRespModel.data == null) { + if (genericRespModel.messageStatus == 2 || + genericRespModel.data == null) { Utils.hideLoading(context); Utils.showToast(genericRespModel.message.toString()); return; @@ -888,7 +1044,8 @@ class AppointmentsVM extends BaseVM { if (genericRespModel.messageStatus == 1) { context.read().onNavbarTapped(1); Utils.showToast(genericRespModel.message.toString()); - applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: AppointmentStatusEnum.cancelled); + applyFilterOnAppointmentsVMForCustomers( + appointmentStatusEnum: AppointmentStatusEnum.cancelled); Utils.hideLoading(context); navigateReplaceWithNameUntilRoute(context, AppRoutes.dashboard); } @@ -909,21 +1066,27 @@ class AppointmentsVM extends BaseVM { } } - Future buildComplaintBottomSheet({required int customerID, required int complainType, required String customerName, required BuildContext context}) { + Future buildComplaintBottomSheet( + {required int customerID, required int complainType, required String customerName, required BuildContext context}) { return showModalBottomSheet( context: context, isScrollControlled: true, enableDrag: true, builder: (BuildContext context) { return InfoBottomSheet( - title: LocaleKeys.reportComplaint.tr().toText(fontSize: 28, isBold: true, letterSpacing: -1.44), + title: LocaleKeys.reportComplaint.tr().toText( + fontSize: 28, isBold: true, letterSpacing: -1.44), description: Padding( - padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), + padding: EdgeInsets.only(bottom: MediaQuery + .of(context) + .viewInsets + .bottom), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ if (customerName.isNotEmpty) ...[ - ("${LocaleKeys.customerName.tr()}: $customerName").toText(fontSize: 15, color: MyColors.lightTextColor), + ("${LocaleKeys.customerName.tr()}: $customerName").toText( + fontSize: 15, color: MyColors.lightTextColor), ], 10.height, TxtField( @@ -945,7 +1108,8 @@ class AppointmentsVM extends BaseVM { final status = await reportComplaintAgainstCustomer( customerID: customerID, comment: complaintDescription, - complaintType: complainType, // 1 for Appointment and 2 for Requests + complaintType: complainType, + // 1 for Appointment and 2 for Requests context: context, ); @@ -965,10 +1129,14 @@ class AppointmentsVM extends BaseVM { ); } - Future reportComplaintAgainstCustomer({required int customerID, required String comment, required int complaintType, required BuildContext context}) async { + Future reportComplaintAgainstCustomer( + {required int customerID, required String comment, required int complaintType, required BuildContext context}) async { Utils.showLoading(context); try { - GenericRespModel genericRespModel = await commonRepo.createComplainFromProvider(customerId: customerID, comment: comment, complainType: complaintType); + GenericRespModel genericRespModel = await commonRepo + .createComplainFromProvider(customerId: customerID, + comment: comment, + complainType: complaintType); Utils.showToast(genericRespModel.message.toString()); Utils.hideLoading(context); return genericRespModel.messageStatus == 1; @@ -980,10 +1148,12 @@ class AppointmentsVM extends BaseVM { } } - Future getProvidersContactInfo({required int providerId, required BuildContext context}) async { + Future getProvidersContactInfo( + {required int providerId, required BuildContext context}) async { Utils.showLoading(context); try { - ProviderContactInfoModel contactInfoModel = await commonRepo.getProvidersContactInfo(providerId: providerId); + ProviderContactInfoModel contactInfoModel = await commonRepo + .getProvidersContactInfo(providerId: providerId); Utils.hideLoading(context); return contactInfoModel; } catch (e, s) { @@ -1006,21 +1176,29 @@ class AppointmentsVM extends BaseVM { if (branchesCategoriesFilterOptions.isNotEmpty) return; branchesCategoriesFilterOptions.clear(); setOnlyState(ViewState.busy); - Services services = await branchRepo.fetchServicesByCategoryId(serviceCategoryId: -1); + Services services = await branchRepo.fetchServicesByCategoryId( + serviceCategoryId: -1); services.data?.forEach((element) { - branchesCategoriesFilterOptions.add(FilterListModel(id: element.id ?? 0, isSelected: false, iconUrl: element.serviceIconUrl ?? "", title: element.description ?? "")); + branchesCategoriesFilterOptions.add(FilterListModel(id: element.id ?? 0, + isSelected: false, + iconUrl: element.serviceIconUrl ?? "", + title: element.description ?? "", + titleN: element.descriptionN ?? "",)); }); - branchesCategoriesFilterOptions.insert(0, FilterListModel(id: 0, isSelected: true, title: "All Branches")); + branchesCategoriesFilterOptions.insert( + 0, FilterListModel(id: 0, isSelected: true, title: "All Branches", titleN: "جميع الفروع")); notifyListeners(); setState(ViewState.idle); } - Future getAllNearBranches({bool isNeedToRebuild = false, bool isFromRefresh = false}) async { + Future getAllNearBranches( + {bool isNeedToRebuild = false, bool isFromRefresh = false}) async { nearbyBranches.clear(); if (isNeedToRebuild) setState(ViewState.busy); if (isFromRefresh) { - var selectedFilter = branchesCategoriesFilterOptions.firstWhere((element) => element.isSelected); + var selectedFilter = branchesCategoriesFilterOptions.firstWhere(( + element) => element.isSelected); log("selectedFilter: ${selectedFilter.id}"); if (selectedFilter.id == 0) { @@ -1055,14 +1233,16 @@ 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!, "")); } } notifyListeners(); } Future getBranchServices({required int categoryId}) async { - branchSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + branchSelectedServiceId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); isHomeTapped = false; pickHomeLocationError = ""; if (categoryId != -1) { @@ -1074,7 +1254,8 @@ class AppointmentsVM extends BaseVM { } List getFilteredBranchServices({required int categoryId}) { - List filteredServices = selectedBranchModel!.branchServices!.where((element) => element.categoryId == categoryId).toList(); + List filteredServices = selectedBranchModel!.branchServices! + .where((element) => element.categoryId == categoryId).toList(); return filteredServices; } @@ -1083,7 +1264,8 @@ class AppointmentsVM extends BaseVM { double longitude = AppState().currentLocation.longitude; setState(ViewState.busy); try { - providerProfileModel = await branchRepo.getBranchAndServicesByProviderId(providerId, latitude: latitude, longitude: longitude); + providerProfileModel = await branchRepo.getBranchAndServicesByProviderId( + providerId, latitude: latitude, longitude: longitude); } catch (e, s) { logger.e(s); setState(ViewState.idle); @@ -1123,7 +1305,8 @@ class AppointmentsVM extends BaseVM { // Provider Filter List branchFilterProviderSearchHistory = []; - void removeBranchFilterProviderSearchHistory({bool isClear = false, required int index}) { + void removeBranchFilterProviderSearchHistory( + {bool isClear = false, required int index}) { if (isClear) { branchFilterProviderSearchHistory.clear(); notifyListeners(); @@ -1145,12 +1328,16 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel branchFilterSelectedProviderId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel branchFilterSelectedProviderId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); - void updateBranchFilterSelectedProviderId(SelectionModel id, {bool isForSearch = false}) async { + void updateBranchFilterSelectedProviderId(SelectionModel id, + {bool isForSearch = false}) async { if (isForSearch) { - DropValue providerDrop = providersDropList.firstWhere((element) => element.id == id.selectedId); - if (!ifAlreadyExist(list: branchFilterProviderSearchHistory, value: providerDrop)) { + DropValue providerDrop = providersDropList.firstWhere((element) => + element.id == id.selectedId); + if (!ifAlreadyExist( + list: branchFilterProviderSearchHistory, value: providerDrop)) { addBranchFilterProviderSearchHistory(value: providerDrop); } } @@ -1162,7 +1349,8 @@ class AppointmentsVM extends BaseVM { // Category Filter List branchFilterCategorySearchHistory = []; - void removeBranchFilterCategorySearchHistory({bool isClear = false, required int index}) { + void removeBranchFilterCategorySearchHistory( + {bool isClear = false, required int index}) { if (isClear) { branchFilterCategorySearchHistory.clear(); notifyListeners(); @@ -1184,12 +1372,16 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel branchFilterSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel branchFilterSelectedCategoryId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); - void updateBranchFilterSelectedCategoryId(SelectionModel id, {bool isForSearch = false}) async { + void updateBranchFilterSelectedCategoryId(SelectionModel id, + {bool isForSearch = false}) async { if (isForSearch) { - DropValue categoryDrop = categoryDropList.firstWhere((element) => element.id == id.selectedId); - if (!ifAlreadyExist(list: branchFilterCategorySearchHistory, value: categoryDrop)) { + DropValue categoryDrop = categoryDropList.firstWhere((element) => + element.id == id.selectedId); + if (!ifAlreadyExist( + list: branchFilterCategorySearchHistory, value: categoryDrop)) { addBranchFilterCategorySearchHistory(value: categoryDrop); } } @@ -1201,7 +1393,8 @@ class AppointmentsVM extends BaseVM { // Services Filter List branchFilterServicesSearchHistory = []; - void removeBranchFilterServicesSearchHistory({bool isClear = false, required int index}) { + void removeBranchFilterServicesSearchHistory( + {bool isClear = false, required int index}) { if (isClear) { branchFilterServicesSearchHistory.clear(); notifyListeners(); @@ -1223,12 +1416,16 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel branchFilterSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel branchFilterSelectedServiceId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); - void updateBranchFilterSelectedServiceId(SelectionModel id, {bool isForSearch = false}) async { + void updateBranchFilterSelectedServiceId(SelectionModel id, + {bool isForSearch = false}) async { if (isForSearch) { - DropValue serviceDrop = servicesDropList.firstWhere((element) => element.id == id.selectedId); - if (!ifAlreadyExist(list: branchFilterServicesSearchHistory, value: serviceDrop)) { + DropValue serviceDrop = servicesDropList.firstWhere((element) => + element.id == id.selectedId); + if (!ifAlreadyExist( + list: branchFilterServicesSearchHistory, value: serviceDrop)) { addBranchFilterServicesSearchHistory(value: serviceDrop); } notifyListeners(); @@ -1251,7 +1448,8 @@ class AppointmentsVM extends BaseVM { return false; } - ifAlreadyExistForStringValue({required List list, required String value}) { + ifAlreadyExistForStringValue( + {required List list, required String value}) { int index = list.indexWhere((element) { return element == value; }); @@ -1283,7 +1481,8 @@ class AppointmentsVM extends BaseVM { providersDropList.clear(); setOnlyState(ViewState.busy); - List providers = await branchRepo.getAllProvidersWitheBasicData(); + List providers = await branchRepo + .getAllProvidersWitheBasicData(); for (var element in providers) { providersDropList.add( DropValue(element.id ?? 0, element.providerName ?? "N/A", ""), @@ -1299,7 +1498,9 @@ class AppointmentsVM extends BaseVM { Category category = await branchRepo.fetchBranchCategory(); category.data?.forEach((element) { categoryDropList.add( - DropValue(element.id ?? 0, ((element.categoryName!.isEmpty ? "N/A" : element.categoryName) ?? "N/A"), ""), + DropValue(element.id ?? 0, + ((element.categoryName!.isEmpty ? "N/A" : element.categoryName) ?? + "N/A"), ""), ); }); setState(ViewState.idle); @@ -1309,7 +1510,8 @@ class AppointmentsVM extends BaseVM { if (servicesDropList.isNotEmpty) return; servicesDropList.clear(); setState(ViewState.busy); - Services services = await branchRepo.fetchServicesByCategoryId(serviceCategoryId: -1); // to get all services + Services services = await branchRepo.fetchServicesByCategoryId( + serviceCategoryId: -1); // to get all services for (var element in services.data!) { servicesDropList.add( @@ -1327,7 +1529,8 @@ class AppointmentsVM extends BaseVM { if (itemsDropList.isNotEmpty) return; itemsDropList.clear(); setState(ViewState.busy); - List itemsList = await branchRepo.getServiceItems(serviceId: -1); // to get all services + List itemsList = await branchRepo.getServiceItems( + serviceId: -1); // to get all services for (ItemData element in itemsList) { if (element.name != null && element.name!.isNotEmpty) { @@ -1348,7 +1551,8 @@ class AppointmentsVM extends BaseVM { serviceDeliveryTypesDropList.clear(); setState(ViewState.busy); - List enums = await commonRepo.getEnumTypeValues(enumTypeID: AppEnums.serviceDeliveryTypeEnumId); + List enums = await commonRepo.getEnumTypeValues( + enumTypeID: AppEnums.serviceDeliveryTypeEnumId); for (EnumsModel element in enums) { serviceDeliveryTypesDropList.add( @@ -1381,9 +1585,12 @@ class AppointmentsVM extends BaseVM { } void clearBranchFilterSelections() { - branchFilterSelectedProviderId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); - branchFilterSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); - branchFilterSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + branchFilterSelectedProviderId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + branchFilterSelectedCategoryId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + branchFilterSelectedServiceId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); } Future getBranchesBasedOnFilters() async { @@ -1420,7 +1627,8 @@ class AppointmentsVM extends BaseVM { setState(ViewState.idle); } - Future getBranchesBasedOnCategoryFilters({required int serviceId}) async { + Future getBranchesBasedOnCategoryFilters( + {required int serviceId}) async { setState(ViewState.busy); if (serviceId == 0) { await getAllNearBranches(); @@ -1439,7 +1647,8 @@ class AppointmentsVM extends BaseVM { List branchesDropList = []; - Future fetchAllBranchesBySelectedProviderId({required List providersIdsList}) async { + Future fetchAllBranchesBySelectedProviderId( + {required List providersIdsList}) async { branchesDropList.clear(); setOnlyState(ViewState.busy); List providers = await branchRepo.getBranchesByFilters( @@ -1448,7 +1657,8 @@ class AppointmentsVM extends BaseVM { longitude: AppState().currentLocation.longitude, ); for (var element in providers) { - branchesDropList.add(DropValue(element.id ?? 0, element.branchName ?? "N/A", "")); + branchesDropList.add( + DropValue(element.id ?? 0, element.branchName ?? "N/A", "")); } setState(ViewState.idle); log("branchesDropList: ${branchesDropList.length}"); @@ -1472,7 +1682,8 @@ class AppointmentsVM extends BaseVM { // Provider Filter For Appointments List appointmentFilterProviderSearchHistory = []; - void removeAppointmentFilterProviderSearchHistory({bool isClear = false, required int index}) { + void removeAppointmentFilterProviderSearchHistory( + {bool isClear = false, required int index}) { if (isClear) { appointmentFilterProviderSearchHistory.clear(); notifyListeners(); @@ -1484,7 +1695,8 @@ class AppointmentsVM extends BaseVM { for (var element in appointmentFilterProviderSearchHistory) { providerIdsSelected.add(element.id); } - fetchAllBranchesBySelectedProviderId(providersIdsList: providerIdsSelected); + fetchAllBranchesBySelectedProviderId( + providersIdsList: providerIdsSelected); } if (appointmentFilterProviderSearchHistory.isEmpty) { @@ -1507,12 +1719,16 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel appointmentFilterSelectedProviderId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel appointmentFilterSelectedProviderId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); - void updateAppointmentFilterSelectedProviderId(SelectionModel id, {bool isForSearch = false}) async { + void updateAppointmentFilterSelectedProviderId(SelectionModel id, + {bool isForSearch = false}) async { if (isForSearch) { - DropValue providerDrop = providersDropList.firstWhere((element) => element.id == id.selectedId); - if (!ifAlreadyExist(list: appointmentFilterProviderSearchHistory, value: providerDrop)) { + DropValue providerDrop = providersDropList.firstWhere((element) => + element.id == id.selectedId); + if (!ifAlreadyExist( + list: appointmentFilterProviderSearchHistory, value: providerDrop)) { addAppointmentFilterProviderSearchHistory(value: providerDrop); } } @@ -1524,7 +1740,8 @@ class AppointmentsVM extends BaseVM { List appointmentFilterBranchSearchHistory = []; - void removeAppointmentFilterBranchSearchHistory({bool isClear = false, required int index}) { + void removeAppointmentFilterBranchSearchHistory( + {bool isClear = false, required int index}) { if (isClear) { appointmentFilterBranchSearchHistory.clear(); notifyListeners(); @@ -1546,12 +1763,16 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel appointmentFilterSelectedBranchId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel appointmentFilterSelectedBranchId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); - void updateAppointmentFilterSelectedBranchId(SelectionModel id, {bool isForSearch = false}) async { + void updateAppointmentFilterSelectedBranchId(SelectionModel id, + {bool isForSearch = false}) async { if (isForSearch) { - DropValue branchesDrop = branchesDropList.firstWhere((element) => element.id == id.selectedId); - if (!ifAlreadyExist(list: appointmentFilterBranchSearchHistory, value: branchesDrop)) { + DropValue branchesDrop = branchesDropList.firstWhere((element) => + element.id == id.selectedId); + if (!ifAlreadyExist( + list: appointmentFilterBranchSearchHistory, value: branchesDrop)) { addAppointmentFilterBranchSearchHistory(value: branchesDrop); } } @@ -1563,7 +1784,8 @@ class AppointmentsVM extends BaseVM { List appointmentFilterCategorySearchHistory = []; - void removeAppointmentFilterCategorySearchHistory({bool isClear = false, required int index}) { + void removeAppointmentFilterCategorySearchHistory( + {bool isClear = false, required int index}) { if (isClear) { appointmentFilterCategorySearchHistory.clear(); notifyListeners(); @@ -1585,12 +1807,16 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel appointmentFilterSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel appointmentFilterSelectedCategoryId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); - void updateAppointmentFilterSelectedCategoryId(SelectionModel id, {bool isForSearch = false}) async { + void updateAppointmentFilterSelectedCategoryId(SelectionModel id, + {bool isForSearch = false}) async { if (isForSearch) { - DropValue categoryDrop = categoryDropList.firstWhere((element) => element.id == id.selectedId); - if (!ifAlreadyExist(list: appointmentFilterCategorySearchHistory, value: categoryDrop)) { + DropValue categoryDrop = categoryDropList.firstWhere((element) => + element.id == id.selectedId); + if (!ifAlreadyExist( + list: appointmentFilterCategorySearchHistory, value: categoryDrop)) { addAppointmentFilterCategorySearchHistory(value: categoryDrop); } } @@ -1600,7 +1826,8 @@ class AppointmentsVM extends BaseVM { List appointmentFilterServicesSearchHistory = []; - void removeAppointmentFilterServicesSearchHistory({bool isClear = false, required int index}) { + void removeAppointmentFilterServicesSearchHistory( + {bool isClear = false, required int index}) { if (isClear) { appointmentFilterServicesSearchHistory.clear(); notifyListeners(); @@ -1622,12 +1849,16 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel appointmentFilterSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel appointmentFilterSelectedServiceId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); - void updateAppointmentFilterSelectedServiceId(SelectionModel id, {bool isForSearch = false}) async { + void updateAppointmentFilterSelectedServiceId(SelectionModel id, + {bool isForSearch = false}) async { if (isForSearch) { - DropValue servicesDrop = servicesDropList.firstWhere((element) => element.id == id.selectedId); - if (!ifAlreadyExist(list: appointmentFilterServicesSearchHistory, value: servicesDrop)) { + DropValue servicesDrop = servicesDropList.firstWhere((element) => + element.id == id.selectedId); + if (!ifAlreadyExist( + list: appointmentFilterServicesSearchHistory, value: servicesDrop)) { addAppointmentFilterServicesSearchHistory(value: servicesDrop); } } @@ -1637,7 +1868,8 @@ class AppointmentsVM extends BaseVM { List appointmentFilterItemsSearchHistory = []; - void removeAppointmentFilterItemsSearchHistory({bool isClear = false, required int index}) { + void removeAppointmentFilterItemsSearchHistory( + {bool isClear = false, required int index}) { if (isClear) { appointmentFilterItemsSearchHistory.clear(); notifyListeners(); @@ -1659,12 +1891,16 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel appointmentFilterSelectedItemId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel appointmentFilterSelectedItemId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); - void updateAppointmentFilterSelectedItemId(SelectionModel id, {bool isForSearch = false}) async { + void updateAppointmentFilterSelectedItemId(SelectionModel id, + {bool isForSearch = false}) async { if (isForSearch) { - DropValue itemsDrop = itemsDropList.firstWhere((element) => element.id == id.selectedId); - if (!ifAlreadyExist(list: appointmentFilterItemsSearchHistory, value: itemsDrop)) { + DropValue itemsDrop = itemsDropList.firstWhere((element) => + element.id == id.selectedId); + if (!ifAlreadyExist( + list: appointmentFilterItemsSearchHistory, value: itemsDrop)) { addAppointmentFilterItemsSearchHistory(value: itemsDrop); } } @@ -1682,7 +1918,8 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - void removeAppointmentFilterCustomerNameSearchHistory({bool isClear = false, required int index}) { + void removeAppointmentFilterCustomerNameSearchHistory( + {bool isClear = false, required int index}) { if (isClear) { appointmentFilterCustomerNameSearchHistory.clear(); notifyListeners(); @@ -1701,7 +1938,8 @@ class AppointmentsVM extends BaseVM { updateAppointmentFiltersCounter(appointmentFiltersCounter + 1); } - if (!ifAlreadyExistForStringValue(list: appointmentFilterCustomerNameSearchHistory, value: value)) { + if (!ifAlreadyExistForStringValue( + list: appointmentFilterCustomerNameSearchHistory, value: value)) { appointmentFilterCustomerNameSearchHistory.add(value); currentCustomerNameFilter = ""; } @@ -1719,7 +1957,8 @@ class AppointmentsVM extends BaseVM { List appointmentFilterMobilePhoneSearchHistory = []; - void removeAppointmentFilterMobilePhoneSearchHistory({bool isClear = false, required int index}) { + void removeAppointmentFilterMobilePhoneSearchHistory( + {bool isClear = false, required int index}) { if (isClear) { appointmentFilterMobilePhoneSearchHistory.clear(); notifyListeners(); @@ -1738,7 +1977,8 @@ class AppointmentsVM extends BaseVM { updateAppointmentFiltersCounter(appointmentFiltersCounter + 1); } - if (!ifAlreadyExistForStringValue(list: appointmentFilterMobilePhoneSearchHistory, value: value)) { + if (!ifAlreadyExistForStringValue( + list: appointmentFilterMobilePhoneSearchHistory, value: value)) { appointmentFilterMobilePhoneSearchHistory.add(value); currentMobilePhoneFilter = ""; } @@ -1749,7 +1989,8 @@ class AppointmentsVM extends BaseVM { List appointmentFilterServiceDeliverySearchHistory = []; - void removeAppointmentFilterServiceDeliverySearchHistory({bool isClear = false, required int index}) { + void removeAppointmentFilterServiceDeliverySearchHistory( + {bool isClear = false, required int index}) { if (isClear) { appointmentFilterServiceDeliverySearchHistory.clear(); notifyListeners(); @@ -1763,7 +2004,8 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - void addAppointmentFilterServiceDeliverySearchHistory({required DropValue value}) { + void addAppointmentFilterServiceDeliverySearchHistory( + {required DropValue value}) { if (appointmentFilterServiceDeliverySearchHistory.isEmpty) { updateAppointmentFiltersCounter(appointmentFiltersCounter + 1); } @@ -1772,12 +2014,16 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - SelectionModel appointmentFilterSelectedServiceDeliveryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + SelectionModel appointmentFilterSelectedServiceDeliveryId = SelectionModel( + selectedOption: "", selectedId: -1, errorValue: ""); - void updateAppointmentFilterSelectedServiceDeliveryId(SelectionModel id, {bool isForSearch = false}) async { + void updateAppointmentFilterSelectedServiceDeliveryId(SelectionModel id, + {bool isForSearch = false}) async { if (isForSearch) { - DropValue itemsDrop = serviceDeliveryTypesDropList.firstWhere((element) => element.id == id.selectedId); - if (!ifAlreadyExist(list: appointmentFilterServiceDeliverySearchHistory, value: itemsDrop)) { + DropValue itemsDrop = serviceDeliveryTypesDropList.firstWhere(( + element) => element.id == id.selectedId); + if (!ifAlreadyExist(list: appointmentFilterServiceDeliverySearchHistory, + value: itemsDrop)) { addAppointmentFilterServiceDeliverySearchHistory(value: itemsDrop); } } @@ -1786,12 +2032,18 @@ class AppointmentsVM extends BaseVM { } void clearAppointmentFilterSelections() { - appointmentFilterSelectedProviderId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); - appointmentFilterSelectedCategoryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); - appointmentFilterSelectedServiceId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); - appointmentFilterSelectedItemId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); - appointmentFilterSelectedServiceDeliveryId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); - appointmentFilterSelectedBranchId = SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + appointmentFilterSelectedProviderId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + appointmentFilterSelectedCategoryId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + appointmentFilterSelectedServiceId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + appointmentFilterSelectedItemId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + appointmentFilterSelectedServiceDeliveryId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); + appointmentFilterSelectedBranchId = + SelectionModel(selectedOption: "", selectedId: -1, errorValue: ""); } void clearAppointmentFilters() { @@ -1807,14 +2059,18 @@ class AppointmentsVM extends BaseVM { clearAppointmentFilterSelections(); if (AppState().currentAppType == AppType.provider) { - applyFilterOnAppointmentsVMForProviders(appointmentStatusEnum: AppointmentStatusEnum.allAppointments, isNeedCustomerFilter: true); + applyFilterOnAppointmentsVMForProviders( + appointmentStatusEnum: AppointmentStatusEnum.allAppointments, + isNeedCustomerFilter: true); } else { - applyFilterOnAppointmentsVMForCustomers(appointmentStatusEnum: AppointmentStatusEnum.allAppointments); + applyFilterOnAppointmentsVMForCustomers( + appointmentStatusEnum: AppointmentStatusEnum.allAppointments); } notifyListeners(); } - Future> getAppointmentsBasedOnFiltersForCustomer({required AppointmentStatusEnum appointmentStatusEnum}) async { + Future> getAppointmentsBasedOnFiltersForCustomer( + {required AppointmentStatusEnum appointmentStatusEnum}) async { try { setState(ViewState.busy); List providersIdsList = []; @@ -1848,7 +2104,8 @@ class AppointmentsVM extends BaseVM { } } - List myAppointments = await appointmentRepo.getMyAppointmentsForCustomersByFilters( + List myAppointments = await appointmentRepo + .getMyAppointmentsForCustomersByFilters( providerIdsList: providersIdsList, categoryIdsList: categoryIdsList, serviceIdsList: servicesIdsList, @@ -1869,7 +2126,8 @@ class AppointmentsVM extends BaseVM { String selectedDateForAppointments = ""; - Future> getAppointmentsBasedOnFiltersForProviders({required int branchID, AppointmentStatusEnum? appointmentStatus}) async { + Future> getAppointmentsBasedOnFiltersForProviders( + {required int branchID, AppointmentStatusEnum? appointmentStatus}) async { try { setState(ViewState.busy); List servicesIdsList = []; @@ -1903,7 +2161,8 @@ class AppointmentsVM extends BaseVM { log("customerPhonesList: $customerPhonesList"); log("customerDeliveryTypesList: $customerDeliveryTypesList"); log("servicesIdsList: $servicesIdsList"); - List myAppointments = await appointmentRepo.getMyAppointmentsForProvidersByFilters( + List myAppointments = await appointmentRepo + .getMyAppointmentsForProvidersByFilters( branchID: branchID, customerNamesList: customerNamesList, customerPhonesList: customerPhonesList, @@ -1924,10 +2183,12 @@ class AppointmentsVM extends BaseVM { } } - Future addProviderToFavorite({required int serviceProviderID, required BuildContext context}) async { + Future addProviderToFavorite( + {required int serviceProviderID, required BuildContext context}) async { Utils.showLoading(context); try { - GenericRespModel genericRespModel = await branchRepo.addProviderToFavourite(providerID: serviceProviderID); + GenericRespModel genericRespModel = await branchRepo + .addProviderToFavourite(providerID: serviceProviderID); Utils.showToast(genericRespModel.message.toString()); Utils.hideLoading(context); return genericRespModel.messageStatus == 1; @@ -1939,11 +2200,13 @@ class AppointmentsVM extends BaseVM { } } - Future removeProviderFromFavorite({required int serviceProviderID, required BuildContext context}) async { + Future removeProviderFromFavorite( + {required int serviceProviderID, required BuildContext context}) async { Utils.showLoading(context); try { - GenericRespModel genericRespModel = await branchRepo.removeProviderFromFavourite(providerID: serviceProviderID); + GenericRespModel genericRespModel = await branchRepo + .removeProviderFromFavourite(providerID: serviceProviderID); Utils.hideLoading(context); Utils.showToast(genericRespModel.message.toString()); return genericRespModel.messageStatus == 1; @@ -1983,10 +2246,12 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - Future getReviewsByBranchId({required int serviceProviderBranchID}) async { + Future getReviewsByBranchId( + {required int serviceProviderBranchID}) async { setState(ViewState.busy); try { - currentBranchReviews = await branchRepo.getBranchRatings(serviceProviderBranchID: serviceProviderBranchID); + currentBranchReviews = await branchRepo.getBranchRatings( + serviceProviderBranchID: serviceProviderBranchID); } catch (e, s) { logger.e(s); setState(ViewState.idle); @@ -1997,7 +2262,8 @@ class AppointmentsVM extends BaseVM { // Chat Related - Future getGeneralChatsListForProvider({required BuildContext context}) async { + Future getGeneralChatsListForProvider( + {required BuildContext context}) async { try { // Utils.showLoading(context); // List buyersChatList = await appointmentRepo.getChatBuyersForAds(adsID: adsID); @@ -2012,7 +2278,8 @@ class AppointmentsVM extends BaseVM { } } - void onGeneralChatMessagesButtonPressed({required BuildContext context}) async { + void onGeneralChatMessagesButtonPressed( + {required BuildContext context}) async { final myUserID = AppState().getUser.data!.userInfo!.userId; // if (adDetailsModel.isMyAd != null && adDetailsModel.isMyAd!) { // await getGeneralChatsListForProvider(context: context); diff --git a/lib/view_models/user_view_model.dart b/lib/view_models/user_view_model.dart index 513208e..4a091a8 100644 --- a/lib/view_models/user_view_model.dart +++ b/lib/view_models/user_view_model.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:easy_localization/easy_localization.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/cupertino.dart'; +import 'package:http/http.dart'; import 'package:http/src/response.dart'; import 'package:local_auth/local_auth.dart'; import 'package:mc_common_app/classes/app_state.dart'; @@ -748,6 +749,7 @@ class UserVM extends BaseVM { } else { context.setLocale(const Locale('ar', 'SA')); } + log ("updated status: ${AppState().isArabic(context)}"); // notifyListeners(); } 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 a6da85c..8efc736 100644 --- a/lib/views/advertisement/ads_detail_view/ads_detail_view.dart +++ b/lib/views/advertisement/ads_detail_view/ads_detail_view.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:mc_common_app/classes/app_state.dart'; import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; @@ -85,6 +86,7 @@ class _AdsDetailViewState extends State { } Widget buildVehicleDetailsWidget() { + bool isArabic = AppState().isArabic(context); return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -94,7 +96,8 @@ class _AdsDetailViewState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( - child: "${widget.adDetails.vehicle!.vehicleTitle} | ${widget.adDetails.vehicle!.color!.label}| ${widget.adDetails.id}".toText(fontSize: 16, maxLines: 2), + child: "${widget.adDetails.vehicle!.vehicleTitle} | ${isArabic ? widget.adDetails.vehicle!.color!.labelN : widget.adDetails.vehicle!.color!.label}|" + " ${widget.adDetails.id}".toText(fontSize: 16, maxLines: 2), ), (widget.adDetails.vehicle!.cityName ?? "").toText(fontSize: 10, color: MyColors.lightTextColor), ], @@ -105,7 +108,7 @@ class _AdsDetailViewState extends State { Row( children: [ ("${LocaleKeys.vehicleModel.tr()}: ").toText(fontSize: 12, color: MyColors.lightTextColor), - "${widget.adDetails.vehicle!.model!.label}".toText(fontSize: 12), + "${isArabic? widget.adDetails.vehicle!.model!.labelN :widget.adDetails.vehicle!.model!.label}".toText(fontSize: 12), ], ), (widget.adDetails.vehicle!.countryName ?? '').toText(fontSize: 10, color: MyColors.lightTextColor), @@ -124,7 +127,7 @@ class _AdsDetailViewState extends State { Row( children: [ ("${LocaleKeys.mileage.tr()}: ").toText(fontSize: 12, color: MyColors.lightTextColor), - "${widget.adDetails.vehicle!.mileage!.mileageEnd} Km".toText(fontSize: 12), + "${widget.adDetails.vehicle!.mileage!.mileageEnd} ${LocaleKeys.km.tr()}".toText(fontSize: 12), ], ), widget.adDetails.createdOn != null ? DateTime.parse(widget.adDetails.createdOn!).getTimeAgo().toText(fontSize: 10, color: MyColors.lightTextColor) : const SizedBox(), @@ -133,13 +136,13 @@ class _AdsDetailViewState extends State { Row( children: [ ("${LocaleKeys.transmission.tr()}: ").toText(fontSize: 12, color: MyColors.lightTextColor), - "${widget.adDetails.vehicle!.transmission!.label}".toText(fontSize: 12), + "${isArabic? widget.adDetails.vehicle!.transmission!.labelN :widget.adDetails.vehicle!.transmission!.label}".toText(fontSize: 12), ], ), Row( children: [ ("${LocaleKeys.odometer.tr()}: ").toText(fontSize: 12, color: MyColors.lightTextColor), - "${widget.adDetails.vehicle!.odometer ?? 0} Km".toText(fontSize: 12), + "${widget.adDetails.vehicle!.odometer ?? 0} ${LocaleKeys.km.tr()}".toText(fontSize: 12), ], ), Row( diff --git a/lib/views/advertisement/components/ads_list_widget.dart b/lib/views/advertisement/components/ads_list_widget.dart index e1be33c..3317ded 100644 --- a/lib/views/advertisement/components/ads_list_widget.dart +++ b/lib/views/advertisement/components/ads_list_widget.dart @@ -17,6 +17,8 @@ import 'package:mc_common_app/view_models/ad_view_model.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:provider/provider.dart'; +import '../../../classes/app_state.dart'; + class AdsListWidget extends StatelessWidget { final List adsList; final ScrollPhysics? scrollPhysics; @@ -117,6 +119,7 @@ class AdCard extends StatelessWidget { @override Widget build(BuildContext context) { + bool isArabic = AppState().isArabic(context); return Stack( alignment: Alignment.center, children: [ 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 a3d3c1f..61257df 100644 --- a/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart +++ b/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart @@ -22,6 +22,8 @@ import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/txt_field.dart'; import 'package:provider/provider.dart'; +import '../../../classes/app_state.dart'; + class AppointmentServicePickBottomSheet extends StatelessWidget { const AppointmentServicePickBottomSheet({super.key}); @@ -70,12 +72,16 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { 8.height, Builder( builder: (context) { + bool isArabic = AppState().isArabic(context); List serviceCategories = []; for (var element in appointmentsVM.branchServices) { if (element.categoryId == appointmentsVM.branchSelectedCategoryId.selectedId) { serviceCategories.add(DropValue( element.serviceProviderServiceId ?? 0, - element.serviceDescription!, + isArabic + ? element.serviceDescriptionN! + : element.serviceDescription!, + // element.serviceDescription!, "", )); } diff --git a/lib/views/appointments/widgets/common_appointment_slider_widget.dart b/lib/views/appointments/widgets/common_appointment_slider_widget.dart index fc08420..78a7631 100644 --- a/lib/views/appointments/widgets/common_appointment_slider_widget.dart +++ b/lib/views/appointments/widgets/common_appointment_slider_widget.dart @@ -173,7 +173,7 @@ class AppointmentHomeTileWidget extends StatelessWidget { children: [ !isForProvider ? MyAssets.miniClock.buildSvg(height: 12) : const SizedBox(), 2.width, - "${isForProvider ? "Appt. on:" : ""} ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime()}" + "${isForProvider ? LocaleKeys.apptOn.tr() : ""} ${appointmentListModel!.duration ?? ""} ${appointmentListModel!.appointmentDate!.toFormattedDateWithoutTime()}" .toText(color: MyColors.lightTextColor, fontSize: 12, letterSpacing: -0.48, height: 19 / 12), ], ), @@ -291,7 +291,7 @@ class AppointmentFragmentTileWidget extends StatelessWidget { (appointmentListModel!.providerName ?? "").toText(color: MyColors.darkTextColor, fontSize: 16, letterSpacing: -0.64, height: 24 / 16), Row( children: [ - ('Branch:').toText(color: MyColors.greyColor, fontSize: 12, letterSpacing: -0.48, height: 18 / 12), + ("${LocaleKeys.branch.tr()}:").toText(color: MyColors.greyColor, fontSize: 12, letterSpacing: -0.48, height: 18 / 12), 2.width, (appointmentListModel!.branchName ?? "").toText(color: MyColors.darkTextColor, fontSize: 12, letterSpacing: -0.48, height: 18 / 12), ], diff --git a/lib/views/requests/create_request_page.dart b/lib/views/requests/create_request_page.dart index d298776..14cde30 100644 --- a/lib/views/requests/create_request_page.dart +++ b/lib/views/requests/create_request_page.dart @@ -88,9 +88,13 @@ class CreateRequestPage extends StatelessWidget { ), ] else ...[ Builder(builder: (context) { + bool isArabic = AppState().isArabic(context); List vehicleTypeDrop = []; for (var element in requestsVM.vehicleTypes) { - vehicleTypeDrop.add(DropValue(element.id?.toInt() ?? 0, element.vehicleTypeName ?? "", "")); + vehicleTypeDrop.add(DropValue(element.id?.toInt() ?? 0, + isArabic + ? element.vehicleTypeNameN ?? "" + : element.vehicleTypeName ?? "", "")); } return DropdownField( (DropValue value) => requestsVM.updateSelectionVehicleTypeId(SelectionModel(selectedId: value.id, selectedOption: value.value)), @@ -155,9 +159,13 @@ class CreateRequestPage extends StatelessWidget { ), 8.height, Builder(builder: (context) { + bool isArabic = AppState().isArabic(context); List vehicleCountriesDrop = []; for (var element in requestsVM.vehicleCountries) { - vehicleCountriesDrop.add(DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", "")); + vehicleCountriesDrop.add(DropValue(element.id?.toInt() ?? 0, + isArabic + ? element.countryNameN ?? "" + : element.countryName ?? "", "")); } return DropdownField( (DropValue value) => requestsVM.updateSelectionVehicleCountryId(SelectionModel(selectedOption: value.value, selectedId: value.id)), @@ -177,9 +185,12 @@ class CreateRequestPage extends StatelessWidget { ] else ...[ 8.height, Builder(builder: (context) { + bool isArabic = AppState().isArabic(context); List vehicleCitiesDrop = []; for (var element in requestsVM.vehicleCities) { - vehicleCitiesDrop.add(DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", "")); + vehicleCitiesDrop.add(DropValue(element.id?.toInt() ?? 0, isArabic + ? element.cityNameN ?? "" + : element.cityName ?? "", "")); } return DropdownField( (DropValue value) => requestsVM.updateSelectionVehicleCityId(SelectionModel(selectedId: value.id, selectedOption: value.value)), diff --git a/lib/views/setting_options/setting_options_faqs.dart b/lib/views/setting_options/setting_options_faqs.dart index 34bf366..7c9838f 100644 --- a/lib/views/setting_options/setting_options_faqs.dart +++ b/lib/views/setting_options/setting_options_faqs.dart @@ -14,6 +14,8 @@ import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; import 'package:easy_localization/easy_localization.dart'; import 'package:provider/provider.dart'; +import '../../classes/app_state.dart'; + class SettingOptionsFAQs extends StatefulWidget { const SettingOptionsFAQs({super.key}); @@ -31,6 +33,7 @@ class _SettingOptionsFAQsState extends State { await settingsOptionsVM.getAllFaqs(); }); super.initState(); + } @override @@ -44,6 +47,7 @@ class _SettingOptionsFAQsState extends State { ), body: Consumer( builder: (BuildContext context, SettingOptionsVM settingsOptionsVM, Widget? child) { + bool isArabic = AppState().isArabic(context); return Container( color: MyColors.backgroundColor, width: double.infinity, @@ -69,7 +73,7 @@ class _SettingOptionsFAQsState extends State { return ExpansionTile( tilePadding: EdgeInsets.zero, shape: const Border(), - title: (faqModel.question ?? "").toText(fontSize: 16).paddingOnly(left: 8, right: 8), + title: (isArabic ? faqModel.questionN ?? "" : faqModel.question ?? "").toText(fontSize: 16).paddingOnly(left: 8, right: 8), onExpansionChanged: (value) { setState(() { settingsOptionsVM.faqsList[index].isCollapsed = value; @@ -85,7 +89,7 @@ class _SettingOptionsFAQsState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ 5.height, - (faqModel.answer ?? "").toText(color: MyColors.lightTextColor, fontSize: 14, fontWeight: MyFonts.Medium), + (isArabic ? faqModel.answerN ?? "" : faqModel.answer ?? "").toText(color: MyColors.lightTextColor, fontSize: 14, fontWeight: MyFonts.Medium), 10.height, ], ).paddingOnly(left: 8, right: 8) diff --git a/lib/views/setting_options/setting_options_more.dart b/lib/views/setting_options/setting_options_more.dart index 37ff91f..d741835 100644 --- a/lib/views/setting_options/setting_options_more.dart +++ b/lib/views/setting_options/setting_options_more.dart @@ -128,11 +128,25 @@ class _SettingOptionsMoreState extends State { CustomSettingOptionsTile( leadingWidget: const Icon(Icons.settings, size: 20), titleText: LocaleKeys.settings.tr(), - needBorderBelow: false, + needBorderBelow: true, onTap: () { // context.read().getAppInvitationHistoryList(); navigateWithName(context, AppRoutes.settingOptionsInviteFriends); }), + + /////////////////////////////////me add to test + CustomSettingOptionsTile( + leadingWidget: const Icon(Icons.translate, size: 20), + titleText: LocaleKeys.language.tr(), + isForLanguage: true, + onTap: () { + context.read().changeLanguage(context); + Future.delayed(const Duration(seconds: 1), () { + setState(() {}); + }); + }, + ), + ////////////////////////////////////////////////////////// ], ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12), borderRadius: 0), 10.height, diff --git a/lib/views/user/edit_account_page.dart b/lib/views/user/edit_account_page.dart index bf9e6c9..fbe9a8e 100644 --- a/lib/views/user/edit_account_page.dart +++ b/lib/views/user/edit_account_page.dart @@ -77,7 +77,7 @@ class _EditAccountPageState extends State { children: [ CustomSettingOptionsTile( leadingWidget: const Icon(Icons.quickreply_outlined, size: 20), - titleText: "Requests", + titleText: LocaleKeys.requests.tr(), needBorderBelow: true, onTap: () { context.read().onNavbarTapped(4); @@ -85,19 +85,19 @@ class _EditAccountPageState extends State { }), CustomSettingOptionsTile( leadingWidget: const Icon(Icons.settings, size: 20), - titleText: "Settings", + titleText: LocaleKeys.settings.tr(), needBorderBelow: true, onTap: () => navigateWithName(context, AppRoutes.settingOptionsInviteFriends), ), CustomSettingOptionsTile( leadingWidget: const Icon(Icons.question_mark_outlined, size: 20), - titleText: "Help", + titleText: LocaleKeys.help.tr(), needBorderBelow: true, onTap: () => navigateWithName(context, AppRoutes.settingOptionsInviteFriends), ), CustomSettingOptionsTile( leadingWidget: const Icon(Icons.person, size: 20), - titleText: "Account", + titleText: LocaleKeys.account.tr(), needBorderBelow: false, onTap: () { context.read().onNavbarTapped(4); @@ -108,7 +108,7 @@ class _EditAccountPageState extends State { 10.height, CustomSettingOptionsTile( leadingWidget: const Icon(Icons.translate, size: 20), - titleText: "Language", + titleText: LocaleKeys.language.tr(), isForLanguage: true, onTap: () {}, ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12), borderRadius: 0), @@ -124,8 +124,8 @@ class _EditAccountPageState extends State { color: MyColors.primaryColor, ), ), - titleText: "My Subscriptions", - subTitle: "Silver", + titleText: LocaleKeys.mySubscription.tr(), + subTitle: LocaleKeys.silver.tr(), isForLanguage: false, needBorderBelow: true, onTap: () { @@ -141,7 +141,7 @@ class _EditAccountPageState extends State { // color: MyColors.primaryColor, ), ), - titleText: "Subscriptions", + titleText: LocaleKeys.subscriptions.tr(), subTitle: null, isForLanguage: false, needBorderBelow: false, @@ -152,7 +152,7 @@ class _EditAccountPageState extends State { ], ).toWhiteContainer(width: double.infinity, pading: const EdgeInsets.all(12), borderRadius: 0), 10.height, - (AppState().currentAppType == AppType.provider) ? const Text("Provider") : const Text("Customer"), + (AppState().currentAppType == AppType.provider) ? const Text(LocaleKeys.provider) : const Text(LocaleKeys.customer), ], ), ), diff --git a/lib/views/user/login_method_selection_page.dart b/lib/views/user/login_method_selection_page.dart index fdc5df3..17d8552 100644 --- a/lib/views/user/login_method_selection_page.dart +++ b/lib/views/user/login_method_selection_page.dart @@ -107,7 +107,7 @@ class _LoginMethodSelectionPageState extends State { ], ), 150.height, - ("Login To Another Account") + LocaleKeys.loginToAnotherAccount.tr() .toText( fontSize: 20, letterSpacing: -1.44, diff --git a/lib/views/user/update_user_city_country.dart b/lib/views/user/update_user_city_country.dart index f38f7bb..9c43077 100644 --- a/lib/views/user/update_user_city_country.dart +++ b/lib/views/user/update_user_city_country.dart @@ -54,14 +54,15 @@ class _UpdateUserCityCountryState extends State { padding: const EdgeInsets.only(right: 20, left: 20, top: 12), child: Builder(builder: (context) { List userCountryDrop = []; + final isArabic = AppState().isArabic(context); for (var element in uVM.userCountries!.data!) { var countryid = country == null ? AppState().getUser.data!.userInfo!.countryId : country!.id; print("Country ID" + countryid.toString()); if (countryid == element.id) { print("Country Matched"); - country = DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", ""); + country = DropValue(element.id?.toInt() ?? 0, isArabic ? element.countryNameN ?? "": element.countryName ?? "", ""); } - userCountryDrop.add(DropValue(element.id?.toInt() ?? 0, element.countryName ?? "", "")); + userCountryDrop.add(DropValue(element.id?.toInt() ?? 0, isArabic ? element.countryNameN ?? "": element.countryName ?? "", "")); } return DropdownField( (DropValue value) async { @@ -82,13 +83,14 @@ class _UpdateUserCityCountryState extends State { padding: const EdgeInsets.only(right: 20, left: 20, top: 12), child: Builder(builder: (context) { List userCityDrop = []; + final isArabic = AppState().isArabic(context); for (var element in uVM.userCities!.data!) { var cid = city == null ? AppState().getUser.data!.userInfo!.cityId : city!.id; print("City ID" + cid.toString()); if (cid == element.id) { - city = DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", ""); + city = DropValue(element.id?.toInt() ?? 0, isArabic ? element.cityNameN ?? "": element.cityName ?? "", ""); } - userCityDrop.add(DropValue(element.id?.toInt() ?? 0, element.cityName ?? "", "")); + userCityDrop.add(DropValue(element.id?.toInt() ?? 0, isArabic ? element.cityNameN ?? "": element.cityName ?? "", "")); } return DropdownField( (DropValue value) { diff --git a/lib/widgets/common_widgets/add_phone_num_wiget.dart b/lib/widgets/common_widgets/add_phone_num_wiget.dart index 04c11ed..8736f25 100644 --- a/lib/widgets/common_widgets/add_phone_num_wiget.dart +++ b/lib/widgets/common_widgets/add_phone_num_wiget.dart @@ -57,7 +57,7 @@ class _AddPhoneNumWidgetState extends State { mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - "Enter Phone Number".toText(fontSize: 16, isBold: true), + LocaleKeys.enterPhoneNumber.tr().toText(fontSize: 16, isBold: true), 8.height, Container( decoration: Utils.containerColorRadiusBorderWidth(MyColors.white, 0, MyColors.darkPrimaryColor, 2), @@ -81,7 +81,7 @@ class _AddPhoneNumWidgetState extends State { 8.height, TxtField( keyboardType: TextInputType.phone, - hint: "Phone without country code ", + hint: LocaleKeys.phoneWithoutCountryCode.tr(), value: phoneNum, isSidePaddingZero: true, onChanged: (v) { @@ -116,7 +116,7 @@ class _AddPhoneNumWidgetState extends State { children: [ Expanded( child: ShowFillButton( - title: "Cancel", + title: LocaleKeys.cancel.tr(), backgroundColor: MyColors.greyButtonColor, txtColor: Colors.black, onPressed: () { diff --git a/lib/widgets/common_widgets/branch_details_card.dart b/lib/widgets/common_widgets/branch_details_card.dart index 87013e0..294c5df 100644 --- a/lib/widgets/common_widgets/branch_details_card.dart +++ b/lib/widgets/common_widgets/branch_details_card.dart @@ -95,24 +95,47 @@ class BranchDetailCard extends StatelessWidget { ], ), 8.height, + // if (services != null) + // Column( + // children: services! + // .take(2) + // .map( + // (e) => Row( + // children: [ + // //TODO: Needs to add icon in the future when added from the provider + // // MyAssets.maintenanceIcon.buildSvg(), + // // 8.width, + // e.serviceDescription.toString().toText(fontSize: 12) + // ], + // ), + // ) + // .toList(), + // ), if (services != null) Column( children: services! .take(2) .map( - (e) => Row( - children: [ - //TODO: Needs to add icon in the future when added from the provider - // MyAssets.maintenanceIcon.buildSvg(), - // 8.width, - e.serviceDescription.toString().toText(fontSize: 12) - ], - ), - ) + (e) { + bool isArabic = AppState().isArabic(context); + String serviceText = isArabic + ? e.serviceDescriptionN.toString() + : e.serviceDescription.toString(); + + return Row( + children: [ + //TODO: Needs to add icon in the future when added from the provider + // MyAssets.maintenanceIcon.buildSvg(), + // 8.width, + serviceText.toText(fontSize: 12) + ], + ); + }, + ) .toList(), ), if (services != null && services!.length > 2) - ("+${services!.length - 2} more").toText( + ("+${services!.length - 2} ${LocaleKeys.more.tr()}").toText( color: MyColors.primaryColor, isUnderLine: true, isBold: true, diff --git a/lib/widgets/common_widgets/filters_list.dart b/lib/widgets/common_widgets/filters_list.dart index 5b9c341..e9bd1e0 100644 --- a/lib/widgets/common_widgets/filters_list.dart +++ b/lib/widgets/common_widgets/filters_list.dart @@ -1,11 +1,14 @@ import 'dart:developer'; +import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; import 'package:mc_common_app/models/general_models/widgets_models.dart'; import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/widgets/extensions/extensions_widget.dart'; +import '../../classes/app_state.dart'; + class FiltersList extends StatelessWidget { final List filterList; final Function(int, int) onFilterTapped; @@ -24,6 +27,7 @@ class FiltersList extends StatelessWidget { @override Widget build(BuildContext context) { + final isArabic = AppState().isArabic(context); return SizedBox( height: 37, width: double.infinity, @@ -32,6 +36,8 @@ class FiltersList extends StatelessWidget { itemCount: filterList.length, scrollDirection: Axis.horizontal, itemBuilder: (BuildContext context, int index) { + print("=================================================="); + print(filterList[index].title); return InkWell( onTap: () { onFilterTapped(index, filterList[index].id); @@ -62,7 +68,12 @@ class FiltersList extends StatelessWidget { ], ], // Text displayed in the chip - filterList[index].title.toText( + (isArabic + ? (filterList[index].titleN ?? filterList[index].title) + : filterList[index].title) + .tr() + .toText( + // filterList[index].title.tr().toText( fontSize: 13, letterSpacing: -0.14, color: filterList[index].isSelected ? MyColors.white : null, diff --git a/pubspec.yaml b/pubspec.yaml index 687d3d7..d78b051 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,6 +43,7 @@ dependencies: change_app_package_name: ^1.3.0 share_plus: any toastification: ^2.3.0 + geolocator_android: 4.5.5 # Firebase Packages