From 38bda8e8ed31ded8c670355292f9ac791793b0ff Mon Sep 17 00:00:00 2001 From: Rand Alshammari Date: Mon, 22 Jun 2026 12:56:39 +0300 Subject: [PATCH] fixed A & E --- lib/models/general_models/enums_model.dart | 6 +- lib/models/general_models/widgets_models.dart | 4 +- .../setting_utils_models/faqs_model.dart | 9 +- lib/repositories/appointment_repo.dart | 2 + lib/view_models/appointments_view_model.dart | 713 ++++++++++++------ .../setting_options/setting_options_faqs.dart | 7 +- lib/widgets/common_widgets/filters_list.dart | 10 +- 7 files changed, 522 insertions(+), 229 deletions(-) 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/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/views/setting_options/setting_options_faqs.dart b/lib/views/setting_options/setting_options_faqs.dart index e18ca1e..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}); @@ -45,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, @@ -70,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; @@ -86,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/widgets/common_widgets/filters_list.dart b/lib/widgets/common_widgets/filters_list.dart index 2fd1cfd..e9bd1e0 100644 --- a/lib/widgets/common_widgets/filters_list.dart +++ b/lib/widgets/common_widgets/filters_list.dart @@ -7,6 +7,8 @@ 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; @@ -25,6 +27,7 @@ class FiltersList extends StatelessWidget { @override Widget build(BuildContext context) { + final isArabic = AppState().isArabic(context); return SizedBox( height: 37, width: double.infinity, @@ -65,7 +68,12 @@ class FiltersList extends StatelessWidget { ], ], // Text displayed in the chip - filterList[index].title.tr().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,