From 56d6bc196bf7f13268b8a20342969327cd2605dc Mon Sep 17 00:00:00 2001 From: Faiz Hashmi Date: Thu, 3 Oct 2024 10:52:19 +0300 Subject: [PATCH] Fixed issues in ads extension and appointment --- assets/langs/ar-SA.json | 9 +- assets/langs/en-US.json | 9 +- lib/generated/codegen_loader.g.dart | 18 ++- lib/generated/locale_keys.g.dart | 7 ++ .../chat_models/chat_message_model.dart | 7 +- lib/repositories/ads_repo.dart | 28 ++++- lib/repositories/branch_repo.dart | 24 ++-- lib/view_models/ad_view_model.dart | 43 +++++--- lib/view_models/appointments_view_model.dart | 103 ++++++++---------- lib/view_models/payment_view_model.dart | 2 - lib/view_models/requests_view_model.dart | 4 +- lib/view_models/service_view_model.dart | 18 ++- .../ads_detail_view/ads_detail_view.dart | 25 +++-- .../ads_detail_view/components.dart | 2 +- .../ad_duration_selection_sheet.dart | 22 +++- .../damage_pictures_bottom_sheet.dart | 2 +- .../advertisement/select_ad_type_view.dart | 8 +- .../book_appointment_services_view.dart | 4 +- .../book_appointments_item_view.dart | 9 +- .../appointments/review_appointment_view.dart | 6 +- ...appointment_service_pick_bottom_sheet.dart | 10 +- lib/views/common_fragments/ads_fragment.dart | 2 +- lib/views/requests/request_detail_page.dart | 3 +- lib/views/user/forget_password_page.dart | 17 +-- lib/views/user/login_with_password_page.dart | 19 +++- lib/widgets/empty_widget.dart | 8 +- 26 files changed, 254 insertions(+), 155 deletions(-) diff --git a/assets/langs/ar-SA.json b/assets/langs/ar-SA.json index 26b3b82..1f4c471 100644 --- a/assets/langs/ar-SA.json +++ b/assets/langs/ar-SA.json @@ -647,5 +647,12 @@ "callNow": "اتصل الآن", "condition": "الحالة", "servicesNotAvailableHomeLocation": "بعض الخدمات غير متوفرة في الموقع المنزلي.", - "additionalChargesNotice": "هذه الرسوم إضافية على رسوم الخدمة الفعلية. قد تختلف الرسوم للعناصر الثقيلة." + "additionalChargesNotice": "هذه الرسوم إضافية على رسوم الخدمة الفعلية. قد تختلف الرسوم للعناصر الثقيلة.", + "selectServiceLocation": "اختر موقع الخدمة", + "apptOn": "التعيين في", + "merged": "مُدمج", + "date": "التاريخ", + "selectAll": "اختر الكل", + "unselectAll": "إلغاء اختيار الكل", + "copySelectedServices": "نسخ الخدمات المحددة" } \ No newline at end of file diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 48f2fac..4ceed5a 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -648,5 +648,12 @@ "callNow": "Call Now", "condition": "Condition", "servicesNotAvailableHomeLocation": "Some services are not available on home location.", - "additionalChargesNotice": "These charges are additional to the actual service charges. For heavy items the charges may vary." + "additionalChargesNotice": "These charges are additional to the actual service charges. For heavy items the charges may vary.", + "selectServiceLocation": "Select Service Location", + "apptOn": "Appt On", + "merged": "Merged", + "date": "Date", + "selectAll": "Select All", + "unselectAll": "Unselect All", + "copySelectedServices": "Copy Selected Services" } \ No newline at end of file diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 29978e5..2f0664a 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -663,7 +663,14 @@ class CodegenLoader extends AssetLoader{ "callNow": "اتصل الآن", "condition": "الحالة", "servicesNotAvailableHomeLocation": "بعض الخدمات غير متوفرة في الموقع المنزلي.", - "additionalChargesNotice": "هذه الرسوم إضافية على رسوم الخدمة الفعلية. قد تختلف الرسوم للعناصر الثقيلة." + "additionalChargesNotice": "هذه الرسوم إضافية على رسوم الخدمة الفعلية. قد تختلف الرسوم للعناصر الثقيلة.", + "selectServiceLocation": "اختر موقع الخدمة", + "apptOn": "التعيين في", + "merged": "مُدمج", + "date": "التاريخ", + "selectAll": "اختر الكل", + "unselectAll": "إلغاء اختيار الكل", + "copySelectedServices": "نسخ الخدمات المحددة" }; static const Map en_US = { "firstTimeLogIn": "First Time Log In", @@ -1315,7 +1322,14 @@ static const Map en_US = { "callNow": "Call Now", "condition": "Condition", "servicesNotAvailableHomeLocation": "Some services are not available on home location.", - "additionalChargesNotice": "These charges are additional to the actual service charges. For heavy items the charges may vary." + "additionalChargesNotice": "These charges are additional to the actual service charges. For heavy items the charges may vary.", + "selectServiceLocation": "Select Service Location", + "apptOn": "Appt On", + "merged": "Merged", + "date": "Date", + "selectAll": "Select All", + "unselectAll": "Unselect All", + "copySelectedServices": "Copy Selected Services" }; 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 0e29163..37af609 100644 --- a/lib/generated/locale_keys.g.dart +++ b/lib/generated/locale_keys.g.dart @@ -627,5 +627,12 @@ abstract class LocaleKeys { static const condition = 'condition'; static const servicesNotAvailableHomeLocation = 'servicesNotAvailableHomeLocation'; static const additionalChargesNotice = 'additionalChargesNotice'; + static const selectServiceLocation = 'selectServiceLocation'; + static const apptOn = 'apptOn'; + static const merged = 'merged'; + static const date = 'date'; + static const selectAll = 'selectAll'; + static const unselectAll = 'unselectAll'; + static const copySelectedServices = 'copySelectedServices'; } diff --git a/lib/models/chat_models/chat_message_model.dart b/lib/models/chat_models/chat_message_model.dart index f4eacb4..4ecfc4a 100644 --- a/lib/models/chat_models/chat_message_model.dart +++ b/lib/models/chat_models/chat_message_model.dart @@ -41,7 +41,7 @@ class ChatMessageModel { @override String toString() { - return 'ChatMessageModel{id: $id, senderUserID: $senderUserID, senderName: $senderName, messageType: $messageType, chatMessageTypeEnum: $chatMessageTypeEnum, chatText: $chatText, requestID: $requestID, reqOfferID: $reqOfferID, serviceProviderID: $serviceProviderID, offerStatus: $offerStatus, reqOffer: $reqOffer, isRead: $isRead, readOn: $readOn, isMyMessage: $isMyMessage}'; + return 'ChatMessageModel{id: $id, senderUserID: $senderUserID, senderName: $senderName, messageType: $messageType, chatMessageTypeEnum: $chatMessageTypeEnum, chatText: $chatText, requestID: $requestID, reqOfferID: $reqOfferID, serviceProviderID: $serviceProviderID, offerStatus: $offerStatus, reqOffer: ${reqOffer.toString()}, isRead: $isRead, readOn: $readOn, isMyMessage: $isMyMessage}'; } ChatMessageModel.fromJson(Map json) { @@ -107,6 +107,11 @@ class ReqOffer { requestOfferStatusEnum = ((json['offerStatus']) as int).toRequestOfferStatusEnum(); requestsTypeEnum = RequestsTypeEnum.serviceRequest; } + + @override + String toString() { + return 'ReqOffer{id: $id, requestID: $requestID, serviceProviderID: $serviceProviderID, offerStatus: $offerStatus, offerStatusText: $offerStatusText, comment: $comment, serviceItemName: $serviceItemName, manufacturedById: $manufacturedById, manufacturedOn: $manufacturedOn, price: $price, requestsTypeEnum: $requestsTypeEnum, requestOfferStatusEnum: $requestOfferStatusEnum}'; + } } class OfferRequestCommentModel { diff --git a/lib/repositories/ads_repo.dart b/lib/repositories/ads_repo.dart index 6cf1a29..37a20e6 100644 --- a/lib/repositories/ads_repo.dart +++ b/lib/repositories/ads_repo.dart @@ -22,12 +22,7 @@ abstract class AdsRepo { Future> getAllAds({required bool isMyAds}); - Future> getExploreAdsBasedOnFilters({ - List? cityIdsList, - List? vehicleModelYearIdsList, - List? vehicleBrandIdsList, - List? createdByRolesIdsList, - }); + Future> getExploreAdsBasedOnFilters({List? cityIdsList, List? vehicleModelYearIdsList, List? vehicleBrandIdsList, List? createdByRolesIdsList}); Future> getMyReservedAds(); @@ -48,6 +43,8 @@ abstract class AdsRepo { Future uploadBankReceiptsOnReserveDealDone({required int adId, required String detailNote, required List pdfReceiptsList}); Future> getChatBuyersForAds({required int adsID}); + + Future createAdExtensionOrder({required int adID, required List specialServiceIds, required int adsDurationId}); } class AdsRepoImp implements AdsRepo { @@ -284,6 +281,25 @@ class AdsRepoImp implements AdsRepo { return Future.value(adsGenericModel); } + @override + Future createAdExtensionOrder({required int adID, required List specialServiceIds, required int adsDurationId}) async { + var postParams = { + "adsID": adID, + "adsDurationID": adsDurationId, + "specialServiceIDs": specialServiceIds, + }; + + String token = appState.getUser.data!.accessToken ?? ""; + GenericRespModel adsGenericModel = await apiClient.postJsonForObject( + (json) => GenericRespModel.fromJson(json), + ApiConsts.adsExtendDurationCreate, + postParams, + token: token, + ); + + return Future.value(adsGenericModel); + } + @override Future deleteAd({required int adId}) async { var postParams = { diff --git a/lib/repositories/branch_repo.dart b/lib/repositories/branch_repo.dart index 237c75c..520e630 100644 --- a/lib/repositories/branch_repo.dart +++ b/lib/repositories/branch_repo.dart @@ -69,7 +69,7 @@ abstract class BranchRepo { Future getMatchedServices(int oldBranchId, int newBranchId, int categoryId); - Future duplicateItems(Map map); + Future duplicateItems({required String providerBranchID, required List items}); Future getAllProviderDealers(Map map); @@ -188,9 +188,7 @@ class BranchRepoImp implements BranchRepo { }; String? token = AppState().getUser.data?.accessToken; debugPrint(token); - return await injector - .get() - .getJsonForObject((json) => Document.fromJson(json), ApiConsts.fetProviderDocument, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? ""); + return await injector.get().getJsonForObject((json) => Document.fromJson(json), ApiConsts.fetProviderDocument, queryParameters: queryParameters, token: AppState().getUser.data!.accessToken ?? ""); } @override @@ -198,14 +196,7 @@ class BranchRepoImp implements BranchRepo { List> map = []; for (int i = 0; i < documents!.length; i++) { if (documents[i].document != null) { - var postParams = { - "id": documents[i].id, - "serviceProviderID": documents[i].serviceProviderId, - "documentID": documents[i].documentId, - "documentExt": documents[i].fileExt, - "documentImage": documents[i].document, - "isActive": true - }; + var postParams = {"id": documents[i].id, "serviceProviderID": documents[i].serviceProviderId, "documentID": documents[i].documentId, "documentExt": documents[i].fileExt, "documentImage": documents[i].document, "isActive": true}; map.add(postParams); } } @@ -314,8 +305,12 @@ class BranchRepoImp implements BranchRepo { } @override - Future duplicateItems(Map map) async { + Future duplicateItems({required String providerBranchID, required List items}) async { String t = AppState().getUser.data!.accessToken ?? ""; + Map map = { + "providerBranchID": providerBranchID, + "serviceItems": items, + }; return await apiClient.postJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.duplicateItems, map, token: t); } @@ -401,8 +396,7 @@ class BranchRepoImp implements BranchRepo { @override Future getBranchAndServicesByProviderId(int providerId) async { var postParams = {"serviceProviderID": providerId.toString()}; - GenericRespModel adsGenericModel = - await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.branchesAndServices, token: appState.getUser.data!.accessToken, queryParameters: postParams); + GenericRespModel adsGenericModel = await apiClient.getJsonForObject((json) => GenericRespModel.fromJson(json), ApiConsts.branchesAndServices, token: appState.getUser.data!.accessToken, queryParameters: postParams); return ProviderProfileModel.fromJson(adsGenericModel.data); } diff --git a/lib/view_models/ad_view_model.dart b/lib/view_models/ad_view_model.dart index da11c17..10382f2 100644 --- a/lib/view_models/ad_view_model.dart +++ b/lib/view_models/ad_view_model.dart @@ -319,11 +319,11 @@ class AdVM extends BaseVM { if (respModel.messageStatus != 1) { Utils.hideLoading(context); - Utils.showToast(respModel.message ?? "Something went wrong!"); + Utils.showToast(respModel.message ?? LocaleKeys.somethingWrong.tr()); return; } Utils.hideLoading(context); - Utils.showToast("A has been marked as sold successfully!"); + Utils.showToast(respModel.message ?? "A has been marked as sold successfully!"); updateIsExploreAds(false); applyFilterOnMyAds(adPostStatusEnum: AdPostStatus.sold); //pending for review navigateReplaceWithName(context, AppRoutes.dashboard); @@ -335,7 +335,7 @@ class AdVM extends BaseVM { if (respModel.messageStatus != 1) { Utils.hideLoading(context); - Utils.showToast(respModel.message ?? "Something went wrong!"); + Utils.showToast(respModel.message ?? LocaleKeys.somethingWrong.tr()); return; } Utils.hideLoading(context); @@ -351,7 +351,7 @@ class AdVM extends BaseVM { if (respModel.messageStatus != 1) { Utils.hideLoading(context); - Utils.showToast(respModel.message ?? "Something went wrong!"); + Utils.showToast(respModel.message ?? LocaleKeys.somethingWrong.tr()); return; } Utils.hideLoading(context); @@ -367,7 +367,7 @@ class AdVM extends BaseVM { if (respModel.messageStatus != 1) { Utils.hideLoading(context); - Utils.showToast(respModel.message ?? "Something went wrong!"); + Utils.showToast(respModel.message ?? LocaleKeys.somethingWrong.tr()); return; } Utils.hideLoading(context); @@ -1674,18 +1674,36 @@ class AdVM extends BaseVM { setState(ViewState.idle); } -///// Edit Work Amir - void onEditUpdateAdPressed({required BuildContext context, required AdDetailsModel previousDetails, required bool isFromExtendAd}) { isAdEditEnabled = true; previousAdDetails = previousDetails; autoFillSelectedVehicleType(); autoFillSelectedVehicleAdsDuration(); - navigateWithName(context, AppRoutes.selectAdTypeView, arguments: [AppState().currentAppType == AppType.provider, isFromExtendAd]); + navigateWithName(context, AppRoutes.selectAdTypeView, arguments: [AppState().currentAppType == AppType.provider, isFromExtendAd, previousDetails.id]); } - autoFillSelectedVehicleType() async { + Future createAdExtensionOrder(BuildContext context, {required int adId, required int adsDurationId}) async { + try { + Utils.showLoading(context); + GenericRespModel respModel = await adsRepo.createAdExtensionOrder(adID: adId, adsDurationId: adsDurationId, specialServiceIds: []); + + if (respModel.messageStatus != 1) { + Utils.hideLoading(context); + Utils.showToast(respModel.message ?? LocaleKeys.somethingWrong.tr()); + return false; + } + Utils.hideLoading(context); + return respModel.messageStatus == 1; + } catch (e) { + Utils.hideLoading(context); + Utils.showToast(e.toString()); + return false; + } + return false; + } + + void autoFillSelectedVehicleType() async { if (vehicleTypes.isEmpty) { await getVehicleTypes(); return; @@ -1701,7 +1719,7 @@ class AdVM extends BaseVM { notifyListeners(); } - autoFillSelectedVehicleAdsDuration() async { + void autoFillSelectedVehicleAdsDuration() async { if (vehicleAdsDurations.isEmpty) { await getVehicleAdsDuration(); } @@ -1732,7 +1750,7 @@ class AdVM extends BaseVM { notifyListeners(); } - autoFillSelectedVehicleAdsDetails() async { + void autoFillSelectedVehicleAdsDetails() async { int index = vehicleBrands.indexWhere((element) => element.id == previousAdDetails!.vehicle!.model!.vehicleBrandID); if (index != -1) { await updateSelectionVehicleBrandId(SelectionModel(selectedId: vehicleBrands[index].id!, selectedOption: vehicleBrands[index].vehicleBrandDescription ?? "")); @@ -1750,14 +1768,13 @@ class AdVM extends BaseVM { if (indexCountry != -1) { updateSelectionVehicleCountryId(SelectionModel(selectedId: vehicleCountries[indexCountry].id!, selectedOption: vehicleCountries[indexCountry].countryName ?? "")); } - updateSelectionVehicleCityId(SelectionModel(selectedId: previousAdDetails!.vehicle!.cityID!, selectedOption: previousAdDetails!.vehicle!.cityName ?? "")); + vehicleDemandAmount = previousAdDetails!.vehicle!.demandAmount!.toInt().toString(); vehicleVin = previousAdDetails!.vehicle!.vehicleVIN.toString(); vehicleTitle = previousAdDetails!.vehicle!.vehicleTitle.toString(); vehicleDescription = previousAdDetails!.vehicle!.vehicleDescription.toString(); financeAvailableStatus = previousAdDetails!.vehicle!.isFinanceAvailable ?? false; - pickedPostingImages.clear(); if (previousAdDetails!.vehicle!.image != null && previousAdDetails!.vehicle!.image!.isNotEmpty) { for (var element in previousAdDetails!.vehicle!.image!) { diff --git a/lib/view_models/appointments_view_model.dart b/lib/view_models/appointments_view_model.dart index 4bb9ecb..c38d0cd 100644 --- a/lib/view_models/appointments_view_model.dart +++ b/lib/view_models/appointments_view_model.dart @@ -49,7 +49,7 @@ class AppointmentsVM extends BaseVM { AppointmentsVM({required this.commonServices, required this.appointmentRepo, required this.commonRepo, required this.branchRepo}); - bool isUpcommingEnabled = true; + bool isUpcomingEnabled = true; bool isFetchingLists = false; int selectedBranch = 0; int selectedAppointmentIndex = 0; @@ -229,10 +229,9 @@ class AppointmentsVM extends BaseVM { } void removeServiceInCurrentAppointment(int index) { - int serviceId = servicesInCurrentAppointment - .elementAt(index) - .serviceProviderServiceId ?? -1; + int serviceId = servicesInCurrentAppointment.elementAt(index).serviceProviderServiceId ?? -1; allSelectedItemsInAppointments.removeWhere((element) => element.serviceProviderServiceId == serviceId); + servicesInCurrentAppointment[index].serviceItems!.clear(); servicesInCurrentAppointment.removeAt(index); notifyListeners(); } @@ -256,7 +255,7 @@ class AppointmentsVM extends BaseVM { Future populateAppointmentsFilterList() async { if (appointmentsFilterOptions.isNotEmpty) return; - myAppointmentsEnum = await commonRepo.getEnumTypeValues(enumTypeID: 13); // 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)); @@ -352,8 +351,7 @@ class AppointmentsVM extends BaseVM { myAppointments = await appointmentRepo.getMyAppointmentsForCustomersByFilters(); // myFilteredAppointments = myAppointments; - myUpComingAppointments = - myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.booked || element.appointmentStatusEnum == AppointmentStatusEnum.confirmed).toList(); + myUpComingAppointments = myAppointments.where((element) => element.appointmentStatusEnum == AppointmentStatusEnum.booked || element.appointmentStatusEnum == AppointmentStatusEnum.confirmed).toList(); setState(ViewState.idle); applyFilterOnAppointmentsVM(appointmentStatusEnum: AppointmentStatusEnum.allAppointments); notifyListeners(); @@ -414,6 +412,11 @@ class AppointmentsVM extends BaseVM { } } + bool isShowMergeButton() { + return myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList!.every((appointment) => appointment.appointmentStatusEnum == AppointmentStatusEnum.confirmed) && + myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList!.length > 1; + } + Future createMergeAppointment(Map map, {bool isNeedToRebuild = false}) async { if (isNeedToRebuild) setState(ViewState.busy); GenericRespModel genericRespModel = await appointmentRepo.createMergeAppointment(map); @@ -423,23 +426,20 @@ class AppointmentsVM extends BaseVM { bool inNeedToEnableMergeButton = false; - updateCheckBoxInMergeRequest(int currentIndex) { - myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected = - !(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false); + void updateCheckBoxInMergeRequest(int currentIndex) { + myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected = !(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false); int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList ?? []); - if (count > 1) + if (count > 1) { inNeedToEnableMergeButton = true; - else + } else { inNeedToEnableMergeButton = false; + } notifyListeners(); } 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}) { @@ -481,10 +481,7 @@ class AppointmentsVM extends BaseVM { int selectedSubServicesCounter = 0; void onItemUpdateOrSelected(int index, bool selected, int itemId) { - int serviceIndex = 0; - if (servicesInCurrentAppointment.isNotEmpty) { - serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!); - } + int serviceIndex = servicesInCurrentAppointment.indexWhere((element) => element.serviceId == currentServiceSelection!.serviceId!); log("index: $index"); log("selected: $selected"); @@ -500,9 +497,10 @@ class AppointmentsVM extends BaseVM { allSelectedItemsInAppointments.add(serviceItemsFromApi[index]); for (var element in allSelectedItemsInAppointments) { if (!ifItemAlreadySelected(element.id!)) { - servicesInCurrentAppointment[serviceIndex].serviceItems!.add(serviceItemsFromApi[index]); - servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = - servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0"); + if (serviceIndex != -1) { + servicesInCurrentAppointment[serviceIndex].serviceItems!.add(serviceItemsFromApi[index]); + servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0"); + } } } } else { @@ -512,10 +510,12 @@ class AppointmentsVM extends BaseVM { log("currentServiceSelection!.serviceItems: ${currentServiceSelection!.serviceItems!.length}"); allSelectedItemsInAppointments.removeWhere((element) => element.id == itemId); - servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = - servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0"); - servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId); + if (serviceIndex != -1) { + servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0"); + servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId); + } } + notifyListeners(); } @@ -613,14 +613,13 @@ 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} SAR".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} SAR".toText(fontSize: 12, isBold: true), + ], + ), ), ), Row( @@ -655,8 +654,7 @@ class AppointmentsVM extends BaseVM { Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ - (selectedService.isHomeSelected ? "${(selectedService.currentTotalServicePrice) + (double.parse((selectedService.rangePricePerKm ?? "0.0")) * totalKms)}" : "${selectedService - .currentTotalServicePrice}") + (selectedService.isHomeSelected ? "${(selectedService.currentTotalServicePrice) + (double.parse((selectedService.rangePricePerKm ?? "0.0")) * totalKms)}" : "${selectedService.currentTotalServicePrice}") .toText(fontSize: 29, isBold: true), 2.width, LocaleKeys.sar.tr().toText(color: MyColors.lightTextColor, fontSize: 16, isBold: true).paddingOnly(bottom: 5), @@ -803,7 +801,7 @@ class AppointmentsVM extends BaseVM { } } - // BRANCHES RELATED +// BRANCHES RELATED List nearbyBranches = []; List myRecentBranches = []; @@ -912,7 +910,7 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - // Provider Filter +// Provider Filter List branchFilterProviderSearchHistory = []; void removeBranchFilterProviderSearchHistory({bool isClear = false, required int index}) { @@ -951,7 +949,7 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - // Category Filter +// Category Filter List branchFilterCategorySearchHistory = []; void removeBranchFilterCategorySearchHistory({bool isClear = false, required int index}) { @@ -990,7 +988,7 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - // Services Filter +// Services Filter List branchFilterServicesSearchHistory = []; void removeBranchFilterServicesSearchHistory({bool isClear = false, required int index}) { @@ -1043,7 +1041,7 @@ class AppointmentsVM extends BaseVM { return false; } - // Rating filter +// Rating filter double branchFilterByRating = 4.0; @@ -1080,10 +1078,10 @@ class AppointmentsVM extends BaseVM { DropValue( element.id ?? 0, ((element.categoryName!.isEmpty - ? "N/A" - : countryCode == "SA" - ? element.categoryNameN - : element.categoryName) ?? + ? "N/A" + : countryCode == "SA" + ? element.categoryNameN + : element.categoryName) ?? "N/A"), ""), ); @@ -1178,7 +1176,7 @@ class AppointmentsVM extends BaseVM { setState(ViewState.idle); } - // Appointments Filter Screen +// Appointments Filter Screen List branchesDropList = []; @@ -1207,7 +1205,7 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - // Provider Filter For Appointments +// Provider Filter For Appointments List appointmentFilterProviderSearchHistory = []; void removeAppointmentFilterProviderSearchHistory({bool isClear = false, required int index}) { @@ -1258,7 +1256,7 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - // Branches Filter For Appointments +// Branches Filter For Appointments List appointmentFilterBranchSearchHistory = []; @@ -1297,7 +1295,7 @@ class AppointmentsVM extends BaseVM { notifyListeners(); } - // Category Filter For Appointments +// Category Filter For Appointments List appointmentFilterCategorySearchHistory = []; @@ -1498,11 +1496,4 @@ class AppointmentsVM extends BaseVM { } setState(ViewState.idle); } - - bool isShowMergeButton() { - return myFilteredAppointments2[selectedAppointmentIndex] - .customerAppointmentList! - .every((appointment) => appointment.appointmentStatusEnum == AppointmentStatusEnum.confirmed); - } - } diff --git a/lib/view_models/payment_view_model.dart b/lib/view_models/payment_view_model.dart index 79ad783..89fba48 100644 --- a/lib/view_models/payment_view_model.dart +++ b/lib/view_models/payment_view_model.dart @@ -211,8 +211,6 @@ class PaymentVM extends ChangeNotifier { navigateReplaceWithName(context, AppRoutes.dashboard); } - - onSubscriptionPaymentSuccess(BuildContext context) { pop(context); diff --git a/lib/view_models/requests_view_model.dart b/lib/view_models/requests_view_model.dart index 6d7df0b..dbeac1f 100644 --- a/lib/view_models/requests_view_model.dart +++ b/lib/view_models/requests_view_model.dart @@ -76,7 +76,9 @@ class RequestsVM extends BaseVM { Future getRequestsBasedOnFilters() async { myFilteredRequests.clear(); setState(ViewState.busy); - int requestTypeIdApi = requestsTypeFilterOptions.firstWhere((element) => element.isSelected).id; + int requestTypeIdApi = requestsTypeFilterOptions + .firstWhere((element) => element.isSelected) + .id; int requestCityIdApi = 0; if (vehicleCityId.selectedId != -1) { diff --git a/lib/view_models/service_view_model.dart b/lib/view_models/service_view_model.dart index c743534..a7e9715 100644 --- a/lib/view_models/service_view_model.dart +++ b/lib/view_models/service_view_model.dart @@ -487,8 +487,22 @@ class ServiceVM extends BaseVM { notifyListeners(); } - Future duplicateItems(Map map) async { - return await branchRepo.duplicateItems(map); + Future duplicateItems({required String providerBranchID, required BuildContext context}) async { + List items = []; + for (var element in matchedServices!) { + items.addAll(element.serviceItems!.where((e) => e.isUpdateOrSelected == true).map((e) => e.id ?? 0).toList()); + } + + try { + Utils.showLoading(context); + GenericRespModel genericRespModel = await branchRepo.duplicateItems(items: items, providerBranchID: providerBranchID); + Utils.hideLoading(context); + Utils.showToast(genericRespModel.message ?? ""); + pop(context); + pop(context); + } catch (e, s) { + Utils.showToast(e.toString()); + } } // Branch Users 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 3d42cd6..28516fd 100644 --- a/lib/views/advertisement/ads_detail_view/ads_detail_view.dart +++ b/lib/views/advertisement/ads_detail_view/ads_detail_view.dart @@ -113,7 +113,7 @@ class _AdsDetailViewState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Flexible( - child: "${widget.adDetails.vehicle!.vehicleTitle} | ${widget.adDetails.vehicle!.color!.label}".toText(fontSize: 16, maxLines: 2), + child: "${widget.adDetails.vehicle!.vehicleTitle} | ${widget.adDetails.vehicle!.color!.label}| ${widget.adDetails.id}".toText(fontSize: 16, maxLines: 2), ), (widget.adDetails.vehicle!.cityName ?? "").toText(fontSize: 10, color: MyColors.lightTextColor), ], @@ -273,6 +273,17 @@ class _AdsDetailViewState extends State { @override Widget build(BuildContext context) { + Widget actionWidget = const SizedBox(); + if ((widget.adDetails.isMyAd ?? false) && (widget.adDetails.adPostStatus != AdPostStatus.reserved) && (widget.adDetails.adPostStatus != AdPostStatus.active)) { + actionWidget = IconButton( + icon: const Icon(Icons.delete_outline, color: MyColors.redColor), + onPressed: () { + return deleteAdBottomSheet(context); + }, + ); + } else { + actionWidget = IconButton(icon: const Icon(Icons.chat_outlined, color: Colors.black), onPressed: () => adVM.onMessagesButtonPressed(context: context, adDetailsModel: widget.adDetails)); + } return Scaffold( appBar: CustomAppBar( title: LocaleKeys.vehicleDetails.tr(), @@ -280,15 +291,7 @@ class _AdsDetailViewState extends State { isRemoveBackButton: false, isDrawerEnabled: false, actions: [ - ((widget.adDetails.isMyAd ?? false) && (widget.adDetails.adPostStatus != AdPostStatus.reserved) && (widget.adDetails.adPostStatus != AdPostStatus.active) - ? IconButton( - icon: const Icon(Icons.delete_outline, color: MyColors.redColor), - onPressed: () { - return deleteAdBottomSheet(context); - }, - ) - : IconButton(icon: const Icon(Icons.chat_outlined, color: Colors.black), onPressed: () => adVM.onMessagesButtonPressed(context: context, adDetailsModel: widget.adDetails))) - .toContainer( + actionWidget.toContainer( margin: const EdgeInsets.fromLTRB(0, 8, 21, 8), paddingAll: 0, padding: const EdgeInsets.only(right: 21), @@ -297,7 +300,7 @@ class _AdsDetailViewState extends State { isEnabledBorder: true, height: 40, width: 42, - ) + ), ], onTap: () {}, ), diff --git a/lib/views/advertisement/ads_detail_view/components.dart b/lib/views/advertisement/ads_detail_view/components.dart index efd1163..22022cc 100644 --- a/lib/views/advertisement/ads_detail_view/components.dart +++ b/lib/views/advertisement/ads_detail_view/components.dart @@ -885,7 +885,7 @@ class BuildAdDetailsActionButtonForMyAds extends StatelessWidget { SelectionModel(selectedId: adDetailsModel.vehicle!.vehicleType!, selectedOption: (adDetailsModel.vehicle!.vehicleType!).toVehicleTypeString(), errorValue: ""), ); - showMyBottomSheet(context, child: const AdDurationSelectionSheet(isFromExtendAd: true, isUpdateAdSelected: false)); + showMyBottomSheet(context, child: AdDurationSelectionSheet(isFromExtendAd: true, isUpdateAdSelected: false, adsID: adDetailsModel.id ?? -1)); }, ), ), diff --git a/lib/views/advertisement/bottom_sheets/ad_duration_selection_sheet.dart b/lib/views/advertisement/bottom_sheets/ad_duration_selection_sheet.dart index 3841c55..8daa533 100644 --- a/lib/views/advertisement/bottom_sheets/ad_duration_selection_sheet.dart +++ b/lib/views/advertisement/bottom_sheets/ad_duration_selection_sheet.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:mc_common_app/config/routes.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; @@ -18,8 +20,14 @@ import 'package:easy_localization/easy_localization.dart'; class AdDurationSelectionSheet extends StatelessWidget { final bool isFromExtendAd; final bool isUpdateAdSelected; + final int adsID; - const AdDurationSelectionSheet({super.key, required this.isFromExtendAd, required this.isUpdateAdSelected}); + const AdDurationSelectionSheet({ + super.key, + required this.isFromExtendAd, + required this.isUpdateAdSelected, + required this.adsID, + }); @override Widget build(BuildContext context) { @@ -118,15 +126,19 @@ class AdDurationSelectionSheet extends StatelessWidget { title: adVM.isFetchingLists ? "" : LocaleKeys.select.tr(), maxWidth: double.infinity, margin: const EdgeInsets.all(21), - onPressed: () { + onPressed: () async { if (adVM.isFetchingLists) { return; } else { if (isFromExtendAd && !isUpdateAdSelected) { - navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.extendAds); - return; + bool status = await adVM.createAdExtensionOrder(context, adId: adsID, adsDurationId: adVM.vehicleAdDurationId.selectedId); + log("hereStatus: $status"); + if (status) { + navigateWithName(context, AppRoutes.paymentMethodsView, arguments: PaymentTypes.extendAds); + } + } else { + navigateReplaceWithName(context, AppRoutes.createAdView); } - navigateReplaceWithName(context, AppRoutes.createAdView); } }, ).toContainer(paddingAll: 0, backgroundColor: Colors.white), diff --git a/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart b/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart index 898f4e0..8943661 100644 --- a/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart +++ b/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart @@ -37,7 +37,7 @@ class _DamagePicturesListState extends State { return const Center(child: CircularProgressIndicator()); } return appointmentsVM.serviceItemsFromApi.isEmpty - ? const EmptyWidget(text: "No Items Found", isWrapedColumn: false,) + ? EmptyWidget(text: LocaleKeys.noItemstoShow.tr(), isWrappedColumn: false) : ListView.separated( itemCount: appointmentsVM.serviceItemsFromApi.length, itemBuilder: (BuildContext context, int index) { diff --git a/lib/views/advertisement/select_ad_type_view.dart b/lib/views/advertisement/select_ad_type_view.dart index 02c2720..7188ba4 100644 --- a/lib/views/advertisement/select_ad_type_view.dart +++ b/lib/views/advertisement/select_ad_type_view.dart @@ -18,7 +18,7 @@ import 'package:provider/provider.dart'; import 'package:easy_localization/easy_localization.dart'; class SelectAdTypeView extends StatelessWidget { - final List arguments; // [0] isProviderOrCustomer [1] isFromExtendAd + final List arguments; // [0] isProviderOrCustomer [1] isFromExtendAd const SelectAdTypeView({Key? key, required this.arguments}) : super(key: key); @@ -42,6 +42,10 @@ class SelectAdTypeView extends StatelessWidget { Widget build(BuildContext context) { bool isProvider = arguments[0]; bool isFromExtendAd = arguments[1]; + int adsId = -1; + if (arguments.length > 2) { + adsId = arguments[2] ?? -1; + } return Scaffold( appBar: CustomAppBar( title: LocaleKeys.selectAdType.tr(), @@ -64,7 +68,7 @@ class SelectAdTypeView extends StatelessWidget { adVM.autoFillSelectedVehicleAdsDetails(); } log("isUpdateAdSelected: ${adVM.isAdEditEnabled}}"); - showMyBottomSheet(context, child: AdDurationSelectionSheet(isUpdateAdSelected: adVM.isAdEditEnabled, isFromExtendAd: isFromExtendAd)); + showMyBottomSheet(context, child: AdDurationSelectionSheet(isUpdateAdSelected: adVM.isAdEditEnabled, isFromExtendAd: isFromExtendAd, adsID: adsId)); }, child: SizedBox( width: double.infinity, diff --git a/lib/views/appointments/book_appointment_services_view.dart b/lib/views/appointments/book_appointment_services_view.dart index 2d581b1..99c91c2 100644 --- a/lib/views/appointments/book_appointment_services_view.dart +++ b/lib/views/appointments/book_appointment_services_view.dart @@ -56,9 +56,7 @@ class BookAppointmentServicesView extends StatelessWidget { children: [ Row( children: [ - Expanded( - child: (serviceData.serviceDescription ?? "").toText(fontSize: 15, isBold: true), - ), + Expanded(child: (serviceData.serviceDescription ?? "").toText(fontSize: 15, isBold: true)), IconButton(onPressed: () => appointmentsVM.removeServiceInCurrentAppointment(serviceIndex), icon: const Icon(Icons.delete_outline, color: MyColors.redColor)) ], ), diff --git a/lib/views/appointments/book_appointments_item_view.dart b/lib/views/appointments/book_appointments_item_view.dart index 30c871c..046a152 100644 --- a/lib/views/appointments/book_appointments_item_view.dart +++ b/lib/views/appointments/book_appointments_item_view.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/extensions/int_extensions.dart'; @@ -25,7 +27,10 @@ class BookAppointmentsItemView extends StatelessWidget { isRemoveBackButton: false, isDrawerEnabled: false, actions: [MyAssets.searchIcon.buildSvg().paddingOnly(right: 21)], - onBackButtonTapped: () => Navigator.pop(context), + onBackButtonTapped: () { + context.read().resetCategorySelectionBottomSheet(); + Navigator.pop(context); + }, ), body: Consumer( builder: (BuildContext context, AppointmentsVM appointmentsVM, Widget? child) { @@ -37,7 +42,7 @@ class BookAppointmentsItemView extends StatelessWidget { width: double.infinity, color: MyColors.darkTextColor, alignment: Alignment.centerLeft, - child: ("${appointmentsVM.selectedSubServicesCounter} " + LocaleKeys.itemsSelected.tr()).toText(fontSize: 16, color: MyColors.white).horPaddingMain(), + child: ("${appointmentsVM.selectedSubServicesCounter} ${LocaleKeys.itemsSelected.tr()}").toText(fontSize: 16, color: MyColors.white).horPaddingMain(), ), 16.height, Column( diff --git a/lib/views/appointments/review_appointment_view.dart b/lib/views/appointments/review_appointment_view.dart index f50b6ee..c0af252 100644 --- a/lib/views/appointments/review_appointment_view.dart +++ b/lib/views/appointments/review_appointment_view.dart @@ -156,7 +156,7 @@ class ReviewAppointment extends StatelessWidget { 3.height, Row(children: [ "${LocaleKeys.dateAndTime.tr()}: ".toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), - "${scheduleData.selectedCustomTimeDateSlotModel!.date!.date} at ${selectedTimeSlot}".toText(fontSize: 12, isBold: true), + "${scheduleData.selectedCustomTimeDateSlotModel!.date!.date} at $selectedTimeSlot".toText(fontSize: 12, isBold: true), ]), Row(children: [ ("${LocaleKeys.location.tr()}: ").toText(fontSize: 12, color: MyColors.lightTextColor, isBold: true), @@ -181,7 +181,7 @@ class ReviewAppointment extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ LocaleKeys.serviceCharges.tr().toText(fontSize: 14, color: MyColors.lightTextColor, isBold: true), - "${scheduleData.amountTotal.toString()} SAR".toText(fontSize: 16, isBold: true), + "${scheduleData.amountTotal.toString()} ${LocaleKeys.sar.tr()}".toText(fontSize: 16, isBold: true), ], ), if (scheduleData.appointmentType == 1) ...[ @@ -200,7 +200,7 @@ class ReviewAppointment extends StatelessWidget { ], ); }, - separatorBuilder: (BuildContext context, int index) => Divider(thickness: 2), + separatorBuilder: (BuildContext context, int index) => const Divider(thickness: 2), ).paddingOnly(bottom: 10), ], ), 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 7aabee9..8381dcd 100644 --- a/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart +++ b/lib/views/appointments/widgets/appointment_service_pick_bottom_sheet.dart @@ -84,15 +84,7 @@ class AppointmentServicePickBottomSheet extends StatelessWidget { ], if (appointmentsVM.branchSelectedServiceId.selectedId != -1 && !appointmentsVM.isFetchingServices) ...[ 16.height, - Row( - children: [ - "Select Service Location".toText( - fontSize: 16, - isBold: true, - color: MyColors.black, - ), - ], - ), + Row(children: [LocaleKeys.selectServiceLocation.tr().toText(fontSize: 16, isBold: true, color: MyColors.black)]), 8.height, Row( children: [ diff --git a/lib/views/common_fragments/ads_fragment.dart b/lib/views/common_fragments/ads_fragment.dart index 1d79aa3..23ac72e 100644 --- a/lib/views/common_fragments/ads_fragment.dart +++ b/lib/views/common_fragments/ads_fragment.dart @@ -136,7 +136,7 @@ class AdsFragment extends StatelessWidget { ), floatingActionButton: FloatingActionButton( onPressed: () async { - navigateWithName(context, AppRoutes.selectAdTypeView, arguments: [injector.get().currentAppType == AppType.provider, false]); + navigateWithName(context, AppRoutes.selectAdTypeView, arguments: [injector.get().currentAppType == AppType.provider, false, -1]); }, backgroundColor: MyColors.darkPrimaryColor, child: const Icon(Icons.add, color: MyColors.white), diff --git a/lib/views/requests/request_detail_page.dart b/lib/views/requests/request_detail_page.dart index 6c03702..d85b491 100644 --- a/lib/views/requests/request_detail_page.dart +++ b/lib/views/requests/request_detail_page.dart @@ -9,7 +9,6 @@ import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/navigator.dart'; import 'package:mc_common_app/utils/utils.dart'; import 'package:mc_common_app/view_models/chat_view_model.dart'; -import 'package:mc_common_app/view_models/requests_view_model.dart'; import 'package:mc_common_app/views/advertisement/components/ads_images_corousel_widget.dart'; import 'package:mc_common_app/views/chat/widgets/chat_bottom_sheets.dart'; import 'package:mc_common_app/views/requests/request_bottomsheets.dart'; @@ -25,7 +24,7 @@ class RequestDetailPage extends StatelessWidget { const RequestDetailPage({Key? key, required this.requestDetailPageArguments}) : super(key: key); Widget buildRequestDetailActionFooter({required int requestId, required RequestStatusEnum requestStatus, required RequestsTypeEnum requestTypeEnum, required String statusText, required BuildContext context}) { - final requestsVM = context.read(); + // final requestsVM = context.read(); switch (requestStatus) { case RequestStatusEnum.submitted: return ShowFillButton( diff --git a/lib/views/user/forget_password_page.dart b/lib/views/user/forget_password_page.dart index c463432..51d7ca5 100644 --- a/lib/views/user/forget_password_page.dart +++ b/lib/views/user/forget_password_page.dart @@ -142,13 +142,16 @@ class _ForgetPasswordPageState extends State { ); return Padding( padding: const EdgeInsets.all(2.0), - child: DropdownField( dropdownValue: tempCountry ,(DropValue value) { - countryCode = value.subValue; - tempCountry = value; -setState(() { - -}); - }, list: dropList, hint: LocaleKeys.selectCountryCode.tr()), + child: DropdownField( + dropdownValue: tempCountry, + (DropValue value) { + countryCode = value.subValue; + tempCountry = value; + setState(() {}); + }, + list: dropList, + hint: LocaleKeys.selectCountryCode.tr(), + ), ); } else { return const Center( diff --git a/lib/views/user/login_with_password_page.dart b/lib/views/user/login_with_password_page.dart index 80c593a..b7f5741 100644 --- a/lib/views/user/login_with_password_page.dart +++ b/lib/views/user/login_with_password_page.dart @@ -40,6 +40,8 @@ class _LoginWithPasswordState extends State { String countryCode = ""; Country? _country; + DropValue? tempCountry; + late UserVM userVM; @override @@ -78,7 +80,7 @@ class _LoginWithPasswordState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: const CustomAppBar(isRemoveBackButton: true, title: ""), + appBar: const CustomAppBar(isRemoveBackButton: true, title: ""), body: Container( width: double.infinity, height: double.infinity, @@ -169,11 +171,18 @@ class _LoginWithPasswordState extends State { if (_country != null) { List dropList = []; _country!.data?.forEach((element) { - dropList.add(DropValue(element.id ?? 0, (element.countryName ?? "") + " " + (element.countryCode ?? ""), element.countryCode ?? "")); + dropList.add(DropValue(element.id ?? 0, "${element.countryName ?? ""} ${element.countryCode ?? ""}", element.countryCode ?? "")); }); - return DropdownField((DropValue value) { - countryCode = value.subValue; - }, list: dropList, hint: LocaleKeys.selectCountryCode.tr()); + return DropdownField( + dropdownValue: tempCountry, + (DropValue value) { + countryCode = value.subValue; + tempCountry = value; + setState(() {}); + }, + list: dropList, + hint: LocaleKeys.selectCountryCode.tr(), + ); } else { return const Center( child: CircularProgressIndicator(), diff --git a/lib/widgets/empty_widget.dart b/lib/widgets/empty_widget.dart index c5b1d36..7f686a3 100644 --- a/lib/widgets/empty_widget.dart +++ b/lib/widgets/empty_widget.dart @@ -5,16 +5,18 @@ import 'package:mc_common_app/theme/colors.dart'; class EmptyWidget extends StatelessWidget { final String text; - final bool isWrapedColumn; + final bool isWrappedColumn; + final Widget? spacerWidget; - const EmptyWidget({Key? key, required this.text, this.isWrapedColumn = true}) : super(key: key); + const EmptyWidget({Key? key, required this.text, this.isWrappedColumn = true, this.spacerWidget}) : super(key: key); @override Widget build(BuildContext context) { - if (isWrapedColumn) { + if (isWrappedColumn) { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ + spacerWidget ?? const SizedBox(), text.toText(fontSize: 16, color: MyColors.lightTextColor, fontWeight: MyFonts.Medium), ], );