From 4a5d6afcbc6f96441fedb26685f2c5211fed773f Mon Sep 17 00:00:00 2001 From: PGAN-MIS Date: Wed, 30 Aug 2023 09:55:03 +0800 Subject: [PATCH] fix bugs for profile and final test in live --- .../profile/education/education_bloc.dart | 4 +- .../profile/eligibility/eligibility_bloc.dart | 43 +- .../eligibility/eligibility_event.dart | 12 +- .../eligibility/eligibility_state.dart | 8 +- .../learning_development_bloc.dart | 42 +- .../learning_development_event.dart | 9 +- .../learning_development_state.dart | 9 +- .../contact/contact_bloc.dart | 62 +- .../contact/contact_event.dart | 58 +- .../profile/workHistory/workHistory_bloc.dart | 52 +- .../workHistory/workHistory_event.dart | 5 +- .../basic_information/address/add_modal.dart | 650 ++-- .../basic_information/address/edit_modal.dart | 875 +++--- .../basic_information/address_screen.dart | 2 +- .../contact_information/add_modal.dart | 366 ++- .../contact_information/edit_modal.dart | 415 ++- .../contact_information_screen.dart | 2 +- .../family/child_add_modal.dart | 2 +- .../family/child_edit_modal.dart | 4 +- .../family/father_add_modal.dart | 2 +- .../family/father_edit_modal.dart | 2 +- .../family/mother_add_modal.dart | 2 +- .../family/mother_edit_modal.dart | 2 +- .../family/related_add_modal.dart | 2 +- .../family/related_edit_modal.dart | 2 +- .../identification/add_modal.dart | 1276 ++++---- .../identification/edit_modal.dart | 699 +++-- .../identification_information_screen.dart | 6 +- .../components/education/add_modal.dart | 707 +++-- .../components/education/edit_modal.dart | 779 +++-- .../education/education_view_attachment.dart | 21 +- .../profile/components/education_screen.dart | 3 +- .../components/eligibility/add_modal.dart | 652 ++-- .../components/eligibility/edit_modal.dart | 850 +++-- .../eligibility_view_attachment.dart | 144 +- .../components/eligibility_screen.dart | 7 +- .../components/family_background_screen.dart | 26 +- .../learning_and_development_screen.dart | 6 +- .../learning_development/add_modal.dart | 2742 ++++++++--------- .../learning_development/edit_modal.dart | 2686 ++++++++-------- .../learning_development_view_attachment.dart | 140 +- .../non_academic/edit_modal.dart | 2 + .../components/reference/add_modal.dart | 612 ++-- .../components/reference/edit_modal.dart | 913 +++--- .../profile/components/references_screen.dart | 2 +- .../components/voluntary_works/add_modal.dart | 1057 ++++--- .../voluntary_works/edit_modal.dart | 31 +- .../components/work_history/add_modal.dart | 52 +- .../components/work_history/edit_modal.dart | 219 +- .../components/work_history_screen.dart | 28 +- .../profile/shared/view_attachment.dart | 62 - lib/sevices/profile/education_services.dart | 4 +- lib/sevices/profile/profile_other_info.dart | 2 +- .../profile/work_history_services.dart | 394 ++- lib/utils/url_launcher_file_downloader.dart | 16 + macos/Podfile.lock | 24 + 56 files changed, 8515 insertions(+), 8279 deletions(-) delete mode 100644 lib/screens/profile/shared/view_attachment.dart create mode 100644 lib/utils/url_launcher_file_downloader.dart diff --git a/lib/bloc/profile/education/education_bloc.dart b/lib/bloc/profile/education/education_bloc.dart index c10fa17..dd7374c 100644 --- a/lib/bloc/profile/education/education_bloc.dart +++ b/lib/bloc/profile/education/education_bloc.dart @@ -241,11 +241,11 @@ class EducationBloc extends Bloc { final result = await Share.shareXFiles( [XFile("$appDocumentPath/${event.fileName}")]); if (result.status == ShareResultStatus.success) { - Fluttertoast.showToast(msg: "Attachment shared successfully"); + Fluttertoast.showToast(msg: "Attachment shared successful"); emit(EducationAttachmentViewState( fileUrl: event.source, fileName: event.fileName)); } else { - Fluttertoast.showToast(msg: "Attachment shared unsuccessfully"); + Fluttertoast.showToast(msg: "Attachment shared unsuccessful"); emit(EducationAttachmentViewState( fileUrl: event.source, fileName: event.fileName)); } diff --git a/lib/bloc/profile/eligibility/eligibility_bloc.dart b/lib/bloc/profile/eligibility/eligibility_bloc.dart index 6710f47..a714bc9 100644 --- a/lib/bloc/profile/eligibility/eligibility_bloc.dart +++ b/lib/bloc/profile/eligibility/eligibility_bloc.dart @@ -1,5 +1,12 @@ +import 'dart:io'; + import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:share_plus/share_plus.dart'; +import 'package:unit2/screens/profile/components/eligibility/eligibility_view_attachment.dart'; import 'package:unit2/utils/attachment_services.dart'; import '../../../model/location/city.dart'; import '../../../model/location/country.dart'; @@ -11,6 +18,7 @@ import '../../../model/utils/eligibility.dart'; import '../../../sevices/profile/eligibility_services.dart'; import '../../../utils/location_utilities.dart'; import '../../../utils/profile_utilities.dart'; +import '../../../utils/request_permission.dart'; import '../../../utils/urls.dart'; part 'eligibility_event.dart'; part 'eligibility_state.dart'; @@ -283,7 +291,40 @@ class EligibilityBloc extends Bloc { }); on((event,emit){ String fileUrl = '${Url.instance.prefixHost()}://${Url.instance.host()}${event.source}'; - emit(EligibilityAttachmentViewState(fileUrl: fileUrl)); + emit(EligibilityAttachmentViewState(fileUrl: fileUrl,fileName: event.filename)); + }); + on((event, emit) async { + emit(EligibilityLoadingState()); + Directory directory; + String? appDocumentPath; + if (await requestPermission(Permission.storage)) { + directory = await getApplicationDocumentsDirectory(); + appDocumentPath = directory.path; + } + try{ + final bool success = await AttachmentServices.instance.downloadAttachment( + filename: event.fileName, + source: event.source, + downLoadDir: appDocumentPath!); + if (success) { + final result = await Share.shareXFiles( + [XFile("$appDocumentPath/${event.fileName}")]); + if (result.status == ShareResultStatus.success) { + Fluttertoast.showToast(msg: "Attachment shared successful"); + emit(EligibilityAttachmentViewState( + fileUrl: event.source, fileName: event.fileName)); + } else { + Fluttertoast.showToast(msg: "Attachment shared unsuccessful"); + emit(EligibilityAttachmentViewState( + fileUrl: event.source, fileName: event.fileName)); + } + } else { + emit(EligibilityAttachmentViewState( + fileUrl: event.source, fileName: event.fileName)); + } + }catch(e){ +emit(EligibilityErrorState(message: e.toString())); + } }); } } diff --git a/lib/bloc/profile/eligibility/eligibility_event.dart b/lib/bloc/profile/eligibility/eligibility_event.dart index 925b105..fab7746 100644 --- a/lib/bloc/profile/eligibility/eligibility_event.dart +++ b/lib/bloc/profile/eligibility/eligibility_event.dart @@ -103,13 +103,15 @@ class DeleteEligibyAttachment extends EligibilityEvent { required this.token}); } -class EligibilityViewAttachments extends EligibilityEvent { - final String source; - const EligibilityViewAttachments({required this.source}); -} class EligibiltyViewAttachmentEvent extends EligibilityEvent{ final String source; - const EligibiltyViewAttachmentEvent({required this.source}); + final String filename; + const EligibiltyViewAttachmentEvent({required this.source, required this.filename}); +} +class ShareAttachment extends EligibilityEvent{ + final String fileName; + final String source; + const ShareAttachment({required this.fileName, required this.source}); } diff --git a/lib/bloc/profile/eligibility/eligibility_state.dart b/lib/bloc/profile/eligibility/eligibility_state.dart index 6f8976c..9f6a005 100644 --- a/lib/bloc/profile/eligibility/eligibility_state.dart +++ b/lib/bloc/profile/eligibility/eligibility_state.dart @@ -109,6 +109,12 @@ class EligibilitytAttachmentDeletedState extends EligibilityState { } class EligibilityAttachmentViewState extends EligibilityState { + final String fileName; final String fileUrl; - const EligibilityAttachmentViewState({required this.fileUrl}); + const EligibilityAttachmentViewState({required this.fileUrl, required this.fileName}); } +class EligibilityAttachmentShareState extends EligibilityState{ + final bool success; + const EligibilityAttachmentShareState({required this.success,}); +} + diff --git a/lib/bloc/profile/learningDevelopment/learning_development_bloc.dart b/lib/bloc/profile/learningDevelopment/learning_development_bloc.dart index 9dd75b7..ad53010 100644 --- a/lib/bloc/profile/learningDevelopment/learning_development_bloc.dart +++ b/lib/bloc/profile/learningDevelopment/learning_development_bloc.dart @@ -1,5 +1,11 @@ +import 'dart:io'; + import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; +import 'package:fluttertoast/fluttertoast.dart'; +import 'package:path_provider/path_provider.dart'; +import 'package:permission_handler/permission_handler.dart'; +import 'package:share_plus/share_plus.dart'; import 'package:unit2/model/location/country.dart'; import 'package:unit2/model/location/region.dart'; import 'package:unit2/sevices/profile/learningDevelopment_service.dart'; @@ -13,6 +19,7 @@ import '../../../model/utils/category.dart'; import '../../../utils/attachment_services.dart'; import '../../../utils/location_utilities.dart'; import '../../../utils/profile_utilities.dart'; +import '../../../utils/request_permission.dart'; import '../../../utils/urls.dart'; part 'learning_development_event.dart'; part 'learning_development_state.dart'; @@ -328,7 +335,40 @@ class LearningDevelopmentBloc }); on((event,emit){ String fileUrl = '${Url.instance.prefixHost()}://${Url.instance.host()}${event.source}'; - emit(LearningAndDevelopmentAttachmentViewState(fileUrl: fileUrl)); + emit(LearningAndDevelopmentAttachmentViewState(fileUrl: fileUrl, filename: event.filename)); + }); + on((event, emit) async { + emit(LearningDevelopmentLoadingState()); + Directory directory; + String? appDocumentPath; + if (await requestPermission(Permission.storage)) { + directory = await getApplicationDocumentsDirectory(); + appDocumentPath = directory.path; + } + try{ + final bool success = await AttachmentServices.instance.downloadAttachment( + filename: event.fileName, + source: event.source, + downLoadDir: appDocumentPath!); + if (success) { + final result = await Share.shareXFiles( + [XFile("$appDocumentPath/${event.fileName}")]); + if (result.status == ShareResultStatus.success) { + Fluttertoast.showToast(msg: "Attachment shared successful"); + emit(LearningAndDevelopmentAttachmentViewState( + fileUrl: event.source, filename: event.fileName)); + } else { + Fluttertoast.showToast(msg: "Attachment shared unsuccessful"); + emit(LearningAndDevelopmentAttachmentViewState( + fileUrl: event.source, filename: event.fileName)); + } + } else { + emit(LearningAndDevelopmentAttachmentViewState( + fileUrl: event.source, filename: event.fileName)); + } + }catch(e){ +emit(LearningDevelopmentErrorState(message: e.toString())); + } }); } diff --git a/lib/bloc/profile/learningDevelopment/learning_development_event.dart b/lib/bloc/profile/learningDevelopment/learning_development_event.dart index d450d7d..e134560 100644 --- a/lib/bloc/profile/learningDevelopment/learning_development_event.dart +++ b/lib/bloc/profile/learningDevelopment/learning_development_event.dart @@ -89,8 +89,15 @@ class DeleteLearningDevAttachment extends LearningDevelopmentEvent{ } class LearningDevelopmentViewAttachmentEvent extends LearningDevelopmentEvent{ + final String filename; final String source; - const LearningDevelopmentViewAttachmentEvent({required this.source}); + const LearningDevelopmentViewAttachmentEvent({required this.source, required this.filename}); +} + +class ShareAttachment extends LearningDevelopmentEvent{ + final String fileName; + final String source; + const ShareAttachment({required this.fileName, required this.source}); } diff --git a/lib/bloc/profile/learningDevelopment/learning_development_state.dart b/lib/bloc/profile/learningDevelopment/learning_development_state.dart index 7507e9c..a5dbb78 100644 --- a/lib/bloc/profile/learningDevelopment/learning_development_state.dart +++ b/lib/bloc/profile/learningDevelopment/learning_development_state.dart @@ -136,6 +136,11 @@ class LearningDevAttachmentDeletedState extends LearningDevelopmentState { class LearningAndDevelopmentAttachmentViewState extends LearningDevelopmentState { + final String filename; final String fileUrl; - const LearningAndDevelopmentAttachmentViewState({required this.fileUrl}); -} \ No newline at end of file + const LearningAndDevelopmentAttachmentViewState({required this.fileUrl, required this.filename}); +} +class LearningDevelopmentAttachmentShareState extends LearningDevelopmentState{ + final bool success; + const LearningDevelopmentAttachmentShareState({required this.success,}); +} diff --git a/lib/bloc/profile/primary_information/contact/contact_bloc.dart b/lib/bloc/profile/primary_information/contact/contact_bloc.dart index e2e1ba2..2d34f51 100644 --- a/lib/bloc/profile/primary_information/contact/contact_bloc.dart +++ b/lib/bloc/profile/primary_information/contact/contact_bloc.dart @@ -46,24 +46,25 @@ class ContactBloc extends Bloc { ServiceType serviceType; List commServiceProvivers; CommService serviceProvider; - try{ - if (serviceTypes.isEmpty) { - serviceTypes = await ProfileUtilities.instance.getServiceType(); - } - serviceType = serviceTypes.firstWhere((ServiceType element) { - return element.id == event.contactInfo.commService!.serviceType!.id; - }); - commServiceProvivers = await ContactService.instance - .getServiceProvider(serviceTypeId: serviceType.id!); - serviceProvider = commServiceProvivers.firstWhere((CommService element) => - element.id == event.contactInfo.commService!.id); - emit(ContactEditingState( - serviceTypes: serviceTypes, - selectedServiceType: serviceType, - commServiceProviders: commServiceProvivers, - selectedProvider: serviceProvider, - contactInfo: event.contactInfo)); - }catch(e){ + try { + if (serviceTypes.isEmpty) { + serviceTypes = await ProfileUtilities.instance.getServiceType(); + } + serviceType = serviceTypes.firstWhere((ServiceType element) { + return element.id == event.contactInfo.commService!.serviceType!.id; + }); + commServiceProvivers = await ContactService.instance + .getServiceProvider(serviceTypeId: serviceType.id!); + serviceProvider = commServiceProvivers.firstWhere( + (CommService element) => + element.id == event.contactInfo.commService!.id); + emit(ContactEditingState( + serviceTypes: serviceTypes, + selectedServiceType: serviceType, + commServiceProviders: commServiceProvivers, + selectedProvider: serviceProvider, + contactInfo: event.contactInfo)); + } catch (e) { emit(ContactErrorState(message: e.toString())); } }); @@ -81,18 +82,17 @@ class ContactBloc extends Bloc { contactInformations.removeWhere( (ContactInfo element) => element.id == event.contactInfo.id); contactInformations.add(contactInfo); - emit(ContactEditedState( - - response: responseStatus)); + emit(ContactEditedState(response: responseStatus)); } else { - emit(ContactEditedState( - - response: responseStatus)); + emit(ContactEditedState(response: responseStatus)); } } catch (e) { emit(ContactErrorState(message: e.toString())); } }); + on((event, emit) { + emit(ContactErrorState(message: event.message)); + }); //// add contact @@ -107,13 +107,9 @@ class ContactBloc extends Bloc { ContactInfo contactInfo = ContactInfo.fromJson(responseStatus['data']['contact_info']); contactInformations.add(contactInfo); - emit(ContactAddedState( - - response: responseStatus)); + emit(ContactAddedState(response: responseStatus)); } else { - emit(ContactAddedState( - - response: responseStatus)); + emit(ContactAddedState(response: responseStatus)); } } catch (e) { emit(ContactErrorState(message: e.toString())); @@ -129,11 +125,9 @@ class ContactBloc extends Bloc { if (success) { contactInformations .removeWhere((element) => element.id == event.contactInfo.id); - emit(ContactDeletedState( - succcess: success)); + emit(ContactDeletedState(succcess: success)); } else { - emit(ContactDeletedState( - succcess: success)); + emit(ContactDeletedState(succcess: success)); } } catch (e) { emit(ContactErrorState(message: e.toString())); diff --git a/lib/bloc/profile/primary_information/contact/contact_event.dart b/lib/bloc/profile/primary_information/contact/contact_event.dart index 5e7106f..48a1692 100644 --- a/lib/bloc/profile/primary_information/contact/contact_event.dart +++ b/lib/bloc/profile/primary_information/contact/contact_event.dart @@ -8,63 +8,71 @@ abstract class ContactEvent extends Equatable { } ////get contacts -class GetContacts extends ContactEvent{ - final List contactInformations; +class GetContacts extends ContactEvent { + final List contactInformations; const GetContacts({required this.contactInformations}); - @override + @override List get props => []; } //// load contacts -class LoadContacts extends ContactEvent{ - - @override +class LoadContacts extends ContactEvent { + @override List get props => []; } //// show add form -class ShowAddForm extends ContactEvent{ +class ShowAddForm extends ContactEvent {} +class CallErrorEvent extends ContactEvent { + final String message; + const CallErrorEvent({required this.message}); } //// show edit form -class ShowEditForm extends ContactEvent{ +class ShowEditForm extends ContactEvent { final ContactInfo contactInfo; const ShowEditForm({required this.contactInfo}); - @override + @override List get props => [contactInfo]; - } ////add event -class AddContactInformation extends ContactEvent{ +class AddContactInformation extends ContactEvent { final int profileId; final String token; final ContactInfo contactInfo; - const AddContactInformation({required this.contactInfo, required this.profileId, required this.token}); - @override - List get props => [profileId,token,contactInfo]; + const AddContactInformation( + {required this.contactInfo, + required this.profileId, + required this.token}); + @override + List get props => [profileId, token, contactInfo]; } ////edit event -class EditContactInformation extends ContactEvent{ +class EditContactInformation extends ContactEvent { final int profileId; final String token; final ContactInfo contactInfo; - const EditContactInformation({required this.contactInfo, required this.profileId, required this.token}); - @override - List get props => [profileId,token,contactInfo]; + const EditContactInformation( + {required this.contactInfo, + required this.profileId, + required this.token}); + @override + List get props => [profileId, token, contactInfo]; } //// delete event -class DeleteContactInformation extends ContactEvent{ - final int profileId; +class DeleteContactInformation extends ContactEvent { + final int profileId; final String token; final ContactInfo contactInfo; - const DeleteContactInformation({required this.contactInfo, required this.profileId, required this.token}); - @override - List get props => [profileId,token,contactInfo]; + const DeleteContactInformation( + {required this.contactInfo, + required this.profileId, + required this.token}); + @override + List get props => [profileId, token, contactInfo]; } - - diff --git a/lib/bloc/profile/workHistory/workHistory_bloc.dart b/lib/bloc/profile/workHistory/workHistory_bloc.dart index b751baa..c3f34f6 100644 --- a/lib/bloc/profile/workHistory/workHistory_bloc.dart +++ b/lib/bloc/profile/workHistory/workHistory_bloc.dart @@ -68,7 +68,7 @@ class WorkHistoryBloc extends Bloc { }); //// ADD WORK HISTORIES on((event, emit) async { - // try { + try { Map status = await WorkHistoryService.instance.add( accomplishment: event.accomplishment, actualDuties: event.actualDuties, @@ -83,36 +83,36 @@ class WorkHistoryBloc extends Bloc { } else { emit(WorkHistoryAddedState(response: status)); } + } catch (e) { + emit(WorkHistoryErrorState(message: e.toString())); + } + }); + +////UPDATE WORK HISTORY + on((event, emit) async { + // try { + Map status = await WorkHistoryService.instance.update( + isPrivate: event.isPrivate, + workHistory: event.workHistory, + token: event.token, + profileId: event.profileId); + if (status['success']) { + WorkHistory workHistory = WorkHistory.fromJson(status['data']); + // workExperiences.removeWhere((WorkHistory work) { + // return work.id == event.workHistory.id; + // }); + workExperiences.add(workHistory); + emit(WorkHistoryEditedState(response: status)); + } else { + emit(WorkHistoryEditedState( + response: status, + )); + } // } catch (e) { // emit(WorkHistoryErrorState(message: e.toString())); // } }); -////UPDATE WORK HISTORY - // on((event, emit) async { - // try { - // Map status = await WorkHistoryService.instance.update( - // oldWorkHistory: event.oldWorkHistory, - // newWorkHistory: event.workHistory, - // token: event.token, - // profileId: event.profileId); - // if (status['success']) { - // WorkHistory workHistory = WorkHistory.fromJson(status['data']); - // workExperiences.removeWhere((WorkHistory work) { - // return work.id == event.oldWorkHistory.id; - // }); - // workExperiences.add(workHistory); - // emit(WorkHistoryEditedState(response: status)); - // } else { - // emit(WorkHistoryEditedState( - // response: status, - // )); - // } - // } catch (e) { - // emit(WorkHistoryErrorState(message: e.toString())); - // } - // }); - ////SHOW EDIT WORK HISTORIES on((event, emit) async { try { diff --git a/lib/bloc/profile/workHistory/workHistory_event.dart b/lib/bloc/profile/workHistory/workHistory_event.dart index 6e73101..a1a8ffc 100644 --- a/lib/bloc/profile/workHistory/workHistory_event.dart +++ b/lib/bloc/profile/workHistory/workHistory_event.dart @@ -46,9 +46,8 @@ class UpdateWorkHistory extends WorkHistorytEvent{ final bool isPrivate; final int profileId; final String token; - final String? actualDuties; - final String? accomplishment; - const UpdateWorkHistory({required this.profileId, required this.token, required this.workHistory, required this.accomplishment, required this.actualDuties, required this.isPrivate}); + + const UpdateWorkHistory({required this.profileId, required this.token, required this.workHistory, required this.isPrivate}); @override List get props => [profileId,token,workHistory,]; } diff --git a/lib/screens/profile/components/basic_information/address/add_modal.dart b/lib/screens/profile/components/basic_information/address/add_modal.dart index fd8514e..1ba59f0 100644 --- a/lib/screens/profile/components/basic_information/address/add_modal.dart +++ b/lib/screens/profile/components/basic_information/address/add_modal.dart @@ -77,348 +77,341 @@ class _AddAddressScreenState extends State { const EdgeInsets.symmetric(vertical: 32, horizontal: 24), child: SizedBox( height: screenHeight * 88, - child: Column( + child: ListView( children: [ - Flexible( - child: ListView( + FormBuilderDropdown( + validator: FormBuilderValidators.required( + errorText: "This field is required"), + decoration: + normalTextFieldStyle("Category*", "Category"), + name: "category", + onChanged: (AddressCategory? category) { + selectedAddressCategory = category; + }, + items: category + .map>( + (AddressCategory category) { + return DropdownMenuItem( + value: category, child: Text(category.name!)); + }).toList()), + const SizedBox( + height: 12, + ), + ////Area Class + FormBuilderDropdown( + decoration: normalTextFieldStyle( + "Area class *", "Area class"), + name: "area_class", + onChanged: (Area? area) { + selectedAreaClass = area!.value; + }, + items: areaClass + .map>((Area area) { + return area.group == 0 + ? DropdownMenuItem( + enabled: false, + value: area, + child: Text(area.value.toUpperCase(), + style: const TextStyle( + color: Colors.black38))) + : DropdownMenuItem( + value: area, + enabled: true, + child: Text( + " ${area.value.toUpperCase()}")); + }).toList()), + const SizedBox( + height: 12, + ), + ////stateful builder + StatefulBuilder(builder: (context, setState) { + return Column( children: [ - //// category - FormBuilderDropdown( - validator: FormBuilderValidators.required( - errorText: "This field is required"), - decoration: - normalTextFieldStyle("Category*", "Category"), - name: "category", - onChanged: (AddressCategory? category) { - selectedAddressCategory = category; - }, - items: category - .map>( - (AddressCategory category) { - return DropdownMenuItem( - value: category, child: Text(category.name!)); - }).toList()), - const SizedBox( - height: 12, - ), - ////Area Class - FormBuilderDropdown( - decoration: normalTextFieldStyle( - "Area class *", "Area class"), - name: "area_class", - onChanged: (Area? area) { - selectedAreaClass = area!.value; - }, - items: areaClass - .map>((Area area) { - return area.group == 0 - ? DropdownMenuItem( - enabled: false, - value: area, - child: Text(area.value.toUpperCase(), - style: const TextStyle( - color: Colors.black38))) - : DropdownMenuItem( - value: area, - enabled: true, - child: Text( - " ${area.value.toUpperCase()}")); - }).toList()), - const SizedBox( - height: 12, - ), - ////stateful builder - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - ////with block & Lot Switch - FormBuilderSwitch( - initialValue: hasLotandBlock, - activeColor: second, - onChanged: (value) { - setState(() { - hasLotandBlock = value!; - }); - }, - decoration: normalTextFieldStyle( - "With Lot and Block?", 'Graduated?'), - name: 'graudated', - title: Text(hasLotandBlock ? "YES" : "NO"), - ), - SizedBox( - height: hasLotandBlock ? 12 : 0, - ), - SizedBox( - width: screenWidth, - child: hasLotandBlock - ? Row( - children: [ - ////block # - Flexible( - flex: 1, - child: FormBuilderTextField( - validator: FormBuilderValidators - .compose([numericRequired]), - keyboardType: - TextInputType.number, - name: "block_number", - decoration: - normalTextFieldStyle( - "Block #*", "Block #"), - )), - const SizedBox( - width: 8, - ), - //// lot # - Flexible( - flex: 1, - child: FormBuilderTextField( - validator: FormBuilderValidators - .compose([numericRequired]), - name: "lot_number", - keyboardType: - TextInputType.number, - decoration: - normalTextFieldStyle( - "Lot #*", "Lot #"), - )), - ], - ) - : Container(), - ), - ], - ); - }), - const SizedBox( - height: 12, - ), - //// Address Line - FormBuilderTextField( - name: "address_line", + ////with block & Lot Switch + FormBuilderSwitch( + initialValue: hasLotandBlock, + activeColor: second, + onChanged: (value) { + setState(() { + hasLotandBlock = value!; + }); + }, decoration: normalTextFieldStyle( - "Address Line ", "Address Line"), + "With Lot and Block?", 'Graduated?'), + name: 'graudated', + title: Text(hasLotandBlock ? "YES" : "NO"), ), - const SizedBox( - height: 12, + SizedBox( + height: hasLotandBlock ? 12 : 0, ), - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - FormBuilderSwitch( - initialValue: overseas, - activeColor: second, - onChanged: (value) { - setState(() { - overseas = value!; - }); - }, - decoration: normalTextFieldStyle( - "Overseas Address?", ''), - name: 'overseas', - title: Text(overseas ? "YES" : "NO"), - ), - SizedBox( - height: overseas == true ? 8 : 0, - ), - SizedBox( - child: overseas == false - ? Column( - children: [ - const SizedBox( - height: 12, - ), - ////REGION DROPDOWN - FormBuilderDropdown( - autovalidateMode: AutovalidateMode - .onUserInteraction, - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - onChanged: (Region? region) async { - if (selectedRegion != region) { + SizedBox( + width: screenWidth, + child: hasLotandBlock + ? Row( + children: [ + ////block # + Flexible( + flex: 1, + child: FormBuilderTextField( + validator: FormBuilderValidators + .compose([numericRequired]), + keyboardType: + TextInputType.number, + name: "block_number", + decoration: + normalTextFieldStyle( + "Block #*", "Block #"), + )), + const SizedBox( + width: 8, + ), + //// lot # + Flexible( + flex: 1, + child: FormBuilderTextField( + validator: FormBuilderValidators + .compose([numericRequired]), + name: "lot_number", + keyboardType: + TextInputType.number, + decoration: + normalTextFieldStyle( + "Lot #*", "Lot #"), + )), + ], + ) + : Container(), + ), + ], + ); + }), + const SizedBox( + height: 12, + ), + //// Address Line + FormBuilderTextField( + name: "address_line", + decoration: normalTextFieldStyle( + "Address Line ", "Address Line"), + ), + const SizedBox( + height: 12, + ), + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, + decoration: normalTextFieldStyle( + "Overseas Address?", ''), + name: 'overseas', + title: Text(overseas ? "YES" : "NO"), + ), + SizedBox( + height: overseas == true ? 8 : 0, + ), + SizedBox( + child: overseas == false + ? Column( + children: [ + const SizedBox( + height: 12, + ), + ////REGION DROPDOWN + FormBuilderDropdown( + autovalidateMode: AutovalidateMode + .onUserInteraction, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + onChanged: (Region? region) async { + if (selectedRegion != region) { + setState(() { + provinceCall = true; + }); + selectedRegion = region; + getProvinces(); + } + }, + initialValue: null, + decoration: normalTextFieldStyle( + "Region*", "Region"), + name: 'region', + items: state.regions + .map>( + (Region region) { + return DropdownMenuItem( + value: region, + child: Text( + region.description!)); + }).toList(), + ), + const SizedBox( + height: 8, + ), + //// PROVINCE DROPDOWN + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: provinceCall, + child: DropdownButtonFormField< + Province?>( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: (value) => + value == null + ? 'required' + : null, + isExpanded: true, + value: selectedProvince, + onChanged: + (Province? province) { + if (selectedProvince != + province) { setState(() { - provinceCall = true; + cityCall = true; }); - selectedRegion = region; - getProvinces(); + selectedProvince = + province; + getCities(); } }, - initialValue: null, - decoration: normalTextFieldStyle( - "Region*", "Region"), - name: 'region', - items: state.regions - .map>( - (Region region) { - return DropdownMenuItem( - value: region, - child: Text( - region.description!)); - }).toList(), - ), - const SizedBox( - height: 8, - ), - //// PROVINCE DROPDOWN - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: (value) => - value == null - ? 'required' - : null, - isExpanded: true, - value: selectedProvince, - onChanged: - (Province? province) { - if (selectedProvince != - province) { - setState(() { - cityCall = true; - }); - selectedProvince = - province; - getCities(); - } - }, - items: provinces == null - ? [] - : provinces!.map< - DropdownMenuItem< - Province>>( - (Province province) { - return DropdownMenuItem( - value: province, - child: FittedBox( - child: Text(province - .description!), - )); - }).toList(), - decoration: - normalTextFieldStyle( - "Province*", - "Province")), - ), - ), - ////CITY MUNICIPALITY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: cityCall, - child: DropdownButtonFormField< - CityMunicipality>( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - isExpanded: true, - onChanged: - (CityMunicipality? city) { - if (selectedMunicipality != - city) { - setState(() { - barangayCall = true; - }); - selectedMunicipality = city; - getBarangays(); - } - }, - decoration: - normalTextFieldStyle( - "Municipality*", - "Municipality"), - value: selectedMunicipality, - items: citymuns == null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality c) { - return DropdownMenuItem( - value: c, - child: Text(c - .description!)); - }).toList(), - ), - ), - ), - //// BARANGAY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: barangayCall, - child: DropdownButtonFormField< - Barangay>( - isExpanded: true, - onChanged: (Barangay? baragay) { - selectedBarangay = baragay; - }, - decoration: - normalTextFieldStyle( - "Barangay*", - "Barangay"), - value: selectedBarangay, - items: barangays == null - ? [] - : barangays!.map< - DropdownMenuItem< - Barangay>>( - (Barangay barangay) { - return DropdownMenuItem( - value: barangay, - child: Text(barangay - .description!)); - }).toList(), - ), - ), - ), - ], - ) - //// COUNTRY DROPDOWN - : SizedBox( - height: 60, - child: FormBuilderDropdown( - initialValue: null, - validator: - FormBuilderValidators.required( + items: provinces == null + ? [] + : provinces!.map< + DropdownMenuItem< + Province>>( + (Province province) { + return DropdownMenuItem( + value: province, + child: FittedBox( + child: Text(province + .description!), + )); + }).toList(), + decoration: + normalTextFieldStyle( + "Province*", + "Province")), + ), + ), + ////CITY MUNICIPALITY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: cityCall, + child: DropdownButtonFormField< + CityMunicipality>( + validator: FormBuilderValidators + .required( errorText: "This field is required"), - items: state.countries - .map>( - (Country country) { - return DropdownMenuItem( - value: country, - child: FittedBox( - child: - Text(country.name!))); - }).toList(), - name: 'country', - decoration: normalTextFieldStyle( - "Country*", "Country"), - onChanged: (Country? value) { - selectedCountry = value; + isExpanded: true, + onChanged: + (CityMunicipality? city) { + if (selectedMunicipality != + city) { + setState(() { + barangayCall = true; + }); + selectedMunicipality = city; + getBarangays(); + } }, + decoration: + normalTextFieldStyle( + "Municipality*", + "Municipality"), + value: selectedMunicipality, + items: citymuns == null + ? [] + : citymuns!.map< + DropdownMenuItem< + CityMunicipality>>( + (CityMunicipality c) { + return DropdownMenuItem( + value: c, + child: Text(c + .description!)); + }).toList(), ), ), - ), - ], - ); - }), - ////sumit button + ), + //// BARANGAY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: barangayCall, + child: DropdownButtonFormField< + Barangay>( + isExpanded: true, + onChanged: (Barangay? baragay) { + selectedBarangay = baragay; + }, + decoration: + normalTextFieldStyle( + "Barangay*", + "Barangay"), + value: selectedBarangay, + items: barangays == null + ? [] + : barangays!.map< + DropdownMenuItem< + Barangay>>( + (Barangay barangay) { + return DropdownMenuItem( + value: barangay, + child: Text(barangay + .description!)); + }).toList(), + ), + ), + ), + ], + ) + //// COUNTRY DROPDOWN + : SizedBox( + height: 60, + child: FormBuilderDropdown( + initialValue: null, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + items: state.countries + .map>( + (Country country) { + return DropdownMenuItem( + value: country, + child: FittedBox( + child: + Text(country.name!))); + }).toList(), + name: 'country', + decoration: normalTextFieldStyle( + "Country*", "Country"), + onChanged: (Country? value) { + selectedCountry = value; + }, + ), + ), + ), ], - ), - ), - SizedBox( + ); + }), + const SizedBox(height: 24,), + SizedBox( width: double.infinity, height: 60, child: ElevatedButton( @@ -464,12 +457,13 @@ class _AddAddressScreenState extends State { }, child: const Text(submit)), ), + ], ), ), )); } - return Placeholder(); + return const Placeholder(); }, ); } diff --git a/lib/screens/profile/components/basic_information/address/edit_modal.dart b/lib/screens/profile/components/basic_information/address/edit_modal.dart index 83901b5..83ac0d4 100644 --- a/lib/screens/profile/components/basic_information/address/edit_modal.dart +++ b/lib/screens/profile/components/basic_information/address/edit_modal.dart @@ -106,208 +106,313 @@ class _EditAddressScreenState extends State { vertical: 32, horizontal: 24), child: SizedBox( height: screenHeight * 88, - child: Column( + child: ListView( children: [ - Flexible( - child: ListView( + //// category + FormBuilderDropdown( + initialValue: selectedAddressCategory, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + decoration: + normalTextFieldStyle("Category*", "Category"), + name: "category", + onChanged: (AddressCategory? category) { + selectedAddressCategory = category; + }, + items: category + .map>( + (AddressCategory category) { + return DropdownMenuItem( + value: category, child: Text(category.name!)); + }).toList()), + const SizedBox( + height: 12, + ), + ////Area Class + FormBuilderDropdown( + initialValue: selectedAreaClass, + decoration: normalTextFieldStyle( + "Area class *", "Area class"), + name: "area_class", + onChanged: (Area? area) { + selectedAreaClass = area; + }, + items: areaClass + .map>((Area area) { + return area.group == 0 + ? DropdownMenuItem( + enabled: false, + value: area, + child: Text(area.value.toUpperCase(), + style: const TextStyle( + color: Colors.black38))) + : DropdownMenuItem( + value: area, + enabled: true, + child: Text( + " ${area.value.toUpperCase()}")); + }).toList()), + const SizedBox( + height: 12, + ), + ////stateful builder + StatefulBuilder(builder: (context, setState) { + return Column( children: [ - //// category - FormBuilderDropdown( - initialValue: selectedAddressCategory, - validator: FormBuilderValidators.required( - errorText: "This field is required"), - decoration: - normalTextFieldStyle("Category*", "Category"), - name: "category", - onChanged: (AddressCategory? category) { - selectedAddressCategory = category; - }, - items: category - .map>( - (AddressCategory category) { - return DropdownMenuItem( - value: category, child: Text(category.name!)); - }).toList()), - const SizedBox( - height: 12, - ), - ////Area Class - FormBuilderDropdown( - initialValue: selectedAreaClass, - decoration: normalTextFieldStyle( - "Area class *", "Area class"), - name: "area_class", - onChanged: (Area? area) { - selectedAreaClass = area; - }, - items: areaClass - .map>((Area area) { - return area.group == 0 - ? DropdownMenuItem( - enabled: false, - value: area, - child: Text(area.value.toUpperCase(), - style: const TextStyle( - color: Colors.black38))) - : DropdownMenuItem( - value: area, - enabled: true, - child: Text( - " ${area.value.toUpperCase()}")); - }).toList()), - const SizedBox( - height: 12, - ), - ////stateful builder - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - ////with block & Lot Switch - FormBuilderSwitch( - initialValue: hasLotandBlock, - activeColor: second, - onChanged: (value) { - setState(() { - hasLotandBlock = value!; - }); - }, - decoration: normalTextFieldStyle( - "With Lot and Block?", 'Graduated?'), - name: 'graudated', - title: Text(hasLotandBlock ? "YES" : "NO"), - ), - SizedBox( - height: hasLotandBlock ? 12 : 0, - ), - SizedBox( - width: screenWidth, - child: hasLotandBlock - ? Row( - children: [ - ////block # - Flexible( - flex: 1, - child: FormBuilderTextField( - initialValue: state.address - .subdivision?.blockNo - ?.toString(), - validator: FormBuilderValidators - .compose([numericRequired]), - keyboardType: - TextInputType.number, - name: "block_number", - decoration: - normalTextFieldStyle( - "Block #*", "Block #"), - )), - const SizedBox( - width: 8, - ), - //// lot # - Flexible( - flex: 1, - child: FormBuilderTextField( - initialValue: state - .address.subdivision?.lotNo - ?.toString(), - validator: FormBuilderValidators - .compose([numericRequired]), - name: "lot_number", - keyboardType: - TextInputType.number, - decoration: - normalTextFieldStyle( - "Lot #*", "Lot #"), - )), - ], - ) - : Container(), - ), - ], - ); - }), - const SizedBox( - height: 12, - ), - //// Address Line - FormBuilderTextField( - initialValue: state.address.details, - name: "address_line", + ////with block & Lot Switch + FormBuilderSwitch( + initialValue: hasLotandBlock, + activeColor: second, + onChanged: (value) { + setState(() { + hasLotandBlock = value!; + }); + }, decoration: normalTextFieldStyle( - "Address Line *", "Address Line"), + "With Lot and Block?", 'Graduated?'), + name: 'graudated', + title: Text(hasLotandBlock ? "YES" : "NO"), ), - const SizedBox( - height: 12, + SizedBox( + height: hasLotandBlock ? 12 : 0, ), - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - FormBuilderSwitch( - initialValue: overseas, - activeColor: second, - onChanged: (value) { - setState(() { - overseas = value!; - }); - }, - decoration: normalTextFieldStyle( - "Overseas Address?", ''), - name: 'overseas', - title: Text(overseas ? "YES" : "NO"), - ), - SizedBox( - height: overseas == true ? 8 : 0, - ), - SizedBox( - child: overseas == false - ? Column( - children: [ - const SizedBox( - height: 12, - ), - ////REGION DROPDOWN - DropdownButtonFormField( + SizedBox( + width: screenWidth, + child: hasLotandBlock + ? Row( + children: [ + ////block # + Flexible( + flex: 1, + child: FormBuilderTextField( + initialValue: state.address + .subdivision?.blockNo + ?.toString(), + validator: FormBuilderValidators + .compose([numericRequired]), + keyboardType: + TextInputType.number, + name: "block_number", + decoration: + normalTextFieldStyle( + "Block #*", "Block #"), + )), + const SizedBox( + width: 8, + ), + //// lot # + Flexible( + flex: 1, + child: FormBuilderTextField( + initialValue: state + .address.subdivision?.lotNo + ?.toString(), + validator: FormBuilderValidators + .compose([numericRequired]), + name: "lot_number", + keyboardType: + TextInputType.number, + decoration: + normalTextFieldStyle( + "Lot #*", "Lot #"), + )), + ], + ) + : Container(), + ), + ], + ); + }), + const SizedBox( + height: 12, + ), + //// Address Line + FormBuilderTextField( + initialValue: state.address.details, + name: "address_line", + decoration: normalTextFieldStyle( + "Address Line *", "Address Line"), + ), + const SizedBox( + height: 12, + ), + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, + decoration: normalTextFieldStyle( + "Overseas Address?", ''), + name: 'overseas', + title: Text(overseas ? "YES" : "NO"), + ), + SizedBox( + height: overseas == true ? 8 : 0, + ), + SizedBox( + child: overseas == false + ? Column( + children: [ + const SizedBox( + height: 12, + ), + ////REGION DROPDOWN + DropdownButtonFormField( + isExpanded: true, + value: selectedRegion, + autovalidateMode: AutovalidateMode + .onUserInteraction, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + onChanged: (Region? region) async { + if (selectedRegion != region) { + setState(() { + provinceCall = true; + }); + selectedRegion = region; + //// GET PROVINCES + try{ + provinces = await LocationUtils + .instance + .getProvinces( + regionCode: + selectedRegion!.code + .toString()); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } + selectedProvince = + provinces![0]; + setState(() { + provinceCall = false; + cityCall = true; + }); + //// GET CITIES + try{ + citymuns = await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = false; + barangayCall = true; + }); + //// GET BARANGAY + try{ + barangays = await LocationUtils + .instance + .getBarangay( + code: + selectedMunicipality! + .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } + selectedBarangay = + barangays![0]; + setState(() { + barangayCall = false; + }); + ////GET CITY MUNICIPALITY + try{ + citymuns = await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = false; + barangayCall = true; + }); + //// GET BARANGAYS + try{ + barangays = await LocationUtils + .instance + .getBarangay( + code: + selectedMunicipality! + .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } + selectedBarangay = + barangays![0]; + setState(() { + barangayCall = false; + }); + } + }, + decoration: normalTextFieldStyle( + "Region*", "Region"), + items: state.regions + .map>( + (Region region) { + return DropdownMenuItem( + value: region, + child: Text( + region.description!)); + }).toList(), + ), + const SizedBox( + height: 8, + ), + //// PROVINCE DROPDOWN + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: provinceCall, + child: DropdownButtonFormField< + Province?>( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: (value) => + value == null + ? 'required' + : null, isExpanded: true, - value: selectedRegion, - autovalidateMode: AutovalidateMode - .onUserInteraction, - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - onChanged: (Region? region) async { - if (selectedRegion != region) { - setState(() { - provinceCall = true; - }); - selectedRegion = region; - //// GET PROVINCES - try{ - provinces = await LocationUtils - .instance - .getProvinces( - regionCode: - selectedRegion!.code - .toString()); - }catch(e){ - NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); - } + value: selectedProvince, + onChanged: (Province? + province) async { + if (selectedProvince != + province) { selectedProvince = - provinces![0]; + province; setState(() { - provinceCall = false; cityCall = true; }); + //// GET CITIES try{ citymuns = await LocationUtils .instance .getCities( - code: selectedProvince! - .code!); + code: + selectedProvince! + .code!); }catch(e){ - NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); - } + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedMunicipality = citymuns![0]; setState(() { @@ -323,40 +428,8 @@ class _EditAddressScreenState extends State { selectedMunicipality! .code!); }catch(e){ - NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); - } - selectedBarangay = - barangays![0]; - setState(() { - barangayCall = false; - }); - ////GET CITY MUNICIPALITY - try{ - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code!); - }catch(e){ - NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); - } - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - barangayCall = true; - }); - //// GET BARANGAYS - try{ - barangays = await LocationUtils - .instance - .getBarangay( - code: - selectedMunicipality! - .code!); - }catch(e){ - NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); - } + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } selectedBarangay = barangays![0]; setState(() { @@ -364,231 +437,151 @@ class _EditAddressScreenState extends State { }); } }, - decoration: normalTextFieldStyle( - "Region*", "Region"), - items: state.regions - .map>( - (Region region) { - return DropdownMenuItem( - value: region, - child: Text( - region.description!)); - }).toList(), - ), - const SizedBox( - height: 8, - ), - //// PROVINCE DROPDOWN - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: (value) => - value == null - ? 'required' - : null, - isExpanded: true, - value: selectedProvince, - onChanged: (Province? - province) async { - if (selectedProvince != - province) { - selectedProvince = - province; - setState(() { - cityCall = true; - }); - - //// GET CITIES - try{ - citymuns = await LocationUtils - .instance - .getCities( - code: - selectedProvince! - .code!); - }catch(e){ - NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); - } - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - barangayCall = true; - }); - //// GET BARANGAY - try{ - barangays = await LocationUtils - .instance - .getBarangay( - code: - selectedMunicipality! - .code!); - }catch(e){ - NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); - } - selectedBarangay = - barangays![0]; - setState(() { - barangayCall = false; - }); - } - }, - items: provinces == null - ? [] - : provinces!.map< - DropdownMenuItem< - Province>>( - (Province province) { - return DropdownMenuItem( - value: province, - child: FittedBox( - child: Text(province - .description!), - )); - }).toList(), - decoration: - normalTextFieldStyle( - "Province*", - "Province")), - ), - ), - ////CITY MUNICIPALITY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: cityCall, - child: DropdownButtonFormField< - CityMunicipality>( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - isExpanded: true, - onChanged: (CityMunicipality? - city) async { - if (selectedMunicipality != - city) { - setState(() { - barangayCall = true; - }); - selectedMunicipality = city; - selectedMunicipality = city; - //// GET BARANGAYS - try{ - barangays = await LocationUtils - .instance - .getBarangay( - code: - selectedMunicipality! - .code!); - }catch(e){ - NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); - } - selectedBarangay = - barangays![0]; - setState(() { - barangayCall = false; - }); - } - }, - decoration: - normalTextFieldStyle( - "Municipality*", - "Municipality"), - value: selectedMunicipality, - items: citymuns == null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality c) { - return DropdownMenuItem( - value: c, - child: Text(c - .description!)); - }).toList(), - ), - ), - ), - //// BARANGAY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: barangayCall, - child: DropdownButtonFormField< - Barangay>( - isExpanded: true, - onChanged: (Barangay? baragay) { - selectedBarangay = baragay; - }, - decoration: - normalTextFieldStyle( - "Barangay*", - "Barangay"), - value: selectedBarangay, - items: barangays == null - ? [] - : barangays!.map< - DropdownMenuItem< - Barangay>>( - (Barangay barangay) { - return DropdownMenuItem( - value: barangay, - child: Text(barangay - .description!)); - }).toList(), - ), - ), - ), - ], - ) - //// COUNTRY DROPDOWN - : SizedBox( - height: 60, - child: FormBuilderDropdown( - initialValue:selectedCountry!.id == 175?null:selectedCountry, - validator: - FormBuilderValidators.required( + items: provinces == null + ? [] + : provinces!.map< + DropdownMenuItem< + Province>>( + (Province province) { + return DropdownMenuItem( + value: province, + child: FittedBox( + child: Text(province + .description!), + )); + }).toList(), + decoration: + normalTextFieldStyle( + "Province*", + "Province")), + ), + ), + ////CITY MUNICIPALITY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: cityCall, + child: DropdownButtonFormField< + CityMunicipality>( + validator: FormBuilderValidators + .required( errorText: "This field is required"), - items: state.countries - .map>( - (Country country) { - return DropdownMenuItem( - value: country, - child: FittedBox( - child: - Text(country.name!))); - }).toList(), - name: 'country', - decoration: normalTextFieldStyle( - "Country*", "Country"), - onChanged: (Country? value) { - setState((){ - selectedCountry = value; - }); + isExpanded: true, + onChanged: (CityMunicipality? + city) async { + if (selectedMunicipality != + city) { + setState(() { + barangayCall = true; + }); + selectedMunicipality = city; + selectedMunicipality = city; + //// GET BARANGAYS + try{ + barangays = await LocationUtils + .instance + .getBarangay( + code: + selectedMunicipality! + .code!); + }catch(e){ + NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); + } + selectedBarangay = + barangays![0]; + setState(() { + barangayCall = false; + }); + } }, + decoration: + normalTextFieldStyle( + "Municipality*", + "Municipality"), + value: selectedMunicipality, + items: citymuns == null + ? [] + : citymuns!.map< + DropdownMenuItem< + CityMunicipality>>( + (CityMunicipality c) { + return DropdownMenuItem( + value: c, + child: Text(c + .description!)); + }).toList(), ), ), - ), - ], - ); - }), - - + ), + //// BARANGAY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: barangayCall, + child: DropdownButtonFormField< + Barangay>( + isExpanded: true, + onChanged: (Barangay? baragay) { + selectedBarangay = baragay; + }, + decoration: + normalTextFieldStyle( + "Barangay*", + "Barangay"), + value: selectedBarangay, + items: barangays == null + ? [] + : barangays!.map< + DropdownMenuItem< + Barangay>>( + (Barangay barangay) { + return DropdownMenuItem( + value: barangay, + child: Text(barangay + .description!)); + }).toList(), + ), + ), + ), + ], + ) + //// COUNTRY DROPDOWN + : SizedBox( + height: 60, + child: FormBuilderDropdown( + initialValue:selectedCountry!.id == 175?null:selectedCountry, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + items: state.countries + .map>( + (Country country) { + return DropdownMenuItem( + value: country, + child: FittedBox( + child: + Text(country.name!))); + }).toList(), + name: 'country', + decoration: normalTextFieldStyle( + "Country*", "Country"), + onChanged: (Country? value) { + setState((){ + selectedCountry = value; + }); + }, + ), + ), + ), ], - ), - ), - SizedBox( + ); + }), + const SizedBox(height: 8,), + SizedBox( width: double.infinity, height: 60, child: ElevatedButton( @@ -645,13 +638,13 @@ class _EditAddressScreenState extends State { }, child: const Text(submit)), ), - + ], ), ), )); } - return Placeholder(); + return const Placeholder(); }, ); } diff --git a/lib/screens/profile/components/basic_information/address_screen.dart b/lib/screens/profile/components/basic_information/address_screen.dart index 1df1ddc..c7ebf40 100644 --- a/lib/screens/profile/components/basic_information/address_screen.dart +++ b/lib/screens/profile/components/basic_information/address_screen.dart @@ -26,7 +26,7 @@ class AddressScreen extends StatelessWidget { int? profileId; String? token; return Scaffold( - resizeToAvoidBottomInset: false, + resizeToAvoidBottomInset: true, appBar: AppBar( title: context.watch().state is AddAddressState?const Text("Add Address"):context.watch().state is EditAddressState?const Text("Edit Address"):const Text("Addresses"), centerTitle: true, diff --git a/lib/screens/profile/components/basic_information/contact_information/add_modal.dart b/lib/screens/profile/components/basic_information/contact_information/add_modal.dart index 03f75da..0d7d0c2 100644 --- a/lib/screens/profile/components/basic_information/contact_information/add_modal.dart +++ b/lib/screens/profile/components/basic_information/contact_information/add_modal.dart @@ -50,210 +50,206 @@ class _AddContactInformationScreenState builder: (context, state) { if (state is ContactAddingState) { return Padding( - padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 24), + padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 24), child: FormBuilder( key: formKey, child: StatefulBuilder(builder: (context, setState) { - return SizedBox( - height: screenHeight * 90, - child: Column( - children: [ - Flexible( - child: ListView( - children: [ - - ////Service Type - FormBuilderDropdown( + return ListView( + children: [ + ////Service Type + FormBuilderDropdown( + validator: FormBuilderValidators.required( + errorText: "This field is required"), + name: "service_type", + items: state.serviceTypes + .map>( + (ServiceType e) { + return DropdownMenuItem( + value: e, child: Text(e.name!)); + }).toList(), + decoration: normalTextFieldStyle("Service Type*", ""), + onChanged: (var service) async { + if (selectedServiceType != service) { + selectedServiceType = service; + setState(() { + callServiceType = true; + selectedCommServiceProvider = null; + numberMailController.text = ""; + }); + + try { + commServiceProviders = await ContactService + .instance + .getServiceProvider( + serviceTypeId: + selectedServiceType!.id!); + } catch (e) { + context + .read() + .add(CallErrorEvent(message: e.toString())); + } + setState(() { + setState(() { + callServiceType = false; + }); + }); + } + }), + const SizedBox( + height: 12, + ), + ////Service Provider + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: callServiceType, + child: DropdownButtonFormField( + isExpanded: true, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + items: commServiceProviders.isEmpty + ? [] + : commServiceProviders + .map>( + (CommService e) { + return DropdownMenuItem( + value: e, + child: Text(e + .serviceProvider!.agency!.name!)); + }).toList(), + decoration: normalTextFieldStyle( + "Communication Service *", ""), + onChanged: (var serviceProvider) { + selectedCommServiceProvider = serviceProvider; + }), + ), + ), + selectedServiceType != null + ? selectedServiceType?.id == 2 + //// Landline + ? FormBuilderTextField( + controller: numberMailController, + inputFormatters: [landLineFormatter], + name: 'number-mail', validator: FormBuilderValidators.required( errorText: "This field is required"), - name: "service_type", - items: state.serviceTypes - .map>( - (ServiceType e) { - return DropdownMenuItem( - value: e, child: Text(e.name!)); - }).toList(), - decoration: normalTextFieldStyle("Service Type*", ""), - onChanged: (var service) async { - if (selectedServiceType != service) { - selectedServiceType = service; - setState(() { - callServiceType = true; - selectedCommServiceProvider = null; - numberMailController.text = ""; - }); - - commServiceProviders = await ContactService - .instance - .getServiceProvider( - serviceTypeId: selectedServiceType!.id!); - setState(() { - setState(() { - callServiceType = false; - }); - }); - } - }), - const SizedBox( - height: 12, - ), - ////Service Provider - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: callServiceType, - child: DropdownButtonFormField( - isExpanded: true, + decoration: normalTextFieldStyle( + "Landline number *", + "(area code) xxx - xxxx"), + ) + : selectedServiceType!.id == 1 || + selectedServiceType!.id == 19 + //// Mobile number + ? FormBuilderTextField( + keyboardType: TextInputType.number, + controller: numberMailController, + name: 'number-mail', + inputFormatters: [mobileFormatter], validator: FormBuilderValidators.required( errorText: "This field is required"), - items: commServiceProviders.isEmpty - ? [] - : commServiceProviders - .map>( - (CommService e) { - return DropdownMenuItem( - value: e, - child: Text(e - .serviceProvider!.agency!.name!)); - }).toList(), decoration: normalTextFieldStyle( - "Communication Service *", ""), - onChanged: (var serviceProvider) { - selectedCommServiceProvider = serviceProvider; - }), - ), - ), - selectedServiceType != null - ? selectedServiceType?.id == 2 - //// Landline + "Mobile number *", + "+63 (9xx) xxx - xxxx"), + ) + : selectedServiceType!.id == 4 + ////Social Media ? FormBuilderTextField( controller: numberMailController, - inputFormatters: [landLineFormatter], name: 'number-mail', - validator: FormBuilderValidators.required( - errorText: "This field is required"), + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), decoration: normalTextFieldStyle( - "Landline number *", - "(area code) xxx - xxxx"), + "Account ID / Username *", ""), ) - : selectedServiceType!.id == 1 || - selectedServiceType!.id == 19 - //// Mobile number + : selectedServiceType!.id == 3 + ////Email Address ? FormBuilderTextField( - keyboardType: TextInputType.number, controller: numberMailController, name: 'number-mail', - inputFormatters: [mobileFormatter], - validator: FormBuilderValidators.required( - errorText: "This field is required"), + validator: FormBuilderValidators + .compose([ + FormBuilderValidators.email( + errorText: + "Input vaild email"), + FormBuilderValidators.required( + errorText: + "This field is required") + ]), decoration: normalTextFieldStyle( - "Mobile number *", - "+63 (9xx) xxx - xxxx"), + "Email Address*", ""), ) - : selectedServiceType!.id == 4 - ////Social Media - ? FormBuilderTextField( - controller: numberMailController, - name: 'number-mail', - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - decoration: normalTextFieldStyle( - "Account ID / Username *", ""), - ) - : selectedServiceType!.id == 3 - ////Email Address - ? FormBuilderTextField( - controller: numberMailController, - name: 'number-mail', - validator: FormBuilderValidators - .compose([ - FormBuilderValidators.email( - errorText: - "Input vaild email"), - FormBuilderValidators.required( - errorText: - "This field is required") - ]), - decoration: normalTextFieldStyle( - "Email Address*", ""), - ) - : Container() - : const SizedBox(), - SizedBox( - height: selectedServiceType != null ? 12 : 0, - ), - //// Primary - FormBuilderSwitch( - initialValue: primaryaContact, - activeColor: second, - onChanged: (value) { - setState(() { - primaryaContact = value!; - }); - }, - decoration: - normalTextFieldStyle("Primary?", 'Primary?'), - name: 'overseas', - title: Text(primaryaContact ? "YES" : "NO"), - ), - //// Active - const SizedBox( - height: 12, - ), - FormBuilderSwitch( - initialValue: primaryaContact, - activeColor: second, - onChanged: (value) { - setState(() { - active = value!; - }); - }, - decoration: normalTextFieldStyle("Active?", ''), - name: 'overseas', - title: Text(active ? "YES" : "NO"), - ), - - - ], - ), - + : Container() + : const SizedBox(), + SizedBox( + height: selectedServiceType != null ? 12 : 0, + ), + //// Primary + FormBuilderSwitch( + initialValue: primaryaContact, + activeColor: second, + onChanged: (value) { + setState(() { + primaryaContact = value!; + }); + }, + decoration: + normalTextFieldStyle("Primary?", 'Primary?'), + name: 'overseas', + title: Text(primaryaContact ? "YES" : "NO"), + ), + //// Active + const SizedBox( + height: 12, + ), + FormBuilderSwitch( + initialValue: primaryaContact, + activeColor: second, + onChanged: (value) { + setState(() { + active = value!; + }); + }, + decoration: normalTextFieldStyle("Active?", ''), + name: 'overseas', + title: Text(active ? "YES" : "NO"), + ), + const SizedBox( + height: 24, + ), + SizedBox( + height: 60, + width: double.infinity, + child: ElevatedButton( + onPressed: () { + if (formKey.currentState!.saveAndValidate()) { + numberMail = + formKey.currentState!.value['number-mail']; + CommService commService = + selectedCommServiceProvider!; + ContactInfo contactInfo = ContactInfo( + id: null, + active: active, + primary: primaryaContact, + numbermail: numberMail, + commService: commService); + final progress = ProgressHUD.of(context); + progress!.showWithText("Loading..."); + context.read().add( + AddContactInformation( + contactInfo: contactInfo, + profileId: widget.profileId, + token: widget.token)); + } + }, + style: + mainBtnStyle(primary, Colors.transparent, second), + child: const Text(submit), ), - SizedBox( - height: 60, - width: double.infinity, - child: ElevatedButton( - onPressed: () { - if (formKey.currentState!.saveAndValidate()) { - numberMail = - formKey.currentState!.value['number-mail']; - CommService commService = - selectedCommServiceProvider!; - ContactInfo contactInfo = ContactInfo( - id: null, - active: active, - primary: primaryaContact, - numbermail: numberMail, - commService: commService); - final progress = ProgressHUD.of(context); - progress!.showWithText("Loading..."); - context.read().add( - AddContactInformation( - contactInfo: contactInfo, - profileId: widget.profileId, - token: widget.token)); - } - }, - style: - mainBtnStyle(primary, Colors.transparent, second), - child: const Text(submit), - ), - ), - - ], - ), + ), + ], ); })), ); diff --git a/lib/screens/profile/components/basic_information/contact_information/edit_modal.dart b/lib/screens/profile/components/basic_information/contact_information/edit_modal.dart index a372064..f2e713d 100644 --- a/lib/screens/profile/components/basic_information/contact_information/edit_modal.dart +++ b/lib/screens/profile/components/basic_information/contact_information/edit_modal.dart @@ -35,7 +35,6 @@ class _EditContactInformationScreenState bool? primaryaContact; bool? active; - var mobileFormatter = MaskTextInputFormatter( mask: "+63 (###) ###-####", filter: {"#": RegExp(r"^[1-9][0-9]*$")}, @@ -51,9 +50,10 @@ class _EditContactInformationScreenState final numberMailController = TextEditingController(); @override void dispose() { - numberMailController.dispose(); + numberMailController.dispose(); super.dispose(); } + @override Widget build(BuildContext context) { return BlocBuilder( @@ -64,221 +64,218 @@ class _EditContactInformationScreenState commServiceProviders = state.commServiceProviders; primaryaContact = state.contactInfo.primary; active = state.contactInfo.active; - numberMailController.text = state.contactInfo.numbermail!; + numberMailController.text = state.contactInfo.numbermail!; return Padding( padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 24), child: FormBuilder( key: formKey, - child: Column( + child: ListView( children: [ - Flexible( - child: ListView( - children: [ - StatefulBuilder(builder: (context, setState) { - return Column(children: [ - ////Service Type - DropdownButtonFormField( - isExpanded: true, - validator: FormBuilderValidators.required( - errorText: "This field is required"), - value: selectedServiceType, - items: state.serviceTypes - .map>( - (ServiceType e) { - return DropdownMenuItem( - value: e, child: Text(e.name!)); - }).toList(), - decoration: - normalTextFieldStyle("Service Type*", ""), - onChanged: (var service) async { - if (selectedServiceType!.id != service!.id) { - selectedServiceType = service; - setState(() { - callServiceType = true; - callServiceType = true; - - numberMailController.text = ""; - }); - commServiceProviders = await ContactService - .instance - .getServiceProvider( - serviceTypeId: - selectedServiceType!.id!); - selectedCommProvider = null; - setState(() { - setState(() { - callServiceType = false; - }); - }); - } - }), - const SizedBox( - height: 12, - ), - ////Service Provider - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: callServiceType, - child: DropdownButtonFormField( - isExpanded: true, - value: selectedCommProvider, - validator: FormBuilderValidators.required( - errorText: "This field is required"), - items: commServiceProviders.isEmpty - ? [] - : commServiceProviders - .map>( - (CommService e) { - return DropdownMenuItem( - value: e, - child: Text(e.serviceProvider! - .agency!.name!)); - }).toList(), - decoration: normalTextFieldStyle( - "Communication Service *", ""), - onChanged: (var commServiceProvider) { - selectedCommProvider = commServiceProvider; - }), - ), - ), - selectedServiceType != null - ? selectedServiceType?.id == 2 - //// Landline - ? FormBuilderTextField( - controller: numberMailController, - name: 'number-mail', - - inputFormatters: [landLineFormatter], - validator: FormBuilderValidators.required( - errorText: "This field is required"), - decoration: normalTextFieldStyle( - "Landline number *", - "(area code) xxx - xxxx"), - ) - : selectedServiceType!.id == 1 || - selectedServiceType!.id == 19 - //// Mobile number - ? FormBuilderTextField( - controller: numberMailController, - name: 'number-mail', - inputFormatters: [mobileFormatter], - - validator: + StatefulBuilder(builder: (context, setState) { + return Column(children: [ + ////Service Type + DropdownButtonFormField( + isExpanded: true, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + value: selectedServiceType, + items: state.serviceTypes + .map>( + (ServiceType e) { + return DropdownMenuItem( + value: e, child: Text(e.name!)); + }).toList(), + decoration: + normalTextFieldStyle("Service Type*", ""), + onChanged: (var service) async { + if (selectedServiceType!.id != service!.id) { + selectedServiceType = service; + setState(() { + callServiceType = true; + callServiceType = true; + + numberMailController.text = ""; + }); + try { + commServiceProviders = await ContactService + .instance + .getServiceProvider( + serviceTypeId: + selectedServiceType!.id!); + } catch (e) { + context.read().add( + CallErrorEvent(message: e.toString())); + } + selectedCommProvider = null; + setState(() { + setState(() { + callServiceType = false; + }); + }); + } + }), + const SizedBox( + height: 12, + ), + ////Service Provider + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: callServiceType, + child: DropdownButtonFormField( + isExpanded: true, + value: selectedCommProvider, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + items: commServiceProviders.isEmpty + ? [] + : commServiceProviders + .map>( + (CommService e) { + return DropdownMenuItem( + value: e, + child: Text(e.serviceProvider! + .agency!.name!)); + }).toList(), + decoration: normalTextFieldStyle( + "Communication Service *", ""), + onChanged: (var commServiceProvider) { + selectedCommProvider = commServiceProvider; + }), + ), + ), + selectedServiceType != null + ? selectedServiceType?.id == 2 + //// Landline + ? FormBuilderTextField( + controller: numberMailController, + name: 'number-mail', + inputFormatters: [landLineFormatter], + validator: FormBuilderValidators.required( + errorText: "This field is required"), + decoration: normalTextFieldStyle( + "Landline number *", + "(area code) xxx - xxxx"), + ) + : selectedServiceType!.id == 1 || + selectedServiceType!.id == 19 + //// Mobile number + ? FormBuilderTextField( + controller: numberMailController, + name: 'number-mail', + inputFormatters: [mobileFormatter], + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + decoration: normalTextFieldStyle( + "Mobile number *", + "+63 (9xx) xxx - xxxx"), + ) + : selectedServiceType!.id == 4 + ////Social Media + ? FormBuilderTextField( + controller: numberMailController, + name: 'number-mail', + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + decoration: normalTextFieldStyle( + "Account ID / Username *", ""), + ) + : selectedServiceType!.id == 3 + ////Email Address + ? FormBuilderTextField( + controller: + numberMailController, + name: 'number-mail', + validator: FormBuilderValidators + .compose([ + FormBuilderValidators.email( + errorText: + "Input vaild email"), FormBuilderValidators.required( errorText: - "This field is required"), - decoration: normalTextFieldStyle( - "Mobile number *", - "+63 (9xx) xxx - xxxx"), - ) - : selectedServiceType!.id == 4 - ////Social Media - ? FormBuilderTextField( - controller: numberMailController, - name: 'number-mail', - - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - decoration: normalTextFieldStyle( - "Account ID / Username *", ""), - ) - : selectedServiceType!.id == 3 - ////Email Address - ? FormBuilderTextField( - controller: numberMailController, - name: 'number-mail', - - validator: FormBuilderValidators - .compose([ - FormBuilderValidators.email( - errorText: - "Input vaild email"), - FormBuilderValidators.required( - errorText: - "This field is required") - ]), - decoration: - normalTextFieldStyle( - "Email Address*", ""), - ) - : Container() - : const SizedBox(), - ]); - }), - SizedBox( - height: selectedServiceType != null ? 12 : 0, - ), - //// Primary - StatefulBuilder(builder: (context, setState) { - return FormBuilderSwitch( - initialValue: primaryaContact, - activeColor: second, - onChanged: (value) { - setState(() { - primaryaContact = value; - }); - }, - decoration: normalTextFieldStyle("", ''), - name: 'primary', - title: const Text("Primary ?"), - ); - }), - //// Active - const SizedBox( - height: 12, - ), - StatefulBuilder(builder: (context, setState) { - return FormBuilderSwitch( - initialValue: active, - activeColor: second, - onChanged: (value) { - setState(() { - active = value; - }); - }, - decoration: normalTextFieldStyle("", ''), - name: 'active', - title: const Text("Active ?"), - ); - }), - - - ], - ), + "This field is required") + ]), + decoration: + normalTextFieldStyle( + "Email Address*", ""), + ) + : Container() + : const SizedBox(), + ]); + }), + SizedBox( + height: selectedServiceType != null ? 12 : 0, ), - SizedBox( - height: 60, - width: double.infinity, - child: ElevatedButton( - onPressed: () { - if (formKey.currentState!.saveAndValidate()) { - numberMail = - formKey.currentState!.value['number-mail']; - CommService commService = selectedCommProvider!; - ContactInfo contactInfo = ContactInfo( - id: state.contactInfo.id, - active: active, - primary: primaryaContact, - numbermail: numberMail, - commService: commService); - final progress = ProgressHUD.of(context); - progress!.showWithText("Loading..."); - context.read().add( - EditContactInformation( - contactInfo: contactInfo, - profileId: widget.profileId, - token: widget.token)); - } - }, - style: - mainBtnStyle(primary, Colors.transparent, second), - child: const Text(submit), - ), - ) + //// Primary + StatefulBuilder(builder: (context, setState) { + return FormBuilderSwitch( + initialValue: primaryaContact, + activeColor: second, + onChanged: (value) { + setState(() { + primaryaContact = value; + }); + }, + decoration: normalTextFieldStyle("", ''), + name: 'primary', + title: const Text("Primary ?"), + ); + }), + //// Active + const SizedBox( + height: 12, + ), + StatefulBuilder(builder: (context, setState) { + return FormBuilderSwitch( + initialValue: active, + activeColor: second, + onChanged: (value) { + setState(() { + active = value; + }); + }, + decoration: normalTextFieldStyle("", ''), + name: 'active', + title: const Text("Active ?"), + ); + }), + const SizedBox( + height: 24, + ), + SizedBox( + height: 60, + width: double.infinity, + child: ElevatedButton( + onPressed: () { + if (formKey.currentState!.saveAndValidate()) { + numberMail = + formKey.currentState!.value['number-mail']; + CommService commService = selectedCommProvider!; + ContactInfo contactInfo = ContactInfo( + id: state.contactInfo.id, + active: active, + primary: primaryaContact, + numbermail: numberMail, + commService: commService); + final progress = ProgressHUD.of(context); + progress!.showWithText("Loading..."); + context.read().add( + EditContactInformation( + contactInfo: contactInfo, + profileId: widget.profileId, + token: widget.token)); + } + }, + style: + mainBtnStyle(primary, Colors.transparent, second), + child: const Text(submit), + ), + ) ], )), ); diff --git a/lib/screens/profile/components/basic_information/contact_information_screen.dart b/lib/screens/profile/components/basic_information/contact_information_screen.dart index 2d666cd..05f3325 100644 --- a/lib/screens/profile/components/basic_information/contact_information_screen.dart +++ b/lib/screens/profile/components/basic_information/contact_information_screen.dart @@ -28,7 +28,7 @@ class ContactInformationScreen extends StatelessWidget { String token; return SafeArea( child: Scaffold( - resizeToAvoidBottomInset: false, + resizeToAvoidBottomInset: true, appBar: AppBar( title: context.watch().state is ContactAddingState ? const Text("Add Contact") diff --git a/lib/screens/profile/components/basic_information/family/child_add_modal.dart b/lib/screens/profile/components/basic_information/family/child_add_modal.dart index 3c1afe2..f1dac9e 100644 --- a/lib/screens/profile/components/basic_information/family/child_add_modal.dart +++ b/lib/screens/profile/components/basic_information/family/child_add_modal.dart @@ -131,7 +131,7 @@ class _ChildAlertState extends State { Icons.date_range, color: Colors.black87, )), - firstDate: DateTime(1970), + firstDate: DateTime(1900), lastDate: DateTime(2100), icon: const Icon(Icons.date_range), ), diff --git a/lib/screens/profile/components/basic_information/family/child_edit_modal.dart b/lib/screens/profile/components/basic_information/family/child_edit_modal.dart index 768f596..29f0347 100644 --- a/lib/screens/profile/components/basic_information/family/child_edit_modal.dart +++ b/lib/screens/profile/components/basic_information/family/child_edit_modal.dart @@ -7,7 +7,6 @@ import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:form_builder_validators/form_builder_validators.dart'; import 'package:unit2/bloc/profile/family/family_bloc.dart'; import 'package:unit2/model/profile/family_backround.dart'; - import '../../../../../model/utils/position.dart'; import '../../../../../theme-data.dart/btn-style.dart'; import '../../../../../theme-data.dart/colors.dart'; @@ -15,7 +14,6 @@ import '../../../../../theme-data.dart/form-style.dart'; import '../../../../../utils/formatters.dart'; import '../../../../../utils/global.dart'; import '../../../../../utils/text_container.dart'; -import '../../../../../utils/validators.dart'; class ChildEditAlert extends StatefulWidget { final FamilyBackground familyBackground; @@ -150,7 +148,7 @@ class _ChildEditAlertState extends State { Icons.date_range, color: Colors.black87, )), - firstDate: DateTime(1970), + firstDate: DateTime(1900), lastDate: DateTime(2100), icon: const Icon(Icons.date_range), ), diff --git a/lib/screens/profile/components/basic_information/family/father_add_modal.dart b/lib/screens/profile/components/basic_information/family/father_add_modal.dart index afd0032..4d8fd9e 100644 --- a/lib/screens/profile/components/basic_information/family/father_add_modal.dart +++ b/lib/screens/profile/components/basic_information/family/father_add_modal.dart @@ -129,7 +129,7 @@ class _FatherAlertState extends State { Icons.date_range, color: Colors.black87, )), - firstDate: DateTime(1970), + firstDate: DateTime(1900), lastDate: DateTime(2100), icon: const Icon(Icons.date_range), ), diff --git a/lib/screens/profile/components/basic_information/family/father_edit_modal.dart b/lib/screens/profile/components/basic_information/family/father_edit_modal.dart index 939e014..cd7aa52 100644 --- a/lib/screens/profile/components/basic_information/family/father_edit_modal.dart +++ b/lib/screens/profile/components/basic_information/family/father_edit_modal.dart @@ -149,7 +149,7 @@ class _FatherEditAlertState extends State { Icons.date_range, color: Colors.black87, )), - firstDate: DateTime(1970), + firstDate: DateTime(1900), lastDate: DateTime(2100), icon: const Icon(Icons.date_range), ), diff --git a/lib/screens/profile/components/basic_information/family/mother_add_modal.dart b/lib/screens/profile/components/basic_information/family/mother_add_modal.dart index 19295cd..e91b965 100644 --- a/lib/screens/profile/components/basic_information/family/mother_add_modal.dart +++ b/lib/screens/profile/components/basic_information/family/mother_add_modal.dart @@ -129,7 +129,7 @@ class _MotherAlertState extends State { Icons.date_range, color: Colors.black87, )), - firstDate: DateTime(1970), + firstDate: DateTime(1900), lastDate: DateTime(2100), icon: const Icon(Icons.date_range), ), diff --git a/lib/screens/profile/components/basic_information/family/mother_edit_modal.dart b/lib/screens/profile/components/basic_information/family/mother_edit_modal.dart index 73a74ed..f6d287b 100644 --- a/lib/screens/profile/components/basic_information/family/mother_edit_modal.dart +++ b/lib/screens/profile/components/basic_information/family/mother_edit_modal.dart @@ -139,7 +139,7 @@ class _MotherEditAlertState extends State { Icons.date_range, color: Colors.black87, )), - firstDate: DateTime(1970), + firstDate: DateTime(1900), lastDate: DateTime(2100), icon: const Icon(Icons.date_range), ), diff --git a/lib/screens/profile/components/basic_information/family/related_add_modal.dart b/lib/screens/profile/components/basic_information/family/related_add_modal.dart index 12f0170..4f27934 100644 --- a/lib/screens/profile/components/basic_information/family/related_add_modal.dart +++ b/lib/screens/profile/components/basic_information/family/related_add_modal.dart @@ -154,7 +154,7 @@ bdayController.dispose(); Icons.date_range, color: Colors.black87, )), - firstDate: DateTime(1970), + firstDate: DateTime(1900), lastDate: DateTime(2100), icon: const Icon(Icons.date_range), ), diff --git a/lib/screens/profile/components/basic_information/family/related_edit_modal.dart b/lib/screens/profile/components/basic_information/family/related_edit_modal.dart index 97edaf4..72849db 100644 --- a/lib/screens/profile/components/basic_information/family/related_edit_modal.dart +++ b/lib/screens/profile/components/basic_information/family/related_edit_modal.dart @@ -172,7 +172,7 @@ class _RelatedEditAlertState extends State { Icons.date_range, color: Colors.black87, )), - firstDate: DateTime(1970), + firstDate: DateTime(1900), lastDate: DateTime(2100), icon: const Icon(Icons.date_range), ), diff --git a/lib/screens/profile/components/basic_information/identification/add_modal.dart b/lib/screens/profile/components/basic_information/identification/add_modal.dart index ef9272e..3ef7946 100644 --- a/lib/screens/profile/components/basic_information/identification/add_modal.dart +++ b/lib/screens/profile/components/basic_information/identification/add_modal.dart @@ -146,508 +146,568 @@ class _AddIdentificationScreenState extends State { key: formKey, child: SizedBox( height: screenHeight * 90, - child: Column( + child: ListView( children: [ - Flexible( - child: ListView( + StatefulBuilder(builder: (context, setState) { + return Column( children: [ - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - FormBuilderDropdown( - validator: FormBuilderValidators.required( - errorText: "This field is required"), - isExpanded: true, - decoration: normalTextFieldStyle( - "Select Agency", "Select Agency"), - name: "requiredAgency", - items: requiredAgency! - .map>( - (Agency agency) { - return DropdownMenuItem( - value: agency, - child: Container( - width: double.infinity, - decoration: - box1().copyWith(boxShadow: []), - child: Text( - agency.name!, - maxLines: 3, - )), - ); - }).toList(), - onChanged: (value) { - selectedAgency = value; + FormBuilderDropdown( + validator: FormBuilderValidators.required( + errorText: "This field is required"), + isExpanded: true, + decoration: normalTextFieldStyle( + "Select Agency", "Select Agency"), + name: "requiredAgency", + items: requiredAgency! + .map>( + (Agency agency) { + return DropdownMenuItem( + value: agency, + child: Container( + width: double.infinity, + decoration: + box1().copyWith(boxShadow: []), + child: Text( + agency.name!, + maxLines: 3, + )), + ); + }).toList(), + onChanged: (value) { + selectedAgency = value; - if (value!.id == 0) { - setState(() { - otherAgency = true; - }); - } else { - isPrivate = value.privateEntity!; - setState(() { - otherAgency = false; - }); - } - }, - ), - SizedBox( - height: otherAgency ? 12 : 0, - ), - ////Other agency - SizedBox( - child: otherAgency - ? StatefulBuilder( - builder: (context, setState) { - return Column( - children: [ - ////Company - SizedBox( - child: SearchField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - itemHeight: 100, - focusNode: - agencyFocusNode, - suggestions: state - .agencies - .map((Agency - agency) => - SearchFieldListItem( - agency.name!, - item: agency, - child: - ListTile( - title: Text( - agency - .name!, - overflow: - TextOverflow - .visible, - ), - subtitle: Text(agency.privateEntity == - true - ? "Private" - : agency.privateEntity == - false - ? "Government" - : ""), - ))) - .toList(), - searchInputDecoration: + if (value!.id == 0) { + setState(() { + otherAgency = true; + }); + } else { + isPrivate = value.privateEntity!; + setState(() { + otherAgency = false; + }); + } + }, + ), + SizedBox( + height: otherAgency ? 12 : 0, + ), + ////Other agency + SizedBox( + child: otherAgency + ? StatefulBuilder( + builder: (context, setState) { + return Column( + children: [ + ////Company + SizedBox( + child: SearchField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + itemHeight: 100, + focusNode: + agencyFocusNode, + suggestions: state + .agencies + .map((Agency + agency) => + SearchFieldListItem( + agency.name!, + item: agency, + child: + ListTile( + title: Text( + agency + .name!, + overflow: + TextOverflow + .visible, + ), + subtitle: Text(agency.privateEntity == + true + ? "Private" + : agency.privateEntity == + false + ? "Government" + : ""), + ))) + .toList(), + searchInputDecoration: + normalTextFieldStyle( + "Agency *", "") + .copyWith( + suffixIcon: + GestureDetector( + child: const Icon( + Icons.arrow_drop_down, + ), + onTap: () => + agencyFocusNode + .unfocus(), + )), + onSuggestionTap: + (agency) { + setState(() { + selectedAgency = + agency.item; + + if (selectedAgency! + .privateEntity == + null) { + showIsPrivateRadio = + true; + } else { + showIsPrivateRadio = + false; + } + + agencyFocusNode + .unfocus(); + }); + }, + validator: (agency) { + if (agency!.isEmpty) { + return "This field is required"; + } + return null; + }, + emptyWidget: EmptyWidget( + controller: + addAgencyController, + onpressed: () { + setState(() { + Agency newAgency = Agency( + id: null, + name: addAgencyController + .text + .toUpperCase(), + category: + null, + privateEntity: + null); + + state.agencies + .insert(0, + newAgency); + selectedAgency = + newAgency; + addAgencyController + .text = ""; + showAgency = true; + + showIsPrivateRadio = + true; + + Navigator.pop( + context); + }); + }, + title: "Add Agency")), + ), + + SizedBox( + height: showAgency ? 12 : 0, + ), + ////SHOW CATEGORY AGENCY + SizedBox( + child: showAgency + ? SearchField( + focusNode: + agencyCategoryFocusNode, + itemHeight: 70, + suggestions: state + .agencyCategory + .map((Category + category) => + SearchFieldListItem( + category + .name!, + item: + category, + child: + ListTile( + title: Text( + category.name!), + subtitle: Text(category + .industryClass! + .name!), + ))) + .toList(), + emptyWidget: + Container( + height: 100, + decoration: box1(), + child: const Center( + child: Text( + "No result found ...")), + ), + onSuggestionTap: + (agencyCategory) { + setState(() { + selectedCategoty = + agencyCategory + .item; + agencyCategoryFocusNode + .unfocus(); + selectedAgency = Agency( + id: null, + name: + selectedAgency! + .name, + category: + selectedCategoty, + privateEntity: + null); + }); + }, + searchInputDecoration: + normalTextFieldStyle( + "Category *", + "") + .copyWith( + suffixIcon: + GestureDetector( + child: const Icon( + Icons + .arrow_drop_down, + ), + onTap: () => + agencyCategoryFocusNode + .unfocus(), + )), + validator: (value) { + if (value! + .isEmpty) { + return "This field is required"; + } + return null; + }, + ) + : const SizedBox(), + ), + const SizedBox( + height: 12, + ), + ////PRVIATE SECTOR + SizedBox( + width: screenWidth, + child: showIsPrivateRadio + ? FormBuilderSwitch( + initialValue: + isPrivate, + title: Text( + isPrivate + ? "YES" + : "NO"), + decoration: normalTextFieldStyle( - "Agency *", "") - .copyWith( - suffixIcon: - GestureDetector( - child: const Icon( - Icons.arrow_drop_down, - ), - onTap: () => - agencyFocusNode - .unfocus(), - )), - onSuggestionTap: - (agency) { + "Private Entity?", + ""), + ////onvhange private sector + onChanged: (value) { setState(() { - selectedAgency = - agency.item; - - if (selectedAgency! - .privateEntity == - null) { - showIsPrivateRadio = - true; - } else { - showIsPrivateRadio = - false; - } - + isPrivate = + value!; + selectedAgency = Agency( + id: null, + name: selectedAgency! + .name, + category: + selectedCategoty, + privateEntity: + isPrivate); agencyFocusNode .unfocus(); + agencyCategoryFocusNode + .unfocus(); }); }, - validator: (agency) { - if (agency!.isEmpty) { - return "This field is required"; - } - return null; - }, - emptyWidget: EmptyWidget( - controller: - addAgencyController, - onpressed: () { - setState(() { - Agency newAgency = Agency( - id: null, - name: addAgencyController - .text - .toUpperCase(), - category: - null, - privateEntity: - null); - state.agencies - .insert(0, - newAgency); - selectedAgency = - newAgency; - addAgencyController - .text = ""; - showAgency = true; - - showIsPrivateRadio = - true; - - Navigator.pop( - context); - }); - }, - title: "Add Agency")), - ), - - SizedBox( - height: showAgency ? 12 : 0, - ), - ////SHOW CATEGORY AGENCY - SizedBox( - child: showAgency - ? SearchField( - focusNode: - agencyCategoryFocusNode, - itemHeight: 70, - suggestions: state - .agencyCategory - .map((Category - category) => - SearchFieldListItem( - category - .name!, - item: - category, - child: - ListTile( - title: Text( - category.name!), - subtitle: Text(category - .industryClass! - .name!), - ))) - .toList(), - emptyWidget: - Container( - height: 100, - decoration: box1(), - child: const Center( - child: Text( - "No result found ...")), - ), - onSuggestionTap: - (agencyCategory) { - setState(() { - selectedCategoty = - agencyCategory - .item; - agencyCategoryFocusNode - .unfocus(); - selectedAgency = Agency( - id: null, - name: - selectedAgency! - .name, - category: - selectedCategoty, - privateEntity: - null); - }); - }, - searchInputDecoration: - normalTextFieldStyle( - "Category *", - "") - .copyWith( - suffixIcon: - GestureDetector( - child: const Icon( - Icons - .arrow_drop_down, - ), - onTap: () => - agencyCategoryFocusNode - .unfocus(), - )), - validator: (value) { - if (value! - .isEmpty) { - return "This field is required"; - } - return null; - }, - ) - : const SizedBox(), - ), - const SizedBox( - height: 12, - ), - ////PRVIATE SECTOR - SizedBox( - width: screenWidth, - child: showIsPrivateRadio - ? FormBuilderSwitch( - initialValue: - isPrivate, - title: Text( - isPrivate - ? "YES" - : "NO"), - decoration: - normalTextFieldStyle( - "Private Entity?", - ""), - ////onvhange private sector - onChanged: (value) { - setState(() { - isPrivate = - value!; - selectedAgency = Agency( - id: null, - name: selectedAgency! - .name, - category: - selectedCategoty, - privateEntity: - isPrivate); - agencyFocusNode - .unfocus(); - agencyCategoryFocusNode - .unfocus(); - }); - }, - - name: 'isPrivate', - validator: - FormBuilderValidators - .required(), - ) - : const SizedBox()), - ], - ); - }) - : const SizedBox(), - ), - ], - ); - }), - SizedBox( - height: otherAgency ? 8 : 0, + name: 'isPrivate', + validator: + FormBuilderValidators + .required(), + ) + : const SizedBox()), + ], + ); + }) + : const SizedBox(), ), + ], + ); + }), + SizedBox( + height: otherAgency ? 8 : 0, + ), + const SizedBox( + height: 8, + ), + //// Identification numner + FormBuilderTextField( + validator: FormBuilderValidators.required( + errorText: "This field is required"), + name: "identification_number", + decoration: normalTextFieldStyle( + "Identification Number *", ""), + ), + const SizedBox( + height: 12, + ), + StatefulBuilder(builder: (context, setState) { + return Row( + children: [ + //// Date Issued + Flexible( + flex: 1, + child: DateTimePicker( + type: DateTimePickerType.date, + controller: dateIssuedController, + use24HourFormat: false, + icon: const Icon(Icons.date_range), + selectableDayPredicate: (date) { + if (expirationDate != null && + expirationDate! + .microsecondsSinceEpoch <= + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, + onChanged: (value) { + setState(() { + issuedDate = DateTime.parse(value); + }); + }, + initialDate: expirationDate == null + ? DateTime.now() + : expirationDate!.subtract( + const Duration(days: 1)), + firstDate: DateTime(1990), + lastDate: DateTime(2100), + timeHintText: "Date Issued", + decoration: normalTextFieldStyle( + "Date Issued *", + "Date Issued *") + .copyWith( + prefixIcon: const Icon( + Icons.date_range, + color: Colors.black87, + )), + )), const SizedBox( - height: 8, + width: 8, ), - //// Identification numner - FormBuilderTextField( - validator: FormBuilderValidators.required( - errorText: "This field is required"), - name: "identification_number", + //// Expiration Date + Flexible( + flex: 1, + child: DateTimePicker( + type: DateTimePickerType.date, + controller: expirationController, + use24HourFormat: false, + icon: const Icon(Icons.date_range), + firstDate: DateTime(1990), + lastDate: DateTime(2100), + selectableDayPredicate: (date) { + if (issuedDate != null && + issuedDate! + .microsecondsSinceEpoch >= + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, + timeHintText: "Expiration date", + decoration: normalTextFieldStyle( + "Expiration Date *", + "Expiration Date *") + .copyWith( + prefixIcon: const Icon( + Icons.date_range, + color: Colors.black87, + )), + initialDate: issuedDate == null + ? DateTime.now() + : issuedDate! + .add(const Duration(days: 1)), + onChanged: (value) { + setState(() { + expirationDate = + DateTime.parse(value); + }); + }, + )), + ], + ); + }), + const SizedBox( + height: 12, + ), + //// as pdf reference + StatefulBuilder(builder: (context, setState) { + return FormBuilderSwitch( + initialValue: asPdfReference, + activeColor: second, + onChanged: (value) { + setState(() { + asPdfReference = value!; + }); + }, + decoration: normalTextFieldStyle( + "As PDF Reference?", ''), + name: 'pdf_reference', + title: Text(asPdfReference ? "YES" : "NO"), + ); + }), + const SizedBox( + height: 12, + ), + //// OVERSEAS + //// OVERSEAS + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, decoration: normalTextFieldStyle( - "Identification Number *", ""), + "Overseas Address?", ''), + name: 'overseas', + title: Text(overseas ? "YES" : "NO"), ), - const SizedBox( - height: 12, + SizedBox( + height: overseas == true ? 8 : 0, ), - StatefulBuilder(builder: (context, setState) { - return Row( - children: [ - //// Date Issued - Flexible( - flex: 1, - child: DateTimePicker( - type: DateTimePickerType.date, - controller: dateIssuedController, - use24HourFormat: false, - icon: const Icon(Icons.date_range), - selectableDayPredicate: (date) { - if (expirationDate != null && - expirationDate! - .microsecondsSinceEpoch <= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - issuedDate = DateTime.parse(value); - }); - }, - initialDate: expirationDate == null - ? DateTime.now() - : expirationDate!.subtract( - const Duration(days: 1)), - firstDate: DateTime(1990), - lastDate: DateTime(2100), - timeHintText: "Date Issued", - decoration: normalTextFieldStyle( - "Date Issued *", - "Date Issued *") - .copyWith( - prefixIcon: const Icon( - Icons.date_range, - color: Colors.black87, - )), - )), - const SizedBox( - width: 8, - ), - //// Expiration Date - Flexible( - flex: 1, - child: DateTimePicker( - type: DateTimePickerType.date, - controller: expirationController, - use24HourFormat: false, - icon: const Icon(Icons.date_range), - firstDate: DateTime(1990), - lastDate: DateTime(2100), - selectableDayPredicate: (date) { - if (issuedDate != null && - issuedDate! - .microsecondsSinceEpoch >= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - timeHintText: "Expiration date", - decoration: normalTextFieldStyle( - "Expiration Date *", - "Expiration Date *") - .copyWith( - prefixIcon: const Icon( - Icons.date_range, - color: Colors.black87, - )), - initialDate: issuedDate == null - ? DateTime.now() - : issuedDate! - .add(const Duration(days: 1)), - onChanged: (value) { - setState(() { - expirationDate = - DateTime.parse(value); - }); - }, - )), - ], - ); - }), - const SizedBox( - height: 12, - ), - //// as pdf reference - StatefulBuilder(builder: (context, setState) { - return FormBuilderSwitch( - initialValue: asPdfReference, - activeColor: second, - onChanged: (value) { - setState(() { - asPdfReference = value!; - }); - }, - decoration: normalTextFieldStyle( - "As PDF Reference?", ''), - name: 'pdf_reference', - title: Text(asPdfReference ? "YES" : "NO"), - ); - }), - const SizedBox( - height: 12, - ), - //// OVERSEAS - //// OVERSEAS - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - FormBuilderSwitch( - initialValue: overseas, - activeColor: second, - onChanged: (value) { - setState(() { - overseas = value!; - }); - }, - decoration: normalTextFieldStyle( - "Overseas Address?", ''), - name: 'overseas', - title: Text(overseas ? "YES" : "NO"), - ), - SizedBox( - height: overseas == true ? 8 : 0, - ), - SizedBox( - child: overseas == false - ? Column( - children: [ - const SizedBox( - height: 12, - ), - ////REGION DROPDOWN - DropdownButtonFormField( - isExpanded: true, + SizedBox( + child: overseas == false + ? Column( + children: [ + const SizedBox( + height: 12, + ), + ////REGION DROPDOWN + DropdownButtonFormField( + isExpanded: true, + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + onChanged: + (Region? region) async { + if (selectedRegion != + region) { + setState(() { + provinceCall = true; + }); + selectedRegion = region; + try { + provinces = await LocationUtils + .instance + .getProvinces( + regionCode: + selectedRegion! + .code + .toString()); + selectedProvince = + provinces![0]; + setState(() { + provinceCall = false; + cityCall = true; + }); + try { + citymuns = await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code + .toString()); + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = false; + }); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + IdentificationBloc>() + .add(ShowErrorState( + message: e + .toString())); + } + } catch (e) { + context + .read< + IdentificationBloc>() + .add(ShowErrorState( + message: e + .toString())); + } + } + }, + value: selectedRegion, + decoration: + normalTextFieldStyle( + "Region*", "Region"), + items: state.regions.map< + DropdownMenuItem< + Region>>( + (Region region) { + return DropdownMenuItem< + Region>( + value: region, + child: Text( + region.description!)); + }).toList(), + ), + const SizedBox( + height: 12, + ), + //// PROVINCE DROPDOWN + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: provinceCall, + child: DropdownButtonFormField< + Province?>( autovalidateMode: AutovalidateMode .onUserInteraction, - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - onChanged: - (Region? region) async { - if (selectedRegion != - region) { + + isExpanded: true, + value: selectedProvince, + onChanged: (Province? + province) async { + if (selectedProvince != + province) { setState(() { - provinceCall = true; + cityCall = true; }); - selectedRegion = region; + selectedProvince = + province; try { - provinces = await LocationUtils + citymuns = await LocationUtils .instance - .getProvinces( - regionCode: - selectedRegion! - .code - .toString()); - selectedProvince = - provinces![0]; + .getCities( + code: selectedProvince! + .code + .toString()); + selectedMunicipality = + citymuns![0]; setState(() { - provinceCall = false; - cityCall = true; + cityCall = false; }); - try { - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code - .toString()); - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - }); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - IdentificationBloc>() - .add(ShowErrorState( - message: e - .toString())); - } } catch (e) { context .read< @@ -658,178 +718,113 @@ class _AddIdentificationScreenState extends State { } } }, - value: selectedRegion, + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + items: provinces == null + ? [] + : provinces!.map< + DropdownMenuItem< + Province>>( + (Province + province) { + return DropdownMenuItem( + value: + province, + child: + FittedBox( + child: Text( + province + .description!), + )); + }).toList(), decoration: normalTextFieldStyle( - "Region*", "Region"), - items: state.regions.map< - DropdownMenuItem< - Region>>( - (Region region) { - return DropdownMenuItem< - Region>( - value: region, - child: Text( - region.description!)); - }).toList(), - ), - const SizedBox( - height: 12, - ), - //// PROVINCE DROPDOWN - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - - isExpanded: true, - value: selectedProvince, - onChanged: (Province? - province) async { - if (selectedProvince != - province) { - setState(() { - cityCall = true; - }); - selectedProvince = - province; - try { - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code - .toString()); - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - }); - } catch (e) { - context - .read< - IdentificationBloc>() - .add(ShowErrorState( - message: e - .toString())); - } - } - }, - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - items: provinces == null - ? [] - : provinces!.map< - DropdownMenuItem< - Province>>( - (Province - province) { - return DropdownMenuItem( - value: - province, - child: - FittedBox( - child: Text( - province - .description!), - )); - }).toList(), - decoration: - normalTextFieldStyle( - "Province*", - "Province")), - ), - ), - ////CITY MUNICIPALITY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: cityCall, - child: - DropdownButtonFormField< - CityMunicipality>( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - isExpanded: true, - onChanged: - (CityMunicipality? - city) { - if (selectedMunicipality != - city) { - selectedMunicipality = - city; - } - }, - decoration: - normalTextFieldStyle( - "Municipality*", - "Municipality"), - value: selectedMunicipality, - items: citymuns == null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality - c) { - return DropdownMenuItem( - value: c, - child: Text(c - .description!)); - }).toList(), - ), - ), - ), - ], - ) - //// COUNTRY DROPDOWN - : SizedBox( - height: 60, - child: DropdownButtonFormField< - Country>( - isExpanded: true, + "Province*", + "Province")), + ), + ), + ////CITY MUNICIPALITY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: cityCall, + child: + DropdownButtonFormField< + CityMunicipality>( validator: FormBuilderValidators .required( errorText: "This field is required"), - items: state.countries.map< - DropdownMenuItem< - Country>>( - (Country country) { - return DropdownMenuItem< - Country>( - value: country, - child: FittedBox( - child: Text( - country.name!))); - }).toList(), - value: selectedCountry, - decoration: normalTextFieldStyle( - "Country*", "Country"), - onChanged: (Country? value) { - selectedCountry = value; + isExpanded: true, + onChanged: + (CityMunicipality? + city) { + if (selectedMunicipality != + city) { + selectedMunicipality = + city; + } }, + decoration: + normalTextFieldStyle( + "Municipality*", + "Municipality"), + value: selectedMunicipality, + items: citymuns == null + ? [] + : citymuns!.map< + DropdownMenuItem< + CityMunicipality>>( + (CityMunicipality + c) { + return DropdownMenuItem( + value: c, + child: Text(c + .description!)); + }).toList(), ), ), - ), - ], - ); - }), + ), + ], + ) + //// COUNTRY DROPDOWN + : SizedBox( + height: 60, + child: DropdownButtonFormField< + Country>( + isExpanded: true, + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + items: state.countries.map< + DropdownMenuItem< + Country>>( + (Country country) { + return DropdownMenuItem< + Country>( + value: country, + child: FittedBox( + child: Text( + country.name!))); + }).toList(), + value: selectedCountry, + decoration: normalTextFieldStyle( + "Country*", "Country"), + onChanged: (Country? value) { + selectedCountry = value; + }, + ), + ), + ), ], - ), - ), - SizedBox( + ); + }), + const SizedBox(height: 8,), + SizedBox( width: double.infinity, height: 60, child: ElevatedButton( @@ -895,9 +890,8 @@ class _AddIdentificationScreenState extends State { }, child: const Text(submit)), ), - const SizedBox( - height: 24, - ), + + ], ), )), diff --git a/lib/screens/profile/components/basic_information/identification/edit_modal.dart b/lib/screens/profile/components/basic_information/identification/edit_modal.dart index 626458a..5a7d0b7 100644 --- a/lib/screens/profile/components/basic_information/identification/edit_modal.dart +++ b/lib/screens/profile/components/basic_information/identification/edit_modal.dart @@ -87,381 +87,375 @@ class _EditIdentificationScreenState extends State { key: formKey, child: SizedBox( height: screenHeight * 90, - child: Column( + child: ListView( children: [ - Flexible( - child: ListView( - children: [ - FormBuilderTextField( - initialValue: state.identification.agency!.name, - enabled: false, - name: "", - decoration: normalTextFieldStyle("", "").copyWith( - filled: true, fillColor: Colors.black12), - ), - SizedBox( - height: otherAgency ? 8 : 0, - ), - - const SizedBox( - height: 12, - ), - //// Identification numner - FormBuilderTextField( - initialValue: - state.identification.identificationNumber, - validator: FormBuilderValidators.required( - errorText: "This field is required"), - name: "identification_number", - decoration: normalTextFieldStyle( - "Identification Number *", ""), - ), - const SizedBox( - height: 12, - ), - StatefulBuilder( - builder: (context,setState) { - return Row( - children: [ - //// Date Issued - Flexible( - flex: 1, - child: DateTimePicker( - controller: dateIssuedController, - use24HourFormat: false, - icon: const Icon(Icons.date_range), - firstDate: DateTime(1990), - lastDate: DateTime(2100), - timeHintText: "Date Issued", - decoration: normalTextFieldStyle( - "Date Issued ", "Date Issued *") - .copyWith( - prefixIcon: const Icon( - Icons.date_range, - color: Colors.black87, - )), - onChanged: (value){ - setState((){ - issuedDate = value; - }); - }, - selectableDayPredicate: (date) { - if ((expDate != "null" && expDate != null) && - DateTime.tryParse(expDate!)! - .microsecondsSinceEpoch <= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - initialDate: expDate == "null" || expDate == null - ? DateTime.now() - : DateTime.tryParse(expDate!)?.subtract( - const Duration(days: 1)), - )), - - const SizedBox( - width: 12, - ), - //// Expiration Date - Flexible( - flex: 1, - child: DateTimePicker( - controller: expirationController, - use24HourFormat: false, - icon: const Icon(Icons.date_range), - firstDate: DateTime(1990), - lastDate: DateTime(2100), - timeHintText: "Expiration date", - onChanged: (value){ - setState((){ - expDate = value; - }); - }, - decoration: normalTextFieldStyle( - "Expiration Date", - "Expiration Date") - .copyWith( - prefixIcon: const Icon( - Icons.date_range, - color: Colors.black87, - )), - selectableDayPredicate: (date) { - if ((issuedDate != "null" && issuedDate != null) && - DateTime.tryParse(issuedDate!)! - .microsecondsSinceEpoch >= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - initialDate: issuedDate == null && issuedDate == "null" - ? DateTime.now() - : DateTime.tryParse(issuedDate!)?.add( - const Duration(days: 1)), - )), - ], - ); - } - ), - const SizedBox( - height: 12, - ), - - //// OVERSEAS - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - FormBuilderSwitch( - initialValue: overseas, - activeColor: second, - onChanged: (value) { - setState(() { - overseas = value!; + FormBuilderTextField( + initialValue: state.identification.agency!.name, + enabled: false, + name: "", + decoration: normalTextFieldStyle("", "").copyWith( + filled: true, fillColor: Colors.black12), + ), + SizedBox( + height: otherAgency ? 8 : 0, + ), + + const SizedBox( + height: 12, + ), + //// Identification numner + FormBuilderTextField( + initialValue: + state.identification.identificationNumber, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + name: "identification_number", + decoration: normalTextFieldStyle( + "Identification Number *", ""), + ), + const SizedBox( + height: 12, + ), + StatefulBuilder( + builder: (context,setState) { + return Row( + children: [ + //// Date Issued + Flexible( + flex: 1, + child: DateTimePicker( + controller: dateIssuedController, + use24HourFormat: false, + icon: const Icon(Icons.date_range), + firstDate: DateTime(1990), + lastDate: DateTime(2100), + timeHintText: "Date Issued", + decoration: normalTextFieldStyle( + "Date Issued ", "Date Issued *") + .copyWith( + prefixIcon: const Icon( + Icons.date_range, + color: Colors.black87, + )), + onChanged: (value){ + setState((){ + issuedDate = value; + }); + }, + selectableDayPredicate: (date) { + if ((expDate != "null" && expDate != null) && + DateTime.tryParse(expDate!)! + .microsecondsSinceEpoch <= + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, + initialDate: expDate == "null" || expDate == null + ? DateTime.now() + : DateTime.tryParse(expDate!)?.subtract( + const Duration(days: 1)), + )), + + const SizedBox( + width: 12, + ), + //// Expiration Date + Flexible( + flex: 1, + child: DateTimePicker( + controller: expirationController, + use24HourFormat: false, + icon: const Icon(Icons.date_range), + firstDate: DateTime(1990), + lastDate: DateTime(2100), + timeHintText: "Expiration date", + onChanged: (value){ + setState((){ + expDate = value; }); }, decoration: normalTextFieldStyle( - "Overseas Address?", ''), - name: 'overseas', - title: Text(overseas ? "YES" : "NO"), - ), - SizedBox( - height: overseas == true ? 12 : 0, - ), - SizedBox( - child: overseas == false - ? Column( - children: [ - const SizedBox( - height: 12, - ), - ////REGION DROPDOWN - DropdownButtonFormField( + "Expiration Date", + "Expiration Date") + .copyWith( + prefixIcon: const Icon( + Icons.date_range, + color: Colors.black87, + )), + selectableDayPredicate: (date) { + if ((issuedDate != "null" && issuedDate != null) && + DateTime.tryParse(issuedDate!)! + .microsecondsSinceEpoch >= + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, + initialDate: issuedDate == null && issuedDate == "null" + ? DateTime.now() + : DateTime.tryParse(issuedDate!)?.add( + const Duration(days: 1)), + )), + ], + ); + } + ), + const SizedBox( + height: 12, + ), + + //// OVERSEAS + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, + decoration: normalTextFieldStyle( + "Overseas Address?", ''), + name: 'overseas', + title: Text(overseas ? "YES" : "NO"), + ), + SizedBox( + height: overseas == true ? 12 : 0, + ), + SizedBox( + child: overseas == false + ? Column( + children: [ + const SizedBox( + height: 12, + ), + ////REGION DROPDOWN + DropdownButtonFormField( + isExpanded: true, + autovalidateMode: AutovalidateMode + .onUserInteraction, + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + onChanged: + (Region? region) async { + if (selectedRegion != region) { + setState(() { + provinceCall = true; + }); + selectedRegion = region; + try { + provinces = await LocationUtils + .instance + .getProvinces( + regionCode: + selectedRegion! + .code + .toString()); + } catch (e) { + context + .read< + IdentificationBloc>() + .add(ShowErrorState( + message: + e.toString())); + } + selectedProvince = + provinces![0]; + setState(() { + provinceCall = false; + cityCall = true; + }); + try { + citymuns = await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code + .toString()); + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = false; + }); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + IdentificationBloc>() + .add(ShowErrorState( + message: e + .toString())); + } + + } + }, + value: selectedRegion, + decoration: normalTextFieldStyle( + "Region*", "Region"), + items: state.regions.map< + DropdownMenuItem>( + (Region region) { + return DropdownMenuItem( + value: region, + child: Text( + region.description!)); + }).toList(), + ), + const SizedBox( + height: 12, + ), + //// PROVINCE DROPDOWN + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: provinceCall, + child: DropdownButtonFormField< + Province?>( + value: selectedProvince, + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: (value) => + value == null + ? 'required' + : null, isExpanded: true, - autovalidateMode: AutovalidateMode - .onUserInteraction, - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - onChanged: - (Region? region) async { - if (selectedRegion != region) { + onChanged: (Province? + province) async { + if (selectedProvince != + province) { setState(() { - provinceCall = true; + cityCall = true; }); - selectedRegion = region; + selectedProvince = + province; try { - provinces = await LocationUtils + citymuns = await LocationUtils .instance - .getProvinces( - regionCode: - selectedRegion! - .code - .toString()); - } catch (e) { + .getCities( + code: selectedProvince! + .code + .toString()); + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = false; + }); + } catch (e) { context .read< IdentificationBloc>() .add(ShowErrorState( - message: - e.toString())); + message: e + .toString())); } - selectedProvince = - provinces![0]; - setState(() { - provinceCall = false; - cityCall = true; - }); - try { - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code - .toString()); - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - }); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - IdentificationBloc>() - .add(ShowErrorState( - message: e - .toString())); - } - } }, - value: selectedRegion, - decoration: normalTextFieldStyle( - "Region*", "Region"), - items: state.regions.map< - DropdownMenuItem>( - (Region region) { - return DropdownMenuItem( - value: region, - child: Text( - region.description!)); - }).toList(), - ), - const SizedBox( - height: 12, - ), - //// PROVINCE DROPDOWN - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - value: selectedProvince, - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: (value) => - value == null - ? 'required' - : null, - isExpanded: true, - onChanged: (Province? - province) async { - if (selectedProvince != + items: provinces == null + ? [] + : provinces!.map< + DropdownMenuItem< + Province>>( + (Province province) { - setState(() { - cityCall = true; - }); - selectedProvince = - province; - try { - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code - .toString()); - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - }); - } catch (e) { - context - .read< - IdentificationBloc>() - .add(ShowErrorState( - message: e - .toString())); - } - } - }, - items: provinces == null - ? [] - : provinces!.map< - DropdownMenuItem< - Province>>( - (Province - province) { - return DropdownMenuItem( - value: province, - child: - FittedBox( - child: Text( - province - .description!), - )); - }).toList(), - decoration: - normalTextFieldStyle( - "Province *", - "Province")), - ), - ), - ////CITY MUNICIPALITY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: cityCall, - child: DropdownButtonFormField< - CityMunicipality>( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - isExpanded: true, - onChanged: - (CityMunicipality? city) { - if (selectedMunicipality != - city) { - selectedMunicipality = - city; - } - }, - decoration: - normalTextFieldStyle( - "Municipality *", - "Municipality"), - value: selectedMunicipality, - items: citymuns == null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality c) { - return DropdownMenuItem( - value: c, - child: Text(c - .description!)); - }).toList(), - ), - ), - ), - ], - ) - //// COUNTRY DROPDOWN - : SizedBox( - height: 60, - child: - DropdownButtonFormField( - isExpanded: true, - validator: - FormBuilderValidators.required( + return DropdownMenuItem( + value: province, + child: + FittedBox( + child: Text( + province + .description!), + )); + }).toList(), + decoration: + normalTextFieldStyle( + "Province *", + "Province")), + ), + ), + ////CITY MUNICIPALITY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: cityCall, + child: DropdownButtonFormField< + CityMunicipality>( + validator: FormBuilderValidators + .required( errorText: "This field is required"), - items: state.countries - .map>( - (Country country) { - return DropdownMenuItem( - value: country, - child: FittedBox( - child: - Text(country.name!))); - }).toList(), - value: selectedCountry?.id==175?null:selectedCountry, - decoration: normalTextFieldStyle( - "Country *", "Country"), - onChanged: (Country? value) { - selectedCountry = value; + isExpanded: true, + onChanged: + (CityMunicipality? city) { + if (selectedMunicipality != + city) { + selectedMunicipality = + city; + } }, + decoration: + normalTextFieldStyle( + "Municipality *", + "Municipality"), + value: selectedMunicipality, + items: citymuns == null + ? [] + : citymuns!.map< + DropdownMenuItem< + CityMunicipality>>( + (CityMunicipality c) { + return DropdownMenuItem( + value: c, + child: Text(c + .description!)); + }).toList(), ), ), - ), - ], - ); - }), - - + ), + ], + ) + //// COUNTRY DROPDOWN + : SizedBox( + height: 60, + child: + DropdownButtonFormField( + isExpanded: true, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + items: state.countries + .map>( + (Country country) { + return DropdownMenuItem( + value: country, + child: FittedBox( + child: + Text(country.name!))); + }).toList(), + value: selectedCountry?.id==175?null:selectedCountry, + decoration: normalTextFieldStyle( + "Country *", "Country"), + onChanged: (Country? value) { + selectedCountry = value; + }, + ), + ), + ), ], - ), - ), - SizedBox( + ); + }), + + const SizedBox(height: 8,), + SizedBox( width: double.infinity, height: 60, child: ElevatedButton( @@ -522,7 +516,6 @@ class _EditIdentificationScreenState extends State { }, child: const Text(submit)), ), - const SizedBox(height: 24,), ], ), )), diff --git a/lib/screens/profile/components/basic_information/identification_information_screen.dart b/lib/screens/profile/components/basic_information/identification_information_screen.dart index 4fc6104..eedd08d 100644 --- a/lib/screens/profile/components/basic_information/identification_information_screen.dart +++ b/lib/screens/profile/components/basic_information/identification_information_screen.dart @@ -3,20 +3,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; -import 'package:fluttericon/font_awesome_icons.dart'; import 'package:unit2/bloc/profile/primary_information/identification/identification_bloc.dart'; import 'package:unit2/bloc/profile/profile_bloc.dart'; -import 'package:unit2/model/profile/basic_information/identification_information.dart'; import 'package:unit2/screens/profile/components/basic_information/identification/add_modal.dart'; import 'package:unit2/screens/profile/components/basic_information/identification/edit_modal.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; -import 'package:unit2/utils/global.dart'; import 'package:unit2/utils/text_container.dart'; import 'package:unit2/widgets/Leadings/add_leading.dart'; import 'package:unit2/widgets/empty_data.dart'; import 'package:unit2/widgets/error_state.dart'; - import '../../../../bloc/user/user_bloc.dart'; import '../../../../utils/alerts.dart'; import '../../../../widgets/Leadings/close_leading.dart'; @@ -29,7 +25,7 @@ class IdentificationsScreen extends StatelessWidget { String? token; int? profileId; return Scaffold( - resizeToAvoidBottomInset: false, + resizeToAvoidBottomInset: true, appBar: AppBar( title: context.watch().state is IdentificationAddingState ? const Text("Add Identification"):context.watch().state is IdentificationEditingState?const Text("Edit Identification"):const Text("Identifications"), diff --git a/lib/screens/profile/components/education/add_modal.dart b/lib/screens/profile/components/education/add_modal.dart index 1e6b8dc..163f8fb 100644 --- a/lib/screens/profile/components/education/add_modal.dart +++ b/lib/screens/profile/components/education/add_modal.dart @@ -88,379 +88,369 @@ class _AddEducationScreenState extends State { child: FormBuilder( key: formKey, child: SizedBox( - height: blockSizeVertical * 85, - child: Column( - children: [ - Flexible( - child: ListView(children: [ - //// LEVEL + child: ListView(children: [ + //// LEVEL + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + FormBuilderDropdown( + validator: FormBuilderValidators.required( + errorText: "This field is required"), + decoration: + normalTextFieldStyle("level*", "level"), + name: "education_level", + onChanged: (EducationLevel? level) { + setState(() { + selectedLevel = level; + }); + }, + items: educationLevel + .map>( + (EducationLevel level) { + return level.type == "label" + ? DropdownMenuItem( + enabled: false, + value: level, + child: Text(level.value.toUpperCase(), + style: const TextStyle( + color: Colors.black38))) + : DropdownMenuItem( + value: level, + enabled: true, + child: Text( + " ${level.value.toUpperCase()}")); + }).toList()), + const SizedBox( + height: 12, + ), + ////school StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - FormBuilderDropdown( - validator: FormBuilderValidators.required( - errorText: "This field is required"), - decoration: - normalTextFieldStyle("level*", "level"), - name: "education_level", - onChanged: (EducationLevel? level) { - setState(() { - selectedLevel = level; - }); - }, - items: educationLevel - .map>( - (EducationLevel level) { - return level.type == "label" - ? DropdownMenuItem( - enabled: false, - value: level, - child: Text(level.value.toUpperCase(), - style: const TextStyle( - color: Colors.black38))) - : DropdownMenuItem( - value: level, - enabled: true, - child: Text( - " ${level.value.toUpperCase()}")); - }).toList()), - const SizedBox( - height: 12, - ), - ////school - StatefulBuilder(builder: (context, setState) { - return SearchField( - inputFormatters: [UpperCaseTextFormatter()], - itemHeight: 70, - suggestionsDecoration: box1(), - suggestions: state.schools - .map((School school) => - SearchFieldListItem(school.name!, - item: school, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10), - child: ListTile( - title: Text(school.name!,overflow: TextOverflow.visible,)), - ))) - .toList(), - validator: (agency) { - if (agency!.isEmpty) { - return "This field is required"; - } - return null; - }, - focusNode: schoolFocusNode, - searchInputDecoration: - normalTextFieldStyle("School *", "").copyWith( - suffixIcon: IconButton( - icon: const Icon(Icons.arrow_drop_down), - onPressed: () { - schoolFocusNode.unfocus(); - }, - )), - onSuggestionTap: (school) { - setState(() { - selectedSchool = school.item; - schoolFocusNode.unfocus(); - }); - }, - emptyWidget: EmptyWidget( - title: "Add School", - controller: addSchoolController, - onpressed: () { - setState(() { - School newSchool = School( - id: null, - name: addSchoolController.text - .toUpperCase()); - state.schools.insert(0, newSchool); - addSchoolController.text = ""; - - Navigator.pop(context); - }); - }), - ); - }), - const SizedBox( - height: 12, - ), - ////Programs - Container( - child: selectedLevel != null && - selectedLevel!.group != 1 - ? SearchField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - itemHeight: 100, - suggestionsDecoration: box1(), - suggestions: state.programs - .map((Course program) => - SearchFieldListItem( - program.program!, - item: program, - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10), - child: ListTile( - title: Text( - program.program!,overflow: TextOverflow.visible,)), - ))) - .toList(), - validator: (agency) { - if (agency!.isEmpty) { - return "This field is required"; - } - return null; - }, - focusNode: programFocusNode, - searchInputDecoration: - normalTextFieldStyle( - "Course/Programs *", "") - .copyWith( - suffixIcon: GestureDetector( - onTap: () => programFocusNode.unfocus(), - child: const Icon( - Icons.arrow_drop_down), - )), - onSuggestionTap: (position) { - setState(() { - selectedProgram = position.item; - programFocusNode.unfocus(); - }); - }, - emptyWidget: EmptyWidget( - title: "Add Program", - controller: addProgramController, - onpressed: () { - setState(() { - Course newProgram = Course( - id: null, - program: addProgramController - .text - .toUpperCase()); - state.programs - .insert(0, newProgram); - addProgramController.text = ""; - - Navigator.pop(context); - }); - }), - ) - : Container()) - ], + return SearchField( + inputFormatters: [UpperCaseTextFormatter()], + itemHeight: 70, + suggestionsDecoration: box1(), + suggestions: state.schools + .map((School school) => + SearchFieldListItem(school.name!, + item: school, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10), + child: ListTile( + title: Text(school.name!,overflow: TextOverflow.visible,)), + ))) + .toList(), + validator: (agency) { + if (agency!.isEmpty) { + return "This field is required"; + } + return null; + }, + focusNode: schoolFocusNode, + searchInputDecoration: + normalTextFieldStyle("School *", "").copyWith( + suffixIcon: IconButton( + icon: const Icon(Icons.arrow_drop_down), + onPressed: () { + schoolFocusNode.unfocus(); + }, + )), + onSuggestionTap: (school) { + setState(() { + selectedSchool = school.item; + schoolFocusNode.unfocus(); + }); + }, + emptyWidget: EmptyWidget( + title: "Add School", + controller: addSchoolController, + onpressed: () { + setState(() { + School newSchool = School( + id: null, + name: addSchoolController.text + .toUpperCase()); + state.schools.insert(0, newSchool); + addSchoolController.text = ""; + + Navigator.pop(context); + }); + }), ); }), const SizedBox( height: 12, ), - StatefulBuilder(builder: (context, setState) { - return Column( + ////Programs + Container( + child: selectedLevel != null && + selectedLevel!.group != 1 + ? SearchField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + itemHeight: 100, + suggestionsDecoration: box1(), + suggestions: state.programs + .map((Course program) => + SearchFieldListItem( + program.program!, + item: program, + child: Padding( + padding: const EdgeInsets + .symmetric( + horizontal: 10), + child: ListTile( + title: Text( + program.program!,overflow: TextOverflow.visible,)), + ))) + .toList(), + validator: (agency) { + if (agency!.isEmpty) { + return "This field is required"; + } + return null; + }, + focusNode: programFocusNode, + searchInputDecoration: + normalTextFieldStyle( + "Course/Programs *", "") + .copyWith( + suffixIcon: GestureDetector( + onTap: () => programFocusNode.unfocus(), + child: const Icon( + Icons.arrow_drop_down), + )), + onSuggestionTap: (position) { + setState(() { + selectedProgram = position.item; + programFocusNode.unfocus(); + }); + }, + emptyWidget: EmptyWidget( + title: "Add Program", + controller: addProgramController, + onpressed: () { + setState(() { + Course newProgram = Course( + id: null, + program: addProgramController + .text + .toUpperCase()); + state.programs + .insert(0, newProgram); + addProgramController.text = ""; + + Navigator.pop(context); + }); + }), + ) + : Container()) + ], + ); + }), + const SizedBox( + height: 12, + ), + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + //// GRADUATED SWITCH + FormBuilderSwitch( + initialValue: graduated, + activeColor: second, + onChanged: (value) { + setState(() { + graduated = value!; + if (graduated) { + unitsEarned = null; + } else { + yearGraduated.text = ""; + } + }); + }, + decoration: normalTextFieldStyle( + "Graduated?", 'Graduated?'), + name: 'graudated', + title: Text(graduated ? "YES" : "NO"), + ), + const SizedBox( + height: 12, + ), + ////FROM + SizedBox( + width: screenWidth, + child: Row( children: [ - //// GRADUATED SWITCH - FormBuilderSwitch( - initialValue: graduated, - activeColor: second, - onChanged: (value) { - setState(() { - graduated = value!; - if (graduated) { - unitsEarned = null; - } else { - yearGraduated.text = ""; - } - }); - }, - decoration: normalTextFieldStyle( - "Graduated?", 'Graduated?'), - name: 'graudated', - title: Text(graduated ? "YES" : "NO"), - ), - const SizedBox( - height: 12, - ), - ////FROM - SizedBox( - width: screenWidth, - child: Row( - children: [ - Flexible( - flex: 1, - child: FormBuilderTextField( - validator: FormBuilderValidators.required( - errorText: "This fied is required"), - decoration: - normalTextFieldStyle("from *", "from"), - name: "", - controller: fromController, - onTap: () { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - content: SizedBox( - width: 300, - height: 300, - child: YearPicker( - firstDate: DateTime( - DateTime.now().year - 100, - 1), - lastDate: DateTime( - DateTime.now().year + 100, - 1), - initialDate: DateTime.now(), - selectedDate: DateTime.now(), - onChanged: (DateTime dateTime) { - fromController.text = - dateTime.year.toString(); - Navigator.pop(context); - }, - ), - ), - ); - }, - ); - }, - ), - ), - const SizedBox( - width: 8, - ), - ////UNTIL - Flexible( - flex: 1, - child: FormBuilderTextField( - validator: FormBuilderValidators.required( - errorText: "This fied is required"), - decoration: normalTextFieldStyle( - "until *", "until"), - name: "", - controller: untilController, - onTap: () { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - content: SizedBox( - width: 300, - height: 300, - child: YearPicker( - firstDate: DateTime( - DateTime.now().year - 100, - 1), - lastDate: DateTime( - DateTime.now().year + 100, - 1), - initialDate: DateTime.now(), - selectedDate: DateTime.now(), - onChanged: (DateTime dateTime) { - untilController.text = - dateTime.year.toString(); - Navigator.pop(context); - }, - ), - ), - ); - }, - ); - }, - ), - ), - const SizedBox( - width: 8, - ), - ], + Flexible( + flex: 1, + child: FormBuilderTextField( + validator: FormBuilderValidators.required( + errorText: "This fied is required"), + decoration: + normalTextFieldStyle("from *", "from"), + name: "", + controller: fromController, + onTap: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + content: SizedBox( + width: 300, + height: 300, + child: YearPicker( + firstDate: DateTime( + DateTime.now().year - 100, + 1), + lastDate: DateTime( + DateTime.now().year + 100, + 1), + initialDate: DateTime.now(), + selectedDate: DateTime.now(), + onChanged: (DateTime dateTime) { + fromController.text = + dateTime.year.toString(); + Navigator.pop(context); + }, + ), + ), + ); + }, + ); + }, ), ), const SizedBox( - height: 12, + width: 8, ), - SizedBox( - child: graduated - ////GRADUATED YEAR - ? FormBuilderTextField( - validator: FormBuilderValidators.required( - errorText: "This fied is required"), - onTap: () { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - content: SizedBox( - width: 300, - height: 300, - child: YearPicker( - firstDate: DateTime( - DateTime.now().year - 100, - 1), - lastDate: DateTime( - DateTime.now().year + 100, - 1), - initialDate: DateTime.now(), - selectedDate: DateTime.now(), - onChanged: (DateTime dateTime) { - yearGraduated.text = - dateTime.year.toString(); - Navigator.pop(context); - }, - ), - ), - ); - }, - ); - }, - name: "year_graduated", - controller: yearGraduated, - decoration: normalTextFieldStyle( - "Year Graduated *", "Year Graduated *"), - ) - //// HIGHEST UNITS EARNED - : FormBuilderTextField( - validator: FormBuilderValidators.required( - errorText: "This fied is required"), - name: "units_earned", - decoration: normalTextFieldStyle( - "Highest Level/Units Earned *", - "Highest Level/Units Earned *")), + ////UNTIL + Flexible( + flex: 1, + child: FormBuilderTextField( + validator: FormBuilderValidators.required( + errorText: "This fied is required"), + decoration: normalTextFieldStyle( + "until *", "until"), + name: "", + controller: untilController, + onTap: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + content: SizedBox( + width: 300, + height: 300, + child: YearPicker( + firstDate: DateTime( + DateTime.now().year - 100, + 1), + lastDate: DateTime( + DateTime.now().year + 100, + 1), + initialDate: DateTime.now(), + selectedDate: DateTime.now(), + onChanged: (DateTime dateTime) { + untilController.text = + dateTime.year.toString(); + Navigator.pop(context); + }, + ), + ), + ); + }, + ); + }, + ), + ), + const SizedBox( + width: 8, ), ], - ); - }), - + ), + ), const SizedBox( height: 12, ), - //// HONORS - MultiSelectDropDown( - onOptionSelected: (List selectedOptions) { - selectedValueItem = selectedOptions; - }, - borderColor: Colors.grey, - borderWidth: 1, - borderRadius: 5, - hint: "Honors", - padding: const EdgeInsets.all(8), - options: valueItemHonorList, - selectionType: SelectionType.multi, - chipConfig: const ChipConfig(wrapType: WrapType.wrap), - dropdownHeight: 300, - optionTextStyle: const TextStyle(fontSize: 16), - selectedOptionIcon: const Icon(Icons.check_circle), + SizedBox( + child: graduated + ////GRADUATED YEAR + ? FormBuilderTextField( + validator: FormBuilderValidators.required( + errorText: "This fied is required"), + onTap: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + content: SizedBox( + width: 300, + height: 300, + child: YearPicker( + firstDate: DateTime( + DateTime.now().year - 100, + 1), + lastDate: DateTime( + DateTime.now().year + 100, + 1), + initialDate: DateTime.now(), + selectedDate: DateTime.now(), + onChanged: (DateTime dateTime) { + yearGraduated.text = + dateTime.year.toString(); + Navigator.pop(context); + }, + ), + ), + ); + }, + ); + }, + name: "year_graduated", + controller: yearGraduated, + decoration: normalTextFieldStyle( + "Year Graduated *", "Year Graduated *"), + ) + //// HIGHEST UNITS EARNED + : FormBuilderTextField( + validator: FormBuilderValidators.required( + errorText: "This fied is required"), + name: "units_earned", + decoration: normalTextFieldStyle( + "Highest Level/Units Earned *", + "Highest Level/Units Earned *")), ), - const SizedBox( - height: 25, - ), - ////sumit button - - - const SizedBox( - height: 20, - ), - ]), - ), - SizedBox( + ], + ); + }), + + const SizedBox( + height: 12, + ), + //// HONORS + MultiSelectDropDown( + onOptionSelected: (List selectedOptions) { + selectedValueItem = selectedOptions; + }, + borderColor: Colors.grey, + borderWidth: 1, + borderRadius: 5, + hint: "Honors", + padding: const EdgeInsets.all(8), + options: valueItemHonorList, + selectionType: SelectionType.multi, + chipConfig: const ChipConfig(wrapType: WrapType.wrap), + dropdownHeight: 300, + optionTextStyle: const TextStyle(fontSize: 16), + selectedOptionIcon: const Icon(Icons.check_circle), + ), + const SizedBox( + height: 25, + ), + ////sumit button + + SizedBox( width: double.infinity, height: 60, child: ElevatedButton( @@ -520,9 +510,8 @@ class _AddEducationScreenState extends State { child: const Text(submit)), ), - - ], - ), + + ]), ), ), ); diff --git a/lib/screens/profile/components/education/edit_modal.dart b/lib/screens/profile/components/education/edit_modal.dart index 44812cd..e5676be 100644 --- a/lib/screens/profile/components/education/edit_modal.dart +++ b/lib/screens/profile/components/education/edit_modal.dart @@ -115,403 +115,398 @@ class _EditEducationScreenState extends State { key: formKey, child: SizedBox( height: blockSizeVertical * 85, - child: Column( - children: [ - Flexible( - child: ListView(children: [ - - //// LEVEL + child: ListView(children: [ + + //// LEVEL + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + FormBuilderDropdown( + initialValue: selectedLevel, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + decoration: + normalTextFieldStyle("level*", "level"), + name: "education_level", + onChanged: (EducationLevel? level) { + setState(() { + selectedLevel = level; + }); + }, + items: educationLevel + .map>( + (EducationLevel level) { + return level.type == "label" + ? DropdownMenuItem( + enabled: false, + value: level, + child: Text(level.value.toUpperCase(), + style: const TextStyle( + color: Colors.black38))) + : DropdownMenuItem( + value: level, + enabled: true, + child: Text( + " ${level.value.toUpperCase()}")); + }).toList()), + const SizedBox( + height: 12, + ), + ////school StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - FormBuilderDropdown( - initialValue: selectedLevel, - validator: FormBuilderValidators.required( - errorText: "This field is required"), - decoration: - normalTextFieldStyle("level*", "level"), - name: "education_level", - onChanged: (EducationLevel? level) { - setState(() { - selectedLevel = level; - }); - }, - items: educationLevel - .map>( - (EducationLevel level) { - return level.type == "label" - ? DropdownMenuItem( - enabled: false, - value: level, - child: Text(level.value.toUpperCase(), - style: const TextStyle( - color: Colors.black38))) - : DropdownMenuItem( - value: level, - enabled: true, - child: Text( - " ${level.value.toUpperCase()}")); - }).toList()), - const SizedBox( - height: 12, - ), - ////school - StatefulBuilder(builder: (context, setState) { - return SearchField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - - suggestionAction: SuggestionAction.next, - onSubmit: (p0) { - schoolFocusNode.unfocus(); - }, - controller: currentSchoolController, - itemHeight: 70, - suggestionsDecoration: box1(), - suggestions: state.schools - .map((School school) => - SearchFieldListItem(school.name!, - item: school, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10), - child: ListTile( - title: Text(school.name!,overflow: TextOverflow.visible,)), - ))) - .toList(), - validator: (agency) { - if (agency!.isEmpty) { - return "This field is required"; - } - return null; - }, - focusNode: schoolFocusNode, - searchInputDecoration: - normalTextFieldStyle("School *", "").copyWith( - suffixIcon: GestureDetector( - child: const Icon(Icons.arrow_drop_down), - onTap: () { - schoolFocusNode.unfocus(); - }, - )), - onSuggestionTap: (school) { - setState(() { - selectedSchool = school.item; - schoolFocusNode.unfocus(); - }); - }, - emptyWidget: EmptyWidget( - title: "Add School", - controller: addSchoolController, - onpressed: () { - setState(() { - School newSchool = School( - id: null, - name: addSchoolController.text - .toUpperCase()); - state.schools.insert(0, newSchool); - addSchoolController.text = ""; - - Navigator.pop(context); - }); - }), - ); - }), - const SizedBox( - height: 12, - ), - - ////Programs - - Container( - child: selectedLevel != null && - selectedLevel!.group != 1 - ? SearchField( - inputFormatters: [UpperCaseTextFormatter()], - suggestionAction: - SuggestionAction.unfocus, - controller: currentProgramController, - itemHeight: 70, - suggestionsDecoration: box1(), - suggestions: state.programs - .map((Course program) => - SearchFieldListItem( - program.program!, - item: program, - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10), - child: ListTile( - title: Text( - program.program!,overflow: TextOverflow.visible,)), - ))) - .toList(), - validator: (agency) { - if (agency!.isEmpty) { - return "This field is required"; - } - return null; - }, - focusNode: programFocusNode, - searchInputDecoration: - normalTextFieldStyle( - "Course/Programs *", "") - .copyWith( - suffixIcon: IconButton( - icon:const Icon( - Icons.arrow_drop_down), onPressed: () { programFocusNode.unfocus(); },),), - onSuggestionTap: (position) { - setState(() { - selectedProgram = position.item; - programFocusNode.unfocus(); - }); - }, - emptyWidget: EmptyWidget( - title: "Add Program", - controller: addProgramController, - onpressed: () { - setState(() { - Course newProgram = Course( - id: null, - program: addProgramController - .text - .toUpperCase()); - state.programs - .insert(0, newProgram); - addProgramController.text = ""; - - Navigator.pop(context); - }); - }), - ) - : Container()), - SizedBox(height: selectedLevel != null && - selectedLevel!.group != 1?12:0,), - ], - ); - }), - - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - //// GRADUATED SWITCH - FormBuilderSwitch( - initialValue: graduated, - activeColor: second, - onChanged: (value) { + return SearchField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + + suggestionAction: SuggestionAction.next, + onSubmit: (p0) { + schoolFocusNode.unfocus(); + }, + controller: currentSchoolController, + itemHeight: 70, + suggestionsDecoration: box1(), + suggestions: state.schools + .map((School school) => + SearchFieldListItem(school.name!, + item: school, + child: Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10), + child: ListTile( + title: Text(school.name!,overflow: TextOverflow.visible,)), + ))) + .toList(), + validator: (agency) { + if (agency!.isEmpty) { + return "This field is required"; + } + return null; + }, + focusNode: schoolFocusNode, + searchInputDecoration: + normalTextFieldStyle("School *", "").copyWith( + suffixIcon: GestureDetector( + child: const Icon(Icons.arrow_drop_down), + onTap: () { + schoolFocusNode.unfocus(); + }, + )), + onSuggestionTap: (school) { + setState(() { + selectedSchool = school.item; + schoolFocusNode.unfocus(); + }); + }, + emptyWidget: EmptyWidget( + title: "Add School", + controller: addSchoolController, + onpressed: () { setState(() { - graduated = value!; - if (graduated) { - unitsController.text = ""; - } else { - yearGraduated.text = ""; - } + School newSchool = School( + id: null, + name: addSchoolController.text + .toUpperCase()); + state.schools.insert(0, newSchool); + addSchoolController.text = ""; + + Navigator.pop(context); }); - }, - decoration: normalTextFieldStyle( - "Graduated?", 'Graduated?'), - name: 'graudated', - title: Text(graduated ? "YES" : "NO"), - ), - const SizedBox( - height: 12, - ), - ////FROM - SizedBox( - width: screenWidth, - child: Row( - children: [ - Flexible( - flex: 1, - child: FormBuilderTextField( - validator: FormBuilderValidators.required( - errorText: "This fied is required"), - decoration: - normalTextFieldStyle("from *", "from"), - name: "", - controller: fromController, - onTap: () { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - content: SizedBox( - width: 300, - height: 300, - child: YearPicker( - firstDate: DateTime( - DateTime.now().year - 100, - 1), - lastDate: DateTime( - DateTime.now().year + 100, - 1), - initialDate: DateTime.now(), - selectedDate: DateTime.now(), - onChanged: (DateTime dateTime) { - fromController.text = - dateTime.year.toString(); - Navigator.pop(context); - }, - ), - ), - ); - }, - ); - }, - ), - ), - const SizedBox( - width: 8, - ), - ////UNTIL - Flexible( - flex: 1, - child: FormBuilderTextField( - validator: FormBuilderValidators.required( - errorText: "This fied is required"), - decoration: normalTextFieldStyle( - "until *", "until"), - name: "", - controller: untilController, - onTap: () { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - content: SizedBox( - width: 300, - height: 300, - child: YearPicker( - firstDate: DateTime( - DateTime.now().year - 100, - 1), - lastDate: DateTime( - DateTime.now().year + 100, - 1), - initialDate: DateTime.now(), - selectedDate: DateTime.now(), - onChanged: (DateTime dateTime) { - untilController.text = - dateTime.year.toString(); - Navigator.pop(context); - }, - ), - ), - ); - }, - ); - }, - ), - ), - - - ], - ), - - ), const SizedBox(height: 20,), - SizedBox( - - child: graduated - ////GRADUATED YEAR - ? FormBuilderTextField( - validator: - FormBuilderValidators.required( - errorText: - "This fied is required"), - onTap: () { - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - content: SizedBox( - width: 300, - height: 300, - child: YearPicker( - firstDate: DateTime( - DateTime.now().year - - 100, - 1), - lastDate: DateTime( - DateTime.now().year + - 100, - 1), - initialDate: - DateTime.now(), - selectedDate: - DateTime.now(), - onChanged: - (DateTime dateTime) { - yearGraduated.text = - dateTime.year - .toString(); - Navigator.pop(context); - }, - ), - ), - ); - }, - ); - }, - name: "year_graduated", - controller: yearGraduated, - decoration: normalTextFieldStyle( - "Year Graduated *", - "Year Graduated *"), - ) - //// HIGHEST UNITS EARNED - : FormBuilderTextField( - validator: - FormBuilderValidators.required( - errorText: - "This fied is required"), - controller: unitsController, - name: "units_earned", - decoration: normalTextFieldStyle( - "Highest Level/Units Earned *", - "Highest Level/Units Earned *")), - ) - - ], + }), ); }), const SizedBox( height: 12, ), - //// HONORS - - StatefulBuilder(builder: (context, setState) { - return MultiSelectDropDown( - onOptionSelected: (List selectedOptions) { - selectedValueItem = selectedOptions; - }, - borderColor: Colors.grey, - borderWidth: 1, - borderRadius: 5, - hint: "Honors", - padding: const EdgeInsets.all(8), - options: valueItemHonorList, - selectionType: SelectionType.multi, - chipConfig: const ChipConfig(wrapType: WrapType.wrap), - dropdownHeight: 300, - optionTextStyle: const TextStyle(fontSize: 16), - selectedOptionIcon: const Icon(Icons.check_circle), - selectedOptions: - (state.educationalBackground.honors!.isNotEmpty && - state.educationalBackground.honors != null) - ? selectedValueItem = state - .educationalBackground.honors! - .map((Honor honor) => ValueItem( - label: honor.name!, value: honor.name)) - .toList() - : [], - ); - }), - - ]), - ), - ////sumit button + + ////Programs + + Container( + child: selectedLevel != null && + selectedLevel!.group != 1 + ? SearchField( + inputFormatters: [UpperCaseTextFormatter()], + suggestionAction: + SuggestionAction.unfocus, + controller: currentProgramController, + itemHeight: 70, + suggestionsDecoration: box1(), + suggestions: state.programs + .map((Course program) => + SearchFieldListItem( + program.program!, + item: program, + child: Padding( + padding: const EdgeInsets + .symmetric( + horizontal: 10), + child: ListTile( + title: Text( + program.program!,overflow: TextOverflow.visible,)), + ))) + .toList(), + validator: (agency) { + if (agency!.isEmpty) { + return "This field is required"; + } + return null; + }, + focusNode: programFocusNode, + searchInputDecoration: + normalTextFieldStyle( + "Course/Programs *", "") + .copyWith( + suffixIcon: IconButton( + icon:const Icon( + Icons.arrow_drop_down), onPressed: () { programFocusNode.unfocus(); },),), + onSuggestionTap: (position) { + setState(() { + selectedProgram = position.item; + programFocusNode.unfocus(); + }); + }, + emptyWidget: EmptyWidget( + title: "Add Program", + controller: addProgramController, + onpressed: () { + setState(() { + Course newProgram = Course( + id: null, + program: addProgramController + .text + .toUpperCase()); + state.programs + .insert(0, newProgram); + addProgramController.text = ""; + + Navigator.pop(context); + }); + }), + ) + : Container()), + SizedBox(height: selectedLevel != null && + selectedLevel!.group != 1?12:0,), + ], + ); + }), + + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + //// GRADUATED SWITCH + FormBuilderSwitch( + initialValue: graduated, + activeColor: second, + onChanged: (value) { + setState(() { + graduated = value!; + if (graduated) { + unitsController.text = ""; + } else { + yearGraduated.text = ""; + } + }); + }, + decoration: normalTextFieldStyle( + "Graduated?", 'Graduated?'), + name: 'graudated', + title: Text(graduated ? "YES" : "NO"), + ), + const SizedBox( + height: 12, + ), + ////FROM + SizedBox( + width: screenWidth, + child: Row( + children: [ + Flexible( + flex: 1, + child: FormBuilderTextField( + validator: FormBuilderValidators.required( + errorText: "This fied is required"), + decoration: + normalTextFieldStyle("from *", "from"), + name: "", + controller: fromController, + onTap: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + content: SizedBox( + width: 300, + height: 300, + child: YearPicker( + firstDate: DateTime( + DateTime.now().year - 100, + 1), + lastDate: DateTime( + DateTime.now().year + 100, + 1), + initialDate: DateTime.now(), + selectedDate: DateTime.now(), + onChanged: (DateTime dateTime) { + fromController.text = + dateTime.year.toString(); + Navigator.pop(context); + }, + ), + ), + ); + }, + ); + }, + ), + ), + const SizedBox( + width: 8, + ), + ////UNTIL + Flexible( + flex: 1, + child: FormBuilderTextField( + validator: FormBuilderValidators.required( + errorText: "This fied is required"), + decoration: normalTextFieldStyle( + "until *", "until"), + name: "", + controller: untilController, + onTap: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + content: SizedBox( + width: 300, + height: 300, + child: YearPicker( + firstDate: DateTime( + DateTime.now().year - 100, + 1), + lastDate: DateTime( + DateTime.now().year + 100, + 1), + initialDate: DateTime.now(), + selectedDate: DateTime.now(), + onChanged: (DateTime dateTime) { + untilController.text = + dateTime.year.toString(); + Navigator.pop(context); + }, + ), + ), + ); + }, + ); + }, + ), + ), + + + ], + ), + + ), const SizedBox(height: 20,), + SizedBox( + + child: graduated + ////GRADUATED YEAR + ? FormBuilderTextField( + validator: + FormBuilderValidators.required( + errorText: + "This fied is required"), + onTap: () { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + content: SizedBox( + width: 300, + height: 300, + child: YearPicker( + firstDate: DateTime( + DateTime.now().year - + 100, + 1), + lastDate: DateTime( + DateTime.now().year + + 100, + 1), + initialDate: + DateTime.now(), + selectedDate: + DateTime.now(), + onChanged: + (DateTime dateTime) { + yearGraduated.text = + dateTime.year + .toString(); + Navigator.pop(context); + }, + ), + ), + ); + }, + ); + }, + name: "year_graduated", + controller: yearGraduated, + decoration: normalTextFieldStyle( + "Year Graduated *", + "Year Graduated *"), + ) + //// HIGHEST UNITS EARNED + : FormBuilderTextField( + initialValue: state.educationalBackground.unitsEarned?.toString(), + validator: + FormBuilderValidators.required( + errorText: + "This fied is required"), + + name: "units_earned", + decoration: normalTextFieldStyle( + "Highest Level/Units Earned *", + "Highest Level/Units Earned *")), + ) + + ], + ); + }), + const SizedBox( + height: 12, + ), + //// HONORS + StatefulBuilder(builder: (context, setState) { + return MultiSelectDropDown( + onOptionSelected: (List selectedOptions) { + selectedValueItem = selectedOptions; + }, + borderColor: Colors.grey, + borderWidth: 1, + borderRadius: 5, + hint: "Honors", + padding: const EdgeInsets.all(8), + options: valueItemHonorList, + selectionType: SelectionType.multi, + chipConfig: const ChipConfig(wrapType: WrapType.wrap), + dropdownHeight: 300, + optionTextStyle: const TextStyle(fontSize: 16), + selectedOptionIcon: const Icon(Icons.check_circle), + selectedOptions: + (state.educationalBackground.honors!.isNotEmpty && + state.educationalBackground.honors != null) + ? selectedValueItem = state + .educationalBackground.honors! + .map((Honor honor) => ValueItem( + label: honor.name!, value: honor.name)) + .toList() + : [], + ); + }), + const SizedBox(height: 14,), + ////sumit button SizedBox( width: double.infinity, @@ -558,7 +553,7 @@ class _EditEducationScreenState extends State { yearGraduated: graduated ? yearGraduated.text : null, unitsEarned: !graduated - ? int.tryParse(unitsController.text) + ? int.tryParse(formKey.currentState!.value['units_earned']) : null, attachments: null, ); @@ -573,9 +568,7 @@ class _EditEducationScreenState extends State { }, child: const Text(submit)), ), - - ], - ), + ]), ), ), ); diff --git a/lib/screens/profile/components/education/education_view_attachment.dart b/lib/screens/profile/components/education/education_view_attachment.dart index 88657f9..f84ca88 100644 --- a/lib/screens/profile/components/education/education_view_attachment.dart +++ b/lib/screens/profile/components/education/education_view_attachment.dart @@ -3,13 +3,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_progress_hud/flutter_progress_hud.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; -import 'package:fluttertoast/fluttertoast.dart'; -import 'package:share_plus/share_plus.dart'; import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart'; import 'package:unit2/bloc/profile/education/education_bloc.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; +import '../../../../utils/url_launcher_file_downloader.dart'; + class EudcationViewAttachment extends StatefulWidget { const EudcationViewAttachment({super.key}); @@ -26,7 +26,7 @@ class _EudcationViewAttachmentState extends State { return Scaffold( floatingActionButton: FloatingActionButton( onPressed: () async { - await _launchInBrowser(fileUrl!); + await launchInBrowser(fileUrl!); }, child: const Icon(Icons.file_download), ), @@ -103,19 +103,4 @@ class _EudcationViewAttachmentState extends State { ), )); } - - Future _launchInBrowser(String url) async { - final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance; - if (!await launcher.launch( - url, - useSafariVC: false, - useWebView: false, - enableJavaScript: false, - enableDomStorage: false, - universalLinksOnly: false, - headers: {}, - )) { - throw Exception('Could not launch $url'); - } - } } diff --git a/lib/screens/profile/components/education_screen.dart b/lib/screens/profile/components/education_screen.dart index 761f285..aec934b 100644 --- a/lib/screens/profile/components/education_screen.dart +++ b/lib/screens/profile/components/education_screen.dart @@ -11,7 +11,6 @@ import 'package:unit2/bloc/profile/profile_bloc.dart'; import 'package:unit2/bloc/user/user_bloc.dart'; import 'package:unit2/model/profile/educational_background.dart'; import 'package:unit2/screens/profile/components/education/add_modal.dart'; -import 'package:unit2/screens/profile/shared/view_attachment.dart'; import 'package:unit2/theme-data.dart/box_shadow.dart'; import 'package:unit2/theme-data.dart/colors.dart'; import 'package:unit2/widgets/Leadings/add_leading.dart'; @@ -41,7 +40,7 @@ class EducationScreen extends StatelessWidget { int profileId; String? token; return Scaffold( - resizeToAvoidBottomInset: false, + resizeToAvoidBottomInset: true, appBar: AppBar( title: context.watch().state is AddEducationState ? const FittedBox(child: Text("Add Educational Background")) diff --git a/lib/screens/profile/components/eligibility/add_modal.dart b/lib/screens/profile/components/eligibility/add_modal.dart index 945ec9a..4c1f0a8 100644 --- a/lib/screens/profile/components/eligibility/add_modal.dart +++ b/lib/screens/profile/components/eligibility/add_modal.dart @@ -71,343 +71,337 @@ class _AddEligibilityScreenState extends State { padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 28), child: FormBuilder( key: formKey, - child: SizedBox( - height: screenHeight * 90, - child: Column( - children: [ - Flexible( - child: ListView(children: [ - ////ELIGIBILITIES DROPDOWN - FormBuilderDropdown( - onChanged: (Eligibility? eligibility) { - selectedEligibility = eligibility; - }, - autovalidateMode: - AutovalidateMode.onUserInteraction, - validator: (value) => - value == null ? 'required' : null, - items: state.eligibilities - .map>( - (Eligibility eligibility) { - return DropdownMenuItem( - value: eligibility, - child: Text(eligibility.title)); - }).toList(), - name: "eligibility", - decoration: normalTextFieldStyle( - "Eligibility", "Eligibility")), - const SizedBox( - height: 8, - ), + child: ListView(children: [ + ////ELIGIBILITIES DROPDOWN + FormBuilderDropdown( + onChanged: (Eligibility? eligibility) { + selectedEligibility = eligibility; + }, + autovalidateMode: + AutovalidateMode.onUserInteraction, + validator: (value) => + value == null ? 'required' : null, + items: state.eligibilities + .map>( + (Eligibility eligibility) { + return DropdownMenuItem( + value: eligibility, + child: Text(eligibility.title)); + }).toList(), + name: "eligibility", + decoration: normalTextFieldStyle( + "Eligibility", "Eligibility")), + const SizedBox( + height: 8, + ), - SizedBox( - width: screenWidth, - child: Row( - children: [ - ////LICENSE NUMBER - Flexible( - flex: 1, - child: FormBuilderTextField( - onChanged: (value) { - license = value; - }, - name: 'license_number', - decoration: normalTextFieldStyle( - "license number", "license number"), - ), - ), - const SizedBox( - width: 8, - ), - ////RATING - Flexible( - flex: 1, - child: FormBuilderTextField( - validator: FormBuilderValidators.numeric( - errorText: "Enter a number"), - keyboardType: - const TextInputType.numberWithOptions(), - onChanged: (value) { - rating = value; - }, - name: 'rating', - decoration: normalTextFieldStyle( - 'rating %', 'rating'), - ), - ), - ], - ), + SizedBox( + width: screenWidth, + child: Row( + children: [ + ////LICENSE NUMBER + Flexible( + flex: 1, + child: FormBuilderTextField( + onChanged: (value) { + license = value; + }, + name: 'license_number', + decoration: normalTextFieldStyle( + "license number", "license number"), ), - const SizedBox( - height: 8, + ), + const SizedBox( + width: 8, + ), + ////RATING + Flexible( + flex: 1, + child: FormBuilderTextField( + validator: FormBuilderValidators.numeric( + errorText: "Enter a number"), + keyboardType: + const TextInputType.numberWithOptions(), + onChanged: (value) { + rating = value; + }, + name: 'rating', + decoration: normalTextFieldStyle( + 'rating %', 'rating'), ), - SizedBox( - width: screenWidth, - child: StatefulBuilder(builder: (context, setState) { - return Row( - children: [ - ////EXAM DATE - Flexible( - flex: 1, - child: DateTimePicker( - use24HourFormat: false, - icon: const Icon(Icons.date_range), - controller: examDateController, - firstDate: DateTime(1990), - lastDate: DateTime(2100), - timeHintText: - "Date of Examination/Conferment", - decoration: - normalTextFieldStyle("Exam date", "") - .copyWith( - prefixIcon: const Icon( - Icons.date_range, - color: Colors.black87, - )), - initialDate: expireDate == null - ? DateTime.now() - : expireDate!.subtract( - const Duration(days: 1)), - selectableDayPredicate: (date) { - if (expireDate != null && - expireDate! - .microsecondsSinceEpoch <= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - examDate = DateTime.parse(value); - }); - }, - )), - const SizedBox( - width: 8, - ), - ////VALIDITY DATE - Flexible( - flex: 1, - child: DateTimePicker( - controller: validityDateController, - firstDate: DateTime(1970), - lastDate: DateTime(2100), - decoration: normalTextFieldStyle( - "Validity date", "Validity date") - .copyWith( - prefixIcon: const Icon( - Icons.date_range, - color: Colors.black87, - )), - selectableDayPredicate: (date) { - if (examDate != null && - examDate!.microsecondsSinceEpoch >= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - expireDate = DateTime.parse(value); - }); - }, - initialDate: examDate == null - ? DateTime.now() - : examDate! - .add(const Duration(days: 1)), - ), - ), - ], - ); - }), - ), - const SizedBox( - height: 8, - ), - Text( - "Placement of Examination/Conferment", - style: Theme.of(context) - .textTheme - .displaySmall! - .copyWith(fontSize: blockSizeVertical * 2), - ), - const SizedBox( - height: 8, - ), - ////OVERSEAS ADDRESS SWITCH - Column( - children: [ - FormBuilderSwitch( - validator: FormBuilderValidators.required( - errorText: 'This field is required'), - initialValue: overseas, - activeColor: second, + ), + ], + ), + ), + const SizedBox( + height: 8, + ), + SizedBox( + width: screenWidth, + child: StatefulBuilder(builder: (context, setState) { + return Row( + children: [ + ////EXAM DATE + Flexible( + flex: 1, + child: DateTimePicker( + use24HourFormat: false, + icon: const Icon(Icons.date_range), + controller: examDateController, + firstDate: DateTime(1990), + lastDate: DateTime(2100), + timeHintText: + "Date of Examination/Conferment", + decoration: + normalTextFieldStyle("Exam date", "") + .copyWith( + prefixIcon: const Icon( + Icons.date_range, + color: Colors.black87, + )), + initialDate: expireDate == null + ? DateTime.now() + : expireDate!.subtract( + const Duration(days: 1)), + selectableDayPredicate: (date) { + if (expireDate != null && + expireDate! + .microsecondsSinceEpoch <= + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, onChanged: (value) { setState(() { - overseas = value; + examDate = DateTime.parse(value); }); }, - decoration: normalTextFieldStyle("", ''), - name: 'overseas', - title: const Text("Overseas Address?"), - ), - const SizedBox( - height: 8, - ), - ////COUNTRY DROPDOWN - SizedBox( - child: overseas == true - ? FormBuilderDropdown( - initialValue: null, - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - items: state.countries - .map>( - (Country country) { - return DropdownMenuItem( - value: country, - child: FittedBox( - child: Text(country.name!))); - }).toList(), - name: 'country', - decoration: normalTextFieldStyle( - "Country*", "Country"), - onChanged: (Country? value) { - selectedCountry = value; - }, - ) - : Column( - children: [ - ////REGION DROPDOWN - FormBuilderDropdown( - autovalidateMode: AutovalidateMode - .onUserInteraction, - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - //// region onchange - onChanged: (Region? region) async { - if (selectedRegion != region) { - setState(() { - provinceCall = true; - }); - selectedRegion = region; - getProvinces(); - } - }, - initialValue: selectedRegion, - decoration: normalTextFieldStyle( - "Region*", "Region"), - name: 'region', - items: state.regions - .map>( - (Region region) { - return DropdownMenuItem( - value: region, - child: Text( - region.description!)); - }).toList(), - ), - const SizedBox( - height: 8, - ), - ////PROVINCE DROPDOWN - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: (value) => - value == null - ? 'required' - : null, - isExpanded: true, - value: selectedProvince, - onChanged: - (Province? province) { - if (selectedProvince != - province) { - setState(() { - cityCall = true; - }); - selectedProvince = - province; - getCities(); - } - }, - items: provinces == null - ? [] - : provinces!.map< - DropdownMenuItem< - Province>>( - (Province province) { - return DropdownMenuItem( - value: province, - child: FittedBox( - child: Text(province - .description!), - )); - }).toList(), - decoration: - normalTextFieldStyle( - "Province*", - "Province")), - ), - ), - - //// CityMunicipalities dropdown - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: cityCall, - child: DropdownButtonFormField< - CityMunicipality>( - validator: (value) => - value == null - ? 'required' - : null, - isExpanded: true, - onChanged: - (CityMunicipality? city) { - selectedMunicipality = city; - }, - decoration: - normalTextFieldStyle( - "Municipality*", - "Municipality"), - value: selectedMunicipality, - items: citymuns == null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality c) { - return DropdownMenuItem( - value: c, - child: Text(c - .description!)); - }).toList(), - ), - ), - ), - ], - )), - ], + )), + const SizedBox( + width: 8, ), - ]), + ////VALIDITY DATE + Flexible( + flex: 1, + child: DateTimePicker( + controller: validityDateController, + firstDate: DateTime(1970), + lastDate: DateTime(2100), + decoration: normalTextFieldStyle( + "Validity date", "Validity date") + .copyWith( + prefixIcon: const Icon( + Icons.date_range, + color: Colors.black87, + )), + selectableDayPredicate: (date) { + if (examDate != null && + examDate!.microsecondsSinceEpoch >= + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, + onChanged: (value) { + setState(() { + expireDate = DateTime.parse(value); + }); + }, + initialDate: examDate == null + ? DateTime.now() + : examDate! + .add(const Duration(days: 1)), + ), + ), + ], + ); + }), + ), + const SizedBox( + height: 8, + ), + Text( + "Placement of Examination/Conferment", + style: Theme.of(context) + .textTheme + .displaySmall! + .copyWith(fontSize: blockSizeVertical * 2), + ), + const SizedBox( + height: 8, + ), + ////OVERSEAS ADDRESS SWITCH + Column( + children: [ + FormBuilderSwitch( + validator: FormBuilderValidators.required( + errorText: 'This field is required'), + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value; + }); + }, + decoration: normalTextFieldStyle("", ''), + name: 'overseas', + title: const Text("Overseas Address?"), ), + const SizedBox( + height: 8, + ), + ////COUNTRY DROPDOWN SizedBox( + child: overseas == true + ? FormBuilderDropdown( + initialValue: null, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + items: state.countries + .map>( + (Country country) { + return DropdownMenuItem( + value: country, + child: FittedBox( + child: Text(country.name!))); + }).toList(), + name: 'country', + decoration: normalTextFieldStyle( + "Country*", "Country"), + onChanged: (Country? value) { + selectedCountry = value; + }, + ) + : Column( + children: [ + ////REGION DROPDOWN + FormBuilderDropdown( + autovalidateMode: AutovalidateMode + .onUserInteraction, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + //// region onchange + onChanged: (Region? region) async { + if (selectedRegion != region) { + setState(() { + provinceCall = true; + }); + selectedRegion = region; + getProvinces(); + } + }, + initialValue: selectedRegion, + decoration: normalTextFieldStyle( + "Region*", "Region"), + name: 'region', + items: state.regions + .map>( + (Region region) { + return DropdownMenuItem( + value: region, + child: Text( + region.description!)); + }).toList(), + ), + const SizedBox( + height: 8, + ), + ////PROVINCE DROPDOWN + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: provinceCall, + child: DropdownButtonFormField< + Province?>( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: (value) => + value == null + ? 'required' + : null, + isExpanded: true, + value: selectedProvince, + onChanged: + (Province? province) { + if (selectedProvince != + province) { + setState(() { + cityCall = true; + }); + selectedProvince = + province; + getCities(); + } + }, + items: provinces == null + ? [] + : provinces!.map< + DropdownMenuItem< + Province>>( + (Province province) { + return DropdownMenuItem( + value: province, + child: FittedBox( + child: Text(province + .description!), + )); + }).toList(), + decoration: + normalTextFieldStyle( + "Province*", + "Province")), + ), + ), + + //// CityMunicipalities dropdown + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: cityCall, + child: DropdownButtonFormField< + CityMunicipality>( + validator: (value) => + value == null + ? 'required' + : null, + isExpanded: true, + onChanged: + (CityMunicipality? city) { + selectedMunicipality = city; + }, + decoration: + normalTextFieldStyle( + "Municipality*", + "Municipality"), + value: selectedMunicipality, + items: citymuns == null + ? [] + : citymuns!.map< + DropdownMenuItem< + CityMunicipality>>( + (CityMunicipality c) { + return DropdownMenuItem( + value: c, + child: Text(c + .description!)); + }).toList(), + ), + ), + ), + ], + )), + ], + ), + const SizedBox(height: 24,), + SizedBox( width: screenWidth, height: 60, child: ElevatedButton( @@ -464,9 +458,7 @@ class _AddEligibilityScreenState extends State { }, child: const Text(submit)), ), - ], - ), - ), + ]), ), ); } diff --git a/lib/screens/profile/components/eligibility/edit_modal.dart b/lib/screens/profile/components/eligibility/edit_modal.dart index d161084..9e0c0f4 100644 --- a/lib/screens/profile/components/eligibility/edit_modal.dart +++ b/lib/screens/profile/components/eligibility/edit_modal.dart @@ -78,8 +78,8 @@ class _EditEligibilityScreenState extends State { validityDateController.text = state.eligibityCert.validityDate == null ? '' : state.eligibityCert.validityDate.toString(); - DateTime? examDate = DateTime.tryParse(examDateController.text) ; - DateTime? expireDate = DateTime.tryParse(validityDateController.text); + DateTime? examDate = DateTime.tryParse(examDateController.text); + DateTime? expireDate = DateTime.tryParse(validityDateController.text); provinces = state.provinces; citymuns = state.cities; regions = state.regions; @@ -96,461 +96,445 @@ class _EditEligibilityScreenState extends State { padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 28), child: FormBuilder( key: formKey, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const SizedBox( - height: 24, - ), - ////ELIGIBILITIES DROPDOWN - DropdownButtonFormField( - validator: (value) => - value == null ? 'required' : null, - isExpanded: true, - onChanged: (Eligibility? eligibility) { - selectedEligibility = eligibility; - }, - value: selectedEligibility, - items: state.eligibilities - .map>( - (Eligibility eligibility) { - return DropdownMenuItem( - value: eligibility, - child: Text(eligibility.title)); - }).toList(), - decoration: normalTextFieldStyle("Eligibility", "")), - const SizedBox( - height: 12, - ), + child: ListView(children: [ + const SizedBox( + height: 24, + ), + ////ELIGIBILITIES DROPDOWN + DropdownButtonFormField( + validator: (value) => value == null ? 'required' : null, + isExpanded: true, + onChanged: (Eligibility? eligibility) { + selectedEligibility = eligibility; + }, + value: selectedEligibility, + items: state.eligibilities + .map>( + (Eligibility eligibility) { + return DropdownMenuItem( + value: eligibility, child: Text(eligibility.title)); + }).toList(), + decoration: normalTextFieldStyle("Eligibility", "")), + const SizedBox( + height: 12, + ), - SizedBox( - width: screenWidth, - child: Row( - children: [ - ////LICENSE NUMBER - Flexible( - flex: 1, - child: FormBuilderTextField( - onChanged: (value) { - license = value; - }, - name: 'license_number', - initialValue: license, - decoration: normalTextFieldStyle( - "license number", "license number"), - ), - ), - const SizedBox( - width: 12, - ), - // //RATING - Flexible( - flex: 1, - child: FormBuilderTextField( - validator: FormBuilderValidators.numeric( - errorText: "Enter a number"), - keyboardType: - const TextInputType.numberWithOptions(), - onChanged: (value) { - rating = value; - }, - name: 'rating', - initialValue: - rating == null ? 'N/A' : rating.toString(), - decoration: - normalTextFieldStyle('rating', 'rating'), - ), - ), - ], + SizedBox( + width: screenWidth, + child: Row( + children: [ + ////LICENSE NUMBER + Flexible( + flex: 1, + child: FormBuilderTextField( + onChanged: (value) { + license = value; + }, + name: 'license_number', + initialValue: license, + decoration: normalTextFieldStyle( + "license number", "license number"), + ), ), - ), - const SizedBox( - height: 12, - ), - SizedBox( - width: screenWidth, - child: StatefulBuilder(builder: (context, setState) { - return Row( - children: [ - // //EXAM DATE - Flexible( - flex: 1, - child: DateTimePicker( - use24HourFormat: false, - controller: examDateController, - firstDate: DateTime(1990), - lastDate: DateTime(2100), - decoration: - normalTextFieldStyle("Exam date", "") - .copyWith( - prefixIcon: const Icon( - Icons.date_range, - color: Colors.black87, - )), - initialDate: expireDate == null - ? DateTime.now() - : expireDate! - .subtract(const Duration(days: 1)), - selectableDayPredicate: (date) { - if (expireDate != null && - expireDate!.microsecondsSinceEpoch <= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - examDate = DateTime.parse(value); - }); - }, - )), + const SizedBox( + width: 12, + ), + // //RATING + Flexible( + flex: 1, + child: FormBuilderTextField( + validator: FormBuilderValidators.numeric( + errorText: "Enter a number"), + keyboardType: + const TextInputType.numberWithOptions(), + onChanged: (value) { + rating = value; + }, + name: 'rating', + initialValue: + rating == null ? 'N/A' : rating.toString(), + decoration: + normalTextFieldStyle('rating', 'rating'), + ), + ), + ], + ), + ), + const SizedBox( + height: 12, + ), + SizedBox( + width: screenWidth, + child: StatefulBuilder(builder: (context, setState) { + return Row( + children: [ + // //EXAM DATE + Flexible( + flex: 1, + child: DateTimePicker( + use24HourFormat: false, + controller: examDateController, + firstDate: DateTime(1990), + lastDate: DateTime(2100), + decoration: + normalTextFieldStyle("Exam date", "") + .copyWith( + prefixIcon: const Icon( + Icons.date_range, + color: Colors.black87, + )), + initialDate: expireDate == null + ? DateTime.now() + : expireDate! + .subtract(const Duration(days: 1)), + selectableDayPredicate: (date) { + if (expireDate != null && + expireDate!.microsecondsSinceEpoch <= + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, + onChanged: (value) { + setState(() { + examDate = DateTime.parse(value); + }); + }, + )), - const SizedBox( - width: 12, - ), - ////VALIDITY DATE - Flexible( - flex: 1, - child: DateTimePicker( - use24HourFormat: false, - controller: validityDateController, - firstDate: DateTime(1970), - lastDate: DateTime(2100), - decoration: - normalTextFieldStyle("validity date", "") - .copyWith( - prefixIcon: const Icon( - Icons.date_range, - color: Colors.black87, - )), - selectableDayPredicate: (date) { - if (examDate != null && - examDate!.microsecondsSinceEpoch >= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - expireDate = DateTime.parse(value); - }); - }, - initialDate: examDate == null - ? DateTime.now() - : examDate!.add(const Duration(days: 1)), - ), - ), - ], - ); - }), - ), - const SizedBox( - height: 20, - ), - Text( - "Placement of Examination/Confinement", - style: Theme.of(context) - .textTheme - .displaySmall! - .copyWith(fontSize: blockSizeVertical * 2), - ), - const SizedBox( - height: 12, - ), - //OVERSEAS ADDRESS SWITCH - StatefulBuilder(builder: (context, StateSetter setState) { - return Column( - children: [ - FormBuilderSwitch( - initialValue: overseas, - activeColor: second, + const SizedBox( + width: 12, + ), + ////VALIDITY DATE + Flexible( + flex: 1, + child: DateTimePicker( + use24HourFormat: false, + controller: validityDateController, + firstDate: DateTime(1970), + lastDate: DateTime(2100), + decoration: + normalTextFieldStyle("validity date", "") + .copyWith( + prefixIcon: const Icon( + Icons.date_range, + color: Colors.black87, + )), + selectableDayPredicate: (date) { + if (examDate != null && + examDate!.microsecondsSinceEpoch >= + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, onChanged: (value) { setState(() { - overseas = value; + expireDate = DateTime.parse(value); }); }, - decoration: normalTextFieldStyle("", ''), - name: 'overseas', - title: const Text("Overseas Address?"), + initialDate: examDate == null + ? DateTime.now() + : examDate!.add(const Duration(days: 1)), ), - const SizedBox( - height: 12, - ), - //COUNTRY DROPDOWN - SizedBox( - child: overseas == true - ? FormBuilderDropdown( + ), + ], + ); + }), + ), + const SizedBox( + height: 20, + ), + Text( + "Placement of Examination/Confinement", + style: Theme.of(context) + .textTheme + .displaySmall! + .copyWith(fontSize: blockSizeVertical * 2), + ), + const SizedBox( + height: 12, + ), + //OVERSEAS ADDRESS SWITCH + StatefulBuilder(builder: (context, StateSetter setState) { + return Column( + children: [ + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value; + }); + }, + decoration: normalTextFieldStyle("", ''), + name: 'overseas', + title: const Text("Overseas Address?"), + ), + const SizedBox( + height: 12, + ), + //COUNTRY DROPDOWN + SizedBox( + child: overseas == true + ? FormBuilderDropdown( + validator: (value) => + value == null ? 'required' : null, + initialValue: selectedCountry!.id == 175 + ? null + : selectedCountry, + items: state.countries + .map>( + (Country country) { + return DropdownMenuItem( + value: country, + child: FittedBox( + child: Text(country.name!))); + }).toList(), + name: 'country', + decoration: normalTextFieldStyle( + "Country*", "Country"), + onChanged: (Country? value) { + selectedCountry = value; + }, + ) + : Column( + children: [ + ////REGION DROPDOWN + DropdownButtonFormField( validator: (value) => value == null ? 'required' : null, - initialValue: selectedCountry!.id == 175 - ? null - : selectedCountry, - items: state.countries - .map>( - (Country country) { - return DropdownMenuItem( - value: country, - child: FittedBox( - child: Text(country.name!))); - }).toList(), - name: 'country', - decoration: normalTextFieldStyle( - "Country*", "Country"), - onChanged: (Country? value) { - selectedCountry = value; + isExpanded: true, + onChanged: (Region? region) async { + setState(() { + provinceCall = true; + }); + selectedRegion = region; + try { + provinces = await LocationUtils + .instance + .getProvinces( + regionCode: selectedRegion! + .code + .toString()); + } catch (e) { + context + .read() + .add(CallErrorState()); + } + selectedProvince = provinces![0]; + setState(() { + provinceCall = false; + cityCall = true; + }); + try { + citymuns = await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code!); + } catch (e) { + NavigationService + .navigatorKey.currentContext + ?.read() + .add(CallErrorState()); + } + selectedMunicipality = citymuns![0]; + setState(() { + cityCall = false; + }); }, - ) - : Column( - children: [ - ////REGION DROPDOWN - DropdownButtonFormField( + value: selectedRegion, + decoration: normalTextFieldStyle( + "Region*", "Region"), + items: regions == null + ? [] + : regions! + .map>( + (Region region) { + return DropdownMenuItem( + value: region, + child: Text( + region.description!)); + }).toList(), + ), + const SizedBox( + height: 12, + ), + ////PROVINCE DROPDOWN + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: provinceCall, + child: DropdownButtonFormField< + Province?>( + validator: (value) => + value == null + ? 'required' + : null, + isExpanded: true, + value: selectedProvince, + onChanged: + (Province? province) async { + setState(() { + cityCall = true; + }); + selectedProvince = province; + try { + citymuns = await LocationUtils + .instance + .getCities( + code: + selectedProvince! + .code + .toString()); + } catch (e) { + context + .read() + .add(CallErrorState()); + } + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = false; + }); + }, + items: provinces == null + ? [] + : provinces!.map< + DropdownMenuItem< + Province>>( + (Province province) { + return DropdownMenuItem( + value: province, + child: FittedBox( + child: Text(province + .description!), + )); + }).toList(), + decoration: normalTextFieldStyle( + "Province*", "Province")), + ), + ), + + //// City municipality + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: cityCall, + child: DropdownButtonFormField< + CityMunicipality>( validator: (value) => value == null ? 'required' : null, isExpanded: true, - onChanged: (Region? region) async { - setState(() { - provinceCall = true; - }); - selectedRegion = region; - try{ - provinces = await LocationUtils - .instance - .getProvinces( - regionCode: - selectedRegion!.code - .toString()); - }catch(e){ - context.read().add(CallErrorState()); - } - selectedProvince = provinces![0]; - setState(() { - provinceCall = false; - cityCall = true; - }); - try{ - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code!); - }catch(e){ - NavigationService.navigatorKey.currentContext?.read().add(CallErrorState()); - } - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - }); + onChanged: + (CityMunicipality? city) { + selectedMunicipality = city; }, - value: selectedRegion, decoration: normalTextFieldStyle( - "Region*", "Region"), - items: regions == null + "Municipality*", + "Municipality"), + value: selectedMunicipality, + items: citymuns == null ? [] - : regions!.map< + : citymuns!.map< DropdownMenuItem< - Region>>( - (Region region) { - return DropdownMenuItem< - Region>( - value: region, - child: Text(region - .description!)); + CityMunicipality>>( + (CityMunicipality c) { + return DropdownMenuItem( + value: c, + child: Text( + c.description!)); }).toList(), ), - const SizedBox( - height: 12, - ), - ////PROVINCE DROPDOWN - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - validator: (value) => - value == null - ? 'required' - : null, - isExpanded: true, - value: selectedProvince, - onChanged: (Province? - province) async { - setState(() { - cityCall = true; - }); - selectedProvince = province; - try{ - - - citymuns = await LocationUtils - .instance - .getCities( - code: - selectedProvince! - .code - .toString()); - }catch(e){ - context.read().add(CallErrorState()); - } - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - }); - }, - items: provinces == null - ? [] - : provinces!.map< - DropdownMenuItem< - Province>>( - (Province province) { - return DropdownMenuItem( - value: province, - child: FittedBox( - child: Text(province - .description!), - )); - }).toList(), - decoration: - normalTextFieldStyle( - "Province*", - "Province")), - ), - ), - - //// City municipality - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: cityCall, - child: DropdownButtonFormField< - CityMunicipality>( - validator: (value) => - value == null - ? 'required' - : null, - isExpanded: true, - onChanged: - (CityMunicipality? city) { - selectedMunicipality = city; - }, - decoration: - normalTextFieldStyle( - "Municipality*", - "Municipality"), - value: selectedMunicipality, - items: citymuns == null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality c) { - return DropdownMenuItem( - value: c, - child: Text(c - .description!)); - }).toList(), - ), - ), - ), - const SizedBox( - height: 20, - ), - ], - )), - ], - ); - }), - - const Expanded( - child: SizedBox(), - ), - - SizedBox( - width: screenWidth, - height: 60, - child: ElevatedButton( - style: mainBtnStyle( - primary, Colors.transparent, second), - onPressed: () { - ExamAddress examAddress; - ////rating - double? rate = - rating == null ? null : double.parse(rating!); - ////license - String? newLicense = license; - ////city municipality - CityMunicipality? cityMunicipality = - selectedMunicipality; - ////exam date - DateTime? examDate = - examDateController.text.isEmpty - ? null - : DateTime.parse(examDateController.text); - // // validity date - DateTime? validityDate = validityDateController - .text.isEmpty + ), + ), + ], + )), + ], + ); + }), + const SizedBox( + height: 18, + ), + SizedBox( + width: screenWidth, + height: 60, + child: ElevatedButton( + style: + mainBtnStyle(primary, Colors.transparent, second), + onPressed: () { + ExamAddress examAddress; + ////rating + double? rate = + rating == null ? null : double.parse(rating!); + ////license + String? newLicense = license; + ////city municipality + CityMunicipality? cityMunicipality = + selectedMunicipality; + ////exam date + DateTime? examDate = examDateController.text.isEmpty + ? null + : DateTime.parse(examDateController.text); + // // validity date + DateTime? validityDate = + validityDateController.text.isEmpty ? null : DateTime.parse(validityDateController.text); - //// exam address - if (overseas!) { - examAddress = ExamAddress( - barangay: null, - id: state.eligibityCert.examAddress?.id, - addressCategory: state.eligibityCert - .examAddress?.addressCategory, - examAddressClass: state.eligibityCert - .examAddress?.examAddressClass, - country: selectedCountry, - cityMunicipality: null); - } else { - examAddress = ExamAddress( - barangay: state - .eligibityCert.examAddress?.barangay, - id: state.eligibityCert.examAddress?.id, - addressCategory: state.eligibityCert - .examAddress?.addressCategory, - examAddressClass: state.eligibityCert - .examAddress?.examAddressClass, - country: Country( - id: 175, - name: 'Philippines', - code: 'PH'), - cityMunicipality: cityMunicipality); - } + //// exam address + if (overseas!) { + examAddress = ExamAddress( + barangay: null, + id: state.eligibityCert.examAddress?.id, + addressCategory: state + .eligibityCert.examAddress?.addressCategory, + examAddressClass: state.eligibityCert + .examAddress?.examAddressClass, + country: selectedCountry, + cityMunicipality: null); + } else { + examAddress = ExamAddress( + barangay: + state.eligibityCert.examAddress?.barangay, + id: state.eligibityCert.examAddress?.id, + addressCategory: state + .eligibityCert.examAddress?.addressCategory, + examAddressClass: state.eligibityCert + .examAddress?.examAddressClass, + country: Country( + id: 175, name: 'Philippines', code: 'PH'), + cityMunicipality: cityMunicipality); + } - EligibityCert eligibityCert = EligibityCert( - id: state.eligibityCert.id, - rating: rate, - examDate: examDate, - attachments: null, - eligibility: selectedEligibility, - examAddress: examAddress, - validityDate: validityDate, - licenseNumber: newLicense, - overseas: overseas); - if (formKey.currentState!.saveAndValidate()) { - final progress = ProgressHUD.of(context); - progress!.showWithText("Loading..."); - context.read().add( - UpdateEligibility( - eligibityCert: eligibityCert, - oldEligibility: - state.eligibityCert.eligibility!.id, - profileId: widget.profileId.toString(), - token: widget.token)); - } - }, - child: const Text(submit)), - ), - ]), + EligibityCert eligibityCert = EligibityCert( + id: state.eligibityCert.id, + rating: rate, + examDate: examDate, + attachments: null, + eligibility: selectedEligibility, + examAddress: examAddress, + validityDate: validityDate, + licenseNumber: newLicense, + overseas: overseas); + if (formKey.currentState!.saveAndValidate()) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Loading..."); + context.read().add( + UpdateEligibility( + eligibityCert: eligibityCert, + oldEligibility: + state.eligibityCert.eligibility!.id, + profileId: widget.profileId.toString(), + token: widget.token)); + } + }, + child: const Text(submit)), + ), + ]), ), ), ); diff --git a/lib/screens/profile/components/eligibility/eligibility_view_attachment.dart b/lib/screens/profile/components/eligibility/eligibility_view_attachment.dart index 9d21ba1..2bf26a7 100644 --- a/lib/screens/profile/components/eligibility/eligibility_view_attachment.dart +++ b/lib/screens/profile/components/eligibility/eligibility_view_attachment.dart @@ -1,73 +1,113 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart'; -import 'package:unit2/bloc/profile/education/education_bloc.dart'; import 'package:unit2/bloc/profile/eligibility/eligibility_bloc.dart'; import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/utils/url_launcher_file_downloader.dart'; +import 'package:unit2/widgets/error_state.dart'; import 'package:url_launcher/url_launcher.dart'; -import '../../../../utils/urls.dart'; -class EligibilityViewAttachment extends StatefulWidget { +class EligibilityViewAttachment extends StatefulWidget { const EligibilityViewAttachment({super.key}); @override - State createState() => _EligibilityViewAttachmentState(); + State createState() => + _EligibilityViewAttachmentState(); } class _EligibilityViewAttachmentState extends State { @override Widget build(BuildContext context) { + String? filename; String? fileUrl; return Scaffold( - floatingActionButton: FloatingActionButton( - onPressed: ()async { - await launchUrl(Uri.parse(fileUrl!)); - }, - child: const Icon(Icons.file_download), - ), - appBar: AppBar( - title: const Text("Attachment"), - centerTitle: true, - actions: [ - IconButton(onPressed: () {}, icon: const Icon(Icons.share)), - ], - ), - body: BlocConsumer(builder: (context,state){ - if(state is EligibilityAttachmentViewState){ - fileUrl = state.fileUrl; - bool isPDF = state.fileUrl[state.fileUrl.length - 1] == 'f' ? true : false; - return SizedBox( - child: isPDF?SfPdfViewer.network( - state.fileUrl,onDocumentLoadFailed: (details) { - Center(child: Text(details.description),); - },): Center( - child: CachedNetworkImage( - progressIndicatorBuilder: (context, url, progress) { - return const SizedBox( - height: 100, - width: 100, - child: CircularProgressIndicator(color: primary,)); + floatingActionButton: FloatingActionButton( + onPressed: () async { + await launchInBrowser(fileUrl!); + }, + child: const Icon(Icons.file_download), + ), + appBar: AppBar( + title: const Text("Attachment"), + centerTitle: true, + actions: [ + IconButton( + onPressed: () { + context.read().add( + ShareAttachment(fileName: filename!, source: fileUrl!)); }, - - imageBuilder: (context, imageProvider) => Container( - decoration: BoxDecoration( - image: DecorationImage( - image: imageProvider, fit: BoxFit.fill)), - ), - imageUrl: - state.fileUrl, - width: double.infinity, - height: 220, - fit: BoxFit.cover, - ), - ), - ); - } - return Container(); - },listener: (context, state) { - - },) - ); + icon: const Icon(Icons.share)), + ], + ), + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: BlocConsumer( + builder: (context, state) { + if (state is EligibilityAttachmentViewState) { + fileUrl = state.fileUrl; + filename = state.fileName; + bool isPDF = state.fileUrl[state.fileUrl.length - 1] == 'f' + ? true + : false; + return SizedBox( + child: isPDF + ? SfPdfViewer.network( + state.fileUrl, + onDocumentLoadFailed: (details) { + Center( + child: Text(details.description), + ); + }, + ) + : Center( + child: CachedNetworkImage( + progressIndicatorBuilder: (context, url, progress) { + return const SizedBox( + height: 100, + width: 100, + child: CircularProgressIndicator( + color: primary, + )); + }, + imageBuilder: (context, imageProvider) => Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, fit: BoxFit.fill)), + ), + imageUrl: state.fileUrl, + width: double.infinity, + height: 220, + fit: BoxFit.cover, + ), + ), + ); + } + if (state is EligibilityErrorState) { + return SomethingWentWrong( + message: state.message, + onpressed: () { + Navigator.pop(context); + }); + } + return Container(); + }, + listener: (context, state) { + if (state is EligibilityLoadingState) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is EligibilityAttachmentViewState || + state is EligibilityErrorState) { + final progress = ProgressHUD.of(context); + progress!.dismiss(); + } + }, + ), + )); } } diff --git a/lib/screens/profile/components/eligibility_screen.dart b/lib/screens/profile/components/eligibility_screen.dart index 4376fd1..2e2a548 100644 --- a/lib/screens/profile/components/eligibility_screen.dart +++ b/lib/screens/profile/components/eligibility_screen.dart @@ -28,7 +28,6 @@ import '../../../bloc/profile/eligibility/eligibility_bloc.dart'; import '../../../utils/alerts.dart'; import '../shared/multiple_attachment.dart'; import '../shared/single_attachment.dart'; -import '../shared/view_attachment.dart'; import 'eligibility/eligibility_view_attachment.dart'; class EligibiltyScreen extends StatelessWidget { @@ -48,7 +47,7 @@ class EligibiltyScreen extends StatelessWidget { return true; }, child: Scaffold( - resizeToAvoidBottomInset: false, + resizeToAvoidBottomInset: true, appBar: AppBar( title: context.watch().state is AddEligibilityState ? const Text("Add Eligiblity") @@ -637,7 +636,7 @@ class EligibiltyScreen extends StatelessWidget { context, MaterialPageRoute( builder: ((context) => BlocProvider.value( - value: EligibilityBloc()..add(EligibiltyViewAttachmentEvent(source: state.eligibilities[index].attachments!.first.source!)), + value: EligibilityBloc()..add(EligibiltyViewAttachmentEvent(source: state.eligibilities[index].attachments!.first.source!,filename: state.eligibilities[index].attachments!.first.filename!)), child: const EligibilityViewAttachment(), )))); @@ -678,7 +677,7 @@ class EligibiltyScreen extends StatelessWidget { context, MaterialPageRoute( builder: ((context) => BlocProvider.value( - value: EligibilityBloc()..add(EligibiltyViewAttachmentEvent(source: source)), + value: EligibilityBloc()..add(EligibiltyViewAttachmentEvent(source: source,filename: filename)), child: const EligibilityViewAttachment(), )))); }, diff --git a/lib/screens/profile/components/family_background_screen.dart b/lib/screens/profile/components/family_background_screen.dart index 24106e8..0e02b42 100644 --- a/lib/screens/profile/components/family_background_screen.dart +++ b/lib/screens/profile/components/family_background_screen.dart @@ -510,8 +510,8 @@ class _FamilyBackgroundScreenState extends State { ) : SizedBox( width: screenWidth, - child: const Text( - "Provide your father's primary information.", + child: Text( + "Provide your father's primary information.",style:Theme.of(context).textTheme.bodySmall, textAlign: TextAlign.center, ), @@ -808,8 +808,8 @@ class _FamilyBackgroundScreenState extends State { ) : SizedBox( width: screenWidth, - child: const Text( - "Provide your mother's primary information", + child: Text( + "Provide your mother's primary information",style: Theme.of(context).textTheme.bodySmall, textAlign: TextAlign.center, ), @@ -1238,13 +1238,13 @@ class _FamilyBackgroundScreenState extends State { ) : SizedBox( width: screenWidth, - child: const Padding( + child: Padding( padding: - EdgeInsets.symmetric( + const EdgeInsets.symmetric( vertical: 8, horizontal: 0), child: Text( - "Provide your spouse's primary and employment information. Leave empty if not applicable.", + "Provide your spouse's primary and employment information. Leave empty if not applicable.",style: Theme.of(context).textTheme.bodySmall, textAlign: TextAlign.center, ), @@ -1540,13 +1540,13 @@ class _FamilyBackgroundScreenState extends State { }).toList()) : SizedBox( width: screenWidth, - child: const Padding( + child: Padding( padding: - EdgeInsets.symmetric( + const EdgeInsets.symmetric( vertical: 8, horizontal: 0), child: Text( - "Provide your child/children's primary information. Leave empty if not applicable..", + "Provide your child/children's primary information. Leave empty if not applicable.",style: Theme.of(context).textTheme.bodySmall, textAlign: TextAlign.center, ), @@ -1854,13 +1854,13 @@ class _FamilyBackgroundScreenState extends State { }).toList()) : SizedBox( width: screenWidth, - child: const Padding( + child: Padding( padding: - EdgeInsets.symmetric( + const EdgeInsets.symmetric( vertical: 8, horizontal: 0), child: Text( - "Provide the other related person's primary information. Leave empty if not applicable.", + "Provide the other related person's primary information. Leave empty if not applicable.",style: Theme.of(context).textTheme.bodySmall, textAlign: TextAlign.center, ), diff --git a/lib/screens/profile/components/learning_and_development_screen.dart b/lib/screens/profile/components/learning_and_development_screen.dart index dbb74c8..1fe52ba 100644 --- a/lib/screens/profile/components/learning_and_development_screen.dart +++ b/lib/screens/profile/components/learning_and_development_screen.dart @@ -28,7 +28,6 @@ import '../../../utils/alerts.dart'; import '../../../widgets/Leadings/close_leading.dart'; import '../shared/multiple_attachment.dart'; import '../shared/single_attachment.dart'; -import '../shared/view_attachment.dart'; import 'learning_development/add_modal.dart'; class LearningAndDevelopmentScreen extends StatelessWidget { @@ -46,6 +45,7 @@ class LearningAndDevelopmentScreen extends StatelessWidget { AttachmentCategory? selectedAttachmentCategory; List attachmentCategories = []; return Scaffold( + resizeToAvoidBottomInset: true, appBar: AppBar( title: context.watch().state is LearningDevelopmentAddingState @@ -680,7 +680,7 @@ class LearningAndDevelopmentScreen extends StatelessWidget { context, MaterialPageRoute( builder: ((context) => BlocProvider.value( - value: LearningDevelopmentBloc()..add(LearningDevelopmentViewAttachmentEvent(source: state.learningsAndDevelopment[index].attachments!.first.source!)), + value: LearningDevelopmentBloc()..add(LearningDevelopmentViewAttachmentEvent(source: state.learningsAndDevelopment[index].attachments!.first.source!,filename: state.learningsAndDevelopment[index].attachments!.first.filename!)), child: const LearningDevelopmentViewAttachment(), )))); }, @@ -721,7 +721,7 @@ class LearningAndDevelopmentScreen extends StatelessWidget { MaterialPageRoute( builder: ((context) => BlocProvider.value( - value: LearningDevelopmentBloc()..add(LearningDevelopmentViewAttachmentEvent(source: source)), + value: LearningDevelopmentBloc()..add(LearningDevelopmentViewAttachmentEvent(source: source,filename: filename)), child: const LearningDevelopmentViewAttachment(), )))); }, diff --git a/lib/screens/profile/components/learning_development/add_modal.dart b/lib/screens/profile/components/learning_development/add_modal.dart index 697d651..e3d1e7d 100644 --- a/lib/screens/profile/components/learning_development/add_modal.dart +++ b/lib/screens/profile/components/learning_development/add_modal.dart @@ -109,15 +109,15 @@ class _AddLearningAndDevelopmentScreenState DateTime? to; @override void dispose() { - fromDateController.dispose(); - toDateController.dispose(); - addTrainingController.dispose(); - addTopicController.dispose(); - topicFocusNode.dispose(); + // fromDateController.dispose(); + // toDateController.dispose(); + // addTrainingController.dispose(); + // addTopicController.dispose(); + // topicFocusNode.dispose(); - addSponsorAgencyController.dispose(); - sponsorByFocusNode.dispose(); - sponsorAgencyCategoryFocusNode.dispose(); + // addSponsorAgencyController.dispose(); + // sponsorByFocusNode.dispose(); + // sponsorAgencyCategoryFocusNode.dispose(); super.dispose(); } @@ -128,1414 +128,1390 @@ class _AddLearningAndDevelopmentScreenState if (state is LearningDevelopmentAddingState) { return FormBuilder( key: formKey, - child: SizedBox( - height: screenHeight * 90, - child: Padding( - padding: const EdgeInsets.all(24), - child: StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - Flexible( - child: ListView( - children: [ - ////Training SearchField - SizedBox( - child: show - ? SearchableDropdownFormField.paginated( - errorWidget: (value) { - return SomethingWentWrong( - message: value, - onpressed: () { - context - .read< - LearningDevelopmentBloc>() - .add( - GetLearningDevelopments( - profileId: widget - .profileId, - token: - widget.token)); - }); - }, - noRecordTex: SizedBox( - width: double.infinity, - height: 300, - child: EmptyWidget( - controller: addTrainingController, - onpressed: () { - setState(() { - show = false; - showOtherInputs = true; - selectedTrainingController - .text = - addTrainingController.text - .toUpperCase(); - selectedTraining = - LearningDevelopmentType( - id: null, - title: - selectedTrainingController - .text); - addTrainingController.text = - ""; - Navigator.of(context).pop(); - Navigator.of(context).pop(); - }); - }, - title: "Add Training"), - ), - isDialogExpanded: false, - hintText: const Text('Search Training'), - margin: const EdgeInsets.all(15), - backgroundDecoration: (child) { - return SizedBox( - width: double.infinity, - child: Card( - child: Padding( - padding: - const EdgeInsets.all(16), - child: child), - ), - ); - }, - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - paginatedRequest: (int page, - String? searchKey) async { - List - paginatedList=[]; - try { - paginatedList = - await LearningDevelopmentServices - .instance - .getConductedTrainings( - page: page, - key: searchKey ??= ""); - } catch (e) { - context - .read() - .add(CallErrorState( - message: e.toString())); - } - return paginatedList.map((e) { - return SearchableDropdownMenuItem( - value: e, - onTap: () {}, - label: e.title!.title!, - child: TrainingDisplayDetails( - ////not what you are looking for - notWhatYourLookingFor: () { - setState(() { - if (e.learningDevelopmentType - ?.id != - null) { - selectedTraining = - LearningDevelopmentType( - id: e.title!.id, - title: null); - } else { - selectedTraining = - LearningDevelopmentType( - id: null, - title: e.title! - .title); - } - show = false; - showOtherInputs = true; - + child: Padding( + padding: const EdgeInsets.all(24), + child: StatefulBuilder(builder: (context, setState) { + return ListView( + children: [ + ////Training SearchField + SizedBox( + child: show + ? SearchableDropdownFormField.paginated( + errorWidget: (value) { + return SomethingWentWrong( + message: value, + onpressed: () { + context + .read< + LearningDevelopmentBloc>() + .add( + GetLearningDevelopments( + profileId: widget + .profileId, + token: + widget.token)); + }); + }, + noRecordTex: SizedBox( + width: double.infinity, + height: 300, + child: EmptyWidget( + controller: addTrainingController, + onpressed: () { + setState(() { + show = false; + showOtherInputs = true; + selectedTrainingController + .text = + addTrainingController.text + .toUpperCase(); + selectedTraining = + LearningDevelopmentType( + id: null, + title: selectedTrainingController - .text = - e.title!.title!; - Navigator.of(context) - .pop(); + .text); + addTrainingController.text = + ""; + Navigator.of(context).pop(); + Navigator.of(context).pop(); + }); + }, + title: "Add Training"), + ), + isDialogExpanded: false, + hintText: const Text('Search Training'), + margin: const EdgeInsets.all(15), + backgroundDecoration: (child) { + return SizedBox( + width: double.infinity, + child: Card( + child: Padding( + padding: + const EdgeInsets.all(16), + child: child), + ), + ); + }, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + paginatedRequest: (int page, + String? searchKey) async { + List + paginatedList=[]; + try { + paginatedList = + await LearningDevelopmentServices + .instance + .getConductedTrainings( + page: page, + key: searchKey ??= ""); + } catch (e) { + context + .read() + .add(CallErrorState( + message: e.toString())); + } + return paginatedList.map((e) { + return SearchableDropdownMenuItem( + value: e, + onTap: () {}, + label: e.title!.title!, + child: TrainingDisplayDetails( + ////not what you are looking for + notWhatYourLookingFor: () { + setState(() { + if (e.learningDevelopmentType + ?.id != + null) { + selectedTraining = + LearningDevelopmentType( + id: e.title!.id, + title: null); + } else { + selectedTraining = + LearningDevelopmentType( + id: null, + title: e.title! + .title); + } + show = false; + showOtherInputs = true; + + selectedTrainingController + .text = + e.title!.title!; + Navigator.of(context) + .pop(); + }); + }, + e: e, + )); + }).toList(); + }, + dropDownMaxHeight: 500, + requestItemCount: 5, + //// on chage + onChanged: (ConductedTraining? value) { + setState(() { + selectedConductedTraining = value; + selectedTrainingController.text = + selectedConductedTraining! + .title!.title!; + show = false; + showTrainingDetails = true; + }); + }, + ) + : const SizedBox(), + ), + const SizedBox( + height: 12, + ), + SizedBox( + ////Training selected Textfield + child: !show + ? FormBuilderTextField( + maxLines: 5, + readOnly: true, + controller: + selectedTrainingController, + name: "", + decoration: + normalTextFieldStyle("", "") + .copyWith( + labelText: "Training", + suffixIcon: IconButton( + onPressed: () { + setState(() { + selectedConductedTraining = + null; + selectedTrainingController + .text = ""; + show = true; + showTrainingDetails = + false; + showOtherInputs = + false; + selectedTraining = + null; }); }, - e: e, - )); - }).toList(); - }, - dropDownMaxHeight: 500, - requestItemCount: 5, - //// on chage - onChanged: (ConductedTraining? value) { + icon: const Icon( + Icons.close))), + ) + : const SizedBox()), + + ////ShowTraining Details + SizedBox( + child: showTrainingDetails + ? TrainingDetails( + trainingTitle: + selectedConductedTraining! + .learningDevelopmentType! + .title!, + totalHours: selectedConductedTraining! + .totalHours!, + trainingTopic: + selectedConductedTraining! + .topic!.title!, + toDate: selectedConductedTraining! + .toDate + .toString(), + fromDate: selectedConductedTraining! + .fromDate! + .toString(), + conductedBy: selectedConductedTraining! + .conductedBy!.name!) + : const SizedBox(), + ), + ///// end show training details + //// show other inputs + SizedBox( + child: showOtherInputs + ? SizedBox( + child: Column(children: [ + const SizedBox( + height: 12, + ), + ////learning development type + FormBuilderDropdown< + LearningDevelopmentType>( + decoration: normalTextFieldStyle( + "Learning Development Type *", + ""), + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + name: "types", + items: state.types + .map((e) => DropdownMenuItem< + LearningDevelopmentType>( + value: e, + child: Text(e.title!))) + .toList(), + onChanged: (value) { + selectedLearningDevelopmentType = + value; + }, + ), + + //// learning development topics + const SizedBox( + height: 12, + ), + StatefulBuilder( + builder: (context, setState) { + return SearchField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + focusNode: topicFocusNode, + itemHeight: 100, + suggestionsDecoration: box1(), + suggestions: state.topics + .map((LearningDevelopmentType + topic) => + SearchFieldListItem( + topic.title!, + item: topic, + child: Padding( + padding: const EdgeInsets + .symmetric( + horizontal: + 10), + child: ListTile( + title: Text( + topic + .title!, + softWrap: + true, + ), + )))) + .toList(), + + searchInputDecoration: + normalTextFieldStyle( + "Topic *", "") + .copyWith( + suffixIcon: + IconButton( + icon: const Icon( + Icons.arrow_drop_down), + onPressed: () { + topicFocusNode.unfocus(); + }, + )), + onSuggestionTap: (topic) { + if (topic.item?.id != null) { + selectedTopic = + LearningDevelopmentType( + id: topic.item!.id, + title: null); + } else { + selectedTopic = + LearningDevelopmentType( + id: null, + title: topic + .item!.title); + } setState(() { - selectedConductedTraining = value; - selectedTrainingController.text = - selectedConductedTraining! - .title!.title!; - show = false; - showTrainingDetails = true; + topicFocusNode.unfocus(); }); }, - ) - : const SizedBox(), - ), - const SizedBox( - height: 12, - ), - SizedBox( - ////Training selected Textfield - child: !show - ? FormBuilderTextField( - maxLines: 5, - readOnly: true, - controller: - selectedTrainingController, - name: "", - decoration: - normalTextFieldStyle("", "") - .copyWith( - labelText: "Training", - suffixIcon: IconButton( - onPressed: () { - setState(() { - selectedConductedTraining = - null; - selectedTrainingController - .text = ""; - show = true; - showTrainingDetails = - false; - showOtherInputs = - false; - selectedTraining = - null; - }); - }, - icon: const Icon( - Icons.close))), - ) - : const SizedBox()), - - ////ShowTraining Details - SizedBox( - child: showTrainingDetails - ? TrainingDetails( - trainingTitle: - selectedConductedTraining! - .learningDevelopmentType! - .title!, - totalHours: selectedConductedTraining! - .totalHours!, - trainingTopic: - selectedConductedTraining! - .topic!.title!, - toDate: selectedConductedTraining! - .toDate - .toString(), - fromDate: selectedConductedTraining! - .fromDate! - .toString(), - conductedBy: selectedConductedTraining! - .conductedBy!.name!) - : const SizedBox(), - ), - ///// end show training details - //// show other inputs - SizedBox( - child: showOtherInputs - ? SizedBox( - child: Column(children: [ - const SizedBox( - height: 12, - ), - ////learning development type - FormBuilderDropdown< - LearningDevelopmentType>( - decoration: normalTextFieldStyle( - "Learning Development Type *", - ""), - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - name: "types", - items: state.types - .map((e) => DropdownMenuItem< - LearningDevelopmentType>( - value: e, - child: Text(e.title!))) - .toList(), - onChanged: (value) { - selectedLearningDevelopmentType = - value; - }, - ), - - //// learning development topics - const SizedBox( - height: 12, - ), - StatefulBuilder( - builder: (context, setState) { - return SearchField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - focusNode: topicFocusNode, - itemHeight: 100, - suggestionsDecoration: box1(), - suggestions: state.topics - .map((LearningDevelopmentType - topic) => - SearchFieldListItem( - topic.title!, - item: topic, - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: - 10), - child: ListTile( - title: Text( - topic - .title!, - softWrap: - true, - ), - )))) - .toList(), - - searchInputDecoration: - normalTextFieldStyle( - "Topic *", "") - .copyWith( - suffixIcon: - IconButton( - icon: const Icon( - Icons.arrow_drop_down), - onPressed: () { - topicFocusNode.unfocus(); - }, - )), - onSuggestionTap: (topic) { - if (topic.item?.id != null) { - selectedTopic = - LearningDevelopmentType( - id: topic.item!.id, - title: null); - } else { - selectedTopic = - LearningDevelopmentType( - id: null, - title: topic - .item!.title); - } - setState(() { - topicFocusNode.unfocus(); - }); - }, - ////EMPTY WIDGET - emptyWidget: EmptyWidget( - title: "Add Topic", - controller: - addTopicController, - onpressed: () { - setState(() { - LearningDevelopmentType - newTopic = - LearningDevelopmentType( - id: null, - title: addTopicController - .text - .toUpperCase()); - state.topics.insert( - 0, newTopic); - topicFocusNode - .unfocus(); - addTopicController - .text = ""; - Navigator.pop(context); - }); - }), - validator: (position) { - if (position!.isEmpty) { - return "This field is required"; - } - return null; - }, - ); + ////EMPTY WIDGET + emptyWidget: EmptyWidget( + title: "Add Topic", + controller: + addTopicController, + onpressed: () { + setState(() { + LearningDevelopmentType + newTopic = + LearningDevelopmentType( + id: null, + title: addTopicController + .text + .toUpperCase()); + state.topics.insert( + 0, newTopic); + topicFocusNode + .unfocus(); + addTopicController + .text = ""; + Navigator.pop(context); + }); }), + validator: (position) { + if (position!.isEmpty) { + return "This field is required"; + } + return null; + }, + ); + }), - const SizedBox( - height: 12, - ), - SizedBox( - width: screenWidth, - child: StatefulBuilder( - builder: (context, setState) { - return StatefulBuilder(builder: - (context, setState) { - return Row( - children: [ - //// FROM DATE - Flexible( - flex: 1, - child: DateTimePicker( - validator: - FormBuilderValidators - .required( - errorText: - "This field is required"), - use24HourFormat: - false, - icon: const Icon( - Icons - .date_range), - controller: - fromDateController, - firstDate: - DateTime(1990), - lastDate: - DateTime(2100), - selectableDayPredicate: - (date) { - if (to != null && - to!.microsecondsSinceEpoch <= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - from = DateTime - .parse( - value); - }); - }, - initialDate: to == - null - ? DateTime.now() - : to!.subtract( - const Duration( - days: - 1)), - timeHintText: - "Date of Examination/Conferment", - decoration: normalTextFieldStyle( - "From *", - "From *") - .copyWith( - prefixIcon: - const Icon( - Icons.date_range, - color: Colors - .black87, - )), - initialValue: null, - )), - const SizedBox( - width: 12, - ), - //// TO DATE - Flexible( - flex: 1, - child: DateTimePicker( - validator: - FormBuilderValidators - .required( - errorText: - "This field is required"), - controller: - toDateController, - firstDate: - DateTime(1990), - selectableDayPredicate: - (date) { - if (from != null && - from!.microsecondsSinceEpoch >= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - to = DateTime - .parse(value); - }); - }, - initialDate: from == - null - ? DateTime.now() - : from!.add( - const Duration( - days: 1)), - lastDate: - DateTime(2100), - decoration: - normalTextFieldStyle( - "To *", - "To *") - .copyWith( + const SizedBox( + height: 12, + ), + SizedBox( + width: screenWidth, + child: StatefulBuilder( + builder: (context, setState) { + return StatefulBuilder(builder: + (context, setState) { + return Row( + children: [ + //// FROM DATE + Flexible( + flex: 1, + child: DateTimePicker( + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + use24HourFormat: + false, + icon: const Icon( + Icons + .date_range), + controller: + fromDateController, + firstDate: + DateTime(1990), + lastDate: + DateTime(2100), + + onChanged: (value) { + setState(() { + from = DateTime + .parse( + value); + }); + }, + initialDate: to == + null + ? DateTime.now() + : to!.subtract( + const Duration( + days: + 1)), + timeHintText: + "Date of Examination/Conferment", + decoration: normalTextFieldStyle( + "From *", + "From *") + .copyWith( prefixIcon: const Icon( - Icons.date_range, - color: Colors - .black87, - ), + Icons.date_range, + color: Colors + .black87, + )), + initialValue: null, + )), + const SizedBox( + width: 12, + ), + //// TO DATE + Flexible( + flex: 1, + child: DateTimePicker( + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + controller: + toDateController, + firstDate: + DateTime(1990), + + onChanged: (value) { + setState(() { + to = DateTime + .parse(value); + }); + }, + initialDate: from == + null + ? DateTime.now() + : from!.add( + const Duration( + days: 1)), + lastDate: + DateTime(2100), + decoration: + normalTextFieldStyle( + "To *", + "To *") + .copyWith( + prefixIcon: + const Icon( + Icons.date_range, + color: Colors + .black87, + ), + ), + initialValue: null, + ), + ), + ], + ); + }); + }), + ), + const SizedBox( + height: 12, + ), + //// total hours conducted + FormBuilderTextField( + validator: numericRequired, + name: "total_hours", + decoration: normalTextFieldStyle( + "Total Hours Conducted *", + "0"), + keyboardType: + TextInputType.number, + ), + const SizedBox( + height: 12, + ), + ////Address + StatefulBuilder( + builder: (context, setState) { + return Column( + children: [ + ////overseas textformfield + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, + decoration: + normalTextFieldStyle( + "Overseas Address?", + ''), + name: 'overseas', + title: Text(overseas + ? "YES" + : "NO"), + ), + SizedBox( + height: overseas == true + ? 8 + : 0, + ), + SizedBox( + child: overseas == false + ? Column( + children: [ + const SizedBox( + height: 12, + ), + ////REGION DROPDOWN + FormBuilderDropdown< + Region?>( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + onChanged: (Region? + region) async { + if (selectedRegion != + region) { + setState( + () { + provinceCall = + true; + }); + selectedRegion = + region; + getProvinces(); + } + }, + initialValue: + null, + decoration: + normalTextFieldStyle( + "Region*", + "Region"), + name: 'region', + items: state.regions.map< + DropdownMenuItem< + Region>>((Region + region) { + return DropdownMenuItem< + Region>( + value: + region, + child: Text( + region + .description!)); + }).toList(), + ), + const SizedBox( + height: 12, + ), + //// PROVINCE DROPDOWN + SizedBox( + height: 60, + child: + ModalProgressHUD( + color: Colors + .transparent, + inAsyncCall: + provinceCall, + child: DropdownButtonFormField< + Province?>( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: (value) => value == null + ? 'required' + : null, + isExpanded: + true, + value: + selectedProvince, + onChanged: + (Province? + province) { + if (selectedProvince != + province) { + setState( + () { + cityCall = + true; + }); + selectedProvince = + province; + getCities(); + } + }, + items: provinces == + null + ? [] + : provinces!.map>((Province + province) { + return DropdownMenuItem( + value: province, + child: FittedBox( + child: Text(province.description!), + )); + }).toList(), + decoration: normalTextFieldStyle( + "Province*", + "Province")), + ), + ), + ////CITY MUNICIPALITY + SizedBox( + height: 60, + child: + ModalProgressHUD( + color: Colors + .white, + inAsyncCall: + cityCall, + child: DropdownButtonFormField< + CityMunicipality>( + validator: FormBuilderValidators.required( + errorText: + "This field is required"), + isExpanded: + true, + onChanged: + (CityMunicipality? + city) { + if (selectedMunicipality != + city) { + setState( + () { + barangayCall = + true; + }); + selectedMunicipality = + city; + getBarangays(); + } + }, + decoration: normalTextFieldStyle( + "Municipality*", + "Municipality"), + value: + selectedMunicipality, + items: citymuns == + null + ? [] + : citymuns!.map< + DropdownMenuItem< + CityMunicipality>>((CityMunicipality + c) { + return DropdownMenuItem( + value: c, + child: Text(c.description!)); + }).toList(), + ), + ), + ), + //// BARANGAY + SizedBox( + height: 60, + child: + ModalProgressHUD( + color: Colors + .white, + inAsyncCall: + barangayCall, + child: DropdownButtonFormField< + Barangay>( + isExpanded: + true, + onChanged: + (Barangay? + baragay) { + selectedBarangay = + baragay; + }, + decoration: normalTextFieldStyle( + "Barangay*", + "Barangay"), + value: + selectedBarangay, + items: barangays == + null + ? [] + : barangays!.map< + DropdownMenuItem< + Barangay>>((Barangay + barangay) { + return DropdownMenuItem( + value: barangay, + child: Text(barangay.description!)); + }).toList(), ), - initialValue: null, ), ), ], - ); - }); - }), - ), - const SizedBox( - height: 12, - ), - //// total hours conducted - FormBuilderTextField( - validator: numericRequired, - name: "total_hours", - decoration: normalTextFieldStyle( - "Total Hours Conducted *", - "0"), - keyboardType: - TextInputType.number, - ), - const SizedBox( - height: 12, - ), - ////Address - StatefulBuilder( - builder: (context, setState) { - return Column( - children: [ - ////overseas textformfield - FormBuilderSwitch( - initialValue: overseas, - activeColor: second, - onChanged: (value) { - setState(() { - overseas = value!; - }); - }, - decoration: - normalTextFieldStyle( - "Overseas Address?", - ''), - name: 'overseas', - title: Text(overseas - ? "YES" - : "NO"), + ) + //// COUNTRY DROPDOWN + : SizedBox( + height: 60, + child: + FormBuilderDropdown< + Country>( + initialValue: + null, + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + items: state + .countries + .map< + DropdownMenuItem< + Country>>((Country + country) { + return DropdownMenuItem< + Country>( + value: + country, + child: FittedBox( + child: Text( + country.name!))); + }).toList(), + name: 'country', + decoration: + normalTextFieldStyle( + "Country*", + "Country"), + onChanged: + (Country? + value) { + selectedCountry = + value; + }, + ), ), - SizedBox( - height: overseas == true - ? 8 - : 0, - ), - SizedBox( - child: overseas == false - ? Column( - children: [ - const SizedBox( - height: 12, - ), - ////REGION DROPDOWN - FormBuilderDropdown< - Region?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - onChanged: (Region? - region) async { - if (selectedRegion != - region) { - setState( - () { - provinceCall = - true; - }); - selectedRegion = - region; - getProvinces(); - } - }, - initialValue: + ), + ], + ); + }), + + ////Conducted By + StatefulBuilder( + builder: (context, setState) { + ////has sponsor switch + return Column( + children: [ + ////Add Conducted Agency============ + SizedBox( + child: SizedBox( + child: Column(children: [ + SearchField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + itemHeight: 100, + focusNode: + conductedByFocusNode, + suggestions: state + .conductedBy + .map((Agency + agency) => + SearchFieldListItem( + agency + .name!, + item: + agency, + child: + ListTile( + title: + Text( + agency + .name!, + overflow: + TextOverflow.visible, + ), + subtitle: Text(agency.privateEntity == + true + ? "Private" + : agency.privateEntity == false + ? "Government" + : ""), + ))) + .toList(), + searchInputDecoration: + normalTextFieldStyle( + " Conducted By *", + "") + .copyWith( + suffixIcon: + GestureDetector( + child: const Icon( + Icons + .arrow_drop_down, + ), + onTap: () => + conductedByFocusNode + .unfocus(), + )), + ////SELETECTED + onSuggestionTap: + (agency) { + setState(() { + if (agency.item + ?.id != + null) { + selectedConductedByAgency = + Agency( + name: null, - decoration: - normalTextFieldStyle( - "Region*", - "Region"), - name: 'region', - items: state.regions.map< - DropdownMenuItem< - Region>>((Region - region) { - return DropdownMenuItem< - Region>( - value: - region, - child: Text( - region - .description!)); - }).toList(), - ), - const SizedBox( - height: 12, - ), - //// PROVINCE DROPDOWN - SizedBox( - height: 60, - child: - ModalProgressHUD( - color: Colors - .transparent, - inAsyncCall: - provinceCall, - child: DropdownButtonFormField< - Province?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: (value) => value == null - ? 'required' - : null, - isExpanded: - true, - value: - selectedProvince, - onChanged: - (Province? - province) { - if (selectedProvince != - province) { - setState( - () { - cityCall = - true; - }); - selectedProvince = - province; - getCities(); - } - }, - items: provinces == - null - ? [] - : provinces!.map>((Province - province) { - return DropdownMenuItem( - value: province, - child: FittedBox( - child: Text(province.description!), - )); - }).toList(), - decoration: normalTextFieldStyle( - "Province*", - "Province")), - ), - ), - ////CITY MUNICIPALITY - SizedBox( - height: 60, - child: - ModalProgressHUD( - color: Colors - .white, - inAsyncCall: - cityCall, - child: DropdownButtonFormField< - CityMunicipality>( - validator: FormBuilderValidators.required( - errorText: - "This field is required"), - isExpanded: - true, - onChanged: - (CityMunicipality? - city) { - if (selectedMunicipality != - city) { - setState( - () { - barangayCall = - true; - }); - selectedMunicipality = - city; - getBarangays(); - } - }, - decoration: normalTextFieldStyle( - "Municipality*", - "Municipality"), - value: - selectedMunicipality, - items: citymuns == - null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>((CityMunicipality - c) { - return DropdownMenuItem( - value: c, - child: Text(c.description!)); - }).toList(), - ), - ), - ), - //// BARANGAY - SizedBox( - height: 60, - child: - ModalProgressHUD( - color: Colors - .white, - inAsyncCall: - barangayCall, - child: DropdownButtonFormField< - Barangay>( - isExpanded: - true, - onChanged: - (Barangay? - baragay) { - selectedBarangay = - baragay; - }, - decoration: normalTextFieldStyle( - "Barangay*", - "Barangay"), - value: - selectedBarangay, - items: barangays == - null - ? [] - : barangays!.map< - DropdownMenuItem< - Barangay>>((Barangay - barangay) { - return DropdownMenuItem( - value: barangay, - child: Text(barangay.description!)); - }).toList(), - ), - ), - ), - ], - ) - //// COUNTRY DROPDOWN - : SizedBox( - height: 60, - child: - FormBuilderDropdown< - Country>( - initialValue: - null, - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - items: state - .countries - .map< - DropdownMenuItem< - Country>>((Country - country) { - return DropdownMenuItem< - Country>( - value: - country, - child: FittedBox( - child: Text( - country.name!))); - }).toList(), - name: 'country', + id: agency + .item! + .id); + } else { + selectedConductedByAgency = Agency( + id: null, + name: agency + .item! + .name); + } + + if (agency.item! + .privateEntity == + null) { + showConductedByAgencyCategory = + true; + showConductedByAgencyPrivateRadio = + true; + } else { + showConductedByAgencyCategory = + false; + showConductedByAgencyPrivateRadio = + false; + } + conductedByFocusNode + .unfocus(); + }); + }, + validator: (agency) { + if (agency! + .isEmpty) { + return "This field is required"; + } + return null; + }, + ////conducter empty widget + emptyWidget: + EmptyWidget( + controller: + addConductedByController, + onpressed: + () { + setState( + () { + Agency newAgency = Agency( + id: + null, + name: addConductedByController + .text + .toUpperCase(), + category: + null, + privateEntity: + null); + state + .conductedBy + .insert( + 0, + newAgency); + + addConductedByController + .text = ""; + Navigator.pop( + context); + }); + }, + title: + "Add Conducted By Agency")), + SizedBox( + height: + showConductedByAgencyCategory + ? 12 + : 0, + ), + ////Sponsor Agency Category + SizedBox( + child: + showConductedByAgencyCategory + ? SearchField( + suggestionDirection: + SuggestionDirection + .up, + focusNode: + conductedByAgencyCategoryFocusNode, + itemHeight: + 70, + suggestions: state + .agencyCategory + .map((Category category) => SearchFieldListItem( + category + .name!, + item: + category, + child: + ListTile( + title: Text(category.name!), + subtitle: Text(category.industryClass!.name!), + ))) + .toList(), + emptyWidget: + Container( + height: + 100, decoration: - normalTextFieldStyle( - "Country*", - "Country"), - onChanged: - (Country? - value) { - selectedCountry = - value; - }, + box1(), + child: const Center( + child: + Text("No result found ...")), ), - ), - ), - ], - ); - }), - - ////Conducted By - StatefulBuilder( - builder: (context, setState) { - ////has sponsor switch - return Column( - children: [ - ////Add Conducted Agency============ - SizedBox( - child: SizedBox( - child: Column(children: [ - SearchField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - itemHeight: 100, - focusNode: - conductedByFocusNode, - suggestions: state - .conductedBy - .map((Agency - agency) => - SearchFieldListItem( - agency - .name!, - item: - agency, - child: - ListTile( - title: - Text( - agency - .name!, - overflow: - TextOverflow.visible, - ), - subtitle: Text(agency.privateEntity == - true - ? "Private" - : agency.privateEntity == false - ? "Government" - : ""), - ))) - .toList(), - searchInputDecoration: - normalTextFieldStyle( - " Conducted By *", - "") - .copyWith( - suffixIcon: - GestureDetector( - child: const Icon( - Icons - .arrow_drop_down, - ), - onTap: () => - conductedByFocusNode - .unfocus(), - )), - ////SELETECTED - onSuggestionTap: - (agency) { - setState(() { - if (agency.item - ?.id != - null) { - selectedConductedByAgency = - Agency( - name: - null, - id: agency - .item! - .id); - } else { + onSuggestionTap: + (agencyCategory) { + setState( + () { + selectedConductedByAgencyCategory = + agencyCategory.item; selectedConductedByAgency = Agency( - id: null, - name: agency - .item! - .name); + id: selectedConductedByAgency + ?.id, + name: selectedConductedByAgency! + .name, + category: + selectedConductedByAgencyCategory, + privateEntity: + showConductedByAgencyPrivateRadio); + conductedByAgencyCategoryFocusNode + .unfocus(); + }); + }, + searchInputDecoration: normalTextFieldStyle( + "Category *", + "") + .copyWith( + suffixIcon: + IconButton( + icon: const Icon( + Icons + .arrow_drop_down), + onPressed: + () { + conductedByAgencyCategoryFocusNode + .unfocus(); + }, + )), + validator: + (value) { + if (value! + .isEmpty) { + return "This field is required"; } + return null; + }, + ) + : const SizedBox(), + ), - if (agency.item! - .privateEntity == - null) { - showConductedByAgencyCategory = - true; - showConductedByAgencyPrivateRadio = - true; - } else { - showConductedByAgencyCategory = - false; - showConductedByAgencyPrivateRadio = - false; - } - conductedByFocusNode + ////Sponsor Agency Private Radio + SizedBox( + height: + showConductedByAgencyPrivateRadio + ? 12 + : 0), + SizedBox( + child: showConductedByAgencyPrivateRadio + ? FormBuilderSwitch( + initialValue: + conductedByCategoryIsPrivate, + title: Text( + conductedByCategoryIsPrivate + ? "YES" + : "NO"), + decoration: normalTextFieldStyle( + "Private Entity?", + 'Private Entity?'), + + ////onvhange private sector + onChanged: + (value) { + setState( + () { + conductedByCategoryIsPrivate = + value!; + selectedConductedByAgency = Agency( + category: selectedConductedByAgency + ?.category, + id: selectedConductedByAgency + ?.id, + name: selectedConductedByAgency! + .name, + privateEntity: + conductedByCategoryIsPrivate); + conductedByAgencyCategoryFocusNode .unfocus(); }); }, - validator: (agency) { - if (agency! - .isEmpty) { - return "This field is required"; - } - return null; - }, - ////conducter empty widget - emptyWidget: - EmptyWidget( - controller: - addConductedByController, - onpressed: - () { - setState( - () { - Agency newAgency = Agency( - id: - null, - name: addConductedByController - .text - .toUpperCase(), - category: - null, - privateEntity: - null); - state - .conductedBy - .insert( - 0, - newAgency); + name: + 'sponsorAgencyPrivate', + validator: + FormBuilderValidators + .required(), + ) + : const SizedBox()), + ]), + )), + ], + ); + }), + ]), + ) + : const SizedBox()), + const SizedBox( + height: 12, + ), - addConductedByController - .text = ""; - Navigator.pop( - context); - }); - }, - title: - "Add Conducted By Agency")), - SizedBox( - height: - showConductedByAgencyCategory - ? 12 - : 0, - ), - ////Sponsor Agency Category - SizedBox( - child: - showConductedByAgencyCategory - ? SearchField( - suggestionDirection: - SuggestionDirection - .up, - focusNode: - conductedByAgencyCategoryFocusNode, - itemHeight: - 70, - suggestions: state - .agencyCategory - .map((Category category) => SearchFieldListItem( - category - .name!, - item: - category, - child: - ListTile( - title: Text(category.name!), - subtitle: Text(category.industryClass!.name!), - ))) - .toList(), - emptyWidget: - Container( - height: - 100, - decoration: - box1(), - child: const Center( - child: - Text("No result found ...")), - ), - onSuggestionTap: - (agencyCategory) { - setState( - () { - selectedConductedByAgencyCategory = - agencyCategory.item; - selectedConductedByAgency = Agency( - id: selectedConductedByAgency - ?.id, - name: selectedConductedByAgency! - .name, - category: - selectedConductedByAgencyCategory, - privateEntity: - showConductedByAgencyPrivateRadio); - conductedByAgencyCategoryFocusNode - .unfocus(); - }); - }, - searchInputDecoration: normalTextFieldStyle( - "Category *", - "") - .copyWith( - suffixIcon: - IconButton( - icon: const Icon( - Icons - .arrow_drop_down), - onPressed: - () { - conductedByAgencyCategoryFocusNode - .unfocus(); - }, - )), - validator: - (value) { - if (value! - .isEmpty) { - return "This field is required"; - } - return null; - }, - ) - : const SizedBox(), - ), - - ////Sponsor Agency Private Radio - SizedBox( - height: - showConductedByAgencyPrivateRadio - ? 12 - : 0), - SizedBox( - child: showConductedByAgencyPrivateRadio - ? FormBuilderSwitch( - initialValue: - conductedByCategoryIsPrivate, - title: Text( - conductedByCategoryIsPrivate - ? "YES" - : "NO"), - decoration: normalTextFieldStyle( - "Private Entity?", - 'Private Entity?'), - - ////onvhange private sector - onChanged: - (value) { - setState( - () { - conductedByCategoryIsPrivate = - value!; - selectedConductedByAgency = Agency( - category: selectedConductedByAgency - ?.category, - id: selectedConductedByAgency - ?.id, - name: selectedConductedByAgency! - .name, - privateEntity: - conductedByCategoryIsPrivate); - conductedByAgencyCategoryFocusNode - .unfocus(); - }); - }, - name: - 'sponsorAgencyPrivate', - validator: - FormBuilderValidators - .required(), - ) - : const SizedBox()), - ]), - )), - ], - ); - }), - ]), - ) - : const SizedBox()), - const SizedBox( - height: 12, - ), - - ////Sponsor - StatefulBuilder(builder: (context, setState) { - ////has sponsor switch - return Column( - children: [ - FormBuilderSwitch( - initialValue: hasSponsor, - activeColor: second, - onChanged: (value) { - setState(() { - hasSponsor = value!; - }); - }, - decoration: normalTextFieldStyle( - "Has Sponsor?", ''), - name: 'sponsor', - title: Text(hasSponsor ? "YES" : "NO"), - ), - ////Add Sponsor Agency============ - SizedBox( - child: hasSponsor - ? SizedBox( - child: Column(children: [ - const SizedBox( - height: 12, - ), - SearchField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - itemHeight: 110, - focusNode: - sponsorByFocusNode, - suggestions: state + ////Sponsor + StatefulBuilder(builder: (context, setState) { + ////has sponsor switch + return Column( + children: [ + FormBuilderSwitch( + initialValue: hasSponsor, + activeColor: second, + onChanged: (value) { + setState(() { + hasSponsor = value!; + }); + }, + decoration: normalTextFieldStyle( + "Has Sponsor?", ''), + name: 'sponsor', + title: Text(hasSponsor ? "YES" : "NO"), + ), + ////Add Sponsor Agency============ + SizedBox( + child: hasSponsor + ? SizedBox( + child: Column(children: [ + const SizedBox( + height: 12, + ), + SearchField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + itemHeight: 110, + focusNode: + sponsorByFocusNode, + suggestions: state + .sponsorAgencies + .map((Agency agency) => + SearchFieldListItem( + agency.name!, + item: agency, + child: ListTile( + title: Text( + agency + .name!, + overflow: + TextOverflow + .visible, + ), + subtitle: Text(agency + .privateEntity == + true + ? "Private" + : agency.privateEntity == + false + ? "Government" + : ""), + ))) + .toList(), + searchInputDecoration: + normalTextFieldStyle( + " Sponsor Agency *", + "") + .copyWith( + suffixIcon: + GestureDetector( + child: const Icon( + Icons.arrow_drop_down, + ), + onTap: () => + sponsorByFocusNode + .unfocus(), + )), + ////SELETECTED + onSuggestionTap: (agency) { + setState(() { + if (agency.item?.id != + null) { + selectedSponsorAgency = + Agency( + name: null, + id: agency + .item! + .id); + } else { + selectedSponsorAgency = + Agency( + id: null, + name: agency + .item! + .name); + } + if (agency.item! + .privateEntity == + null) { + showSponsorCategoryAgency = + true; + showSponsorAgencyPrivateRadio = + true; + } else { + showSponsorCategoryAgency = + false; + showSponsorAgencyPrivateRadio = + false; + } + sponsorByFocusNode + .unfocus(); + }); + }, + validator: (agency) { + if (agency!.isEmpty) { + return "This field is required"; + } + return null; + }, + ////sponsor empty widget + emptyWidget: EmptyWidget( + controller: + addSponsorAgencyController, + onpressed: () { + setState(() { + Agency newAgency = Agency( + id: null, + name: addSponsorAgencyController + .text + .toUpperCase(), + category: null, + privateEntity: + null); + state .sponsorAgencies - .map((Agency agency) => - SearchFieldListItem( - agency.name!, - item: agency, - child: ListTile( - title: Text( - agency - .name!, - overflow: - TextOverflow - .visible, - ), - subtitle: Text(agency - .privateEntity == - true - ? "Private" - : agency.privateEntity == - false - ? "Government" - : ""), - ))) - .toList(), - searchInputDecoration: - normalTextFieldStyle( - " Sponsor Agency *", - "") - .copyWith( - suffixIcon: - GestureDetector( - child: const Icon( - Icons.arrow_drop_down, - ), - onTap: () => - sponsorByFocusNode - .unfocus(), - )), - ////SELETECTED - onSuggestionTap: (agency) { - setState(() { - if (agency.item?.id != - null) { - selectedSponsorAgency = - Agency( - name: null, - id: agency - .item! - .id); - } else { - selectedSponsorAgency = - Agency( - id: null, - name: agency - .item! - .name); - } - if (agency.item! - .privateEntity == - null) { - showSponsorCategoryAgency = - true; - showSponsorAgencyPrivateRadio = - true; - } else { - showSponsorCategoryAgency = - false; - showSponsorAgencyPrivateRadio = - false; - } - sponsorByFocusNode - .unfocus(); - }); - }, - validator: (agency) { - if (agency!.isEmpty) { - return "This field is required"; - } - return null; - }, - ////sponsor empty widget - emptyWidget: EmptyWidget( - controller: - addSponsorAgencyController, - onpressed: () { - setState(() { - Agency newAgency = Agency( - id: null, - name: addSponsorAgencyController - .text - .toUpperCase(), - category: null, - privateEntity: - null); - state - .sponsorAgencies - .insert(0, - newAgency); + .insert(0, + newAgency); - addSponsorAgencyController - .text = ""; - Navigator.pop( - context); + addSponsorAgencyController + .text = ""; + Navigator.pop( + context); + }); + }, + title: + "Add Sponsor Agency")), + SizedBox( + height: + showSponsorCategoryAgency + ? 12 + : 0, + ), + ////Sponsor Agency Category + SizedBox( + child: + showSponsorCategoryAgency + ? SearchField( + suggestionDirection: + SuggestionDirection + .up, + focusNode: + sponsorAgencyCategoryFocusNode, + itemHeight: 70, + suggestions: state + .agencyCategory + .map((Category + category) => + SearchFieldListItem( + category + .name!, + item: + category, + child: + ListTile( + title: + Text(category.name!), + subtitle: + Text(category.industryClass!.name!), + ))) + .toList(), + emptyWidget: + Container( + height: 100, + decoration: + box1(), + child: const Center( + child: Text( + "No result found ...")), + ), + onSuggestionTap: + (agencyCategory) { + setState(() { + selectedSponsorAgencyCategory = + agencyCategory + .item; + selectedSponsorAgency = Agency( + id: selectedSponsorAgency + ?.id, + name: selectedSponsorAgency! + .name, + category: + selectedSponsorAgencyCategory, + privateEntity: + sponsorAgencyIsPrivate); + sponsorAgencyCategoryFocusNode + .unfocus(); + }); + }, + searchInputDecoration: + normalTextFieldStyle( + "Category *", + "") + .copyWith( + suffixIcon: + IconButton( + icon: const Icon( + Icons + .arrow_drop_down), + onPressed: () { + sponsorAgencyCategoryFocusNode + .unfocus(); + }, + )), + validator: + (value) { + if (value! + .isEmpty) { + return "This field is required"; + } + return null; + }, + ) + : const SizedBox(), + ), + + ////Sponsor Agency Private Radio + SizedBox( + height: + showSponsorAgencyPrivateRadio + ? 12 + : 0), + SizedBox( + child: + showSponsorAgencyPrivateRadio + ? FormBuilderSwitch( + initialValue: + sponsorAgencyIsPrivate, + title: Text( + sponsorAgencyIsPrivate + ? "YES" + : "NO"), + decoration: normalTextFieldStyle( + "Private Entity?", + 'Private Entity?'), + + ////onvhange private sector + onChanged: + (value) { + setState(() { + sponsorAgencyIsPrivate = + value!; + selectedSponsorAgency = Agency( + category: + selectedSponsorAgency + ?.category, + id: selectedSponsorAgency + ?.id, + name: selectedSponsorAgency! + .name, + privateEntity: + selectedSponsorAgency?.privateEntity); + sponsorAgencyCategoryFocusNode + .unfocus(); }); }, - title: - "Add Sponsor Agency")), - SizedBox( - height: - showSponsorCategoryAgency - ? 12 - : 0, - ), - ////Sponsor Agency Category - SizedBox( - child: - showSponsorCategoryAgency - ? SearchField( - suggestionDirection: - SuggestionDirection - .up, - focusNode: - sponsorAgencyCategoryFocusNode, - itemHeight: 70, - suggestions: state - .agencyCategory - .map((Category - category) => - SearchFieldListItem( - category - .name!, - item: - category, - child: - ListTile( - title: - Text(category.name!), - subtitle: - Text(category.industryClass!.name!), - ))) - .toList(), - emptyWidget: - Container( - height: 100, - decoration: - box1(), - child: const Center( - child: Text( - "No result found ...")), - ), - onSuggestionTap: - (agencyCategory) { - setState(() { - selectedSponsorAgencyCategory = - agencyCategory - .item; - selectedSponsorAgency = Agency( - id: selectedSponsorAgency - ?.id, - name: selectedSponsorAgency! - .name, - category: - selectedSponsorAgencyCategory, - privateEntity: - sponsorAgencyIsPrivate); - sponsorAgencyCategoryFocusNode - .unfocus(); - }); - }, - searchInputDecoration: - normalTextFieldStyle( - "Category *", - "") - .copyWith( - suffixIcon: - IconButton( - icon: const Icon( - Icons - .arrow_drop_down), - onPressed: () { - sponsorAgencyCategoryFocusNode - .unfocus(); - }, - )), - validator: - (value) { - if (value! - .isEmpty) { - return "This field is required"; - } - return null; - }, - ) - : const SizedBox(), - ), - ////Sponsor Agency Private Radio - SizedBox( - height: - showSponsorAgencyPrivateRadio - ? 12 - : 0), - SizedBox( - child: - showSponsorAgencyPrivateRadio - ? FormBuilderSwitch( - initialValue: - sponsorAgencyIsPrivate, - title: Text( - sponsorAgencyIsPrivate - ? "YES" - : "NO"), - decoration: normalTextFieldStyle( - "Private Entity?", - 'Private Entity?'), + name: + 'sponsorAgencyPrivate', + validator: + FormBuilderValidators + .required(), + ) + : const SizedBox()), + ]), + ) + : const SizedBox(), + ), + ], + ); + }), - ////onvhange private sector - onChanged: - (value) { - setState(() { - sponsorAgencyIsPrivate = - value!; - selectedSponsorAgency = Agency( - category: - selectedSponsorAgency - ?.category, - id: selectedSponsorAgency - ?.id, - name: selectedSponsorAgency! - .name, - privateEntity: - selectedSponsorAgency?.privateEntity); - sponsorAgencyCategoryFocusNode - .unfocus(); - }); - }, - - name: - 'sponsorAgencyPrivate', - validator: - FormBuilderValidators - .required(), - ) - : const SizedBox()), - ]), - ) - : const SizedBox(), - ), - ], - ); - }), - - const SizedBox( - height: 12, - ), - FormBuilderTextField( - validator: numericRequired, - name: "total_hours_attended", - keyboardType: TextInputType.number, - decoration: normalTextFieldStyle( - "Total Hours Attended *", - "Total Hours Attended *"), - ), - ], - ), - ), - SizedBox( - width: double.infinity, - height: 60, - child: ElevatedButton( - style: mainBtnStyle( - primary, Colors.transparent, second), - child: const Text(submit), - onPressed: () { - if (formKey.currentState!.saveAndValidate()) { - ConductedTraining? training; - Agency? sponsor; - Venue venue; - ////Address - if (overseas) { - venue = Venue( - id: null, - country: selectedCountry, - barangay: null, - category: null, - areaClass: null, - cityMunicipality: null); - } else { - venue = Venue( - id: null, - country: Country( - id: 175, - name: 'Philippines', - code: 'PH'), - barangay: selectedBarangay, - areaClass: null, - category: null, - cityMunicipality: selectedMunicipality); - } - if (showTrainingDetails) { - training = ConductedTraining( - locked: false, - id: selectedConductedTraining!.id, - venue: Venue( - country: selectedConductedTraining! - .venue!.country)); - } else { - training = ConductedTraining( - title: selectedTraining, - topic: selectedTopic, - id: null, - locked: false, - venue: venue, - toDate: - DateTime.parse(toDateController.text), - fromDate: DateTime.parse( - fromDateController.text), - totalHours: double.parse(formKey - .currentState!.value['total_hours']), - conductedBy: selectedConductedByAgency, - sessionsAttended: [], - learningDevelopmentType: - selectedLearningDevelopmentType); - } - if (hasSponsor) { - sponsor = selectedSponsorAgency; - } - LearningDevelopement learningDevelopement = - LearningDevelopement( - attachments: null, - sponsoredBy: sponsor, - conductedTraining: training, - totalHoursAttended: double.parse(formKey - .currentState! - .value['total_hours_attended'])); - final progress = ProgressHUD.of(context); - progress!.showWithText("Loading..."); - context.read().add( - AddLearningAndDevelopment( - learningDevelopement: - learningDevelopement, - profileId: widget.profileId, - token: widget.token)); + const SizedBox( + height: 12, + ), + FormBuilderTextField( + validator: numericRequired, + name: "total_hours_attended", + keyboardType: TextInputType.number, + decoration: normalTextFieldStyle( + "Total Hours Attended *", + "Total Hours Attended *"), + ), + const SizedBox(height: 16,), + SizedBox( + width: double.infinity, + height: 60, + child: ElevatedButton( + style: mainBtnStyle( + primary, Colors.transparent, second), + child: const Text(submit), + onPressed: () { + if (formKey.currentState!.saveAndValidate()) { + ConductedTraining? training; + Agency? sponsor; + Venue venue; + ////Address + if (overseas) { + venue = Venue( + id: null, + country: selectedCountry, + barangay: null, + category: null, + areaClass: null, + cityMunicipality: null); + } else { + venue = Venue( + id: null, + country: Country( + id: 175, + name: 'Philippines', + code: 'PH'), + barangay: selectedBarangay, + areaClass: null, + category: null, + cityMunicipality: selectedMunicipality); } - }, - ), + if (showTrainingDetails) { + training = ConductedTraining( + locked: false, + id: selectedConductedTraining!.id, + venue: Venue( + country: selectedConductedTraining! + .venue!.country)); + } else { + training = ConductedTraining( + title: selectedTraining, + topic: selectedTopic, + id: null, + locked: false, + venue: venue, + toDate: + DateTime.parse(toDateController.text), + fromDate: DateTime.parse( + fromDateController.text), + totalHours: double.parse(formKey + .currentState!.value['total_hours']), + conductedBy: selectedConductedByAgency, + sessionsAttended: [], + learningDevelopmentType: + selectedLearningDevelopmentType); + } + if (hasSponsor) { + sponsor = selectedSponsorAgency; + } + LearningDevelopement learningDevelopement = + LearningDevelopement( + attachments: null, + sponsoredBy: sponsor, + conductedTraining: training, + totalHoursAttended: double.parse(formKey + .currentState! + .value['total_hours_attended'])); + final progress = ProgressHUD.of(context); + progress!.showWithText("Loading..."); + context.read().add( + AddLearningAndDevelopment( + learningDevelopement: + learningDevelopement, + profileId: widget.profileId, + token: widget.token)); + } + }, ), - ], - ); - }), - ), + ), + ], + ); + }), )); } return const Center( diff --git a/lib/screens/profile/components/learning_development/edit_modal.dart b/lib/screens/profile/components/learning_development/edit_modal.dart index ea5e04e..6937150 100644 --- a/lib/screens/profile/components/learning_development/edit_modal.dart +++ b/lib/screens/profile/components/learning_development/edit_modal.dart @@ -185,1387 +185,1380 @@ class _EditLearningAndDevelopmentScreenState to = state.learningDevelopement.conductedTraining?.toDate; return FormBuilder( key: formKey, - child: SizedBox( - height: screenHeight * 90, - child: Padding( - padding: const EdgeInsets.all(24), - child: Column( - children: [ - Flexible( - child: ListView( - children: [ - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - const SizedBox( - height: 10, - ), - SizedBox( - ////Training selected Textfield - child: FormBuilderTextField( - inputFormatters: [UpperCaseTextFormatter()], - onChanged: (value) { - selectedTraining = + child: Padding( + padding: const EdgeInsets.all(24), + child: ListView( + children: [ + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + const SizedBox( + height: 10, + ), + SizedBox( + ////Training selected Textfield + child: FormBuilderTextField( + inputFormatters: [UpperCaseTextFormatter()], + onChanged: (value) { + selectedTraining = + LearningDevelopmentType( + id: null, + title: selectedTrainingController + .text); + }, + enabled: enabled, + maxLines: 5, + controller: selectedTrainingController, + name: "", + decoration: normalTextFieldStyle("", "") + .copyWith( + labelText: "Training", + filled: !enabled, + fillColor: Colors.grey.shade300), + )), + SizedBox( + child: SizedBox( + child: Column(children: [ + const SizedBox( + height: 12, + ), + ////learning development type + FormBuilderDropdown< + LearningDevelopmentType>( + enabled: enabled, + name: "types", + decoration: normalTextFieldStyle( + "Learning Development Type *", + "") + .copyWith( + filled: !enabled, + fillColor: + Colors.grey.shade300), + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + items: state.types + .map((e) => DropdownMenuItem< + LearningDevelopmentType>( + value: e, + child: Text(e.title!))) + .toList(), + onChanged: (value) { + selectedLearningDevelopmentType = + value; + }, + initialValue: + selectedLearningDevelopmentType, + ), + + //// learning development topics + const SizedBox( + height: 12, + ), + StatefulBuilder( + builder: (context, setState) { + return SearchField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + + enabled: enabled, + controller: currentTopicController, + focusNode: topicFocusNode, + itemHeight: 100, + suggestionsDecoration: box1(), + suggestions: state.topics + .map((LearningDevelopmentType + topic) => + SearchFieldListItem( + topic.title!, + item: topic, + child: Padding( + padding: + const EdgeInsets + .symmetric( + horizontal: + 10), + child: ListTile( + title: Text( + topic.title!, + softWrap: true, + ), + )))) + .toList(), + + searchInputDecoration: + normalTextFieldStyle("Topic *", + "") + .copyWith( + filled: !enabled, + fillColor: + Colors.grey.shade300, + suffixIcon: IconButton( + icon: const Icon(Icons + .arrow_drop_down), + onPressed: () { + topicFocusNode + .unfocus(); + }, + )), + onSuggestionTap: (topic) { + if (topic.item?.id != null) { + selectedTopic = + LearningDevelopmentType( + id: topic.item!.id, + title: null); + } else { + selectedTopic = LearningDevelopmentType( id: null, - title: selectedTrainingController - .text); - }, - enabled: enabled, - maxLines: 5, - controller: selectedTrainingController, - name: "", - decoration: normalTextFieldStyle("", "") - .copyWith( - labelText: "Training", - filled: !enabled, - fillColor: Colors.grey.shade300), - )), - SizedBox( - child: SizedBox( - child: Column(children: [ - const SizedBox( - height: 12, - ), - ////learning development type - FormBuilderDropdown< - LearningDevelopmentType>( - enabled: enabled, - name: "types", - decoration: normalTextFieldStyle( - "Learning Development Type *", - "") - .copyWith( - filled: !enabled, - fillColor: - Colors.grey.shade300), - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - items: state.types - .map((e) => DropdownMenuItem< - LearningDevelopmentType>( - value: e, - child: Text(e.title!))) - .toList(), - onChanged: (value) { - selectedLearningDevelopmentType = - value; - }, - initialValue: - selectedLearningDevelopmentType, - ), + title: topic.item!.title); + } + setState(() { + topicFocusNode.unfocus(); + }); + }, + ////EMPTY WIDGET + emptyWidget: EmptyWidget( + title: "Add Topic", + controller: addTopicController, + onpressed: () { + setState(() { + LearningDevelopmentType + newTopic = + LearningDevelopmentType( + id: null, + title: + addTopicController + .text + .toUpperCase()); + state.topics + .insert(0, newTopic); + topicFocusNode.unfocus(); + addTopicController.text = ""; + Navigator.pop(context); + }); + }), + validator: (position) { + if (position!.isEmpty) { + return "This field is required"; + } + return null; + }, + ); + }), - //// learning development topics - const SizedBox( - height: 12, - ), - StatefulBuilder( - builder: (context, setState) { - return SearchField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - - enabled: enabled, - controller: currentTopicController, - focusNode: topicFocusNode, - itemHeight: 100, - suggestionsDecoration: box1(), - suggestions: state.topics - .map((LearningDevelopmentType - topic) => - SearchFieldListItem( - topic.title!, - item: topic, - child: Padding( - padding: - const EdgeInsets - .symmetric( - horizontal: - 10), - child: ListTile( - title: Text( - topic.title!, - softWrap: true, - ), - )))) - .toList(), - - searchInputDecoration: - normalTextFieldStyle("Topic *", - "") + const SizedBox( + height: 12, + ), + SizedBox( + width: screenWidth, + child: Row( + children: [ + //// FROM DATE + Flexible( + flex: 1, + child: DateTimePicker( + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + use24HourFormat: false, + icon: const Icon( + Icons.date_range), + controller: + fromDateController, + firstDate: DateTime(1990), + lastDate: DateTime(2100), + selectableDayPredicate: + (date) { + if (to != null && + to!.microsecondsSinceEpoch < + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, + onChanged: (value) { + setState(() { + from = + DateTime.tryParse(value); + }); + }, + initialDate: to??=DateTime.now(), + timeHintText: + "Date of Examination/Conferment", + decoration: + normalTextFieldStyle( + "From *", "From *") .copyWith( filled: !enabled, - fillColor: - Colors.grey.shade300, - suffixIcon: IconButton( - icon: const Icon(Icons - .arrow_drop_down), + fillColor: Colors + .grey + .shade300, + prefixIcon: + const Icon( + Icons + .date_range, + color: Colors + .black87, + )), + )), + const SizedBox( + width: 12, + ), + //// TO DATE + Flexible( + flex: 1, + child: DateTimePicker( + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + controller: toDateController, + firstDate: DateTime(1990), + lastDate: DateTime(2100), + decoration: + normalTextFieldStyle( + "To *", "To *") + .copyWith( + filled: !enabled, + fillColor: + Colors.grey.shade300, + prefixIcon: const Icon( + Icons.date_range, + color: Colors.black87, + ), + ), + selectableDayPredicate: (date) { + if (from != null && + from!.microsecondsSinceEpoch > + date.microsecondsSinceEpoch) { + return false; + } + return true; + }, + onChanged: (value) { + setState(() { + to = DateTime.tryParse(value); + }); + }, + initialDate: from??=DateTime.now() + ), + ), + ], + ), + ), + const SizedBox( + height: 12, + ), + //// total hours conducted + FormBuilderTextField( + initialValue: state.learningDevelopement + .conductedTraining!.totalHours + .toString(), + validator: numericRequired, + name: "total_hours", + decoration: normalTextFieldStyle( + "Total Hours Conducted *", + "0", + ).copyWith( + filled: !enabled, + fillColor: Colors.grey.shade300), + keyboardType: TextInputType.number, + ), + const SizedBox( + height: 12, + ), + ////Address + + const SizedBox( + height: 12, + ), + StatefulBuilder( + builder: (context, setState) { + return Column( + children: [ + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, + decoration: normalTextFieldStyle( + "Overseas Address?", ''), + name: 'overseas', + title: + Text(overseas ? "YES" : "NO"), + ), + SizedBox( + height: overseas == true ? 8 : 0, + ), + SizedBox( + child: overseas == false + ? Column( + children: [ + const SizedBox( + height: 12, + ), + ////REGION DROPDOWN + FormBuilderDropdown< + Region?>( + enabled: !enabled + ? overseas + : true, + name: "region", + isExpanded: true, + initialValue: + selectedRegion, + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + onChanged: (Region? + region) async { + if (selectedRegion != + region) { + setState(() { + provinceCall = + true; + }); + selectedRegion = + region; + //// GET PROVINCES + try { + provinces = await LocationUtils + .instance + .getProvinces( + regionCode: selectedRegion! + .code + .toString()); + } catch (e) { + context + .read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } + selectedProvince = + provinces![0]; + setState(() { + provinceCall = + false; + cityCall = true; + }); + //// GET CITIES + try { + citymuns = await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = + false; + barangayCall = + true; + }); + //// GET BARANGAY + try { + barangays = await LocationUtils + .instance + .getBarangay( + code: selectedMunicipality! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } + selectedBarangay = + barangays![0]; + setState(() { + barangayCall = + false; + }); + ////GET CITY MUNICIPALITY + try { + citymuns = await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = + false; + barangayCall = + true; + }); + //// GET BARANGAYS + try { + barangays = await LocationUtils + .instance + .getBarangay( + code: selectedMunicipality! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } + selectedBarangay = + barangays![0]; + setState(() { + barangayCall = + false; + }); + } + }, + decoration: normalTextFieldStyle( + "Region*", + "Region") + .copyWith( + filled: !enabled + ? !overseas + : false, + fillColor: Colors + .grey + .shade300), + items: state.regions.map< + DropdownMenuItem< + Region>>((Region + region) { + return DropdownMenuItem< + Region>( + value: region, + child: Text(region + .description!)); + }).toList(), + ), + const SizedBox( + height: 8, + ), + //// PROVINCE DROPDOWN + SizedBox( + height: 60, + child: + ModalProgressHUD( + color: Colors + .transparent, + inAsyncCall: + provinceCall, + child: + DropdownButtonFormField< + Province?>( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: (value) => value == null + ? 'required' + : null, + isExpanded: + true, + value: + selectedProvince, + onChanged: + (Province? + province) async { + if (selectedProvince != + province) { + selectedProvince = + province; + setState( + () { + cityCall = + true; + }); + + //// GET CITIES + try { + citymuns = await LocationUtils + .instance + .getCities(code: selectedProvince!.code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read() + .add(CallErrorState(message: e.toString())); + } + selectedMunicipality = + citymuns![0]; + setState( + () { + cityCall = + false; + barangayCall = + true; + }); + //// GET BARANGAY + try { + barangays = await LocationUtils + .instance + .getBarangay(code: selectedMunicipality!.code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read() + .add(CallErrorState(message: e.toString())); + } + selectedBarangay = + barangays![0]; + setState( + () { + barangayCall = + false; + }); + } + }, + items: provinces == + null + ? [] + : provinces!.map>((Province + province) { + return DropdownMenuItem( + enabled: !enabled ? overseas : true, + value: province, + child: FittedBox( + child: Text(province.description!), + )); + }).toList(), + decoration: normalTextFieldStyle("Province*", "Province").copyWith( + filled: !enabled + ? !overseas + : false, + fillColor: Colors + .grey + .shade300)), + ), + ), + ////CITY MUNICIPALITY + SizedBox( + height: 60, + child: + ModalProgressHUD( + color: Colors.white, + inAsyncCall: + cityCall, + child: DropdownButtonFormField< + CityMunicipality>( + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + isExpanded: true, + onChanged: + (CityMunicipality? + city) async { + if (selectedMunicipality != + city) { + setState(() { + barangayCall = + true; + }); + selectedMunicipality = + city; + + //// GET BARANGAYS + try { + barangays = await LocationUtils + .instance + .getBarangay( + code: + selectedMunicipality!.code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + LearningDevelopmentBloc>() + .add(CallErrorState( + message: + e.toString())); + } + selectedBarangay = + barangays![ + 0]; + setState(() { + barangayCall = + false; + }); + } + }, + decoration: normalTextFieldStyle( + "Municipality*", + "Municipality") + .copyWith( + filled: !enabled + ? !overseas + : false, + fillColor: Colors + .grey + .shade300), + value: + selectedMunicipality, + items: citymuns == + null + ? [] + : citymuns!.map< + DropdownMenuItem< + CityMunicipality>>( + (CityMunicipality + c) { + return DropdownMenuItem( + enabled: !enabled + ? overseas + : true, + value: + c, + child: + Text(c.description!)); + }).toList(), + ), + ), + ), + //// BARANGAY + SizedBox( + height: 60, + child: + ModalProgressHUD( + color: Colors.white, + inAsyncCall: + barangayCall, + child: + DropdownButtonFormField< + Barangay>( + isExpanded: true, + onChanged: + (Barangay? + baragay) { + selectedBarangay = + baragay; + }, + decoration: normalTextFieldStyle( + "Barangay*", + "Barangay") + .copyWith( + filled: !enabled + ? !overseas + : false, + fillColor: Colors + .grey + .shade300), + value: + selectedBarangay, + items: barangays == + null + ? [] + : barangays!.map< + DropdownMenuItem< + Barangay>>((Barangay + barangay) { + return DropdownMenuItem( + enabled: !enabled + ? overseas + : true, + value: + barangay, + child: + Text(barangay.description!)); + }).toList(), + ), + ), + ), + ], + ) + //// COUNTRY DROPDOWN + : SizedBox( + height: 60, + child: + FormBuilderDropdown< + Country>( + enabled: overseas, + initialValue: + selectedCountry + ?.id == + 175 + ? null + : selectedCountry, + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + items: state.countries.map< + DropdownMenuItem< + Country>>( + (Country country) { + return DropdownMenuItem< + Country>( + value: country, + child: FittedBox( + child: Text( + country + .name!))); + }).toList(), + name: 'country', + decoration: normalTextFieldStyle( + "Country*", + "Country") + .copyWith( + filled: + !overseas, + fillColor: Colors + .grey + .shade300), + onChanged: + (Country? value) { + selectedCountry = + value; + }, + ), + ), + ), + ], + ); + }), + + ////Conducted By + StatefulBuilder( + builder: (context, setState) { + ////has sponsor switch + return Column( + children: [ + ////Add Conducted Agency============ + SizedBox( + child: SizedBox( + child: Column(children: [ + SearchField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + enabled: enabled, + controller: + selectedConductedByController, + itemHeight: 100, + focusNode: + conductedByFocusNode, + suggestions: state + .conductedBy + .map((Agency agency) => + SearchFieldListItem( + agency.name!, + item: agency, + child: ListTile( + title: Text( + agency + .name!, + overflow: + TextOverflow + .visible, + ), + subtitle: Text(agency + .privateEntity == + true + ? "Private" + : agency.privateEntity == + false + ? "Government" + : ""), + ))) + .toList(), + searchInputDecoration: + normalTextFieldStyle( + " Conducted By *", + "") + .copyWith( + suffixIcon: + GestureDetector( + child: + const Icon( + Icons + .arrow_drop_down, + ), + onTap: () => + conductedByFocusNode + .unfocus(), + ), + filled: + !enabled, + fillColor: Colors + .grey + .shade300), + ////SELETECTED + onSuggestionTap: (agency) { + setState(() { + if (agency.item?.id != + null) { + selectedConductedByAgency = + Agency( + name: null, + id: agency + .item! + .id); + } else { + selectedConductedByAgency = + Agency( + id: null, + name: agency + .item! + .name); + } + + if (agency.item! + .privateEntity == + null) { + showConductedByAgencyCategory = + true; + showConductedByAgencyPrivateRadio = + true; + } else { + showConductedByAgencyCategory = + false; + showConductedByAgencyPrivateRadio = + false; + } + conductedByFocusNode + .unfocus(); + }); + }, + validator: (agency) { + if (agency!.isEmpty) { + return "This field is required"; + } + return null; + }, + ////conducter empty widget + emptyWidget: EmptyWidget( + controller: + addConductedByController, + onpressed: () { + setState(() { + Agency newAgency = Agency( + id: null, + name: addConductedByController + .text + .toUpperCase(), + category: null, + privateEntity: + null); + state.conductedBy + .insert(0, + newAgency); + + addConductedByController + .text = ""; + Navigator.pop( + context); + }); + }, + title: + "Add Conducted By Agency")), + SizedBox( + height: + showConductedByAgencyCategory + ? 12 + : 0, + ), + ////Conducted By Agency Category + SizedBox( + child: + showConductedByAgencyCategory + ? SearchField( + focusNode: + conductedByAgencyCategoryFocusNode, + itemHeight: 70, + suggestions: state + .agencyCategory + .map((Category + category) => + SearchFieldListItem( + category + .name!, + item: + category, + child: + ListTile( + title: + Text(category.name!), + subtitle: + Text(category.industryClass!.name!), + ))) + .toList(), + emptyWidget: + Container( + height: 100, + decoration: + box1(), + child: const Center( + child: Text( + "No result found ...")), + ), + onSuggestionTap: + (agencyCategory) { + setState(() { + selectedConductedByAgencyCategory = + agencyCategory + .item; + selectedConductedByAgency = Agency( + id: selectedConductedByAgency + ?.id, + name: selectedConductedByAgency! + .name, + category: + selectedConductedByAgencyCategory, + privateEntity: + showConductedByAgencyPrivateRadio); + conductedByAgencyCategoryFocusNode + .unfocus(); + }); + }, + searchInputDecoration: + normalTextFieldStyle( + "Category *", + "") + .copyWith( + suffixIcon: + IconButton( + icon: const Icon( + Icons + .arrow_drop_down), onPressed: () { - topicFocusNode + conductedByAgencyCategoryFocusNode .unfocus(); }, )), - onSuggestionTap: (topic) { - if (topic.item?.id != null) { - selectedTopic = - LearningDevelopmentType( - id: topic.item!.id, - title: null); - } else { - selectedTopic = - LearningDevelopmentType( - id: null, - title: topic.item!.title); - } - setState(() { - topicFocusNode.unfocus(); - }); - }, - ////EMPTY WIDGET - emptyWidget: EmptyWidget( - title: "Add Topic", - controller: addTopicController, - onpressed: () { - setState(() { - LearningDevelopmentType - newTopic = - LearningDevelopmentType( - id: null, - title: - addTopicController - .text - .toUpperCase()); - state.topics - .insert(0, newTopic); - topicFocusNode.unfocus(); - addTopicController.text = ""; - Navigator.pop(context); - }); - }), - validator: (position) { - if (position!.isEmpty) { - return "This field is required"; - } - return null; - }, - ); - }), - - const SizedBox( - height: 12, - ), - SizedBox( - width: screenWidth, - child: Row( - children: [ - //// FROM DATE - Flexible( - flex: 1, - child: DateTimePicker( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - use24HourFormat: false, - icon: const Icon( - Icons.date_range), - controller: - fromDateController, - firstDate: DateTime(1990), - lastDate: DateTime(2100), - selectableDayPredicate: - (date) { - if (to != null && - to!.microsecondsSinceEpoch < - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - from = - DateTime.tryParse(value); - }); - }, - initialDate: to??=DateTime.now(), - timeHintText: - "Date of Examination/Conferment", - decoration: - normalTextFieldStyle( - "From *", "From *") - .copyWith( - filled: !enabled, - fillColor: Colors - .grey - .shade300, - prefixIcon: - const Icon( - Icons - .date_range, - color: Colors - .black87, - )), - )), - const SizedBox( - width: 12, - ), - //// TO DATE - Flexible( - flex: 1, - child: DateTimePicker( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - controller: toDateController, - firstDate: DateTime(1990), - lastDate: DateTime(2100), - decoration: - normalTextFieldStyle( - "To *", "To *") - .copyWith( - filled: !enabled, - fillColor: - Colors.grey.shade300, - prefixIcon: const Icon( - Icons.date_range, - color: Colors.black87, - ), - ), - selectableDayPredicate: (date) { - if (from != null && - from!.microsecondsSinceEpoch > - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - to = DateTime.tryParse(value); - }); - }, - initialDate: from??=DateTime.now() - ), - ), - ], - ), - ), - const SizedBox( - height: 12, - ), - //// total hours conducted - FormBuilderTextField( - initialValue: state.learningDevelopement - .conductedTraining!.totalHours - .toString(), - validator: numericRequired, - name: "total_hours", - decoration: normalTextFieldStyle( - "Total Hours Conducted *", - "0", - ).copyWith( - filled: !enabled, - fillColor: Colors.grey.shade300), - keyboardType: TextInputType.number, - ), - const SizedBox( - height: 12, - ), - ////Address - - const SizedBox( - height: 12, - ), - StatefulBuilder( - builder: (context, setState) { - return Column( - children: [ - FormBuilderSwitch( - initialValue: overseas, - activeColor: second, - onChanged: (value) { - setState(() { - overseas = value!; - }); - }, - decoration: normalTextFieldStyle( - "Overseas Address?", ''), - name: 'overseas', - title: - Text(overseas ? "YES" : "NO"), - ), - SizedBox( - height: overseas == true ? 8 : 0, - ), - SizedBox( - child: overseas == false - ? Column( - children: [ - const SizedBox( - height: 12, - ), - ////REGION DROPDOWN - FormBuilderDropdown< - Region?>( - enabled: !enabled - ? overseas - : true, - name: "region", - isExpanded: true, - initialValue: - selectedRegion, - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: - FormBuilderValidators - .required( - errorText: - "This field is required"), - onChanged: (Region? - region) async { - if (selectedRegion != - region) { - setState(() { - provinceCall = - true; - }); - selectedRegion = - region; - //// GET PROVINCES - try { - provinces = await LocationUtils - .instance - .getProvinces( - regionCode: selectedRegion! - .code - .toString()); - } catch (e) { - context - .read< - LearningDevelopmentBloc>() - .add(CallErrorState( - message: - e.toString())); - } - selectedProvince = - provinces![0]; - setState(() { - provinceCall = - false; - cityCall = true; - }); - //// GET CITIES - try { - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - LearningDevelopmentBloc>() - .add(CallErrorState( - message: - e.toString())); - } - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = - false; - barangayCall = - true; - }); - //// GET BARANGAY - try { - barangays = await LocationUtils - .instance - .getBarangay( - code: selectedMunicipality! - .code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - LearningDevelopmentBloc>() - .add(CallErrorState( - message: - e.toString())); - } - selectedBarangay = - barangays![0]; - setState(() { - barangayCall = - false; - }); - ////GET CITY MUNICIPALITY - try { - citymuns = await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - LearningDevelopmentBloc>() - .add(CallErrorState( - message: - e.toString())); - } - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = - false; - barangayCall = - true; - }); - //// GET BARANGAYS - try { - barangays = await LocationUtils - .instance - .getBarangay( - code: selectedMunicipality! - .code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - LearningDevelopmentBloc>() - .add(CallErrorState( - message: - e.toString())); - } - selectedBarangay = - barangays![0]; - setState(() { - barangayCall = - false; - }); - } - }, - decoration: normalTextFieldStyle( - "Region*", - "Region") - .copyWith( - filled: !enabled - ? !overseas - : false, - fillColor: Colors - .grey - .shade300), - items: state.regions.map< - DropdownMenuItem< - Region>>((Region - region) { - return DropdownMenuItem< - Region>( - value: region, - child: Text(region - .description!)); - }).toList(), - ), - const SizedBox( - height: 8, - ), - //// PROVINCE DROPDOWN - SizedBox( - height: 60, - child: - ModalProgressHUD( - color: Colors - .transparent, - inAsyncCall: - provinceCall, - child: - DropdownButtonFormField< - Province?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: (value) => value == null - ? 'required' - : null, - isExpanded: - true, - value: - selectedProvince, - onChanged: - (Province? - province) async { - if (selectedProvince != - province) { - selectedProvince = - province; - setState( - () { - cityCall = - true; - }); - - //// GET CITIES - try { - citymuns = await LocationUtils - .instance - .getCities(code: selectedProvince!.code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read() - .add(CallErrorState(message: e.toString())); - } - selectedMunicipality = - citymuns![0]; - setState( - () { - cityCall = - false; - barangayCall = - true; - }); - //// GET BARANGAY - try { - barangays = await LocationUtils - .instance - .getBarangay(code: selectedMunicipality!.code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read() - .add(CallErrorState(message: e.toString())); - } - selectedBarangay = - barangays![0]; - setState( - () { - barangayCall = - false; - }); - } - }, - items: provinces == - null - ? [] - : provinces!.map>((Province - province) { - return DropdownMenuItem( - enabled: !enabled ? overseas : true, - value: province, - child: FittedBox( - child: Text(province.description!), - )); - }).toList(), - decoration: normalTextFieldStyle("Province*", "Province").copyWith( - filled: !enabled - ? !overseas - : false, - fillColor: Colors - .grey - .shade300)), - ), - ), - ////CITY MUNICIPALITY - SizedBox( - height: 60, - child: - ModalProgressHUD( - color: Colors.white, - inAsyncCall: - cityCall, - child: DropdownButtonFormField< - CityMunicipality>( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - isExpanded: true, - onChanged: - (CityMunicipality? - city) async { - if (selectedMunicipality != - city) { - setState(() { - barangayCall = - true; - }); - selectedMunicipality = - city; - - //// GET BARANGAYS - try { - barangays = await LocationUtils - .instance - .getBarangay( - code: - selectedMunicipality!.code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - LearningDevelopmentBloc>() - .add(CallErrorState( - message: - e.toString())); - } - selectedBarangay = - barangays![ - 0]; - setState(() { - barangayCall = - false; - }); - } - }, - decoration: normalTextFieldStyle( - "Municipality*", - "Municipality") - .copyWith( - filled: !enabled - ? !overseas - : false, - fillColor: Colors - .grey - .shade300), - value: - selectedMunicipality, - items: citymuns == - null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality - c) { - return DropdownMenuItem( - enabled: !enabled - ? overseas - : true, - value: - c, - child: - Text(c.description!)); - }).toList(), - ), - ), - ), - //// BARANGAY - SizedBox( - height: 60, - child: - ModalProgressHUD( - color: Colors.white, - inAsyncCall: - barangayCall, - child: - DropdownButtonFormField< - Barangay>( - isExpanded: true, - onChanged: - (Barangay? - baragay) { - selectedBarangay = - baragay; - }, - decoration: normalTextFieldStyle( - "Barangay*", - "Barangay") - .copyWith( - filled: !enabled - ? !overseas - : false, - fillColor: Colors - .grey - .shade300), - value: - selectedBarangay, - items: barangays == - null - ? [] - : barangays!.map< - DropdownMenuItem< - Barangay>>((Barangay - barangay) { - return DropdownMenuItem( - enabled: !enabled - ? overseas - : true, - value: - barangay, - child: - Text(barangay.description!)); - }).toList(), - ), - ), - ), - ], + validator: + (value) { + if (value! + .isEmpty) { + return "This field is required"; + } + return null; + }, ) - //// COUNTRY DROPDOWN - : SizedBox( - height: 60, - child: - FormBuilderDropdown< - Country>( - enabled: overseas, + : const SizedBox(), + ), + + ////Sponsor Agency Private Radio + SizedBox( + height: + showConductedByAgencyPrivateRadio + ? 12 + : 0), + SizedBox( + child: + showConductedByAgencyPrivateRadio + ? FormBuilderSwitch( initialValue: - selectedCountry - ?.id == - 175 - ? null - : selectedCountry, + conductedByCategoryIsPrivate, + title: Text( + conductedByCategoryIsPrivate + ? "YES" + : "NO"), + decoration: normalTextFieldStyle( + "Private Entity?", + 'Private Entity?'), + + ////onvhange private sector + onChanged: + (value) { + setState(() { + conductedByCategoryIsPrivate = + value!; + selectedConductedByAgency = Agency( + category: + selectedConductedByAgency + ?.category, + id: selectedConductedByAgency + ?.id, + name: selectedConductedByAgency! + .name, + privateEntity: + conductedByCategoryIsPrivate); + conductedByAgencyCategoryFocusNode + .unfocus(); + }); + }, + name: + 'sponsorAgencyPrivate', validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - items: state.countries.map< - DropdownMenuItem< - Country>>( - (Country country) { - return DropdownMenuItem< - Country>( - value: country, - child: FittedBox( - child: Text( - country - .name!))); - }).toList(), - name: 'country', - decoration: normalTextFieldStyle( - "Country*", - "Country") - .copyWith( - filled: - !overseas, - fillColor: Colors - .grey - .shade300), - onChanged: - (Country? value) { - selectedCountry = - value; - }, - ), - ), + .required(), + ) + : const SizedBox()), + ]), + )), + ], + ); + }), + ]), + )), + const SizedBox( + height: 12, + ), + + ////Sponsor + StatefulBuilder(builder: (context, setState) { + ////has sponsor switch + return Column( + children: [ + FormBuilderSwitch( + initialValue: hasSponsor, + activeColor: second, + onChanged: (value) { + setState(() { + hasSponsor = value!; + }); + }, + decoration: normalTextFieldStyle( + "Has Sponsor?", ''), + name: 'sponsor', + title: + Text(hasSponsor ? "YES" : "NO"), + ), + ////Add Sponsor Agency============ + SizedBox( + child: hasSponsor + ? SizedBox( + child: Column(children: [ + const SizedBox( + height: 12, ), - ], - ); - }), - - ////Conducted By - StatefulBuilder( - builder: (context, setState) { - ////has sponsor switch - return Column( - children: [ - ////Add Conducted Agency============ - SizedBox( - child: SizedBox( - child: Column(children: [ - SearchField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - enabled: enabled, - controller: - selectedConductedByController, - itemHeight: 100, - focusNode: - conductedByFocusNode, - suggestions: state - .conductedBy - .map((Agency agency) => - SearchFieldListItem( - agency.name!, - item: agency, - child: ListTile( - title: Text( - agency - .name!, - overflow: - TextOverflow - .visible, - ), - subtitle: Text(agency - .privateEntity == - true - ? "Private" - : agency.privateEntity == - false - ? "Government" - : ""), - ))) - .toList(), - searchInputDecoration: - normalTextFieldStyle( - " Conducted By *", - "") - .copyWith( - suffixIcon: - GestureDetector( - child: - const Icon( - Icons - .arrow_drop_down, - ), - onTap: () => - conductedByFocusNode - .unfocus(), - ), - filled: - !enabled, - fillColor: Colors - .grey - .shade300), - ////SELETECTED - onSuggestionTap: (agency) { - setState(() { - if (agency.item?.id != - null) { - selectedConductedByAgency = - Agency( - name: null, - id: agency - .item! - .id); - } else { - selectedConductedByAgency = - Agency( - id: null, - name: agency - .item! - .name); - } - - if (agency.item! - .privateEntity == - null) { - showConductedByAgencyCategory = - true; - showConductedByAgencyPrivateRadio = - true; - } else { - showConductedByAgencyCategory = - false; - showConductedByAgencyPrivateRadio = - false; - } - conductedByFocusNode - .unfocus(); - }); - }, - validator: (agency) { - if (agency!.isEmpty) { - return "This field is required"; - } - return null; - }, - ////conducter empty widget - emptyWidget: EmptyWidget( + SearchField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + controller: + selectedSponsorAgencyController, + itemHeight: 70, + focusNode: + sponsorByFocusNode, + suggestions: state + .sponsorAgencies + .map((Agency + agency) => + SearchFieldListItem( + agency + .name!, + item: + agency, + child: + ListTile( + title: + Text( + agency + .name!, + overflow: + TextOverflow.ellipsis, + ), + subtitle: Text(agency.privateEntity == + true + ? "Private" + : agency.privateEntity == false + ? "Government" + : ""), + ))) + .toList(), + searchInputDecoration: + normalTextFieldStyle( + " Sponsor Agency *", + "") + .copyWith( + suffixIcon: + GestureDetector( + child: const Icon( + Icons + .arrow_drop_down, + ), + onTap: () => + sponsorByFocusNode + .unfocus(), + )), + ////SELETECTED + onSuggestionTap: + (agency) { + setState(() { + if (agency + .item?.id != + null) { + selectedSponsorAgency = + Agency( + name: + null, + id: agency + .item! + .id); + } else { + selectedSponsorAgency = + Agency( + id: null, + name: agency + .item! + .name); + } + if (agency.item! + .privateEntity == + null) { + showSponsorCategoryAgency = + true; + showSponsorAgencyPrivateRadio = + true; + } else { + showSponsorCategoryAgency = + false; + showSponsorAgencyPrivateRadio = + false; + } + sponsorByFocusNode + .unfocus(); + }); + }, + validator: (agency) { + if (agency!.isEmpty) { + return "This field is required"; + } + return null; + }, + ////sponsor empty widget + emptyWidget: + EmptyWidget( controller: - addConductedByController, + addSponsorAgencyController, onpressed: () { setState(() { Agency newAgency = Agency( - id: null, - name: addConductedByController + id: + null, + name: addSponsorAgencyController .text .toUpperCase(), - category: null, + category: + null, privateEntity: null); - state.conductedBy - .insert(0, + state + .sponsorAgencies + .insert( + 0, newAgency); - addConductedByController + addSponsorAgencyController .text = ""; Navigator.pop( context); }); }, title: - "Add Conducted By Agency")), - SizedBox( - height: - showConductedByAgencyCategory - ? 12 - : 0, - ), - ////Conducted By Agency Category - SizedBox( - child: - showConductedByAgencyCategory - ? SearchField( - focusNode: - conductedByAgencyCategoryFocusNode, - itemHeight: 70, - suggestions: state - .agencyCategory - .map((Category - category) => - SearchFieldListItem( - category - .name!, - item: - category, - child: - ListTile( - title: - Text(category.name!), - subtitle: - Text(category.industryClass!.name!), - ))) - .toList(), - emptyWidget: - Container( - height: 100, - decoration: - box1(), - child: const Center( - child: Text( - "No result found ...")), - ), - onSuggestionTap: - (agencyCategory) { - setState(() { - selectedConductedByAgencyCategory = - agencyCategory - .item; - selectedConductedByAgency = Agency( - id: selectedConductedByAgency - ?.id, - name: selectedConductedByAgency! - .name, - category: - selectedConductedByAgencyCategory, - privateEntity: - showConductedByAgencyPrivateRadio); - conductedByAgencyCategoryFocusNode - .unfocus(); - }); - }, - searchInputDecoration: - normalTextFieldStyle( - "Category *", - "") - .copyWith( - suffixIcon: - IconButton( - icon: const Icon( - Icons - .arrow_drop_down), - onPressed: () { - conductedByAgencyCategoryFocusNode - .unfocus(); - }, - )), - validator: - (value) { - if (value! - .isEmpty) { - return "This field is required"; - } - return null; - }, - ) - : const SizedBox(), - ), - - ////Sponsor Agency Private Radio - SizedBox( - height: - showConductedByAgencyPrivateRadio - ? 12 - : 0), - SizedBox( - child: - showConductedByAgencyPrivateRadio - ? FormBuilderSwitch( - initialValue: - conductedByCategoryIsPrivate, - title: Text( - conductedByCategoryIsPrivate - ? "YES" - : "NO"), - decoration: normalTextFieldStyle( - "Private Entity?", - 'Private Entity?'), - - ////onvhange private sector - onChanged: - (value) { - setState(() { - conductedByCategoryIsPrivate = - value!; - selectedConductedByAgency = Agency( - category: - selectedConductedByAgency - ?.category, - id: selectedConductedByAgency - ?.id, - name: selectedConductedByAgency! - .name, - privateEntity: - conductedByCategoryIsPrivate); - conductedByAgencyCategoryFocusNode - .unfocus(); - }); - }, - name: - 'sponsorAgencyPrivate', - validator: - FormBuilderValidators - .required(), - ) - : const SizedBox()), - ]), - )), - ], - ); - }), - ]), - )), - const SizedBox( - height: 12, - ), - - ////Sponsor - StatefulBuilder(builder: (context, setState) { - ////has sponsor switch - return Column( - children: [ - FormBuilderSwitch( - initialValue: hasSponsor, - activeColor: second, - onChanged: (value) { - setState(() { - hasSponsor = value!; - }); - }, - decoration: normalTextFieldStyle( - "Has Sponsor?", ''), - name: 'sponsor', - title: - Text(hasSponsor ? "YES" : "NO"), - ), - ////Add Sponsor Agency============ - SizedBox( - child: hasSponsor - ? SizedBox( - child: Column(children: [ - const SizedBox( - height: 12, - ), - SearchField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - controller: - selectedSponsorAgencyController, - itemHeight: 70, - focusNode: - sponsorByFocusNode, - suggestions: state - .sponsorAgencies - .map((Agency - agency) => - SearchFieldListItem( - agency - .name!, - item: - agency, - child: - ListTile( - title: - Text( - agency - .name!, - overflow: - TextOverflow.ellipsis, - ), - subtitle: Text(agency.privateEntity == - true - ? "Private" - : agency.privateEntity == false - ? "Government" - : ""), - ))) - .toList(), - searchInputDecoration: - normalTextFieldStyle( - " Sponsor Agency *", - "") - .copyWith( - suffixIcon: - GestureDetector( - child: const Icon( - Icons - .arrow_drop_down, + "Add Sponsor Agency")), + SizedBox( + height: + showSponsorCategoryAgency + ? 12 + : 0, + ), + ////Sponsor Agency Category + SizedBox( + child: + showSponsorCategoryAgency + ? SearchField( + suggestionDirection: + SuggestionDirection + .up, + focusNode: + sponsorAgencyCategoryFocusNode, + itemHeight: + 70, + suggestions: state + .agencyCategory + .map((Category category) => SearchFieldListItem( + category + .name!, + item: + category, + child: + ListTile( + title: + Text(category.name!), + subtitle: + Text(category.industryClass!.name!), + ))) + .toList(), + emptyWidget: + Container( + height: 100, + decoration: + box1(), + child: const Center( + child: Text( + "No result found ...")), ), - onTap: () => - sponsorByFocusNode - .unfocus(), - )), - ////SELETECTED - onSuggestionTap: - (agency) { + onSuggestionTap: + (agencyCategory) { + setState( + () { + selectedSponsorAgencyCategory = + agencyCategory + .item; + selectedSponsorAgency = Agency( + id: selectedSponsorAgency + ?.id, + name: selectedSponsorAgency! + .name, + category: + selectedSponsorAgencyCategory, + privateEntity: + sponsorAgencyIsPrivate); + sponsorAgencyCategoryFocusNode + .unfocus(); + }); + }, + searchInputDecoration: normalTextFieldStyle( + "Category *", + "") + .copyWith( + suffixIcon: + IconButton( + icon: const Icon( + Icons + .arrow_drop_down), + onPressed: + () { + sponsorAgencyCategoryFocusNode + .unfocus(); + }, + )), + validator: + (value) { + if (value! + .isEmpty) { + return "This field is required"; + } + return null; + }, + ) + : const SizedBox(), + ), + + ////Sponsor Agency Private Radio + SizedBox( + height: + showSponsorAgencyPrivateRadio + ? 12 + : 0), + SizedBox( + child: showSponsorAgencyPrivateRadio + ? FormBuilderSwitch( + initialValue: + sponsorAgencyIsPrivate, + title: Text( + sponsorAgencyIsPrivate + ? "YES" + : "NO"), + decoration: normalTextFieldStyle( + "Private Entity?", + 'Private Entity?'), + + ////onvhange private sector + onChanged: + (value) { setState(() { - if (agency - .item?.id != - null) { - selectedSponsorAgency = - Agency( - name: - null, - id: agency - .item! - .id); - } else { - selectedSponsorAgency = - Agency( - id: null, - name: agency - .item! - .name); - } - if (agency.item! - .privateEntity == - null) { - showSponsorCategoryAgency = - true; - showSponsorAgencyPrivateRadio = - true; - } else { - showSponsorCategoryAgency = - false; - showSponsorAgencyPrivateRadio = - false; - } - sponsorByFocusNode + sponsorAgencyIsPrivate = + value!; + selectedSponsorAgency = Agency( + category: + selectedSponsorAgency + ?.category, + id: selectedSponsorAgency + ?.id, + name: selectedSponsorAgency! + .name, + privateEntity: + selectedSponsorAgency?.privateEntity); + sponsorAgencyCategoryFocusNode .unfocus(); }); }, - validator: (agency) { - if (agency!.isEmpty) { - return "This field is required"; - } - return null; - }, - ////sponsor empty widget - emptyWidget: - EmptyWidget( - controller: - addSponsorAgencyController, - onpressed: () { - setState(() { - Agency newAgency = Agency( - id: - null, - name: addSponsorAgencyController - .text - .toUpperCase(), - category: - null, - privateEntity: - null); - state - .sponsorAgencies - .insert( - 0, - newAgency); - addSponsorAgencyController - .text = ""; - Navigator.pop( - context); - }); - }, - title: - "Add Sponsor Agency")), - SizedBox( - height: - showSponsorCategoryAgency - ? 12 - : 0, - ), - ////Sponsor Agency Category - SizedBox( - child: - showSponsorCategoryAgency - ? SearchField( - suggestionDirection: - SuggestionDirection - .up, - focusNode: - sponsorAgencyCategoryFocusNode, - itemHeight: - 70, - suggestions: state - .agencyCategory - .map((Category category) => SearchFieldListItem( - category - .name!, - item: - category, - child: - ListTile( - title: - Text(category.name!), - subtitle: - Text(category.industryClass!.name!), - ))) - .toList(), - emptyWidget: - Container( - height: 100, - decoration: - box1(), - child: const Center( - child: Text( - "No result found ...")), - ), - onSuggestionTap: - (agencyCategory) { - setState( - () { - selectedSponsorAgencyCategory = - agencyCategory - .item; - selectedSponsorAgency = Agency( - id: selectedSponsorAgency - ?.id, - name: selectedSponsorAgency! - .name, - category: - selectedSponsorAgencyCategory, - privateEntity: - sponsorAgencyIsPrivate); - sponsorAgencyCategoryFocusNode - .unfocus(); - }); - }, - searchInputDecoration: normalTextFieldStyle( - "Category *", - "") - .copyWith( - suffixIcon: - IconButton( - icon: const Icon( - Icons - .arrow_drop_down), - onPressed: - () { - sponsorAgencyCategoryFocusNode - .unfocus(); - }, - )), - validator: - (value) { - if (value! - .isEmpty) { - return "This field is required"; - } - return null; - }, - ) - : const SizedBox(), - ), - - ////Sponsor Agency Private Radio - SizedBox( - height: - showSponsorAgencyPrivateRadio - ? 12 - : 0), - SizedBox( - child: showSponsorAgencyPrivateRadio - ? FormBuilderSwitch( - initialValue: - sponsorAgencyIsPrivate, - title: Text( - sponsorAgencyIsPrivate - ? "YES" - : "NO"), - decoration: normalTextFieldStyle( - "Private Entity?", - 'Private Entity?'), - - ////onvhange private sector - onChanged: - (value) { - setState(() { - sponsorAgencyIsPrivate = - value!; - selectedSponsorAgency = Agency( - category: - selectedSponsorAgency - ?.category, - id: selectedSponsorAgency - ?.id, - name: selectedSponsorAgency! - .name, - privateEntity: - selectedSponsorAgency?.privateEntity); - sponsorAgencyCategoryFocusNode - .unfocus(); - }); - }, - - name: - 'sponsorAgencyPrivate', - validator: - FormBuilderValidators - .required(), - ) - : const SizedBox()), - ]), - ) - : const SizedBox(), - ), - ], - ); - }), - const SizedBox( - height: 12, - ), - const SizedBox( - height: 12, - ), - FormBuilderTextField( - initialValue: state - .learningDevelopement.totalHoursAttended - .toString(), - validator: numericRequired, - name: "total_hours_attended", - keyboardType: TextInputType.number, - decoration: normalTextFieldStyle( - "Total Hours Attended *", - "Total Hours Attended *"), - ), - ], - ); - }), - ], - ), - ), - SizedBox( + name: + 'sponsorAgencyPrivate', + validator: + FormBuilderValidators + .required(), + ) + : const SizedBox()), + ]), + ) + : const SizedBox(), + ), + ], + ); + }), + const SizedBox( + height: 12, + ), + const SizedBox( + height: 12, + ), + FormBuilderTextField( + initialValue: state + .learningDevelopement.totalHoursAttended + .toString(), + validator: numericRequired, + name: "total_hours_attended", + keyboardType: TextInputType.number, + decoration: normalTextFieldStyle( + "Total Hours Attended *", + "Total Hours Attended *"), + ), + ], + ); + }), + const SizedBox(height: 16,), + SizedBox( height: 60, width: double.infinity, child: ElevatedButton( @@ -1642,8 +1635,7 @@ class _EditLearningAndDevelopmentScreenState }, ), ) - ], - ), + ], ), )); } diff --git a/lib/screens/profile/components/learning_development/learning_development_view_attachment.dart b/lib/screens/profile/components/learning_development/learning_development_view_attachment.dart index 7d07997..e86086a 100644 --- a/lib/screens/profile/components/learning_development/learning_development_view_attachment.dart +++ b/lib/screens/profile/components/learning_development/learning_development_view_attachment.dart @@ -1,71 +1,107 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_progress_hud/flutter_progress_hud.dart'; +import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart'; import 'package:unit2/bloc/profile/learningDevelopment/learning_development_bloc.dart'; import 'package:unit2/theme-data.dart/colors.dart'; +import 'package:unit2/utils/url_launcher_file_downloader.dart'; import 'package:url_launcher/url_launcher.dart'; -class LearningDevelopmentViewAttachment extends StatefulWidget { +class LearningDevelopmentViewAttachment extends StatefulWidget { const LearningDevelopmentViewAttachment({super.key}); @override - State createState() => _LearningDevelopmentViewAttachmentState(); + State createState() => + _LearningDevelopmentViewAttachmentState(); } -class _LearningDevelopmentViewAttachmentState extends State { +class _LearningDevelopmentViewAttachmentState + extends State { @override Widget build(BuildContext context) { String? fileUrl; + String? filename; + return Scaffold( - floatingActionButton: FloatingActionButton( - onPressed: ()async { - await launchUrl(Uri.parse(fileUrl!)); - }, - child: const Icon(Icons.file_download), - ), - appBar: AppBar( - title: const Text("Attachment"), - centerTitle: true, - actions: [ - IconButton(onPressed: () {}, icon: const Icon(Icons.share)), - ], - ), - body: BlocConsumer(builder: (context,state){ - if(state is LearningAndDevelopmentAttachmentViewState){ - fileUrl = state.fileUrl; - bool isPDF = state.fileUrl[state.fileUrl.length - 1] == 'f' ? true : false; - return SizedBox( - child: isPDF?SfPdfViewer.network( - state.fileUrl,onDocumentLoadFailed: (details) { - Center(child: Text(details.description),); - },): Center( - child: CachedNetworkImage( - progressIndicatorBuilder: (context, url, progress) { - return const SizedBox( - height: 100, - width: 100, - child: CircularProgressIndicator(color: primary,)); - }, - - imageBuilder: (context, imageProvider) => Container( - decoration: BoxDecoration( - image: DecorationImage( - image: imageProvider, fit: BoxFit.fill)), - ), - imageUrl: - state.fileUrl, - width: double.infinity, - height: 220, - fit: BoxFit.cover, - ), - ), - ); - } - return Container(); - },listener: (context, state) { - - },) - ); + floatingActionButton: FloatingActionButton( + onPressed: () async { + await launchInBrowser(fileUrl!); + }, + child: const Icon(Icons.file_download), + ), + appBar: AppBar( + title: const Text("Attachment"), + centerTitle: true, + actions: context.watch().state is LearningAndDevelopmentAttachmentViewState ? [ + IconButton(onPressed: () { + context.read().add(ShareAttachment(fileName: filename!, source: fileUrl!)); + }, icon: const Icon(Icons.share)), + ]:[] + ), + body: ProgressHUD( + padding: const EdgeInsets.all(24), + backgroundColor: Colors.black87, + indicatorWidget: const SpinKitFadingCircle(color: Colors.white), + child: + BlocConsumer( + builder: (context, state) { + if (state is LearningAndDevelopmentAttachmentViewState) { + fileUrl = state.fileUrl; + filename = state.filename; + bool isPDF = state.fileUrl[state.fileUrl.length - 1] == 'f' + ? true + : false; + return SizedBox( + child: isPDF + ? SfPdfViewer.network( + + state.fileUrl, + onDocumentLoadFailed: (details) { + Center( + child: Text(details.description), + ); + }, + ) + : Center( + child: CachedNetworkImage( + progressIndicatorBuilder: (context, url, progress) { + return const SizedBox( + height: 100, + width: 100, + child: CircularProgressIndicator( + color: primary, + )); + }, + imageBuilder: (context, imageProvider) => Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, fit: BoxFit.fill)), + ), + imageUrl: state.fileUrl, + width: double.infinity, + height: 220, + fit: BoxFit.cover, + ), + ), + ); + } + return Container(); + }, + listener: (context, state) { + + if (state is LearningDevelopmentLoadingState) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Please wait..."); + } + if (state is LearningAndDevelopmentAttachmentViewState || + state is LearningDevelopmentErrorState) { + final progress = ProgressHUD.of(context); + progress!.dismiss(); + } + }, + ), + )); } } diff --git a/lib/screens/profile/components/other_information/non_academic/edit_modal.dart b/lib/screens/profile/components/other_information/non_academic/edit_modal.dart index 91a8a9c..87610a8 100644 --- a/lib/screens/profile/components/other_information/non_academic/edit_modal.dart +++ b/lib/screens/profile/components/other_information/non_academic/edit_modal.dart @@ -83,6 +83,7 @@ class _EditNonAcademicRecognitionScreenState child: Column( children: [ FormBuilderTextField( + inputFormatters: [UpperCaseTextFormatter()], name: 'title', initialValue: state.nonAcademicRecognition.title, @@ -205,6 +206,7 @@ class _EditNonAcademicRecognitionScreenState Column( children: [ TextFormField( + inputFormatters: [UpperCaseTextFormatter()], controller: addAgencyController, decoration: diff --git a/lib/screens/profile/components/reference/add_modal.dart b/lib/screens/profile/components/reference/add_modal.dart index 5140b44..25508a8 100644 --- a/lib/screens/profile/components/reference/add_modal.dart +++ b/lib/screens/profile/components/reference/add_modal.dart @@ -53,316 +53,303 @@ class _AddReferenceScreenState extends State { return BlocBuilder( builder: (context, state) { if (state is AddReferenceState) { - return SingleChildScrollView( - child: FormBuilder( - key: formKey, - child: SizedBox( - height: screenHeight * .90, - child: Padding( - padding: const EdgeInsets.all(28), - child: Column( - + return FormBuilder( + key: formKey, + child: Padding( + padding: const EdgeInsets.all(28), + child: ListView( + children: [ + + Row( children: [ - const SizedBox(height: 15,), + ////LAST NAME Flexible( - child: ListView( - children: [ - - Row( - children: [ - ////LAST NAME - Flexible( - flex: 1, - child: FormBuilderTextField( - inputFormatters: [UpperCaseTextFormatter()], - decoration: normalTextFieldStyle( - "Last name *", "Last name *"), - name: "lastname", - validator: FormBuilderValidators.required( - errorText: "This field is required"), - ), - ), - const SizedBox( - width: 8, - ), - ////FIRST NAME - Flexible( - flex: 1, - child: FormBuilderTextField( - inputFormatters: [UpperCaseTextFormatter()], - decoration: normalTextFieldStyle( - "First name *", "First name *"), - name: "firstname", - validator: FormBuilderValidators.required( - errorText: "This field is required"), - ), - ), - ], - ), - const SizedBox( - height: 12, - ), - Row( - children: [ - Flexible( - flex: 1, - child: FormBuilderTextField( - inputFormatters: [ - UpperCaseTextFormatter() - ], - decoration: normalTextFieldStyle( - "Middle name ", ""), - name: "middlename", - - ), - ), - const SizedBox( - width: 8, - ), - ////Mobile - Flexible( - flex: 1, - child: FormBuilderTextField( - keyboardType: TextInputType.number, - inputFormatters: [mobileFormatter], - name: "mobile", - decoration: normalTextFieldStyle( - "Mobile *", - "+63 (9xx) xxx - xxxx"), - validator: FormBuilderValidators.required( - errorText: "This field is required"), - ), - ), - ], - ), - const SizedBox( - height: 12, - ), - FormBuilderDropdown( - name: 'category', - validator: - FormBuilderValidators.required(errorText: "This field is required"), - decoration: normalTextFieldStyle( - "Address Category", "Address Category"), - items: state.categories - .map>( - (AddressCategory cat) { - return DropdownMenuItem( - value: cat, - child: Text(cat.name!), - ); - }).toList(), - onChanged: (value) { - setState(() { - selectedCategory = value; - }); - }, - ), - const SizedBox( - height: 12, - ), - ////OVERSEAS ADDRESS - FormBuilderSwitch( - initialValue: overseas, - activeColor: second, - onChanged: (value) { - setState(() { - overseas = value!; - }); - }, - decoration: normalTextFieldStyle("", ''), - name: 'overseas', - title: const Text("Overseas Address?"), - ), - SizedBox( - height: overseas == true ? 12 : 0, - ), - SizedBox( - child: overseas == false - ? Column( - children: [ - const SizedBox( - height: 12, - ), - ////REGION DROPDOWN - FormBuilderDropdown( - autovalidateMode: - AutovalidateMode.onUserInteraction, - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - onChanged: (Region? region) async { - if (selectedRegion != region) { - setState(() { - provinceCall = true; - }); - selectedRegion = region; - getProvinces(); - } - }, - initialValue: null, - decoration: normalTextFieldStyle( - "Region*", "Region"), - name: 'region', - items: state.regions - .map>( - (Region region) { - return DropdownMenuItem( - value: region, - child: Text(region.description!)); - }).toList(), - ), - const SizedBox( - height: 12, - ), - //// PROVINCE DROPDOWN - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - autovalidateMode: AutovalidateMode - .onUserInteraction, - validator: (value) => - value == null - ? 'This field is required' - : null, - isExpanded: true, - value: selectedProvince, - onChanged: (Province? province) { - if (selectedProvince != - province) { - setState(() { - cityCall = true; - }); - selectedProvince = province; - getCities(); - } - }, - items: provinces == null - ? [] - : provinces!.map< - DropdownMenuItem< - Province>>( - (Province province) { - return DropdownMenuItem( - value: province, - child: FittedBox( - child: Text(province - .description!), - )); - }).toList(), - decoration: normalTextFieldStyle( - "Province*", "Province")), - ), - ), - ////CITY MUNICIPALITY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: cityCall, - child: DropdownButtonFormField< - CityMunicipality>( - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - isExpanded: true, - onChanged: - (CityMunicipality? city) { - if (selectedMunicipality != - city) { - setState(() { - barangayCall = true; - }); - selectedMunicipality = city; - getBarangays(); - } - }, - decoration: normalTextFieldStyle( - "Municipality*", - "Municipality"), - value: selectedMunicipality, - items: citymuns == null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality c) { - return DropdownMenuItem( - value: c, - child: Text( - c.description!)); - }).toList(), - ), - ), - ), - //// BARANGAY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: barangayCall, - child: - DropdownButtonFormField( - isExpanded: true, - onChanged: (Barangay? baragay) { - selectedBarangay = baragay; - }, - decoration: normalTextFieldStyle( - "Barangay*", "Barangay"), - value: selectedBarangay, - items: barangays == null - ? [] - : barangays!.map< - DropdownMenuItem< - Barangay>>( - (Barangay barangay) { - return DropdownMenuItem( - value: barangay, - child: Text(barangay - .description!)); - }).toList(), - ), - ), - ), - ], - ) - //// COUNTRY DROPDOWN - : SizedBox( - height: 60, - child: FormBuilderDropdown( - initialValue: null, - validator: FormBuilderValidators.required( - errorText: "This field is required"), - items: state.countries - .map>( - (Country country) { - return DropdownMenuItem( - value: country, - child: FittedBox( - child: Text(country.name!))); - }).toList(), - name: 'country', - decoration: normalTextFieldStyle( - "Country*", "Country"), - onChanged: (Country? value) { - selectedCountry = value; - }, - ), - ), - ), - - - - ], + flex: 1, + child: FormBuilderTextField( + inputFormatters: [UpperCaseTextFormatter()], + decoration: normalTextFieldStyle( + "Last name *", "Last name *"), + name: "lastname", + validator: FormBuilderValidators.required( + errorText: "This field is required"), ), ), - SizedBox( + const SizedBox( + width: 8, + ), + ////FIRST NAME + Flexible( + flex: 1, + child: FormBuilderTextField( + inputFormatters: [UpperCaseTextFormatter()], + decoration: normalTextFieldStyle( + "First name *", "First name *"), + name: "firstname", + validator: FormBuilderValidators.required( + errorText: "This field is required"), + ), + ), + ], + ), + const SizedBox( + height: 12, + ), + Row( + children: [ + Flexible( + flex: 1, + child: FormBuilderTextField( + inputFormatters: [ + UpperCaseTextFormatter() + ], + decoration: normalTextFieldStyle( + "Middle name ", ""), + name: "middlename", + + ), + ), + const SizedBox( + width: 8, + ), + ////Mobile + Flexible( + flex: 1, + child: FormBuilderTextField( + keyboardType: TextInputType.number, + inputFormatters: [mobileFormatter], + name: "mobile", + decoration: normalTextFieldStyle( + "Mobile *", + "+63 (9xx) xxx - xxxx"), + validator: FormBuilderValidators.required( + errorText: "This field is required"), + ), + ), + ], + ), + const SizedBox( + height: 12, + ), + FormBuilderDropdown( + name: 'category', + validator: + FormBuilderValidators.required(errorText: "This field is required"), + decoration: normalTextFieldStyle( + "Address Category", "Address Category"), + items: state.categories + .map>( + (AddressCategory cat) { + return DropdownMenuItem( + value: cat, + child: Text(cat.name!), + ); + }).toList(), + onChanged: (value) { + setState(() { + selectedCategory = value; + }); + }, + ), + const SizedBox( + height: 12, + ), + ////OVERSEAS ADDRESS + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, + decoration: normalTextFieldStyle("", ''), + name: 'overseas', + title: const Text("Overseas Address?"), + ), + SizedBox( + height: overseas == true ? 12 : 0, + ), + SizedBox( + child: overseas == false + ? Column( + children: [ + const SizedBox( + height: 12, + ), + ////REGION DROPDOWN + FormBuilderDropdown( + autovalidateMode: + AutovalidateMode.onUserInteraction, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + onChanged: (Region? region) async { + if (selectedRegion != region) { + setState(() { + provinceCall = true; + }); + selectedRegion = region; + getProvinces(); + } + }, + initialValue: null, + decoration: normalTextFieldStyle( + "Region*", "Region"), + name: 'region', + items: state.regions + .map>( + (Region region) { + return DropdownMenuItem( + value: region, + child: Text(region.description!)); + }).toList(), + ), + const SizedBox( + height: 12, + ), + //// PROVINCE DROPDOWN + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: provinceCall, + child: DropdownButtonFormField< + Province?>( + autovalidateMode: AutovalidateMode + .onUserInteraction, + validator: (value) => + value == null + ? 'This field is required' + : null, + isExpanded: true, + value: selectedProvince, + onChanged: (Province? province) { + if (selectedProvince != + province) { + setState(() { + cityCall = true; + }); + selectedProvince = province; + getCities(); + } + }, + items: provinces == null + ? [] + : provinces!.map< + DropdownMenuItem< + Province>>( + (Province province) { + return DropdownMenuItem( + value: province, + child: FittedBox( + child: Text(province + .description!), + )); + }).toList(), + decoration: normalTextFieldStyle( + "Province*", "Province")), + ), + ), + ////CITY MUNICIPALITY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: cityCall, + child: DropdownButtonFormField< + CityMunicipality>( + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + isExpanded: true, + onChanged: + (CityMunicipality? city) { + if (selectedMunicipality != + city) { + setState(() { + barangayCall = true; + }); + selectedMunicipality = city; + getBarangays(); + } + }, + decoration: normalTextFieldStyle( + "Municipality*", + "Municipality"), + value: selectedMunicipality, + items: citymuns == null + ? [] + : citymuns!.map< + DropdownMenuItem< + CityMunicipality>>( + (CityMunicipality c) { + return DropdownMenuItem( + value: c, + child: Text( + c.description!)); + }).toList(), + ), + ), + ), + //// BARANGAY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: barangayCall, + child: + DropdownButtonFormField( + isExpanded: true, + onChanged: (Barangay? baragay) { + selectedBarangay = baragay; + }, + decoration: normalTextFieldStyle( + "Barangay*", "Barangay"), + value: selectedBarangay, + items: barangays == null + ? [] + : barangays!.map< + DropdownMenuItem< + Barangay>>( + (Barangay barangay) { + return DropdownMenuItem( + value: barangay, + child: Text(barangay + .description!)); + }).toList(), + ), + ), + ), + ], + ) + //// COUNTRY DROPDOWN + : SizedBox( + height: 60, + child: FormBuilderDropdown( + initialValue: null, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + items: state.countries + .map>( + (Country country) { + return DropdownMenuItem( + value: country, + child: FittedBox( + child: Text(country.name!))); + }).toList(), + name: 'country', + decoration: normalTextFieldStyle( + "Country*", "Country"), + onChanged: (Country? value) { + selectedCountry = value; + }, + ), + ), + ), + const SizedBox(height: 16,), + SizedBox( width: double.infinity, height: 60, child: ElevatedButton( @@ -438,13 +425,12 @@ class _AddReferenceScreenState extends State { } }, ), - ), - - ], - ), - ), - )), - ); + ), + + + ], + ), + )); } return Container(); }, diff --git a/lib/screens/profile/components/reference/edit_modal.dart b/lib/screens/profile/components/reference/edit_modal.dart index b233d94..658db44 100644 --- a/lib/screens/profile/components/reference/edit_modal.dart +++ b/lib/screens/profile/components/reference/edit_modal.dart @@ -72,473 +72,461 @@ class _EditReferenceScreenState extends State { return FormBuilder( key: formKey, - child: SizedBox( - height: screenHeight * .90, - child: Padding( - padding: const EdgeInsets.all(28), - child: Column( - children: [ - Flexible( - child: Column( - children: [ - const SizedBox(height: 25), - Row( - children: [ - ////LAST NAME - Flexible( - flex: 1, - child: FormBuilderTextField( - inputFormatters: [UpperCaseTextFormatter(),mobileFormatter], - initialValue: state.ref.lastName, - decoration: normalTextFieldStyle( - "Last name *", "Last name *"), - name: "lastname", - validator: FormBuilderValidators.required( - errorText: "This field is required"), - ), - ), - const SizedBox( - width: 8, - ), - ////FIRST NAME - Flexible( - flex: 1, - child: FormBuilderTextField( - inputFormatters: [UpperCaseTextFormatter()], - initialValue: state.ref.firstName, - decoration: normalTextFieldStyle( - "First name *", "First name *"), - name: "firstname", - validator: FormBuilderValidators.required( - errorText: "This field is required"), - ), - ), - ], - ), - const SizedBox( - height: 12, - ), - Row( - children: [ - Flexible( - flex: 1, - child: FormBuilderTextField( - inputFormatters: [UpperCaseTextFormatter()], - initialValue: state.ref.middleName, - decoration: normalTextFieldStyle( - "Middle name *", "Midlle name *"), - name: "middlename", - ), - ), - const SizedBox( - width: 8, - ), - ////CATEGORY - Flexible( - flex: 1, - child: FormBuilderTextField( - initialValue: state.ref.contactNo, - name: "mobile", - decoration: normalTextFieldStyle( - "Tel./Mobile *", "Tel./Mobile"), - validator: FormBuilderValidators.required( - errorText: "This field is required"), - ), - ), - ], - ), - const SizedBox( - height: 12, - ), - FormBuilderDropdown( - name: 'category', - validator: FormBuilderValidators.required( - errorText: "This field is required"), - decoration: normalTextFieldStyle( - "Address Category", "Address Category"), - items: state.categories - .map>( - (AddressCategory cat) { - return DropdownMenuItem( - value: cat, - child: Text(cat.name!), - ); - }).toList(), - initialValue: selectedCategory, - onChanged: (value) { - selectedCategory = value; - }, - ), - const SizedBox( - height: 12, - ), - ////OVERSEAS ADDRESS - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - FormBuilderSwitch( - initialValue: overseas, - activeColor: second, - onChanged: (value) { - setState(() { - overseas = value!; - }); - }, - decoration: normalTextFieldStyle("", ''), - name: 'overseas', - title: const Text("Overseas Address?"), - ), - SizedBox( - height: overseas == true ? 12 : 0, - ), - SizedBox( - child: overseas == false - ? Column( - children: [ - const SizedBox( - height: 12, - ), - ////REGION DROPDOWN - DropdownButtonFormField( - isExpanded: true, - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - onChanged: - (Region? region) async { - setState(() { - provinceCall = true; + child: Padding( + padding: const EdgeInsets.all(28), + child: ListView( + children: [ + Row( + children: [ + ////LAST NAME + Flexible( + flex: 1, + child: FormBuilderTextField( + inputFormatters: [UpperCaseTextFormatter(),mobileFormatter], + initialValue: state.ref.lastName, + decoration: normalTextFieldStyle( + "Last name *", "Last name *"), + name: "lastname", + validator: FormBuilderValidators.required( + errorText: "This field is required"), + ), + ), + const SizedBox( + width: 8, + ), + ////FIRST NAME + Flexible( + flex: 1, + child: FormBuilderTextField( + inputFormatters: [UpperCaseTextFormatter()], + initialValue: state.ref.firstName, + decoration: normalTextFieldStyle( + "First name *", "First name *"), + name: "firstname", + validator: FormBuilderValidators.required( + errorText: "This field is required"), + ), + ), + ], + ), + const SizedBox( + height: 12, + ), + Row( + children: [ + Flexible( + flex: 1, + child: FormBuilderTextField( + inputFormatters: [UpperCaseTextFormatter()], + initialValue: state.ref.middleName, + decoration: normalTextFieldStyle( + "Middle name *", "Midlle name *"), + name: "middlename", + ), + ), + const SizedBox( + width: 8, + ), + ////CATEGORY + Flexible( + flex: 1, + child: FormBuilderTextField( + initialValue: state.ref.contactNo, + name: "mobile", + decoration: normalTextFieldStyle( + "Tel./Mobile *", "Tel./Mobile"), + validator: FormBuilderValidators.required( + errorText: "This field is required"), + ), + ), + ], + ), + const SizedBox( + height: 12, + ), + FormBuilderDropdown( + name: 'category', + validator: FormBuilderValidators.required( + errorText: "This field is required"), + decoration: normalTextFieldStyle( + "Address Category", "Address Category"), + items: state.categories + .map>( + (AddressCategory cat) { + return DropdownMenuItem( + value: cat, + child: Text(cat.name!), + ); + }).toList(), + initialValue: selectedCategory, + onChanged: (value) { + selectedCategory = value; + }, + ), + const SizedBox( + height: 12, + ), + ////OVERSEAS ADDRESS + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, + decoration: normalTextFieldStyle("", ''), + name: 'overseas', + title: const Text("Overseas Address?"), + ), + SizedBox( + height: overseas == true ? 12 : 0, + ), + SizedBox( + child: overseas == false + ? Column( + children: [ + const SizedBox( + height: 12, + ), + ////REGION DROPDOWN + DropdownButtonFormField( + isExpanded: true, + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + onChanged: + (Region? region) async { + setState(() { + provinceCall = true; - selectedRegion = region; - }); - //// GET PROVINCES - try { - provinces = await LocationUtils - .instance - .getProvinces( - regionCode: - selectedRegion! - .code - .toString()); - } catch (e) { - context - .read() - .add(CallErrorState()); - } - selectedProvince = - provinces![0]; - setState(() { - provinceCall = false; - cityCall = true; - }); - ////GET CITY MUNICIPALITY - try { - citymuns = await LocationUtils - .instance - .getCities( - code: - selectedProvince! - .code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read() - .add(CallErrorState()); - } - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - barangayCall = true; - }); - //// GET BARANGAYS - try { - barangays = await LocationUtils + selectedRegion = region; + }); + //// GET PROVINCES + try { + provinces = await LocationUtils + .instance + .getProvinces( + regionCode: + selectedRegion! + .code + .toString()); + } catch (e) { + context + .read() + .add(CallErrorState()); + } + selectedProvince = + provinces![0]; + setState(() { + provinceCall = false; + cityCall = true; + }); + ////GET CITY MUNICIPALITY + try { + citymuns = await LocationUtils + .instance + .getCities( + code: + selectedProvince! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read() + .add(CallErrorState()); + } + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = false; + barangayCall = true; + }); + //// GET BARANGAYS + try { + barangays = await LocationUtils + .instance + .getBarangay( + code: + selectedMunicipality! + .code!); + selectedBarangay = + barangays![0]; + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read() + .add(CallErrorState()); + } + setState(() { + barangayCall = false; + }); + }, + value: selectedRegion, + decoration: + normalTextFieldStyle( + "Region*", "Region"), + items: state.regions.map< + DropdownMenuItem< + Region>>( + (Region region) { + return DropdownMenuItem< + Region>( + value: region, + child: Text( + region.description!)); + }).toList(), + ), + const SizedBox( + height: 12, + ), + //// PROVINCE DROPDOWN + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: provinceCall, + child: DropdownButtonFormField< + Province?>( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: (value) => + value == null + ? 'required' + : null, + isExpanded: true, + onChanged: (Province? + province) async { + selectedProvince = + province; + setState(() { + cityCall = true; + }); + //// GET CITIES + try { + citymuns = + await LocationUtils + .instance + .getCities( + code: selectedProvince! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + ReferencesBloc>() + .add( + CallErrorState()); + } + selectedMunicipality = + citymuns![0]; + setState(() { + cityCall = false; + barangayCall = true; + }); + //// GET BARANGAY + try { + barangays = + await LocationUtils + .instance + .getBarangay( + code: selectedMunicipality! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + ReferencesBloc>() + .add( + CallErrorState()); + } + selectedBarangay = + barangays![0]; + setState(() { + barangayCall = false; + }); + }, + value: selectedProvince, + items: provinces == null + ? [] + : provinces!.map< + DropdownMenuItem< + Province>>( + (Province + province) { + return DropdownMenuItem( + value: + province, + child: + FittedBox( + child: Text( + province + .description!), + )); + }).toList(), + decoration: + normalTextFieldStyle( + "Province*", + "Province")), + ), + ), + ////CITY MUNICIPALITY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: cityCall, + child: + DropdownButtonFormField< + CityMunicipality>( + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + isExpanded: true, + onChanged: + (CityMunicipality? + city) async { + setState(() { + barangayCall = true; + }); + selectedMunicipality = + city; + //// GET BARANGAYS + try { + barangays = + await LocationUtils .instance .getBarangay( - code: - selectedMunicipality! - .code!); - selectedBarangay = - barangays![0]; - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read() - .add(CallErrorState()); - } - setState(() { - barangayCall = false; - }); - }, - value: selectedRegion, - decoration: - normalTextFieldStyle( - "Region*", "Region"), - items: state.regions.map< + code: selectedMunicipality! + .code!); + } catch (e) { + NavigationService + .navigatorKey + .currentContext + ?.read< + ReferencesBloc>() + .add( + CallErrorState()); + } + selectedBarangay = + barangays![0]; + setState(() { + barangayCall = false; + }); + }, + decoration: + normalTextFieldStyle( + "Municipality*", + "Municipality"), + value: selectedMunicipality, + items: citymuns == null + ? [] + : citymuns!.map< DropdownMenuItem< - Region>>( - (Region region) { - return DropdownMenuItem< - Region>( - value: region, - child: Text( - region.description!)); - }).toList(), - ), - const SizedBox( - height: 12, - ), - //// PROVINCE DROPDOWN - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: (value) => - value == null - ? 'required' - : null, - isExpanded: true, - onChanged: (Province? - province) async { - selectedProvince = - province; - setState(() { - cityCall = true; - }); - //// GET CITIES - try { - citymuns = - await LocationUtils - .instance - .getCities( - code: selectedProvince! - .code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - ReferencesBloc>() - .add( - CallErrorState()); - } - selectedMunicipality = - citymuns![0]; - setState(() { - cityCall = false; - barangayCall = true; - }); - //// GET BARANGAY - try { - barangays = - await LocationUtils - .instance - .getBarangay( - code: selectedMunicipality! - .code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - ReferencesBloc>() - .add( - CallErrorState()); - } - selectedBarangay = - barangays![0]; - setState(() { - barangayCall = false; - }); - }, - value: selectedProvince, - items: provinces == null - ? [] - : provinces!.map< - DropdownMenuItem< - Province>>( - (Province - province) { - return DropdownMenuItem( - value: - province, - child: - FittedBox( - child: Text( - province - .description!), - )); - }).toList(), - decoration: - normalTextFieldStyle( - "Province*", - "Province")), - ), - ), - ////CITY MUNICIPALITY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: cityCall, - child: - DropdownButtonFormField< - CityMunicipality>( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - isExpanded: true, - onChanged: - (CityMunicipality? - city) async { - setState(() { - barangayCall = true; - }); - selectedMunicipality = - city; - //// GET BARANGAYS - try { - barangays = - await LocationUtils - .instance - .getBarangay( - code: selectedMunicipality! - .code!); - } catch (e) { - NavigationService - .navigatorKey - .currentContext - ?.read< - ReferencesBloc>() - .add( - CallErrorState()); - } - selectedBarangay = - barangays![0]; - setState(() { - barangayCall = false; - }); - }, - decoration: - normalTextFieldStyle( - "Municipality*", - "Municipality"), - value: selectedMunicipality, - items: citymuns == null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality - c) { - return DropdownMenuItem( - value: c, - child: Text(c - .description!)); - }).toList(), - ), - ), - ), - //// BARANGAY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: barangayCall, - child: - DropdownButtonFormField< - Barangay>( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - isExpanded: true, - onChanged: - (Barangay? baragay) { - selectedBarangay = - baragay; - }, - decoration: - normalTextFieldStyle( - "Barangay*", - "Barangay"), - value: selectedBarangay, - items: barangays == null - ? [] - : barangays!.map< - DropdownMenuItem< - Barangay>>( - (Barangay - barangay) { - return DropdownMenuItem( - value: barangay, - child: Text(barangay - .description!)); - }).toList(), - ), - ), - ), - ], - ) - //// COUNTRY DROPDOWN - : SizedBox( - height: 60, - child: DropdownButtonFormField< - Country>( - isExpanded: true, - value: selectedCountry?.id == 175 - ? null - : selectedCountry, - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - items: state.countries.map< - DropdownMenuItem< - Country>>( - (Country country) { - return DropdownMenuItem< - Country>( - value: country, - child: FittedBox( - child: Text( - country.name!))); - }).toList(), - - decoration: normalTextFieldStyle( - "Country*", "Country"), - //// country dropdown - onChanged: (Country? value) { - selectedCountry = value; - }, - ), + CityMunicipality>>( + (CityMunicipality + c) { + return DropdownMenuItem( + value: c, + child: Text(c + .description!)); + }).toList(), ), - ), - ], - ); - }), + ), + ), + //// BARANGAY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: barangayCall, + child: + DropdownButtonFormField< + Barangay>( + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + isExpanded: true, + onChanged: + (Barangay? baragay) { + selectedBarangay = + baragay; + }, + decoration: + normalTextFieldStyle( + "Barangay*", + "Barangay"), + value: selectedBarangay, + items: barangays == null + ? [] + : barangays!.map< + DropdownMenuItem< + Barangay>>( + (Barangay + barangay) { + return DropdownMenuItem( + value: barangay, + child: Text(barangay + .description!)); + }).toList(), + ), + ), + ), + ], + ) + //// COUNTRY DROPDOWN + : SizedBox( + height: 60, + child: DropdownButtonFormField< + Country>( + isExpanded: true, + value: selectedCountry?.id == 175 + ? null + : selectedCountry, + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + items: state.countries.map< + DropdownMenuItem< + Country>>( + (Country country) { + return DropdownMenuItem< + Country>( + value: country, + child: FittedBox( + child: Text( + country.name!))); + }).toList(), - const SizedBox( - height: 20, - ), - ], - ), - ), - SizedBox( + decoration: normalTextFieldStyle( + "Country*", "Country"), + //// country dropdown + onChanged: (Country? value) { + selectedCountry = value; + }, + ), + ), + ), + ], + ); + }), + const SizedBox(height: 16,), + SizedBox( width: double.infinity, height: 60, child: ElevatedButton( @@ -616,8 +604,7 @@ class _EditReferenceScreenState extends State { }, ), ), - ], - ), + ], ), )); } diff --git a/lib/screens/profile/components/references_screen.dart b/lib/screens/profile/components/references_screen.dart index ab349c4..a9731fe 100644 --- a/lib/screens/profile/components/references_screen.dart +++ b/lib/screens/profile/components/references_screen.dart @@ -23,7 +23,7 @@ class ReferencesScreen extends StatelessWidget { int? profileId; String? token; return Scaffold( - resizeToAvoidBottomInset: false, + resizeToAvoidBottomInset: true, appBar: AppBar( title: context.watch().state is AddReferenceState ? const Text("Add Personal Reference") diff --git a/lib/screens/profile/components/voluntary_works/add_modal.dart b/lib/screens/profile/components/voluntary_works/add_modal.dart index 88c5198..ffea1bf 100644 --- a/lib/screens/profile/components/voluntary_works/add_modal.dart +++ b/lib/screens/profile/components/voluntary_works/add_modal.dart @@ -85,597 +85,592 @@ class _AddVoluntaryWorkScreenState extends State { padding: const EdgeInsets.symmetric(vertical: 32, horizontal: 28), child: FormBuilder( key: formKey, - child: Column( + child: ListView( children: [ - Flexible( - child: ListView( + ////POSITIONS + StatefulBuilder(builder: (context, setState) { + return SearchField( + inputFormatters: [UpperCaseTextFormatter()], + itemHeight: 70, + suggestionsDecoration: box1(), + suggestions: state.positions + .map((PositionTitle position) => + SearchFieldListItem(position.title!, + item: position, + child: Padding( + padding: + const EdgeInsets.symmetric( + horizontal: 10), + child: ListTile( + title: Text( + position.title!, + overflow: + TextOverflow.visible, + ), + )))) + .toList(), + focusNode: positionFocusNode, + searchInputDecoration: + normalTextFieldStyle("Position *", "") + .copyWith( + suffixIcon: GestureDetector( + child: const Icon(Icons.arrow_drop_down), + onTap: () => positionFocusNode.unfocus(), + )), + onSuggestionTap: (position) { + setState(() { + selectedPosition = position.item; + positionFocusNode.unfocus(); + }); + }, + ////EMPTY WIDGET + emptyWidget: EmptyWidget( + title: "Add Position", + controller: addPositionController, + onpressed: () { + setState(() { + PositionTitle newAgencyPosition = PositionTitle( + id: null, + title: addPositionController.text + .toUpperCase()); + + state.positions + .insert(0, newAgencyPosition); + + addPositionController.text = ""; + Navigator.pop(context); + }); + }), + validator: (position) { + if (position!.isEmpty) { + return "This field is required"; + } + return null; + }, + ); + }), + const SizedBox( + height: 12, + ), + ////AGENCY + StatefulBuilder(builder: (context, setState) { + return Column( children: [ - ////POSITIONS - StatefulBuilder(builder: (context, setState) { - return SearchField( + SearchField( inputFormatters: [UpperCaseTextFormatter()], - itemHeight: 70, - suggestionsDecoration: box1(), - suggestions: state.positions - .map((PositionTitle position) => - SearchFieldListItem(position.title!, - item: position, - child: Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 10), - child: ListTile( - title: Text( - position.title!, - overflow: - TextOverflow.visible, - ), - )))) + itemHeight: 100, + focusNode: agencyFocusNode, + suggestions: state.agencies + .map((Agency agency) => + SearchFieldListItem(agency.name!, + item: agency, + child: ListTile( + title: Text( + agency.name!, + overflow: + TextOverflow.visible, + ), + subtitle: Text(agency + .privateEntity == + true + ? "Private" + : agency.privateEntity == + false + ? "Government" + : ""), + ))) .toList(), - focusNode: positionFocusNode, searchInputDecoration: - normalTextFieldStyle("Position *", "") + normalTextFieldStyle("Agency *", "") .copyWith( suffixIcon: GestureDetector( - child: const Icon(Icons.arrow_drop_down), - onTap: () => positionFocusNode.unfocus(), + child: const Icon( + Icons.arrow_drop_down, + ), + onTap: () => agencyFocusNode.unfocus(), )), - onSuggestionTap: (position) { + ////SELETECTED + onSuggestionTap: (agency) { setState(() { - selectedPosition = position.item; - positionFocusNode.unfocus(); + selectedAgency = agency.item; + if (selectedAgency!.privateEntity == + null) { + showAgency = true; + showIsPrivateRadio = true; + } else { + showAgency = false; + showIsPrivateRadio = false; + } + agencyFocusNode.unfocus(); }); }, - ////EMPTY WIDGET - emptyWidget: EmptyWidget( - title: "Add Position", - controller: addPositionController, - onpressed: () { - setState(() { - PositionTitle newAgencyPosition = PositionTitle( - id: null, - title: addPositionController.text - .toUpperCase()); - - state.positions - .insert(0, newAgencyPosition); - - addPositionController.text = ""; - Navigator.pop(context); - }); - }), - validator: (position) { - if (position!.isEmpty) { + validator: (agency) { + if (agency!.isEmpty) { return "This field is required"; } return null; }, - ); - }), - const SizedBox( - height: 12, + emptyWidget: EmptyWidget( + controller: addAgencyController, + onpressed: () { + setState(() { + Agency newAgency = Agency( + id: null, + name: addAgencyController.text + .toUpperCase(), + category: null, + privateEntity: null); + state.agencies.insert(0, newAgency); + + addAgencyController.text = ""; + Navigator.pop(context); + }); + }, + title: "Add Agency")), + + SizedBox( + height: showAgency ? 12 : 0, ), - ////AGENCY - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - SearchField( - inputFormatters: [UpperCaseTextFormatter()], - itemHeight: 100, - focusNode: agencyFocusNode, - suggestions: state.agencies - .map((Agency agency) => - SearchFieldListItem(agency.name!, - item: agency, + ////SHOW CATEGORY AGENCY + SizedBox( + child: showAgency + ? SearchField( + focusNode: agencyCategoryFocusNode, + itemHeight: 70, + suggestions: state.agencyCategory + .map((Category category) => + SearchFieldListItem( + category.name!, + item: category, child: ListTile( title: Text( - agency.name!, - overflow: - TextOverflow.visible, - ), - subtitle: Text(agency - .privateEntity == - true - ? "Private" - : agency.privateEntity == - false - ? "Government" - : ""), + category.name!), + subtitle: Text(category + .industryClass! + .name!), ))) .toList(), - searchInputDecoration: - normalTextFieldStyle("Agency *", "") - .copyWith( - suffixIcon: GestureDetector( - child: const Icon( - Icons.arrow_drop_down, - ), - onTap: () => agencyFocusNode.unfocus(), - )), - ////SELETECTED - onSuggestionTap: (agency) { + emptyWidget: Container( + height: 100, + decoration: box1(), + child: const Center( + child: Text( + "No result found ...")), + ), + onSuggestionTap: (agencyCategory) { setState(() { - selectedAgency = agency.item; - if (selectedAgency!.privateEntity == - null) { - showAgency = true; - showIsPrivateRadio = true; - } else { - showAgency = false; - showIsPrivateRadio = false; - } - agencyFocusNode.unfocus(); + selectedCategoty = + agencyCategory.item; + agencyCategoryFocusNode.unfocus(); }); }, - validator: (agency) { - if (agency!.isEmpty) { + searchInputDecoration: + normalTextFieldStyle( + "Category *", "") + .copyWith( + suffixIcon: IconButton( + icon: const Icon( + Icons.arrow_drop_down), + onPressed: () { + agencyCategoryFocusNode.unfocus(); + }, + )), + validator: (value) { + if (value!.isEmpty) { return "This field is required"; } return null; }, - emptyWidget: EmptyWidget( - controller: addAgencyController, - onpressed: () { - setState(() { - Agency newAgency = Agency( - id: null, - name: addAgencyController.text - .toUpperCase(), - category: null, - privateEntity: null); - state.agencies.insert(0, newAgency); + ) + : const SizedBox(), + ), + SizedBox( + height: showIsPrivateRadio ? 12 : 0, + ), + ////PRVIATE SECTOR + SizedBox( + child: showIsPrivateRadio + ? FormBuilderSwitch( + initialValue: false, + title: + Text(isPrivate ? "YES" : "NO"), + decoration: normalTextFieldStyle( + "Private Entity?", + 'Private Entity?'), - addAgencyController.text = ""; - Navigator.pop(context); - }); - }, - title: "Add Agency")), + ////onvhange private sector + onChanged: (value) { + setState(() { + isPrivate = value!; + agencyCategoryFocusNode + .unfocus(); + }); + }, - SizedBox( - height: showAgency ? 12 : 0, - ), - ////SHOW CATEGORY AGENCY - SizedBox( - child: showAgency - ? SearchField( - focusNode: agencyCategoryFocusNode, - itemHeight: 70, - suggestions: state.agencyCategory - .map((Category category) => - SearchFieldListItem( - category.name!, - item: category, - child: ListTile( - title: Text( - category.name!), - subtitle: Text(category - .industryClass! - .name!), - ))) - .toList(), - emptyWidget: Container( - height: 100, - decoration: box1(), - child: const Center( - child: Text( - "No result found ...")), - ), - onSuggestionTap: (agencyCategory) { - setState(() { - selectedCategoty = - agencyCategory.item; - agencyCategoryFocusNode.unfocus(); - }); - }, - searchInputDecoration: - normalTextFieldStyle( - "Category *", "") - .copyWith( - suffixIcon: IconButton( - icon: const Icon( - Icons.arrow_drop_down), - onPressed: () { - agencyCategoryFocusNode.unfocus(); - }, - )), - validator: (value) { - if (value!.isEmpty) { - return "This field is required"; - } - return null; - }, - ) - : const SizedBox(), - ), - SizedBox( - height: showIsPrivateRadio ? 12 : 0, - ), - ////PRVIATE SECTOR - SizedBox( - child: showIsPrivateRadio - ? FormBuilderSwitch( - initialValue: false, - title: - Text(isPrivate ? "YES" : "NO"), - decoration: normalTextFieldStyle( - "Private Entity?", - 'Private Entity?'), - - ////onvhange private sector - onChanged: (value) { - setState(() { - isPrivate = value!; - agencyCategoryFocusNode - .unfocus(); - }); - }, - - name: 'isPrivate', - validator: FormBuilderValidators - .required(), - ) - : const SizedBox()), - const SizedBox( - height: 12, - ), - //// total hours - FormBuilderTextField( - validator: FormBuilderValidators.required( - errorText: "This Field is required"), - name: "total_hours", - keyboardType: TextInputType.number, - decoration: - normalTextFieldStyle("Total Hours*", "0"), - ), - const SizedBox( - height: 12, - ), - ////Currently Involved - StatefulBuilder(builder: (context, setState) { - return Column( - children: [ - FormBuilderSwitch( - initialValue: currentlyInvolved, - activeColor: second, - onChanged: (value) { - setState(() { - currentlyInvolved = value!; - }); - }, - decoration: normalTextFieldStyle( - "Currently Involved?", - 'Graduated?'), - name: 'currently_involved', - title: Text( - currentlyInvolved ? "YES" : "NO"), - ), - const SizedBox( - height: 12, - ), - SizedBox( - width: screenWidth, - child: StatefulBuilder( - builder: (context, setState) { - return Row( - children: [ - //// FROM DATE - Flexible( - flex: 1, - child: DateTimePicker( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - use24HourFormat: false, - icon: const Icon( - Icons.date_range), - controller: - fromDateController, - firstDate: DateTime(1990), - lastDate: DateTime(2100), - selectableDayPredicate: - (date) { - if (to != null && - to!.microsecondsSinceEpoch <= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - from = DateTime.parse( - value); - }); - }, - initialDate: to == null - ? DateTime.now() - : to!.subtract( - const Duration( - days: 1)), - timeHintText: - "Date of Examination/Conferment", - decoration: - normalTextFieldStyle( - "From *", - "From *") - .copyWith( - prefixIcon: - const Icon( - Icons.date_range, - color: Colors.black87, - )), - initialValue: null, - )), - const SizedBox( - width: 12, - ), - //// TO DATE - Flexible( - flex: 1, - child: currentlyInvolved - ? TextFormField( - enabled: false, - initialValue: "PRESENT", - style: const TextStyle( - color: - Colors.black45), - decoration: - normalTextFieldStyle( - "", "") - .copyWith(), - ) - : DateTimePicker( - validator: - FormBuilderValidators - .required( - errorText: - "This field is required"), - controller: - toDateController, - selectableDayPredicate: - (date) { - if (from != null && - from!.microsecondsSinceEpoch >= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, - onChanged: (value) { - setState(() { - to = DateTime.parse( - value); - }); - }, - initialDate: from == - null - ? DateTime.now() - : from!.add( - const Duration( - days: 1)), - firstDate: - DateTime(1990), - lastDate: - DateTime(2100), - decoration: normalTextFieldStyle( - "To *", "To *") - .copyWith( - prefixIcon: - const Icon( - Icons - .date_range, - color: Colors - .black87, - ), - prefixText: - currentlyInvolved - ? "PRESENT" - : ""), - initialValue: null, - ), - ), - ], - ); - }), - ), - ], - ); - }), - ], - ); - }), + name: 'isPrivate', + validator: FormBuilderValidators + .required(), + ) + : const SizedBox()), const SizedBox( height: 12, ), - //// OVERSEAS + //// total hours + FormBuilderTextField( + validator: FormBuilderValidators.required( + errorText: "This Field is required"), + name: "total_hours", + keyboardType: TextInputType.number, + decoration: + normalTextFieldStyle("Total Hours*", "0"), + ), + const SizedBox( + height: 12, + ), + ////Currently Involved StatefulBuilder(builder: (context, setState) { return Column( children: [ FormBuilderSwitch( - initialValue: overseas, + initialValue: currentlyInvolved, activeColor: second, onChanged: (value) { setState(() { - overseas = value!; + currentlyInvolved = value!; }); }, decoration: normalTextFieldStyle( - "Overseas Address?", ''), - name: 'overseas', - title: Text(overseas ? "YES" : "NO"), + "Currently Involved?", + 'Graduated?'), + name: 'currently_involved', + title: Text( + currentlyInvolved ? "YES" : "NO"), + ), + const SizedBox( + height: 12, ), SizedBox( - height: overseas == true ? 12 : 0, - ), - SizedBox( - child: overseas == false - ? Column( - children: [ - const SizedBox( - height: 12, - ), - ////REGION DROPDOWN - FormBuilderDropdown( - autovalidateMode: AutovalidateMode - .onUserInteraction, + width: screenWidth, + child: StatefulBuilder( + builder: (context, setState) { + return Row( + children: [ + //// FROM DATE + Flexible( + flex: 1, + child: DateTimePicker( validator: FormBuilderValidators .required( errorText: "This field is required"), - onChanged: - (Region? region) async { - if (selectedRegion != region) { - setState(() { - provinceCall = true; - }); - selectedRegion = region; - getProvinces(); - } + use24HourFormat: false, + icon: const Icon( + Icons.date_range), + controller: + fromDateController, + firstDate: DateTime(1990), + lastDate: DateTime(2100), + // selectableDayPredicate: + // (date) { + // if (to != null && + // to!.microsecondsSinceEpoch >= + // date.microsecondsSinceEpoch) { + // return false; + // } + // return true; + // }, + onChanged: (value) { + setState(() { + from = DateTime.parse( + value); + }); }, + initialDate: to == null + ? DateTime.now() + : to!.subtract( + const Duration( + days: 1)), + timeHintText: + "Date of Examination/Conferment", + decoration: + normalTextFieldStyle( + "From *", + "From *") + .copyWith( + prefixIcon: + const Icon( + Icons.date_range, + color: Colors.black87, + )), initialValue: null, - decoration: normalTextFieldStyle( - "Region*", "Region"), - name: 'region', - items: state.regions.map< - DropdownMenuItem>( - (Region region) { - return DropdownMenuItem( - value: region, - child: Text( - region.description!)); - }).toList(), - ), - const SizedBox( - height: 12, - ), - //// PROVINCE DROPDOWN - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.transparent, - inAsyncCall: provinceCall, - child: DropdownButtonFormField< - Province?>( - autovalidateMode: - AutovalidateMode - .onUserInteraction, - validator: (value) => - value == null - ? 'required' - : null, - isExpanded: true, - value: selectedProvince, - onChanged: - (Province? province) { - if (selectedProvince != - province) { - setState(() { - cityCall = true; - }); - selectedProvince = - province; - getCities(); - } - }, - items: provinces == null - ? [] - : provinces!.map< - DropdownMenuItem< - Province>>( - (Province - province) { - return DropdownMenuItem( - value: province, - child: - FittedBox( - child: Text( - province - .description!), - )); - }).toList(), - decoration: - normalTextFieldStyle( - "Province*", - "Province")), - ), - ), - ////CITY MUNICIPALITY - SizedBox( - height: 60, - child: ModalProgressHUD( - color: Colors.white, - inAsyncCall: cityCall, - child: DropdownButtonFormField< - CityMunicipality>( - validator: FormBuilderValidators - .required( - errorText: - "This field is required"), - isExpanded: true, - onChanged: - (CityMunicipality? city) { - if (selectedMunicipality != - city) { - selectedMunicipality = - city; - } - }, + )), + const SizedBox( + width: 12, + ), + //// TO DATE + Flexible( + flex: 1, + child: currentlyInvolved + ? TextFormField( + enabled: false, + initialValue: "PRESENT", + style: const TextStyle( + color: + Colors.black45), decoration: normalTextFieldStyle( - "Municipality*", - "Municipality"), - value: selectedMunicipality, - items: citymuns == null - ? [] - : citymuns!.map< - DropdownMenuItem< - CityMunicipality>>( - (CityMunicipality c) { - return DropdownMenuItem( - value: c, - child: Text(c - .description!)); - }).toList(), + "", "") + .copyWith(), + ) + : DateTimePicker( + validator: + FormBuilderValidators + .required( + errorText: + "This field is required"), + controller: + toDateController, + // selectableDayPredicate: + // (date) { + // if (from != null && + // from!.microsecondsSinceEpoch > + // date.microsecondsSinceEpoch) { + // return false; + // } + // return true; + // }, + onChanged: (value) { + setState(() { + to = DateTime.parse( + value); + }); + }, + initialDate: from == + null + ? DateTime.now() + : from!.add( + const Duration( + days: 1)), + firstDate: + DateTime(1990), + lastDate: + DateTime(2100), + decoration: normalTextFieldStyle( + "To *", "To *") + .copyWith( + prefixIcon: + const Icon( + Icons + .date_range, + color: Colors + .black87, + ), + prefixText: + currentlyInvolved + ? "PRESENT" + : ""), + initialValue: null, ), - ), - ), - ], - ) - //// COUNTRY DROPDOWN - : SizedBox( - height: 60, - child: FormBuilderDropdown( - initialValue: null, - validator: - FormBuilderValidators.required( - errorText: - "This field is required"), - items: state.countries - .map>( - (Country country) { - return DropdownMenuItem( - value: country, - child: FittedBox( - child: - Text(country.name!))); - }).toList(), - name: 'country', - decoration: normalTextFieldStyle( - "Country*", "Country"), - onChanged: (Country? value) { - selectedCountry = value; - }, - ), ), + ], + ); + }), ), ], ); }), ], - ), + ); + }), + const SizedBox( + height: 12, ), - SizedBox( + //// OVERSEAS + StatefulBuilder(builder: (context, setState) { + return Column( + children: [ + FormBuilderSwitch( + initialValue: overseas, + activeColor: second, + onChanged: (value) { + setState(() { + overseas = value!; + }); + }, + decoration: normalTextFieldStyle( + "Overseas Address?", ''), + name: 'overseas', + title: Text(overseas ? "YES" : "NO"), + ), + SizedBox( + height: overseas == true ? 12 : 0, + ), + SizedBox( + child: overseas == false + ? Column( + children: [ + const SizedBox( + height: 12, + ), + ////REGION DROPDOWN + FormBuilderDropdown( + autovalidateMode: AutovalidateMode + .onUserInteraction, + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + onChanged: + (Region? region) async { + if (selectedRegion != region) { + setState(() { + provinceCall = true; + }); + selectedRegion = region; + getProvinces(); + } + }, + initialValue: null, + decoration: normalTextFieldStyle( + "Region*", "Region"), + name: 'region', + items: state.regions.map< + DropdownMenuItem>( + (Region region) { + return DropdownMenuItem( + value: region, + child: Text( + region.description!)); + }).toList(), + ), + const SizedBox( + height: 12, + ), + //// PROVINCE DROPDOWN + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.transparent, + inAsyncCall: provinceCall, + child: DropdownButtonFormField< + Province?>( + autovalidateMode: + AutovalidateMode + .onUserInteraction, + validator: (value) => + value == null + ? 'required' + : null, + isExpanded: true, + value: selectedProvince, + onChanged: + (Province? province) { + if (selectedProvince != + province) { + setState(() { + cityCall = true; + }); + selectedProvince = + province; + getCities(); + } + }, + items: provinces == null + ? [] + : provinces!.map< + DropdownMenuItem< + Province>>( + (Province + province) { + return DropdownMenuItem( + value: province, + child: + FittedBox( + child: Text( + province + .description!), + )); + }).toList(), + decoration: + normalTextFieldStyle( + "Province*", + "Province")), + ), + ), + ////CITY MUNICIPALITY + SizedBox( + height: 60, + child: ModalProgressHUD( + color: Colors.white, + inAsyncCall: cityCall, + child: DropdownButtonFormField< + CityMunicipality>( + validator: FormBuilderValidators + .required( + errorText: + "This field is required"), + isExpanded: true, + onChanged: + (CityMunicipality? city) { + if (selectedMunicipality != + city) { + selectedMunicipality = + city; + } + }, + decoration: + normalTextFieldStyle( + "Municipality*", + "Municipality"), + value: selectedMunicipality, + items: citymuns == null + ? [] + : citymuns!.map< + DropdownMenuItem< + CityMunicipality>>( + (CityMunicipality c) { + return DropdownMenuItem( + value: c, + child: Text(c + .description!)); + }).toList(), + ), + ), + ), + ], + ) + //// COUNTRY DROPDOWN + : SizedBox( + height: 60, + child: FormBuilderDropdown( + initialValue: null, + validator: + FormBuilderValidators.required( + errorText: + "This field is required"), + items: state.countries + .map>( + (Country country) { + return DropdownMenuItem( + value: country, + child: FittedBox( + child: + Text(country.name!))); + }).toList(), + name: 'country', + decoration: normalTextFieldStyle( + "Country*", "Country"), + onChanged: (Country? value) { + selectedCountry = value; + }, + ), + ), + ), + ], + ); + }), + const SizedBox(height: 16,), + SizedBox( width: double.infinity, height: 60, child: ElevatedButton( diff --git a/lib/screens/profile/components/voluntary_works/edit_modal.dart b/lib/screens/profile/components/voluntary_works/edit_modal.dart index 520a478..29b420c 100644 --- a/lib/screens/profile/components/voluntary_works/edit_modal.dart +++ b/lib/screens/profile/components/voluntary_works/edit_modal.dart @@ -156,6 +156,7 @@ class _EditVoluntaryWorkScreenState extends State { onSuggestionTap: (position) { setState(() { selectedPosition = position.item; + print(selectedPosition!.title); positionFocusNode.unfocus(); }); }, @@ -193,6 +194,8 @@ class _EditVoluntaryWorkScreenState extends State { return Column( children: [ SearchField( + + enabled: false, inputFormatters: [ UpperCaseTextFormatter() ], @@ -222,6 +225,8 @@ class _EditVoluntaryWorkScreenState extends State { searchInputDecoration: normalTextFieldStyle("Agency *", "") .copyWith( + filled: true, + fillColor: Colors.grey.shade300, suffixIcon: GestureDetector( child: const Icon( Icons.arrow_drop_down, @@ -267,7 +272,10 @@ class _EditVoluntaryWorkScreenState extends State { }); }, title: "Add Agency")), - + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("You cannot change agency on update mode",style: Theme.of(context).textTheme.bodySmall,), + ), SizedBox( height: showAgency ? 12 : 0, ), @@ -424,15 +432,7 @@ class _EditVoluntaryWorkScreenState extends State { Icons.date_range, color: Colors.black87, )), - selectableDayPredicate: - (date) { - if (to != null && - to!.microsecondsSinceEpoch <= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, + onChanged: (value) { setState(() { from = DateTime.parse( @@ -475,15 +475,7 @@ class _EditVoluntaryWorkScreenState extends State { DateTime(1990), lastDate: DateTime(2100), - selectableDayPredicate: - (date) { - if (from != null && - from!.microsecondsSinceEpoch >= - date.microsecondsSinceEpoch) { - return false; - } - return true; - }, + onChanged: (value) { setState(() { to = DateTime.parse( @@ -522,6 +514,7 @@ class _EditVoluntaryWorkScreenState extends State { ], ); }), + const SizedBox( height: 12, ), diff --git a/lib/screens/profile/components/work_history/add_modal.dart b/lib/screens/profile/components/work_history/add_modal.dart index 75b0aab..5c353b4 100644 --- a/lib/screens/profile/components/work_history/add_modal.dart +++ b/lib/screens/profile/components/work_history/add_modal.dart @@ -197,6 +197,7 @@ class _AddWorkHistoryScreenState extends State { ////AGENCY StatefulBuilder(builder: (context, setState) { return Column( + mainAxisAlignment: MainAxisAlignment.start, children: [ SearchField( inputFormatters: [UpperCaseTextFormatter()], @@ -407,6 +408,7 @@ class _AddWorkHistoryScreenState extends State { SizedBox( child: showSalaryGradeAndSalaryStep ? Column( + mainAxisAlignment: MainAxisAlignment.start, children: [ Row( children: [ @@ -481,20 +483,7 @@ class _AddWorkHistoryScreenState extends State { ], ); }), - const SizedBox( - height: 12, - ), - //// NAME OF OFFICE UNIT - FormBuilderTextField( - onChanged: (value){ - sOffice = value; - }, - validator: FormBuilderValidators.required( - errorText: "This field is required"), - name: 'office', - decoration: normalTextFieldStyle( - "Name of Office/Unit", "Name of Office/Unit"), - ), + const SizedBox( height: 12, ), @@ -518,7 +507,10 @@ class _AddWorkHistoryScreenState extends State { const SizedBox( height: 12, ), - const Text("Immediate SuperVisor"), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("Immediate SuperVisor",textAlign: TextAlign.start, style: Theme.of(context).textTheme.titleMedium,), + ), const SizedBox( height: 12, ), @@ -557,12 +549,26 @@ class _AddWorkHistoryScreenState extends State { decoration: normalTextFieldStyle("Last name", "Last Name"), ), - + const SizedBox( + height: 12, + ), + //// NAME OF OFFICE UNIT + FormBuilderTextField( + onChanged: (value){ + sOffice = value; + }, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + name: 'office', + decoration: normalTextFieldStyle( + "Name of Office/Unit", "Name of Office/Unit"), + ), const SizedBox( height: 12, ), StatefulBuilder(builder: (context, setState) { return Column( + mainAxisAlignment: MainAxisAlignment.start, children: [ ////CURRENTLY EMPLOYED FormBuilderSwitch( @@ -690,12 +696,18 @@ class _AddWorkHistoryScreenState extends State { ], ); }), - - const Text("Work Experience"), + const SizedBox( + height: 8, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("Work Experience",style: Theme.of(context).textTheme.titleMedium,), + ), const SizedBox( height: 8, ), FormBuilderTextField( + maxLines: 3, onChanged: (value){ accomplishment = value; }, @@ -709,6 +721,7 @@ class _AddWorkHistoryScreenState extends State { height: 12, ), FormBuilderTextField( + maxLines: 3, onChanged: (value){ duties = value; }, @@ -733,8 +746,7 @@ class _AddWorkHistoryScreenState extends State { style: mainBtnStyle(primary, Colors.transparent, second), onPressed: () { - print(salaryGrade); - print(salaryGradeStep); + if (_formKey.currentState!.validate()) { final progress = ProgressHUD.of(context); diff --git a/lib/screens/profile/components/work_history/edit_modal.dart b/lib/screens/profile/components/work_history/edit_modal.dart index 5c0f633..5e8eafd 100644 --- a/lib/screens/profile/components/work_history/edit_modal.dart +++ b/lib/screens/profile/components/work_history/edit_modal.dart @@ -48,6 +48,12 @@ class _EditWorkHistoryScreenState extends State { String? salary; String? salaryGrade; String? salaryGradeStep; + String? accomplishments; + String? duties; + String? sFname; + String? sMname; + String? sLname; + String? sOffice; //show agency category is a variable to show adding of agency category if you add agency manually bool showAgencyCategory = false; //showSalaryGadeAndSalaryStep is a variable that will show salary @@ -91,6 +97,12 @@ class _EditWorkHistoryScreenState extends State { currentlyEmployed = state.workHistory.toDate == null ? true : false; from = state.workHistory.fromDate; to = state.workHistory.toDate; + accomplishments = state.workHistory.accomplishment == null?null:state.workHistory.accomplishment!.first.accomplishment!; + duties = state.workHistory.actualDuties == null? null:state.workHistory.actualDuties!.first.description; + sFname = state.workHistory.supervisor?.firstname; + sMname = state.workHistory.supervisor?.middlename; + sLname = state.workHistory.supervisor?.lastname; + sOffice = state.workHistory.supervisor?.stationName; return FormBuilder( key: _formKey, child: SizedBox( @@ -146,10 +158,11 @@ class _EditWorkHistoryScreenState extends State { controller: addPositionController, onpressed: () { setState(() { - PositionTitle newAgencyPosition = PositionTitle( - id: null, - title: addPositionController.text - .toUpperCase()); + PositionTitle newAgencyPosition = + PositionTitle( + id: null, + title: addPositionController.text + .toUpperCase()); state.agencyPositions .insert(0, newAgencyPosition); selectedPosition = newAgencyPosition; @@ -209,8 +222,10 @@ class _EditWorkHistoryScreenState extends State { ////AGENCY StatefulBuilder(builder: (context, setState) { return Column( + mainAxisAlignment: MainAxisAlignment.start, children: [ SearchField( + enabled: false, inputFormatters: [UpperCaseTextFormatter()], controller: oldAgencyController, itemHeight: 100, @@ -288,6 +303,7 @@ class _EditWorkHistoryScreenState extends State { }); }, title: "Add Agency")), + Text("You cannot change agency on update mode",textAlign: TextAlign.start,style: Theme.of(context).textTheme.bodySmall,), SizedBox( height: showAgencyCategory ? 12 : 0, @@ -476,6 +492,7 @@ class _EditWorkHistoryScreenState extends State { ], ); }), + const SizedBox( height: 12, ), @@ -494,10 +511,71 @@ class _EditWorkHistoryScreenState extends State { normalTextFieldStyle("Monthly Salary *", "") .copyWith(prefix: const Text("₱ ")), ), - + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("Immediate SuperVisor",style: Theme.of(context).textTheme.titleMedium,), + ), const SizedBox( height: 12, ), + ////IMMEDIATE SUPERVISOR + FormBuilderTextField( + initialValue: sFname, + onChanged: (value) { + sFname = value; + }, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + name: 'supervisor_firstname', + decoration: normalTextFieldStyle( + "First name", "First Name"), + ), + const SizedBox( + height: 12, + ), + FormBuilderTextField( + initialValue: sMname, + onChanged: (value) { + sMname = value; + }, + name: 'supervisor_middlename', + decoration: normalTextFieldStyle( + "Middle name", "Middle Name"), + ), + const SizedBox( + height: 12, + ), + FormBuilderTextField( + initialValue: sLname, + onChanged: (value) { + sLname = value; + }, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + name: 'supervisor_lastname', + decoration: + normalTextFieldStyle("Last name", "Last Name"), + ), + + const SizedBox( + height: 12, + ), + //// NAME OF OFFICE UNIT + FormBuilderTextField( + initialValue: + sOffice, + onChanged: (value) { + sOffice = value; + }, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + name: 'office', + decoration: normalTextFieldStyle( + "Name of Office/Unit", "Name of Office/Unit"), + ), + const SizedBox( + height: 12, + ), StatefulBuilder(builder: (context, setState) { return Column( children: [ @@ -640,12 +718,52 @@ class _EditWorkHistoryScreenState extends State { ); }), ), + const SizedBox( + height: 8, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Text("Work Experience",textAlign: TextAlign.start, style: Theme.of(context).textTheme.titleMedium,), + ), + const SizedBox( + height: 8, + ), + FormBuilderTextField( + initialValue: accomplishments, + maxLines: 3, + onChanged: (value){ + accomplishments = value; + }, + name: "accomplishment", + decoration: normalTextFieldStyle( + "List of Accomplishment and Contribution", + "", + ), + ), + const SizedBox( + height: 12, + ), + FormBuilderTextField( + initialValue: duties, + maxLines: 3, + onChanged: (value){ + duties = value; + }, + validator: FormBuilderValidators.required( + errorText: "This field is required"), + name: "summary", + decoration: normalTextFieldStyle( + "Summary of Actual Duties", + "", + ), + ), ], ); }), ], ), ), + const SizedBox(height: 25,), ////SUBMIT BUTTON SizedBox( width: double.infinity, @@ -654,50 +772,55 @@ class _EditWorkHistoryScreenState extends State { style: mainBtnStyle(primary, Colors.transparent, second), onPressed: () { - // if (_formKey.currentState!.saveAndValidate()) { - // final progress = ProgressHUD.of(context); - // progress!.showWithText("Loading..."); - // salary = _formKey.currentState!.value['salary']; - // selectedPosition ??= state.workHistory.position; - // salaryGrade = - // _formKey.currentState!.value['salary_grade']; - // salaryGradeStep = - // _formKey.currentState!.value['salary_step']; - // selectedAgency ??= state.workHistory.agency; + if (_formKey.currentState!.saveAndValidate()) { + final progress = ProgressHUD.of(context); + progress!.showWithText("Loading..."); + salary = _formKey.currentState!.value['salary']; + selectedPosition ??= state.workHistory.position; + salaryGrade = + _formKey.currentState!.value['salary_grade']; + salaryGradeStep = + _formKey.currentState!.value['salary_step']; + selectedAgency ??= state.workHistory.agency; - // selectedStatus ??= AppoinemtStatus( - // value: state.workHistory.statusAppointment!, - // label: state.workHistory.statusAppointment!); - // WorkHistory newWorkHistory = WorkHistory( - // id: state.workHistory.id, - // position: selectedPosition, - // agency: selectedAgency, - // fromDate: fromDateController.text.isEmpty - // ? null - // : DateTime.parse(fromDateController.text), - // toDate: toDateController.text.isEmpty || - // toDateController.text.toUpperCase() == - // "PRESENT" || - // toDateController.text.toLowerCase() == - // 'null' - // ? null - // : DateTime.parse(toDateController.text), - // monthlySalary: double.parse(salary!), - // appointmentStatus: selectedStatus!.value, - // salaryGrade: salaryGrade == null - // ? null - // : int.parse(salaryGrade!), - // sgStep: salaryGradeStep == null - // ? null - // : int.parse(salaryGradeStep!), - // ); - // context.read().add( - // UpdateWorkHistory( - // oldWorkHistory: state.workHistory, - // profileId: widget.profileId.toString(), - // token: widget.token, - // workHistory: newWorkHistory)); - // } + selectedStatus ??= AppoinemtStatus( + value: state.workHistory.statusAppointment!, + label: state.workHistory.statusAppointment!); + WorkHistory newWorkHistory = WorkHistory( + accomplishment: accomplishments == null?null: [Accomplishment(id: state.workHistory.accomplishment!.first.id, workExperienceId: state.workHistory.id, accomplishment: accomplishments)], + actualDuties: duties == null? null: [ActualDuty(id: state.workHistory.actualDuties!.first.id, workExperienceId: state.workHistory.id, description: duties!)], + agencydepid: state.workHistory.agency!.id, + supervisor: Supervisor(agencyId: state.workHistory.agencydepid,id: state.workHistory.supervisor!.id,firstname: sFname,middlename: sMname,lastname: sLname,stationName: sOffice), + id: state.workHistory.id, + position: selectedPosition, + agency: selectedAgency, + fromDate: fromDateController.text.isEmpty + ? null + : DateTime.parse(fromDateController.text), + toDate: toDateController.text.isEmpty || + toDateController.text.toUpperCase() == + "PRESENT" || + toDateController.text.toLowerCase() == + 'null' + ? null + : DateTime.parse(toDateController.text), + monthlysalary: double.parse(salary!), + statusAppointment: selectedStatus!.value, + salarygrade: salaryGrade == null + ? null + : int.parse(salaryGrade!), + sgstep: salaryGradeStep == null + ? null + : int.parse(salaryGradeStep!), + ); + context.read().add( + UpdateWorkHistory( + + isPrivate: state.workHistory.agency!.privateEntity!, + profileId: widget.profileId, + token: widget.token, + workHistory: newWorkHistory)); + } }, child: const Text(submit)), ), diff --git a/lib/screens/profile/components/work_history_screen.dart b/lib/screens/profile/components/work_history_screen.dart index 9255c4b..63822ad 100644 --- a/lib/screens/profile/components/work_history_screen.dart +++ b/lib/screens/profile/components/work_history_screen.dart @@ -322,20 +322,20 @@ class WorkHistoryScreen extends StatelessWidget { } if (value == 1) { ////edit eligibilty-= = = = = = = = =>> - final progress = - ProgressHUD.of( - context); - progress!.showWithText( - "Loading..."); - WorkHistory workHistory = - state.workExperiences[ - index]; - context - .read< - WorkHistoryBloc>() - .add(ShowEditWorkHistoryForm( - workHistory: - workHistory)); + // final progress = + // ProgressHUD.of( + // context); + // progress!.showWithText( + // "Loading..."); + // WorkHistory workHistory = + // state.workExperiences[ + // index]; + // context + // .read< + // WorkHistoryBloc>() + // .add(ShowEditWorkHistoryForm( + // workHistory: + // workHistory)); } ////Attachment if (value == 3) { diff --git a/lib/screens/profile/shared/view_attachment.dart b/lib/screens/profile/shared/view_attachment.dart deleted file mode 100644 index 54bd51d..0000000 --- a/lib/screens/profile/shared/view_attachment.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter/material.dart'; -import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart'; -import 'package:unit2/theme-data.dart/colors.dart'; -import 'package:unit2/widgets/error_state.dart'; - -import '../../../utils/urls.dart'; - -class ImageAttachment extends StatefulWidget { - final String imgUrl; - const ImageAttachment({super.key, required this.imgUrl}); - - @override - State createState() => _ImageAttachmentState(); -} - -class _ImageAttachmentState extends State { - @override - Widget build(BuildContext context) { - bool isPDF = widget.imgUrl[widget.imgUrl.length - 1] == 'f' ? true : false; - - return Scaffold( - floatingActionButton: FloatingActionButton( - onPressed: () {}, - child: const Icon(Icons.file_download), - ), - appBar: AppBar( - title: const Text("Attachment"), - centerTitle: true, - actions: [ - IconButton(onPressed: () {}, icon: const Icon(Icons.share)), - ], - ), - body: isPDF - ? SfPdfViewer.network( - '${Url.instance.prefixHost()}://${Url.instance.host()}${widget.imgUrl}',onDocumentLoadFailed: (details) { - Center(child: Text(details.description),); - },) - : Center( - child: CachedNetworkImage( - progressIndicatorBuilder: (context, url, progress) { - return const SizedBox( - height: 100, - width: 100, - child: CircularProgressIndicator(color: primary,)); - }, - - imageBuilder: (context, imageProvider) => Container( - decoration: BoxDecoration( - image: DecorationImage( - image: imageProvider, fit: BoxFit.fill)), - ), - imageUrl: - '${Url.instance.prefixHost()}://${Url.instance.host()}${widget.imgUrl}', - width: double.infinity, - height: 220, - fit: BoxFit.cover, - ), - ), - ); - } -} diff --git a/lib/sevices/profile/education_services.dart b/lib/sevices/profile/education_services.dart index 9ed67ed..05a86f5 100644 --- a/lib/sevices/profile/education_services.dart +++ b/lib/sevices/profile/education_services.dart @@ -68,7 +68,7 @@ class EducationService { try { http.Response response = await Request.instance .postRequest(path: path, param: {}, body: body, headers: headers); - if (response.statusCode == 2011) { + if (response.statusCode == 201) { Map data = jsonDecode(response.body); statusResponse = data; } else { @@ -150,7 +150,7 @@ class EducationService { http.Response response = await Request.instance.deleteRequest( path: path, headers: headers, body: body, param: params); - if (response.statusCode == 2001) { + if (response.statusCode == 200) { Map data = jsonDecode(response.body); success = data['success']; } else { diff --git a/lib/sevices/profile/profile_other_info.dart b/lib/sevices/profile/profile_other_info.dart index 5561b1c..8945835 100644 --- a/lib/sevices/profile/profile_other_info.dart +++ b/lib/sevices/profile/profile_other_info.dart @@ -21,7 +21,7 @@ class ProfileOtherInfoServices{ try { http.Response response = await Request.instance .getRequest(path: path, headers: headers, param: {}); - if (response.statusCode == 20012) { + if (response.statusCode == 200) { Map data = jsonDecode(response.body); if (data['data'] != null) { data['data'].forEach((var e) { diff --git a/lib/sevices/profile/work_history_services.dart b/lib/sevices/profile/work_history_services.dart index e46b08d..d227099 100644 --- a/lib/sevices/profile/work_history_services.dart +++ b/lib/sevices/profile/work_history_services.dart @@ -40,7 +40,6 @@ class WorkHistoryService { return workExperiences; } - ////delete workhistory Future delete( {required int profileId, @@ -69,10 +68,10 @@ class WorkHistoryService { http.Response response = await Request.instance.deleteRequest( path: path, headers: headers, body: body, param: params); - if(response.statusCode == 200){ + if (response.statusCode == 200) { Map data = jsonDecode(response.body); success = data['success']; - }else{ + } else { success = false; } } catch (e) { @@ -81,7 +80,6 @@ class WorkHistoryService { return success!; } - ////edit work history // Future> update({required WorkHistory oldWorkHistory, required WorkHistory newWorkHistory, required String token, required String profileId})async{ // Map? statusResponse={}; @@ -108,8 +106,7 @@ class WorkHistoryService { // "oldPosId":oldWorkHistory.position!.id, // "_oldAgencyId":oldWorkHistory.agency!.id, // "oldFromDate":oldWorkHistory.fromDate?.toString(), - // }; - + // }; // try{ // http.Response response = await Request.instance.putRequest(path: path, headers: headers, body: body, param: {}); @@ -125,74 +122,129 @@ class WorkHistoryService { // } // } - - ////Add work history - Future>add({required WorkHistory workHistory, required String token, required int profileId , required bool isPrivate,required String? accomplishment, required String? actualDuties})async{ - String authtoken = "Token $token"; + Future> add( + {required WorkHistory workHistory, + required String token, + required int profileId, + required bool isPrivate, + required String? accomplishment, + required String? actualDuties}) async { + String authtoken = "Token $token"; String path = '${Url.instance.workhistory()}$profileId/'; - Map headers = { + Map headers = { 'Content-Type': 'application/json; charset=UTF-8', 'Authorization': authtoken }; - Map body = {}; - Map statusResponse = {}; - String fromDate = DateFormat('yyyy-MM-dd').format(workHistory.fromDate!); - String? toDate; - if(workHistory.toDate != null){ - toDate = DateFormat('yyyy-MM-dd').format(workHistory.toDate!); - } - if(workHistory.toDate == null){ - body = { -"a_category_id ": workHistory.agency?.category?.id == null? "":workHistory.agency!.category!.id.toString(), - "a_name" : workHistory.agency?.name == null? "":workHistory.agency!.name!, - " a_private_entity ": workHistory.agency?.privateEntity == null?"":workHistory.agency!.privateEntity.toString(), - "accomplishment" : accomplishment??"", - "actual_duties ": actualDuties!, - "agency_id" : workHistory.agency?.id == null?"": workHistory.agency!.id.toString() , - "from_date" : fromDate, - "monthly_salary" : workHistory.monthlysalary == null? "": workHistory.monthlysalary.toString(), - "position_id" : workHistory.position?.id == null? "": workHistory.position!.id.toString(), - "position_name" : workHistory.position?.title == null? "":workHistory.position!.title!, - "s_fname" : workHistory.supervisor?.firstname == null?"":workHistory.supervisor!.firstname!, - "s_lname" : workHistory.supervisor?.lastname == null? "":workHistory.supervisor!.lastname!, - "s_mname" : workHistory.supervisor?.middlename == null?"":workHistory.supervisor!.middlename!, - "s_office" : workHistory.supervisor?.stationName == null?"":workHistory.supervisor!.stationName!, - "salary_grade" : workHistory.salarygrade == null? "":workHistory.salarygrade.toString(), - "sg_step" : workHistory.sgstep == null?"":workHistory.sgstep.toString() , - 'status_appointment' : workHistory.statusAppointment??"", - }; - }else{ - body = { -"a_category_id ": workHistory.agency?.category?.id == null? "":workHistory.agency!.category!.id.toString(), - "a_name" : workHistory.agency?.name == null? "":workHistory.agency!.name!, - " a_private_entity ": workHistory.agency?.privateEntity == null?"":workHistory.agency!.privateEntity.toString(), - "accomplishment" : accomplishment??"", - "actual_duties ": actualDuties!, - "agency_id" : workHistory.agency?.id == null?"": workHistory.agency!.id.toString() , - "from_date" : workHistory.fromDate == null? "2018-10-04":"2018-06-04", - "monthly_salary" : workHistory.monthlysalary == null? "": workHistory.monthlysalary.toString(), - "position_id" : workHistory.position?.id == null? "": workHistory.position!.id.toString(), - "position_name" : workHistory.position?.title == null? "":workHistory.position!.title!, - "s_fname" : workHistory.supervisor?.firstname == null?"":workHistory.supervisor!.firstname!, - "s_lname" : workHistory.supervisor?.lastname == null? "":workHistory.supervisor!.lastname!, - "s_mname" : workHistory.supervisor?.middlename == null?"":workHistory.supervisor!.middlename!, - "s_office" : workHistory.supervisor?.stationName == null?"":workHistory.supervisor!.stationName!, - "salary_grade" : workHistory.salarygrade == null? "":workHistory.salarygrade.toString(), - "sg_step" : workHistory.sgstep == null?"":workHistory.sgstep.toString() , - 'status_appointment' : workHistory.statusAppointment??"", - "to_date" : toDate!, - }; + Map body = {}; + Map statusResponse = {}; + String fromDate = DateFormat('yyyy-MM-dd').format(workHistory.fromDate!); + String? toDate = workHistory.toDate == null + ? null + : DateFormat('yyyy-MM-dd').format(workHistory.toDate!); + + if (workHistory.toDate == null) { + body = { + "a_category_id ": workHistory.agency?.category?.id == null + ? "" + : workHistory.agency!.category!.id.toString(), + "a_name": + workHistory.agency?.name == null ? "" : workHistory.agency!.name!, + " a_private_entity ": workHistory.agency?.privateEntity == null + ? "" + : workHistory.agency!.privateEntity.toString(), + "accomplishment": accomplishment ?? "", + "actual_duties ": actualDuties!, + "agency_id": workHistory.agency?.id == null + ? "" + : workHistory.agency!.id.toString(), + "from_date": fromDate, + "monthly_salary": workHistory.monthlysalary == null + ? "" + : workHistory.monthlysalary.toString(), + "position_id": workHistory.position?.id == null + ? "" + : workHistory.position!.id.toString(), + "position_name": workHistory.position?.title == null + ? "" + : workHistory.position!.title!, + "s_fname": workHistory.supervisor?.firstname == null + ? "" + : workHistory.supervisor!.firstname!, + "s_lname": workHistory.supervisor?.lastname == null + ? "" + : workHistory.supervisor!.lastname!, + "s_mname": workHistory.supervisor?.middlename == null + ? "" + : workHistory.supervisor!.middlename!, + "s_office": workHistory.supervisor?.stationName == null + ? "" + : workHistory.supervisor!.stationName!, + "salary_grade": workHistory.salarygrade == null + ? "" + : workHistory.salarygrade.toString(), + "sg_step": + workHistory.sgstep == null ? "" : workHistory.sgstep.toString(), + 'status_appointment': workHistory.statusAppointment ?? "", + }; + } else { + body = { + "a_category_id ": workHistory.agency?.category?.id == null + ? "" + : workHistory.agency!.category!.id.toString(), + "a_name": + workHistory.agency?.name == null ? "" : workHistory.agency!.name!, + " a_private_entity ": workHistory.agency?.privateEntity == null + ? "" + : workHistory.agency!.privateEntity.toString(), + "accomplishment": accomplishment ?? "", + "actual_duties ": actualDuties!, + "agency_id": workHistory.agency?.id == null + ? "" + : workHistory.agency!.id.toString(), + "from_date": fromDate, + "monthly_salary": workHistory.monthlysalary == null + ? "" + : workHistory.monthlysalary.toString(), + "position_id": workHistory.position?.id == null + ? "" + : workHistory.position!.id.toString(), + "position_name": workHistory.position?.title == null + ? "" + : workHistory.position!.title!, + "s_fname": workHistory.supervisor?.firstname == null + ? "" + : workHistory.supervisor!.firstname!, + "s_lname": workHistory.supervisor?.lastname == null + ? "" + : workHistory.supervisor!.lastname!, + "s_mname": workHistory.supervisor?.middlename == null + ? "" + : workHistory.supervisor!.middlename!, + "s_office": workHistory.supervisor?.stationName == null + ? "" + : workHistory.supervisor!.stationName!, + "salary_grade": workHistory.salarygrade == null + ? "" + : workHistory.salarygrade.toString(), + "sg_step": + workHistory.sgstep == null ? "" : workHistory.sgstep.toString(), + 'status_appointment': workHistory.statusAppointment ?? "", + "to_date": toDate!, + }; } - - var request = http.MultipartRequest('POST',Uri.parse('${Url.instance.prefixHost()}://${Url.instance.host()}$path')); - request.fields.addAll(body); - request.headers.addAll(headers); + + var request = http.MultipartRequest( + 'POST', + Uri.parse( + '${Url.instance.prefixHost()}://${Url.instance.host()}$path')); + request.fields.addAll(body); + request.headers.addAll(headers); try { http.StreamedResponse response = await request.send(); - final steamResponse = await response.stream.bytesToString(); + final steamResponse = await response.stream.bytesToString(); Map data = jsonDecode(steamResponse); - if (response.statusCode == 201) { + if (response.statusCode == 201) { statusResponse = data; } else { String message = data['response']['details']; @@ -204,91 +256,151 @@ class WorkHistoryService { } catch (e) { throw e.toString(); } -return statusResponse; + return statusResponse; } -Future>update({required WorkHistory workHistory, required String token, required int profileId , required bool isPrivate,required String? accomplishment, required String? actualDuties})async{ - String authtoken = "Token $token"; + Future> update( + {required WorkHistory workHistory, + required String token, + required int profileId, + required bool isPrivate}) async { + String authtoken = "Token $token"; String path = '${Url.instance.workhistory()}$profileId/'; - Map headers = { + Map headers = { 'Content-Type': 'application/json; charset=UTF-8', 'Authorization': authtoken }; - Map body = {}; - Map statusResponse = {}; - String fromDate = DateFormat('yyyy-MM-dd').format(workHistory.fromDate!); - String? toDate; - if(workHistory.toDate != null){ - toDate = DateFormat('yyyy-MM-dd').format(workHistory.toDate!); - } - if(workHistory.toDate == null){ - body = { -"a_category_id ": workHistory.agency?.category?.id == null? "":workHistory.agency!.category!.id.toString(), - "a_name" : workHistory.agency?.name == null? "":workHistory.agency!.name!, - " a_private_entity ": workHistory.agency?.privateEntity == null?"":workHistory.agency!.privateEntity.toString(), - "accomplishment" : accomplishment??"", - "actual_duties ": actualDuties!, - "agency_id" : workHistory.agency?.id == null?"": workHistory.agency!.id.toString() , - "from_date" : fromDate, - "monthly_salary" : workHistory.monthlysalary == null? "": workHistory.monthlysalary.toString(), - "position_id" : workHistory.position?.id == null? "": workHistory.position!.id.toString(), - "position_name" : workHistory.position?.title == null? "":workHistory.position!.title!, - "s_fname" : workHistory.supervisor?.firstname == null?"":workHistory.supervisor!.firstname!, - "s_lname" : workHistory.supervisor?.lastname == null? "":workHistory.supervisor!.lastname!, - "s_mname" : workHistory.supervisor?.middlename == null?"":workHistory.supervisor!.middlename!, - "s_office" : workHistory.supervisor?.stationName == null?"":workHistory.supervisor!.stationName!, - "salary_grade" : workHistory.salarygrade == null? "":workHistory.salarygrade.toString(), - "sg_step" : workHistory.sgstep == null?"":workHistory.sgstep.toString() , - 'status_appointment' : workHistory.statusAppointment??"", - }; - }else{ - body = { -"a_category_id ": workHistory.agency?.category?.id == null? "":workHistory.agency!.category!.id.toString(), - "a_name" : workHistory.agency?.name == null? "":workHistory.agency!.name!, - " a_private_entity ": workHistory.agency?.privateEntity == null?"":workHistory.agency!.privateEntity.toString(), - "accomplishment" : accomplishment??"", - "actual_duties ": actualDuties!, - "agency_id" : workHistory.agency?.id == null?"": workHistory.agency!.id.toString() , - "from_date" : workHistory.fromDate == null? "2018-10-04":"2018-06-04", - "monthly_salary" : workHistory.monthlysalary == null? "": workHistory.monthlysalary.toString(), - "position_id" : workHistory.position?.id == null? "": workHistory.position!.id.toString(), - "position_name" : workHistory.position?.title == null? "":workHistory.position!.title!, - "s_fname" : workHistory.supervisor?.firstname == null?"":workHistory.supervisor!.firstname!, - "s_lname" : workHistory.supervisor?.lastname == null? "":workHistory.supervisor!.lastname!, - "s_mname" : workHistory.supervisor?.middlename == null?"":workHistory.supervisor!.middlename!, - "s_office" : workHistory.supervisor?.stationName == null?"":workHistory.supervisor!.stationName!, - "salary_grade" : workHistory.salarygrade == null? "":workHistory.salarygrade.toString(), - "sg_step" : workHistory.sgstep == null?"":workHistory.sgstep.toString() , - 'status_appointment' : workHistory.statusAppointment??"", - "to_date" : toDate!, - }; + + Map body = {}; + Map statusResponse = {}; + String fromDate = DateFormat('yyyy-MM-dd').format(workHistory.fromDate!); + String? toDate = workHistory.toDate == null + ? null + : DateFormat('yyyy-MM-dd').format(workHistory.toDate!); + if (workHistory.toDate == null) { + body = { + "a_category_id ": workHistory.agency?.category?.id == null + ? "" + : workHistory.agency!.category!.id.toString(), + "a_name": + workHistory.agency?.name == null ? "" : workHistory.agency!.name!, + " a_private_entity ": workHistory.agency?.privateEntity == null + ? "" + : workHistory.agency!.privateEntity.toString(), + "accomplishment": workHistory.accomplishment == null + ? "" + : workHistory.accomplishment!.first.accomplishment!, + "actual_duties ": workHistory.actualDuties == null + ? "" + : workHistory.actualDuties!.first.description, + "agency_id": workHistory.agency?.id == null + ? "" + : workHistory.agency!.id.toString(), + "from_date": fromDate, + "monthly_salary": workHistory.monthlysalary == null + ? "" + : workHistory.monthlysalary.toString(), + "position_id": workHistory.position?.id == null + ? "" + : workHistory.position!.id.toString(), + "position_name": workHistory.position?.title == null + ? "" + : workHistory.position!.title!, + "s_fname": workHistory.supervisor?.firstname == null + ? "" + : workHistory.supervisor!.firstname!, + "s_lname": workHistory.supervisor?.lastname == null + ? "" + : workHistory.supervisor!.lastname!, + "s_mname": workHistory.supervisor?.middlename == null + ? "" + : workHistory.supervisor!.middlename!, + "s_office": workHistory.supervisor?.stationName == null + ? "" + : workHistory.supervisor!.stationName!, + "salary_grade": workHistory.salarygrade == null + ? "" + : workHistory.salarygrade.toString(), + "sg_step": + workHistory.sgstep == null ? "" : workHistory.sgstep.toString(), + 'status_appointment': workHistory.statusAppointment ?? "", + }; + } else { + body = { + "a_category_id ": workHistory.agency?.category?.id == null + ? "" + : workHistory.agency!.category!.id.toString(), + "a_name": + workHistory.agency?.name == null ? "" : workHistory.agency!.name!, + " a_private_entity ": workHistory.agency?.privateEntity == null + ? "" + : workHistory.agency!.privateEntity.toString(), + "accomplishment": workHistory.accomplishment == null + ? "" + : workHistory.accomplishment!.first.accomplishment!, + "actual_duties ": workHistory.actualDuties == null + ? "" + : workHistory.actualDuties!.first.description, + "agency_id": workHistory.agency?.id == null + ? "" + : workHistory.agency!.id.toString(), + "from_date": fromDate, + "monthly_salary": workHistory.monthlysalary == null + ? "" + : workHistory.monthlysalary.toString(), + "position_id": workHistory.position?.id == null + ? "" + : workHistory.position!.id.toString(), + "position_name": workHistory.position?.title == null + ? "" + : workHistory.position!.title!, + "s_fname": workHistory.supervisor?.firstname == null + ? "" + : workHistory.supervisor!.firstname!, + "s_lname": workHistory.supervisor?.lastname == null + ? "" + : workHistory.supervisor!.lastname!, + "s_mname": workHistory.supervisor?.middlename == null + ? "" + : workHistory.supervisor!.middlename!, + "s_office": workHistory.supervisor?.stationName == null + ? "" + : workHistory.supervisor!.stationName!, + "salary_grade": workHistory.salarygrade == null + ? "" + : workHistory.salarygrade.toString(), + "sg_step": + workHistory.sgstep == null ? "" : workHistory.sgstep.toString(), + 'status_appointment': workHistory.statusAppointment ?? "", + "to_date": toDate!, + }; } - - var request = http.MultipartRequest('PUT',Uri.parse('${Url.instance.prefixHost()}://${Url.instance.host()}$path')); - request.fields.addAll(body); - request.headers.addAll(headers); - try { - http.StreamedResponse response = await request.send(); - final steamResponse = await response.stream.bytesToString(); - Map data = jsonDecode(steamResponse); - if (response.statusCode == 201) { - statusResponse = data; - } else { - String message = data['response']['details']; - statusResponse.addAll({'message': message}); - statusResponse.addAll( - {'success': false}, - ); - } - } catch (e) { - throw e.toString(); + + var request = http.MultipartRequest( + 'PUT', + Uri.parse( + '${Url.instance.prefixHost()}://${Url.instance.host()}$path')); + request.fields.addAll(body); + request.headers.addAll(headers); + // try { + http.StreamedResponse response = await request.send(); + final steamResponse = await response.stream.bytesToString(); + Map data = jsonDecode(steamResponse); + if (response.statusCode == 201) { + statusResponse = data; + } else { + String message = data['response']['details']; + statusResponse.addAll({'message': message}); + statusResponse.addAll( + {'success': false}, + ); } -return statusResponse; + // } catch (e) { + // throw e.toString(); + // } + return statusResponse; } - - - ////get agency position Future> getAgencyPosition() async { List agencyPositions = []; @@ -324,7 +436,7 @@ return statusResponse; AppoinemtStatus(value: "Coterminous", label: "Coterminous"), AppoinemtStatus(value: "Elected", label: "Elected"), AppoinemtStatus(value: "Job Order", label: "Job Order"), - AppoinemtStatus(value: "Permanent", label: "Permanent"), + AppoinemtStatus(value: "Permanent", label: "Permanent"), AppoinemtStatus(value: "Elected", label: "Elected"), ]; } diff --git a/lib/utils/url_launcher_file_downloader.dart b/lib/utils/url_launcher_file_downloader.dart new file mode 100644 index 0000000..ac3155f --- /dev/null +++ b/lib/utils/url_launcher_file_downloader.dart @@ -0,0 +1,16 @@ +import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'; + + Future launchInBrowser(String url) async { + final UrlLauncherPlatform launcher = UrlLauncherPlatform.instance; + if (!await launcher.launch( + url, + useSafariVC: false, + useWebView: false, + enableJavaScript: false, + enableDomStorage: false, + universalLinksOnly: false, + headers: {}, + )) { + throw Exception('Could not launch $url'); + } + } \ No newline at end of file diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 9a31980..e8df21a 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -5,6 +5,8 @@ PODS: - FlutterMacOS - audioplayers_darwin (0.0.1): - FlutterMacOS + - device_info_plus (0.0.1): + - FlutterMacOS - FlutterMacOS (1.0.0) - FMDB (2.7.5): - FMDB/standard (= 2.7.5) @@ -24,17 +26,24 @@ PODS: - FlutterMacOS - rive_common (0.0.1): - FlutterMacOS + - share_plus (0.0.1): + - FlutterMacOS - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS - sqflite (0.0.2): - FlutterMacOS - FMDB (>= 2.7.5) + - syncfusion_pdfviewer_macos (0.0.1): + - FlutterMacOS + - url_launcher_macos (0.0.1): + - FlutterMacOS DEPENDENCIES: - assets_audio_player (from `Flutter/ephemeral/.symlinks/plugins/assets_audio_player/macos`) - assets_audio_player_web (from `Flutter/ephemeral/.symlinks/plugins/assets_audio_player_web/macos`) - audioplayers_darwin (from `Flutter/ephemeral/.symlinks/plugins/audioplayers_darwin/macos`) + - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) - FlutterMacOS (from `Flutter/ephemeral`) - location (from `Flutter/ephemeral/.symlinks/plugins/location/macos`) - modal_progress_hud_nsn (from `Flutter/ephemeral/.symlinks/plugins/modal_progress_hud_nsn/macos`) @@ -43,8 +52,11 @@ DEPENDENCIES: - platform_device_id (from `Flutter/ephemeral/.symlinks/plugins/platform_device_id/macos`) - platform_device_id_macos (from `Flutter/ephemeral/.symlinks/plugins/platform_device_id_macos/macos`) - rive_common (from `Flutter/ephemeral/.symlinks/plugins/rive_common/macos`) + - share_plus (from `Flutter/ephemeral/.symlinks/plugins/share_plus/macos`) - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos`) - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/macos`) + - syncfusion_pdfviewer_macos (from `Flutter/ephemeral/.symlinks/plugins/syncfusion_pdfviewer_macos/macos`) + - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) SPEC REPOS: trunk: @@ -57,6 +69,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/assets_audio_player_web/macos audioplayers_darwin: :path: Flutter/ephemeral/.symlinks/plugins/audioplayers_darwin/macos + device_info_plus: + :path: Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos FlutterMacOS: :path: Flutter/ephemeral location: @@ -73,15 +87,22 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/platform_device_id_macos/macos rive_common: :path: Flutter/ephemeral/.symlinks/plugins/rive_common/macos + share_plus: + :path: Flutter/ephemeral/.symlinks/plugins/share_plus/macos shared_preferences_foundation: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/macos sqflite: :path: Flutter/ephemeral/.symlinks/plugins/sqflite/macos + syncfusion_pdfviewer_macos: + :path: Flutter/ephemeral/.symlinks/plugins/syncfusion_pdfviewer_macos/macos + url_launcher_macos: + :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos SPEC CHECKSUMS: assets_audio_player: be2578e6f11dd4d183412e97143673c3c4cb2e8a assets_audio_player_web: 917101123b6db8f73156835c0fa266c11340ff15 audioplayers_darwin: dcad41de4fbd0099cb3749f7ab3b0cb8f70b810c + device_info_plus: 5401765fde0b8d062a2f8eb65510fb17e77cf07f FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a location: 7cdb0665bd6577d382b0a343acdadbcb7f964775 @@ -91,8 +112,11 @@ SPEC CHECKSUMS: platform_device_id: 3e414428f45df149bbbfb623e2c0ca27c545b763 platform_device_id_macos: f763bb55f088be804d61b96eb4710b8ab6598e94 rive_common: fab8476ce8352bf54152a913f393a8696d3dc98c + share_plus: 76dd39142738f7a68dd57b05093b5e8193f220f7 shared_preferences_foundation: e2dae3258e06f44cc55f49d42024fd8dd03c590c sqflite: a5789cceda41d54d23f31d6de539d65bb14100ea + syncfusion_pdfviewer_macos: e9194851581cad04b28b53913d0636d39a4ed4b2 + url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7