diff --git a/assets/langs/en-US.json b/assets/langs/en-US.json index 178eeea..48f2fac 100644 --- a/assets/langs/en-US.json +++ b/assets/langs/en-US.json @@ -40,7 +40,7 @@ "forgetPass": "Forget Password ?", "phoneNumberVerified": "Phone Number Verified", "verifyNewPassword": "Verify New Password", - "EnterPass": "Enter Password ?", + "EnterPass": "Enter Password", "alreadySigned": " Already Signed Up and Logged In", "emailChangedSuccessfully": "Email is Changed Successfully", "passwordIsUpdated": "Password is Updated", diff --git a/lib/generated/codegen_loader.g.dart b/lib/generated/codegen_loader.g.dart index 8529b51..29978e5 100644 --- a/lib/generated/codegen_loader.g.dart +++ b/lib/generated/codegen_loader.g.dart @@ -707,7 +707,7 @@ static const Map en_US = { "forgetPass": "Forget Password ?", "phoneNumberVerified": "Phone Number Verified", "verifyNewPassword": "Verify New Password", - "EnterPass": "Enter Password ?", + "EnterPass": "Enter Password", "alreadySigned": " Already Signed Up and Logged In", "emailChangedSuccessfully": "Email is Changed Successfully", "passwordIsUpdated": "Password is Updated", diff --git a/lib/models/provider_branches_models/profile/document.dart b/lib/models/provider_branches_models/profile/document.dart index 7be8a60..8f2f87c 100644 --- a/lib/models/provider_branches_models/profile/document.dart +++ b/lib/models/provider_branches_models/profile/document.dart @@ -21,16 +21,14 @@ class Document { int? messageStatus; String? message; - factory Document.fromJson(Map json) => - Document( + factory Document.fromJson(Map json) => Document( totalItemsCount: json["totalItemsCount"] == null ? null : json["totalItemsCount"], data: json["data"] == null ? null : List.from(json["data"].map((x) => DocumentData.fromJson(x))), messageStatus: json["messageStatus"] == null ? null : json["messageStatus"], message: json["message"] == null ? null : json["message"], ); - Map toJson() => - { + Map toJson() => { "totalItemsCount": totalItemsCount == null ? null : totalItemsCount, "data": data == null ? null : List.from(data!.map((x) => x.toJson())), "messageStatus": messageStatus == null ? null : messageStatus, @@ -39,7 +37,19 @@ class Document { } class DocumentData { - DocumentData({this.id, this.serviceProviderId, this.documentId, this.documentUrl, this.status, this.comment, this.isActive, this.document, this.fileExt, this.documentName}); + DocumentData({ + this.id, + this.serviceProviderId, + this.documentId, + this.documentUrl, + this.status, + this.comment, + this.isActive, + this.document, + this.fileExt, + this.documentName, + this.isLocalFile, + }); int? id; int? serviceProviderId; @@ -51,23 +61,22 @@ class DocumentData { String? document; String? fileExt; String? documentName; + bool? isLocalFile; - factory DocumentData.fromJson(Map json) => - DocumentData( - id: json["id"] == null ? null : json["id"], - serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"], - documentId: json["documentID"] == null ? null : json["documentID"], - documentUrl: json["documentURL"], - status: json["status"] == null ? null : json["status"], - comment: json["comment"], - isActive: json["isActive"] == null ? null : json["isActive"], - document: null, - fileExt: null, - documentName: json["documentName"] == null ? null : json["documentName"], - ); + factory DocumentData.fromJson(Map json) => DocumentData( + id: json["id"] == null ? null : json["id"], + serviceProviderId: json["serviceProviderID"] == null ? null : json["serviceProviderID"], + documentId: json["documentID"] == null ? null : json["documentID"], + documentUrl: json["documentURL"], + status: json["status"] == null ? null : json["status"], + comment: json["comment"], + isActive: json["isActive"] == null ? null : json["isActive"], + document: null, + fileExt: null, + documentName: json["documentName"] == null ? null : json["documentName"], + isLocalFile: false); - Map toJson() => - { + Map toJson() => { "id": id == null ? null : id, "serviceProviderID": serviceProviderId == null ? null : serviceProviderId, "documentID": documentId == null ? null : documentId, diff --git a/lib/services/common_services.dart b/lib/services/common_services.dart index 3f0a050..ab50cc8 100644 --- a/lib/services/common_services.dart +++ b/lib/services/common_services.dart @@ -109,4 +109,6 @@ class CommonServicesImp implements CommonAppServices { return 0.0; } } + + } diff --git a/lib/view_models/appointments_view_model.dart b/lib/view_models/appointments_view_model.dart index 0164622..4bb9ecb 100644 --- a/lib/view_models/appointments_view_model.dart +++ b/lib/view_models/appointments_view_model.dart @@ -229,7 +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.removeAt(index); notifyListeners(); @@ -350,7 +352,8 @@ 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(); @@ -421,7 +424,8 @@ class AppointmentsVM extends BaseVM { bool inNeedToEnableMergeButton = false; updateCheckBoxInMergeRequest(int currentIndex) { - myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected = !(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false); + myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList![currentIndex].isSelected = + !(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList?[currentIndex].isSelected ?? false); int count = countSelected(myFilteredAppointments2[selectedAppointmentIndex].customerAppointmentList ?? []); if (count > 1) @@ -432,7 +436,10 @@ 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}) { @@ -494,7 +501,8 @@ class AppointmentsVM extends BaseVM { 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"); + servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice = + servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice + double.parse((serviceItemsFromApi[index].price) ?? "0.0"); } } } else { @@ -504,7 +512,8 @@ 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].currentTotalServicePrice = + servicesInCurrentAppointment[serviceIndex].currentTotalServicePrice - double.parse((serviceItemsFromApi[index].price) ?? "0.0"); servicesInCurrentAppointment[serviceIndex].serviceItems!.removeWhere((element) => element.id == itemId); } notifyListeners(); @@ -604,13 +613,14 @@ 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( @@ -645,7 +655,8 @@ 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), @@ -1069,10 +1080,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"), ""), ); @@ -1487,4 +1498,11 @@ 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/service_view_model.dart b/lib/view_models/service_view_model.dart index bf62eb7..c743534 100644 --- a/lib/view_models/service_view_model.dart +++ b/lib/view_models/service_view_model.dart @@ -64,6 +64,7 @@ class ServiceVM extends BaseVM { List commercialCertificates = []; List vatCertificates = []; List homePageBranches = []; + List categories = []; void updateSelectionOpenTime(String date) { openTime = date; @@ -118,68 +119,111 @@ class ServiceVM extends BaseVM { notifyListeners(); } - // Future selectFile(BuildContext context, int index) async { - // final status = await AppPermissions.checkStoragePermissions(context); - // if (status) { - // final File? file = await commonServices.pickFile( - // context, - // fileType: FileType.custom, - // allowedExtensions: ['png', 'pdf', 'jpeg'], - // ); - // if (file != null) { - // int sizeInBytes = file.lengthSync(); - // // double sizeInMb = sizeInBytes / (1024 * 1024); - // if (sizeInBytes > 1000000) { - // Utils.showToast(LocaleKeys.fileLarger.tr()); - // } else { - // document!.data![index].document = Utils.convertFileToBase64(file); - // document!.data![index].fileExt = Utils.checkFileExt(file.path); - // document!.data![index].documentUrl = file.path; - // setState(ViewState.idle); - // // return document!.data![index].document; - // } - // } else { - // // User canceled the picker - // } - // } - // } - - // Future selectFile(BuildContext context, int index) async { - // File? file = await commonServices.pickFile(context, fileType: FileType.custom, allowedExtensions: ['png', 'pdf', 'jpeg']); - // - // if (file != null) { - // int sizeInBytes = file.lengthSync(); - // // double sizeInMb = sizeInBytes / (1024 * 1024); - // if (sizeInBytes > 1000000) { - // Utils.showToast(LocaleKeys.fileLarger.tr()); - // } else { - // document!.data![index].document = Utils.convertFileToBase64(file); - // document!.data![index].fileExt = Utils.checkFileExt(file.path); - // document!.data![index].documentUrl = file.path; - // document!.data![index].isFileAttached = true; - // return Utils.convertFileToBase64(file); - // } - // } else { - // // User canceled the picker - // } - // return null; - // } + filterUserBranchCategories() { + categories = []; + print("Filter Branch Executed"); + List? localbranches; + if (branches!.data != null) { + if (selectedBranchStatus == 3) { + localbranches = branches!.data!.serviceProviderBranch!.where((element) => element.statusId == 3).toList(); + } else { + localbranches = branches!.data!.serviceProviderBranch!.where((element) => element.statusId != 3).toList(); + } + } + + for (var branch in localbranches!) { + for (var element in branch.branchServices!) { + categories.add( + CategoryData( + id: element.categoryId, + categoryName: element.categoryName, + categoryNameN: element.categoryName, + ), + ); + } + categories = categories.toSet().toList(); + for (var payment in categories) { + for (var element in branch.branchServices!) { + if (payment.id == element.categoryId) { + payment.services ??= []; + payment.services!.add(element); + } + } + } + } + + categories = categories; + } + +// Future selectFile(BuildContext context, int index) async { +// final status = await AppPermissions.checkStoragePermissions(context); +// if (status) { +// final File? file = await commonServices.pickFile( +// context, +// fileType: FileType.custom, +// allowedExtensions: ['png', 'pdf', 'jpeg'], +// ); +// if (file != null) { +// int sizeInBytes = file.lengthSync(); +// // double sizeInMb = sizeInBytes / (1024 * 1024); +// if (sizeInBytes > 1000000) { +// Utils.showToast(LocaleKeys.fileLarger.tr()); +// } else { +// document!.data![index].document = Utils.convertFileToBase64(file); +// document!.data![index].fileExt = Utils.checkFileExt(file.path); +// document!.data![index].documentUrl = file.path; +// setState(ViewState.idle); +// // return document!.data![index].document; +// } +// } else { +// // User canceled the picker +// } +// } +// } + +// Future selectFile(BuildContext context, int index) async { +// File? file = await commonServices.pickFile(context, fileType: FileType.custom, allowedExtensions: ['png', 'pdf', 'jpeg']); +// +// if (file != null) { +// int sizeInBytes = file.lengthSync(); +// // double sizeInMb = sizeInBytes / (1024 * 1024); +// if (sizeInBytes > 1000000) { +// Utils.showToast(LocaleKeys.fileLarger.tr()); +// } else { +// document!.data![index].document = Utils.convertFileToBase64(file); +// document!.data![index].fileExt = Utils.checkFileExt(file.path); +// document!.data![index].documentUrl = file.path; +// document!.data![index].isFileAttached = true; +// return Utils.convertFileToBase64(file); +// } +// } else { +// // User canceled the picker +// } +// return null; +// } Future pickPdfReceiptFile(BuildContext context, int documentID, int index) async { List imageModels = []; - List? files = await commonServices.pickMultipleFiles(context, allowMultiple: false); + List? files = await commonServices.pickMultipleFiles( + context, + allowMultiple: false, + ); if (files == null) return null; for (var element in files) { - imageModels.add(ImageModel(filePath: element.path, isFromNetwork: false)); + imageModels.add(ImageModel( + filePath: element.path, + isFromNetwork: false, + )); } documentID == 1 ? commerceCertificates.addAll(imageModels) : documentID == 2 - ? commercialCertificates.addAll(imageModels) - : vatCertificates.addAll(imageModels); + ? commercialCertificates.addAll(imageModels) + : vatCertificates.addAll(imageModels); document!.data![index].document = Utils.convertFileToBase64(files.first); document!.data![index].fileExt = Utils.checkFileExt(files.first.path); document!.data![index].documentUrl = files.first.path; + document!.data![index].isLocalFile = true; notifyListeners(); } @@ -192,6 +236,16 @@ class ServiceVM extends BaseVM { notifyListeners(); } + Future removeNetworkImag(String filePath) async { + int index = document!.data!.indexWhere((element) => element.documentUrl == filePath); + if (index == -1) { + return; + } + document!.data![index].documentUrl = null; + document!.data![index].isLocalFile = true; + notifyListeners(); + } + Future commercialRemove(String filePath) async { int index = commercialCertificates.indexWhere((element) => element.filePath == filePath); if (index == -1) { @@ -214,7 +268,7 @@ class ServiceVM extends BaseVM { return await branchRepo.serviceProviderDocumentsUpdate(data); } - // Create new branch +// Create new branch Future getBranchAndServices() async { setState(ViewState.busy); branches = await branchRepo.getBranchAndServices(); @@ -319,7 +373,7 @@ class ServiceVM extends BaseVM { pickedBranchImages.clear(); } - // Create Services +// Create Services Services? services; List categoryDropList = []; List servicesDropList = []; @@ -335,10 +389,10 @@ class ServiceVM 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"), "", ), @@ -382,7 +436,9 @@ class ServiceVM extends BaseVM { } Future createService(List> map) async { + setState(ViewState.busy); return await branchRepo.createService(map); + setState(ViewState.idle); } Future updateServices(List> map) async { @@ -435,7 +491,7 @@ class ServiceVM extends BaseVM { return await branchRepo.duplicateItems(map); } - // Branch Users +// Branch Users List allProviderDealersList = []; List branchUserList = []; @@ -449,6 +505,28 @@ class ServiceVM extends BaseVM { setState(ViewState.idle); } +// filterUserBranchCategories() { +// for (var element in branchData.branchServices!) { +// categories.add( +// CategoryData( +// id: element.categoryId, +// categoryName: element.categoryName, +// categoryNameN: element.categoryName, +// ), +// ); +// } +// categories = categories.toSet().toList(); +// for (var payment in categories) { +// for (var element in branchData.branchServices!) { +// if (payment.id == element.categoryId) { +// payment.services ??= []; +// payment.services!.add(element); +// } +// } +// } +// branchData.categories = categories; +// } + Future getBranchUsers(Map map) async { setState(ViewState.busy); GenericRespModel response = await branchRepo.getBranchUsers(map); @@ -482,7 +560,9 @@ class ServiceVM extends BaseVM { File file = File(imageModel.filePath!); List imageBytes = await file.readAsBytes(); String image = base64Encode(imageBytes); - String fileName = file.path.split('/').last; + String fileName = file.path + .split('/') + .last; branchPostingImages = BranchPostingImages( imageName: fileName, imageStr: image, diff --git a/lib/views/advertisement/components/ads_images_corousel_widget.dart b/lib/views/advertisement/components/ads_images_corousel_widget.dart index 5d1c4b3..52ad8a7 100644 --- a/lib/views/advertisement/components/ads_images_corousel_widget.dart +++ b/lib/views/advertisement/components/ads_images_corousel_widget.dart @@ -24,7 +24,7 @@ class _CarouselWithIndicatorState extends State { if (widget.imagesList.isEmpty) { return Center( child: SizedBox( - height: 25.h, + height: 26.h, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -39,17 +39,18 @@ class _CarouselWithIndicatorState extends State { ); } return SizedBox( - height: 25.h, - child: Column(children: [ + height: 26.h, + child: ListView(shrinkWrap: true, children: [ CarouselSlider( items: widget.imagesList - .map((item) => Container( - margin: const EdgeInsets.all(5.0), - child: ClipRRect( - borderRadius: const BorderRadius.all(Radius.circular(5.0)), - child: item.imageUrl.buildNetworkImage(), - ), - )) + .map((item) => + Container( + margin: const EdgeInsets.all(5.0), + child: ClipRRect( + borderRadius: const BorderRadius.all(Radius.circular(5.0)), + child: item.imageUrl.buildNetworkImage(), + ), + )) .toList(), carouselController: _controller, options: CarouselOptions( @@ -64,7 +65,10 @@ class _CarouselWithIndicatorState extends State { ), Row( mainAxisAlignment: MainAxisAlignment.center, - children: widget.imagesList.asMap().entries.map((entry) { + children: widget.imagesList + .asMap() + .entries + .map((entry) { return GestureDetector( onTap: () => _controller.animateToPage(entry.key), child: Container( diff --git a/lib/views/advertisement/components/ads_list_widget.dart b/lib/views/advertisement/components/ads_list_widget.dart index 45d921f..60740bb 100644 --- a/lib/views/advertisement/components/ads_list_widget.dart +++ b/lib/views/advertisement/components/ads_list_widget.dart @@ -34,7 +34,7 @@ class AdsListWidget extends StatelessWidget { return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - LocaleKeys.noAdsShow.tr().toText(fontSize: 16, color: MyColors.lightTextColor), + LocaleKeys.noAdsShow.tr().toText(fontSize: 16, color: MyColors.lightTextColor, fontWeight: MyFonts.Medium), ], ); } diff --git a/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart b/lib/views/advertisement/components/damage_pictures_bottom_sheet.dart index 95f46e1..898f4e0 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() + ? const EmptyWidget(text: "No Items Found", isWrapedColumn: false,) : ListView.separated( itemCount: appointmentsVM.serviceItemsFromApi.length, itemBuilder: (BuildContext context, int index) { diff --git a/lib/views/appointments/widgets/common_appointment_slider_widget.dart b/lib/views/appointments/widgets/common_appointment_slider_widget.dart index 5e2339b..1fc4f9e 100644 --- a/lib/views/appointments/widgets/common_appointment_slider_widget.dart +++ b/lib/views/appointments/widgets/common_appointment_slider_widget.dart @@ -167,7 +167,7 @@ class AppointmentHomeTileWidget extends StatelessWidget { height: 19 / 12, ) : const SizedBox(), - (AppState().currentAppType == AppType.provider ? appointmentListModel!.providerName ?? "" : appointmentListModel!.branchName ?? "").toText(color: MyColors.black, fontSize: 16, letterSpacing: -0.64, height: 24 / 16), + (AppState().currentAppType == AppType.provider ? appointmentListModel!.customerName ?? "" : appointmentListModel!.branchName ?? "").toText(color: MyColors.black, fontSize: 16, letterSpacing: -0.64, height: 24 / 16), Row( children: [ !isForProvider ? MyAssets.miniClock.buildSvg(height: 12) : const SizedBox(), diff --git a/lib/views/setting_options/provider_license_page.dart b/lib/views/setting_options/provider_license_page.dart index 211ada4..534196a 100644 --- a/lib/views/setting_options/provider_license_page.dart +++ b/lib/views/setting_options/provider_license_page.dart @@ -15,6 +15,7 @@ import 'package:mc_common_app/models/provider_branches_models/profile/document.d import 'package:mc_common_app/theme/colors.dart'; import 'package:mc_common_app/utils/enums.dart'; import 'package:mc_common_app/utils/utils.dart'; +import 'package:mc_common_app/view_models/ad_view_model.dart'; import 'package:mc_common_app/view_models/service_view_model.dart'; import 'package:mc_common_app/views/advertisement/components/picked_images_container_widget.dart'; import 'package:mc_common_app/widgets/button/show_fill_button.dart'; @@ -40,8 +41,8 @@ class _ProviderLicensePageState extends State { void initState() { super.initState(); scheduleMicrotask(() { - branchVM = Provider.of(context, listen: false); - branchVM.getServiceProviderDocument(AppState().getUser.data!.userInfo!.providerId ?? 0); + // branchVM = Provider.of(context, listen: false); + context.read().getServiceProviderDocument(AppState().getUser.data!.userInfo!.providerId ?? 0); }); } @@ -106,11 +107,11 @@ class _ProviderLicensePageState extends State { updateDocument(ServiceVM model) async { Utils.showLoading(context); - GenericRespModel res = await model.updateDocument(model.document!.data); Utils.hideLoading(context); if (res.messageStatus == 1) { Utils.showToast(LocaleKeys.documentsUploadedSuccessfully.tr()); + Navigator.of(context).pop(); } else { Utils.showToast(res.message ?? ""); } @@ -138,27 +139,24 @@ class _ProviderLicensePageState extends State { isBackgroundEnabled: true, ), 10.height, - if (document.documentId == 1 - ? model.commerceCertificates.isNotEmpty - : document.documentId == 2 - ? model.commercialCertificates.isNotEmpty - : model.vatCertificates.isNotEmpty) ...[ + if (isNeedToShow(model: model, document: document)) ...[ PickedFilesContainer( - pickedFiles: document.documentId == 1 - ? model.commerceCertificates - : document.documentId == 2 - ? model.commercialCertificates - : model.vatCertificates, - onCrossPressedPrimary: document.documentId == 1 + // isReview: document.status == 3 ? true : false, + pickedFiles: isLocalOrNetworkFiles(model: model, document: document), + onCrossPressedPrimary: chkIsLocalOrNetwork(document: document) + ? model.removeNetworkImag + : document.documentId == 1 ? model.commerceRemove : document.documentId == 2 ? model.commercialRemove : model.vatRemove, isPdf: model.document!.data![index].fileExt == "pdf", + isFromNetwork: document.isLocalFile! ? false : true, onAddFilePressed: () { model.pickPdfReceiptFile(context, document.documentId!, index); }, ), + if (document.comment != null && document.comment.isNotEmpty && document.status == 4) ...[buildStatusContainer(document: document)] ] else ...[ 10.height, @@ -222,4 +220,80 @@ class _ProviderLicensePageState extends State { ); } } + + List isLocalOrNetworkFiles({required ServiceVM model, required DocumentData document}) { + bool isNetworkImage = false; + if (!document.isLocalFile!) { + isNetworkImage = document.documentUrl != null && document.documentUrl.isNotEmpty ? true : false; + } + if (isNetworkImage) { + return [ImageModel(id: document.id, isFromNetwork: isNetworkImage, filePath: document.documentUrl)]; + } else if (document.documentId == 1) { + return model.commerceCertificates; + } else if (document.documentId == 2) { + return model.commercialCertificates; + } else { + return model.vatCertificates; + } + } + + bool isNeedToShow({required ServiceVM model, required DocumentData document}) { + bool allow = false; + bool isNetworkImage = document.documentUrl != null && document.documentUrl.isNotEmpty ? true : false; + if (isNetworkImage) { + allow = true; + } else { + if (document.documentId == 1 && model.commerceCertificates.isNotEmpty) { + allow = true; + } + if (document.documentId == 2 && model.commercialCertificates.isNotEmpty) { + allow = true; + } + if (document.documentId == 3 && model.vatCertificates.isNotEmpty) { + allow = true; + } + } + return allow; + } + + dynamic checkOnCrossPress({required ServiceVM model, required DocumentData document}) async { + bool isNetworkImage = document.documentUrl != null && document.documentUrl.isNotEmpty ? true : false; + if (isNetworkImage) { + return document.documentUrl; + } else { + if (document.documentId == 1) { + model.commerceRemove; + } + if (document.documentId == 2) { + model.commercialRemove; + } + if (document.documentId == 3) { + model.vatRemove; + } + } + } + + bool chkIsLocalOrNetwork({required DocumentData document}) { + bool isNetworkImage = false; + if (!document.isLocalFile!) { + isNetworkImage = document.documentUrl != null && document.documentUrl.isNotEmpty ? true : false; + } + return isNetworkImage; + } + + Widget buildStatusContainer({required DocumentData document}) { + return Center( + child: document.comment.toString().toText( + color: MyColors.adCancelledStatusColor, + fontSize: 14, + // isItalic: true, + ), + ).toContainer( + marginAll: 10, + paddingAll: 10, + borderRadius: 8, + width: double.infinity, + backgroundColor: MyColors.adCancelledStatusColor.withOpacity(0.16), + ); + } } diff --git a/lib/views/user/forget_password_page.dart b/lib/views/user/forget_password_page.dart index c4add4b..c463432 100644 --- a/lib/views/user/forget_password_page.dart +++ b/lib/views/user/forget_password_page.dart @@ -29,13 +29,13 @@ class _ForgetPasswordPageState extends State { ClassType type = ClassType.EMAIL; Country? _country; String countryCode = ""; + DropValue? tempCountry; late UserVM userVM; @override void initState() { super.initState(); - scheduleMicrotask(() { userVM = Provider.of(context, listen: false); getCountryList(); @@ -142,8 +142,12 @@ class _ForgetPasswordPageState extends State { ); return Padding( padding: const EdgeInsets.all(2.0), - child: DropdownField((DropValue value) { + child: DropdownField( dropdownValue: tempCountry ,(DropValue value) { countryCode = value.subValue; + tempCountry = value; +setState(() { + +}); }, list: dropList, hint: LocaleKeys.selectCountryCode.tr()), ); } else { diff --git a/lib/views/user/login_with_password_page.dart b/lib/views/user/login_with_password_page.dart index 2e0ccf6..80c593a 100644 --- a/lib/views/user/login_with_password_page.dart +++ b/lib/views/user/login_with_password_page.dart @@ -35,7 +35,7 @@ class _LoginWithPasswordState extends State { //TODO: ONLY FOR DEVELOPMENT PURPOSE // String phoneNum = "966504278212", password = "Fa@1234"; // String phoneNum = "966504278213", password = "Fa@1234"; - String phoneNum = "966504278213", password = "Fa@1234"; + String phoneNum = "", password = ""; String email = ""; String countryCode = ""; Country? _country; @@ -48,23 +48,23 @@ class _LoginWithPasswordState extends State { scheduleMicrotask(() { userVM = Provider.of(context, listen: false); context.read().getAvailBio(); - if (AppState().currentAppType == AppType.provider) { - phoneNum = "966530896018"; - password = "Amir@1234"; - - // phoneNum = "966569755630"; - // password = "Amir12345@"; //AAmir Sal - - // phoneNum = "966598646795"; - // password = "Zahoor@123"; - - // User Details - // phoneNum = "966554870506"; - // password = "Sikander123@"; // "lastName": "sik", - // "email": "sikander@gmail.com", - // phoneNum = "966569755630"; - // password = "Amir12345@"; - } + // if (AppState().currentAppType == AppType.provider) { + // phoneNum = "966530896018"; + // password = "Amir@1234"; + // + // // phoneNum = "966569755630"; + // // password = "Amir12345@"; //AAmir Sal + // + // // phoneNum = "966598646795"; + // // password = "Zahoor@123"; + // + // // User Details + // // phoneNum = "966554870506"; + // // password = "Sikander123@"; // "lastName": "sik", + // // "email": "sikander@gmail.com", + // // phoneNum = "966569755630"; + // // password = "Amir12345@"; + // } getCountryList(); }); @@ -78,7 +78,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, diff --git a/lib/widgets/empty_widget.dart b/lib/widgets/empty_widget.dart index 3e4cac0..c5b1d36 100644 --- a/lib/widgets/empty_widget.dart +++ b/lib/widgets/empty_widget.dart @@ -1,11 +1,25 @@ import 'package:flutter/material.dart'; +import 'package:mc_common_app/classes/consts.dart'; import 'package:mc_common_app/extensions/string_extensions.dart'; +import 'package:mc_common_app/theme/colors.dart'; class EmptyWidget extends StatelessWidget { - const EmptyWidget({Key? key}) : super(key: key); + final String text; + final bool isWrapedColumn; + + const EmptyWidget({Key? key, required this.text, this.isWrapedColumn = true}) : super(key: key); @override Widget build(BuildContext context) { - return Center(child: "No Data Found".toText()); + if (isWrapedColumn) { + return Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + text.toText(fontSize: 16, color: MyColors.lightTextColor, fontWeight: MyFonts.Medium), + ], + ); + } + + return Center(child: text.toText(fontSize: 16, color: MyColors.lightTextColor, fontWeight: MyFonts.Medium)); } }