Untitled
plain_text
a month ago
35 kB
1
Indexable
Never
builder: (context, state) { if (context.read<ResidencyApplicationBloc>().applicationType == 'first_time' || context.read<ResidencyApplicationBloc>().applicationType == 'renewal') { applicant = getApplicant(locale, true); } else { applicant = getApplicant(locale, false); } return SingleChildScrollView( child: Column(children: [ const SizedBox(height: 10), applicationTypeWidget(context, locale, applicationType), const SizedBox(height: 10), if (context .read<ResidencyApplicationBloc>() .applicationType == 'modify_card_information') typeOfModificationWidget(context, locale), const SizedBox(height: 10), if (context .read<ResidencyApplicationBloc>() .applicationType == 'damage_or_loss_allowance') allowanceTypeWidget(context, allowanceType, locale), if (context .read<ResidencyApplicationBloc>() .applicationType == 'first_time' || context .read<ResidencyApplicationBloc>() .applicationType == 'renewal') residenceStatusWidget( context, locale, residenceStatus, proofResidence, sponsorStatus, sponsorResidencyStatus, ), const SizedBox(height: 10), applicantDetails(context, locale, applicant), if (context .read<ResidencyApplicationBloc>() .applicationType == 'first_time' || context .read<ResidencyApplicationBloc>() .applicationType == 'renewal') personalNumberWidget(context, locale), if (context .read<ResidencyApplicationBloc>() .applicationType == 'first_time') dateOfBirthWidget(context, locale), if (context .read<ResidencyApplicationBloc>() .applicationType == 'renewal' || context .read<ResidencyApplicationBloc>() .applicationType == 'damage_or_loss_allowance' || context .read<ResidencyApplicationBloc>() .applicationType == 'modify_card_information') //رقم الإقامة القديمة oldResidenceNumberWidget(context, locale), if (context .read<ResidencyApplicationBloc>() .applicationType == 'first_time' || context .read<ResidencyApplicationBloc>() .applicationType == 'renewal') requiredDurationWidget(context, requiredDuration, locale), const SizedBox(height: 10), passportNumberWidget(context, locale), // const SizedBox(height: 10), phoneWidget(context), const SizedBox( height: 10, ), buttonWidget(context), ]), ); }, ), ), ), ); } Widget typeOfModificationWidget(BuildContext context, var locale) { return Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomTextField( label: Text("${locale.getTranslatedValues('Type of modification')} *"), controller: context .read<ResidencyApplicationBloc>() .typeOfModificationController, enabled: false, validator: (value) { if (value == null || value.isEmpty) { return '${locale.getTranslatedValues("this_field_is_required")}'; } else { return null; } }, ), ), ); } Widget oldResidenceNumberWidget(BuildContext context, var locale) { return Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomTextField( label: Text("${locale.getTranslatedValues('Old Residence Number')} *"), controller: context .read<ResidencyApplicationBloc>() .oldResidenceNumberController, validator: (value) { if (value == null || value.isEmpty) { return '${locale.getTranslatedValues("this_field_is_required")}'; } else { return null; } }, ), ), ); } Widget allowanceTypeWidget( BuildContext context, List<DropdownMenuItem<String>> items, var locale, ) { return Padding( padding: const EdgeInsets.only(bottom: 10, top: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.95, child: CustomDropDownID( items: items, labelText: "${locale.getTranslatedValues('Allowance type')} *", value: context.read<ResidencyApplicationBloc>().allowanceType, onChanged: (p0) { context.read<ResidencyApplicationBloc>().allowanceType = p0.toString(); context.read<ResidencyApplicationBloc>().add(Refresh()); }, ), ), ); } Widget requiredDurationWidget( BuildContext context, List<DropdownMenuItem<String>> items, var locale, ) { return Padding( padding: const EdgeInsets.only(bottom: 10, top: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.95, child: CustomDropDownID( items: items, labelText: "${locale.getTranslatedValues('Required duration')} *", value: context.read<ResidencyApplicationBloc>().requiredDuration, onChanged: (p0) { context.read<ResidencyApplicationBloc>().requiredDuration = p0.toString(); context.read<ResidencyApplicationBloc>().add(Refresh()); }, ), ), ); } Widget dateOfBirthWidget(BuildContext context, var locale) => Padding( padding: const EdgeInsets.only(bottom: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.90, child: CustomDateTextField( controller: context.read<ResidencyApplicationBloc>().dateOfBirthController, maximumDate: DateTime.now().add(const Duration(seconds: 1)), label: AppLocalization.of(context).getTranslatedValues("dateOfBirth"), ), ), ); Widget personalNumberWidget(BuildContext context, var locale) => Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomTextField( label: Text("${locale.getTranslatedValues('Personal Number')} *"), controller: context .read<ResidencyApplicationBloc>() .personalNumberController, validator: (value) { if (value == null || value.isEmpty) { return '${locale.getTranslatedValues("this_field_is_required")}'; } else { return null; } }, ), ), ); Widget residenceStatusWidget( BuildContext context, var locale, List<DropdownMenuItem<String>> applicant, List<DropdownMenuItem<String>> proofResidence, List<DropdownMenuItem<String>> sponsorStatus, List<DropdownMenuItem<String>> sponsorResidencyStatus, ) => Column( children: [ Padding( padding: const EdgeInsets.only(bottom: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.95, child: CustomDropDownID( items: applicant, labelText: "${locale.getTranslatedValues('Residence_Status')} *", value: context.read<ResidencyApplicationBloc>().residenceStatus, onChanged: (p0) { context.read<ResidencyApplicationBloc>().residenceStatus = p0.toString(); context.read<ResidencyApplicationBloc>().allowanceType = 'Please select'; context .read<ResidencyApplicationBloc>() .companyActivityNumber .clear(); context.read<ResidencyApplicationBloc>().proofResidence = 'Please select'; context.read<ResidencyApplicationBloc>().applicantDetails = 'Please select'; context.read<ResidencyApplicationBloc>().sponsorStatus = 'Please select'; context .read<ResidencyApplicationBloc>() .sponsorResidencyStatus = 'Please select'; context .read<ResidencyApplicationBloc>() .sponsorResidencyStatus = 'Please select'; context .read<ResidencyApplicationBloc>() .oldResidenceNumberController .text = ''; context.read<ResidencyApplicationBloc>().add(Refresh()); }, ), ), ), if ((context.read<ResidencyApplicationBloc>().applicationType == 'first_time' || context.read<ResidencyApplicationBloc>().applicationType == 'renewal') && context.read<ResidencyApplicationBloc>().residenceStatus == "self_financing_accommodation") Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.95, child: CustomDropDownID( items: proofResidence, labelText: "${locale.getTranslatedValues('proof_Of_Residence')} *", value: context.read<ResidencyApplicationBloc>().proofResidence, onChanged: (p0) { if (p0.toString() != 'registration_deed') { context .read<ResidencyApplicationBloc>() .specialNumberofRegistrationDeed .text = ''; } context.read<ResidencyApplicationBloc>().proofResidence = p0.toString(); context.read<ResidencyApplicationBloc>().add(Refresh()); }, ), ), ), if (context.read<ResidencyApplicationBloc>().residenceStatus == 'residence_of_a_spouse_dependent') Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.95, child: CustomDropDownID( items: sponsorStatus, labelText: "${locale.getTranslatedValues('Sponsor Status')} *", value: context.read<ResidencyApplicationBloc>().sponsorStatus, onChanged: (p0) { context .read<ResidencyApplicationBloc>() .guarantorsTemporaryPassportNumber .text = ''; context .read<ResidencyApplicationBloc>() .jordanianSponsorsNationalNumber .text = ''; context.read<ResidencyApplicationBloc>().sponsorStatus = p0.toString(); context.read<ResidencyApplicationBloc>().add(Refresh()); }, ), ), ), // if (context.read<ResidencyApplicationBloc>().sponsorStatus != 'Please select') Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.95, child: CustomDropDownID( items: proofResidence, labelText: "${locale.getTranslatedValues('proof_Of_Residence')} *", value: context.read<ResidencyApplicationBloc>().proofResidence, onChanged: (p0) { context.read<ResidencyApplicationBloc>().proofResidence = p0.toString(); context.read<ResidencyApplicationBloc>().add(Refresh()); }, ), ), ), if (context.read<ResidencyApplicationBloc>().sponsorStatus == 'foreign') Padding( padding: const EdgeInsets.symmetric(vertical: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.95, child: CustomDropDownID( items: sponsorResidencyStatus, labelText: "${locale.getTranslatedValues('Sponsor_residency_status')} *", value: context .read<ResidencyApplicationBloc>() .sponsorResidencyStatus, onChanged: (p0) { context .read<ResidencyApplicationBloc>() .sponsorResidencyStatus = p0.toString(); context.read<ResidencyApplicationBloc>().add(Refresh()); }, ), ), ), ], ); Widget applicantDetails(BuildContext context, var locale, List<DropdownMenuItem<String>> applicant) => Column( children: [ SizedBox( width: MediaQuery.of(context).size.width * 0.95, child: CustomDropDownID( items: applicant, labelText: "${locale.getTranslatedValues('mit_lbl_applicant_detail')} *", value: context.read<ResidencyApplicationBloc>().applicantDetails, onChanged: (p0) { context.read<ResidencyApplicationBloc>().applicantDetails = p0.toString(); context.read<ResidencyApplicationBloc>().add(Refresh()); }, ), ), if (context.read<ResidencyApplicationBloc>().sponsorStatus == 'jordanain_does_not_have_a_national_number' || context.read<ResidencyApplicationBloc>().sponsorStatus == 'jordanain_holds_a_national_number') Padding( padding: const EdgeInsets.only(top: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomTextField( label: Text(context .read<ResidencyApplicationBloc>() .sponsorStatus == 'jordanain_does_not_have_a_national_number' ? "${locale.getTranslatedValues('Guarantors temporary passport number')} *" : "${locale.getTranslatedValues('Jordanian Sponsors National Number')} *"), controller: context.read<ResidencyApplicationBloc>().sponsorStatus == 'jordanain_does_not_have_a_national_number' ? context .read<ResidencyApplicationBloc>() .guarantorsTemporaryPassportNumber : context .read<ResidencyApplicationBloc>() .jordanianSponsorsNationalNumber, validator: (value) { if (value == null || value.isEmpty) { return '${locale.getTranslatedValues("this_field_is_required")}'; } else { return null; } }, ), ), ), if (context.read<ResidencyApplicationBloc>().residenceStatus == 'investor_residency') Padding( padding: const EdgeInsets.only(top: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomTextField( label: Text( "${locale.getTranslatedValues('Company Activity Number')} *"), controller: context .read<ResidencyApplicationBloc>() .companyActivityNumber, validator: (value) { if (value == null || value.isEmpty) { return '${locale.getTranslatedValues("this_field_is_required")}'; } else { return null; } }, ), ), ), if (context.read<ResidencyApplicationBloc>().sponsorResidencyStatus == 'work permit') SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomTextField( label: Text( "${locale.getTranslatedValues('Foreign Sponsors Work Permit Number')} *"), controller: context .read<ResidencyApplicationBloc>() .foreignSponsorsWorkPermitNumberController, validator: (value) { if (value == null || value.isEmpty) { return '${locale.getTranslatedValues("this_field_is_required")}'; } else { return null; } }, ), ), if (context.read<ResidencyApplicationBloc>().sponsorResidencyStatus == 'residence_permit') Padding( padding: const EdgeInsets.only(top: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomTextField( label: Text( "${locale.getTranslatedValues('Foreign Sponsors Residence Permit Number')} *"), controller: context .read<ResidencyApplicationBloc>() .foreignSponsorsResidencePermitNumber, validator: (value) { if (value == null || value.isEmpty) { return '${locale.getTranslatedValues("this_field_is_required")}'; } else { return null; } }, ), ), ), if (context.read<ResidencyApplicationBloc>().proofResidence == 'registration_deed') Padding( padding: const EdgeInsets.only(top: 10), child: SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomTextField( label: Text( "${locale.getTranslatedValues('Special Number of Registration Deed')} *"), controller: context .read<ResidencyApplicationBloc>() .specialNumberofRegistrationDeed, validator: (value) { if (value == null || value.isEmpty) { return '${locale.getTranslatedValues("this_field_is_required")}'; } else { return null; } }, ), ), ), ], ); Widget applicationTypeWidget( BuildContext context, var locale, List<DropdownMenuItem<String>> applicationType, ) => SizedBox( width: MediaQuery.of(context).size.width * 0.95, child: CustomDropDownID( items: applicationType, labelText: "${locale.getTranslatedValues('Application Type')} *", value: context.read<ResidencyApplicationBloc>().applicationType, onChanged: (p0) { context.read<ResidencyApplicationBloc>().applicationType = p0.toString(); context.read<ResidencyApplicationBloc>().proofResidence = 'Please select'; context.read<ResidencyApplicationBloc>().applicantDetails = 'Please select'; context.read<ResidencyApplicationBloc>().residenceStatus = 'Please select'; context .read<ResidencyApplicationBloc>() .oldResidenceNumberController.text = ''; context .read<ResidencyApplicationBloc>().passportNumberController.text = ''; context.read<ResidencyApplicationBloc>().add(Refresh()); }, ), ); Widget passportNumberWidget(BuildContext context, var locale) => SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomTextField( label: Text( "${locale.getTranslatedValues('passport_or_documnent_no')} *"), controller: context.read<ResidencyApplicationBloc>().passportNumberController, validator: (value) { if (value == null || value.isEmpty) { return '${locale.getTranslatedValues("this_field_is_required")}'; } else { return null; } }, ), ); Widget phoneWidget(BuildContext context) => SizedBox( width: MediaQuery.of(context).size.width * 0.9, child: CustomPhoneField( keyboardType: const TextInputType.numberWithOptions(decimal: true), controller: context.read<ResidencyApplicationBloc>().phoneNoController, initialCountryCode: 'JO', padding: const EdgeInsets.all(5), onChanged: (cc) { log('ccc ${cc.completeNumber}'); }, onCountryChanged: (value) { context.read<ResidencyApplicationBloc>().ownerContryPhoneCode = value.countryCode!; }, validator: (value) { if (value == null || value.isEmpty) { return AppLocalization.of(context) .getTranslatedValues("this_field_is_required"); } return null; }, hintText: '${AppLocalization.of(context).getTranslatedValues("phone_number")} *', ), ); Widget buttonWidget(BuildContext context) => SizedBox( width: MediaQuery.of(context).size.width * 0.85, child: CustomButton( onPressed: () { if (formKey.currentState!.validate()) { if (!validValidation()) { Fluttertoast.showToast( msg: AppLocalization.of(context) .getTranslatedValues("fields_required"), toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.black, textColor: Colors.white, fontSize: 16.0); } else { ResidencyApplicationBloc.get(context) .add(CreateResidencyApplicationEvent()); } } else { Fluttertoast.showToast( msg: AppLocalization.of(context) .getTranslatedValues("fields_required"), toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.black, textColor: Colors.white, fontSize: 16.0); } }, backgroundColor: primaryColor, child: CustomText( AppLocalization.of(context).getTranslatedValues('continue')), ), ); bool validValidation() { if (context.read<ResidencyApplicationBloc>().applicationType == 'Please select' || context.read<ResidencyApplicationBloc>().applicantDetails == 'Please select') { return false; } if (context.read<ResidencyApplicationBloc>().applicationType == 'first_time') { if (context.read<ResidencyApplicationBloc>().residenceStatus == 'Please select') { return false; } if (context.read<ResidencyApplicationBloc>().requiredDuration == 'Please select') { return false; } if (context.read<ResidencyApplicationBloc>().residenceStatus == 'self_financing_accommodation') { // return false; if (context.read<ResidencyApplicationBloc>().proofResidence == 'Please select') { return false; } } if (context.read<ResidencyApplicationBloc>().residenceStatus == 'residence_of_a_spouse_dependent') { // return false; if (context.read<ResidencyApplicationBloc>().sponsorStatus == 'Please select') { return false; } if (context.read<ResidencyApplicationBloc>().proofResidence == 'Please select') { return false; } if (context.read<ResidencyApplicationBloc>().sponsorStatus == 'foreign') { if (context.read<ResidencyApplicationBloc>().sponsorResidencyStatus == 'Please select') { return false; } } } } if (context.read<ResidencyApplicationBloc>().applicationType == 'renewal') { if (context.read<ResidencyApplicationBloc>().residenceStatus != 'investor_residency') { if (context.read<ResidencyApplicationBloc>().proofResidence == 'Please select') { return false; } } } if (context.read<ResidencyApplicationBloc>().applicationType == 'damage_or_loss_allowance') { if (context.read<ResidencyApplicationBloc>().allowanceType == 'Please select') { return false; } } if (context.read<ResidencyApplicationBloc>().applicationType == 'modify_card_information') {} return true; } List<DropdownMenuItem<String>> getApplicationType(var locale) { return [ DropdownMenuItem( value: 'Please select', child: Text("${locale.getTranslatedValues('please_select')}"), ), DropdownMenuItem( value: 'first_time', child: Text("${locale.getTranslatedValues('first_time')}"), ), DropdownMenuItem( value: 'renewal', child: Text("${locale.getTranslatedValues('renewal')}"), ), DropdownMenuItem( value: 'damage_or_loss_allowance', child: Text("${locale.getTranslatedValues('damage_or_loss_allowance')}"), ), DropdownMenuItem( value: 'modify_card_information', child: Text("${locale.getTranslatedValues('modify_card_information')}"), ), ]; } List<DropdownMenuItem<String>> getApplicant(var locale, bool removeSponsor) { if (removeSponsor) { return [ DropdownMenuItem( value: 'Please select', child: Text("${locale.getTranslatedValues('please_select')}"), ), DropdownMenuItem( value: 'commissioner', child: Text("${locale.getTranslatedValues('commissioner')}"), ), DropdownMenuItem( value: 'the_resident_himself', child: Text("${locale.getTranslatedValues('the_resident_himself')}"), ), ]; } return [ DropdownMenuItem( value: 'Please select', child: Text("${locale.getTranslatedValues('please_select')}"), ), DropdownMenuItem( value: 'sponsor', child: Text("${locale.getTranslatedValues('sponsor')}"), ), DropdownMenuItem( value: 'commissioner', child: Text("${locale.getTranslatedValues('commissioner')}"), ), DropdownMenuItem( value: 'the_resident_himself', child: Text("${locale.getTranslatedValues('the_resident_himself')}"), ), ]; } List<DropdownMenuItem<String>> getRequiredDuration(var locale) { return [ DropdownMenuItem( value: 'Please select', child: Text("${locale.getTranslatedValues('please_select')}"), ), DropdownMenuItem( value: '3Months', child: Text("${locale.getTranslatedValues('3Months')}"), ), DropdownMenuItem( value: '6Months', child: Text("${locale.getTranslatedValues('6Months')}"), ), DropdownMenuItem( value: '1year', child: Text("${locale.getTranslatedValues('1year')}"), ), DropdownMenuItem( value: '2year', child: Text("${locale.getTranslatedValues('2year')}"), ), DropdownMenuItem( value: '3year', child: Text("${locale.getTranslatedValues('3year')}"), ), DropdownMenuItem( value: '4year', child: Text("${locale.getTranslatedValues('4year')}"), ), DropdownMenuItem( value: '5year', child: Text("${locale.getTranslatedValues('5year')}"), ), ]; } List<DropdownMenuItem<String>> getResidenceStatus(var locale) { return [ DropdownMenuItem( value: 'Please select', child: Text("${locale.getTranslatedValues('please_select')}"), ), DropdownMenuItem( value: 'self_financing_accommodation', child: Text( "${locale.getTranslatedValues('self_financing_accommodation')}"), ), DropdownMenuItem( value: 'student_residency', child: Text("${locale.getTranslatedValues('student_residency')}"), ), DropdownMenuItem( value: 'residence_of_a_spouse_dependent', child: Text( "${locale.getTranslatedValues('residence_of_a_spouse_dependent')}"), ), DropdownMenuItem( value: 'investor_residency', child: Text("${locale.getTranslatedValues('investor_residency')}"), ), ]; } List<DropdownMenuItem<String>> getAllowanceType(var locale) { return [ DropdownMenuItem( value: 'Please select', child: Text("${locale.getTranslatedValues('please_select')}"), ), DropdownMenuItem( value: 'damaged_allowance', child: Text("${locale.getTranslatedValues('damaged_allowance')}"), ), DropdownMenuItem( value: 'lost_allowance', child: Text("${locale.getTranslatedValues('lost_allowance')}"), ), ]; } List<DropdownMenuItem<String>> getProofResidence(var locale) { return [ DropdownMenuItem( value: 'Please select', child: Text("${locale.getTranslatedValues('please_select')}"), ), DropdownMenuItem( value: 'Lease', child: Text("${locale.getTranslatedValues('Lease')}"), ), DropdownMenuItem( value: 'registration_deed', child: Text("${locale.getTranslatedValues('registration_deed')}"), ), ]; } List<DropdownMenuItem<String>> getSponsorStatus(var locale) { return [ DropdownMenuItem( value: 'Please select', child: Text("${locale.getTranslatedValues('please_select')}"), ), DropdownMenuItem( value: 'foreign', child: Text("${locale.getTranslatedValues('foreign')}"), ), DropdownMenuItem( value: 'jordanain_holds_a_national_number', child: Text( "${locale.getTranslatedValues('jordanain_holds_a_national_number')}"), ), DropdownMenuItem( value: 'jordanain_does_not_have_a_national_number', child: Text( "${locale.getTranslatedValues('jordanain_does_not_have_a_national_number')}"), ), ]; } List<DropdownMenuItem<String>> getSponsorResidencyStatus(var locale) { return [ DropdownMenuItem( value: 'Please select', child: Text("${locale.getTranslatedValues('please_select')}"), ), DropdownMenuItem( value: 'work permit', child: Text("${locale.getTranslatedValues('work permit')}"), ), DropdownMenuItem( value: 'residence_permit', child: Text("${locale.getTranslatedValues('residence_permit')}"), ), ]; } }