Untitled
unknown
plain_text
2 years ago
64 kB
12
Indexable
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:sanad_flutter/core/widgets/custom_date_text_field.dart';
import 'package:sanad_flutter/features/aseza/residency_application/presentation/bloc/residency_application_bloc.dart';
import '../../../../../core/config/app_localization.dart';
import '../../../../../core/config/sanad_colors.dart';
import '../../../../../core/widgets/custom_button.dart';
import '../../../../../core/widgets/custom_drop_down_id_.dart';
import '../../../../../core/widgets/custom_text.dart';
import '../../../../../core/widgets/custom_text_field.dart';
import '../../../../main/domain/entities/user.dart';
import '../../../../main/presentation/bloc/user_data_bloc.dart';
import 'get_nationalty_residency.dart';
class CompanyRepresentativeInfo extends StatefulWidget {
const CompanyRepresentativeInfo({super.key});
@override
State<CompanyRepresentativeInfo> createState() =>
_CompanyRepresentativeInfoState();
}
class _CompanyRepresentativeInfoState extends State<CompanyRepresentativeInfo> {
String radioSelected2 = 'no';
final formKey = GlobalKey<FormState>();
addInitialValues(BuildContext context, User? user) {
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.LastEntry !=
null) {
ResidencyApplicationBloc.get(context).lastEntryDateController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.LastEntry!
.split('T')
.first;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.LastExit !=
null) {
ResidencyApplicationBloc.get(context).lastExitDateController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.LastExit!
.split('T')
.first;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.MedicalExamtionStartDate !=
null) {
ResidencyApplicationBloc.get(context)
.dateCommencementMedicalExaminationController
.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.MedicalExamtionStartDate!
.split('T')
.first;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.MedicalExamtionEndDate !=
null) {
ResidencyApplicationBloc.get(context)
.dateCompletionMedicalExaminationController
.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.MedicalExamtionEndDate!
.split('T')
.first;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.GuarantorName !=
null) {
ResidencyApplicationBloc.get(context).sponsorsNameCompany.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.GuarantorName!;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.GuarantorPermitEndDate !=
null) {
ResidencyApplicationBloc.get(context)
.theExpirationDateOfTheSponsorsAuthorization
.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.GuarantorPermitEndDate!;
}
if (ResidencyApplicationBloc.get(context).applicationType != 'first_time') {
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.RecipientFullName !=
null) {
ResidencyApplicationBloc.get(context).fullResidentNameController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.RecipientFullName!;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.OldResidencyEndDate !=
null) {
ResidencyApplicationBloc.get(context)
.previousDateExpirationController
.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.OldResidencyEndDate!;
}
ResidencyApplicationBloc.get(context).firstNameController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.FirstName!;
ResidencyApplicationBloc.get(context).fathersNameController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.SecondName!;
ResidencyApplicationBloc.get(context).grandfathersNameController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.ThirdName!;
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Gender !=
null) {
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Gender!
.toString()
.endsWith('0')) {
ResidencyApplicationBloc.get(context).gender = 'male';
} else {
ResidencyApplicationBloc.get(context).gender = 'female';
}
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.LastName !=
null) {
ResidencyApplicationBloc.get(context).familyNameController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.LastName!;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.NationalityName !=
null) {
ResidencyApplicationBloc.get(context).selectedDropdownNationality =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.NationalityName!;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.CurrentAddress !=
null) {
ResidencyApplicationBloc.get(context)
.residentialAddressController
.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.CurrentAddress!;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.MotherName !=
null) {
ResidencyApplicationBloc.get(context).mothersNameController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.MotherName!;
}
if (!getTypeEnable()) {
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Email !=
null) {
ResidencyApplicationBloc.get(context).emailController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Email!;
}
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.PlaceOfBirth !=
null) {
ResidencyApplicationBloc.get(context).placeBirthController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.PlaceOfBirth!;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.MarityStatus !=
null) {
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.MarityStatus! ==
121610001) {
ResidencyApplicationBloc.get(context).maritalStatus = 'maried';
} else {
ResidencyApplicationBloc.get(context).maritalStatus = 'single';
}
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Qualification !=
null) {
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Qualification! ==
121610000) {
ResidencyApplicationBloc.get(context).degree = 'notFound';
} else if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Qualification! ==
121610001) {
ResidencyApplicationBloc.get(context).degree = 'diploma';
} else if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Qualification! ==
121610002) {
ResidencyApplicationBloc.get(context).degree = 'Bachelors';
} else {
ResidencyApplicationBloc.get(context).degree = 'otherThat';
}
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Career !=
null) {
ResidencyApplicationBloc.get(context).occupationController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.Career!;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.PlaceOfIssuance !=
null) {
ResidencyApplicationBloc.get(context).placeOfIssueController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.PlaceOfIssuance!;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.DateOfIssuance !=
null) {
context.read<ResidencyApplicationBloc>().releaseDateController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.DateOfIssuance!;
}
if (ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.DateOfExpiry !=
null) {
context.read<ResidencyApplicationBloc>().endDateController.text =
ResidencyApplicationBloc.get(context)
.ResidencyApplicationCreate!
.DateOfExpiry!
.split('T')
.first;
}
context.read<ResidencyApplicationBloc>().mojDocumentType = 'passport';
}
}
@override
Widget build(BuildContext context) {
var locale = AppLocalization.of(context);
return BlocBuilder<ResidencyApplicationBloc, ResidencyApplicationState>(
builder: (context, state) {
User? user = context.read<UserDataBloc>().userData;
var locale = AppLocalization.of(context);
addInitialValues(context, user);
return Form(
key: formKey,
child: Padding(
padding: const EdgeInsets.only(top: 18),
child: SizedBox(
width: MediaQuery.of(context).size.width * double.infinity,
child: SingleChildScrollView(
child: Column(
children: [
CustomText(
'${AppLocalization.of(context).getTranslatedValues("Electronic link information")}',
style: const TextStyle(color: primaryColor),
),
const SizedBox(height: 10),
lastEntryDateWidgets(context),
lastExitDateWidgets(context),
dateCommencementMedicalExaminationWidget(context),
dateCompletionMedicalExaminationWidget(context),
sponsorsNameCompanyWidget(context),
theExpirationDateOfTheSponsorsAuthorizationWidget(context),
fullResidentNameWidget(context),
previousDateExpirationWidget(context),
CustomText(
'${AppLocalization.of(context).getTranslatedValues("Resident Information")}',
style: const TextStyle(color: primaryColor),
),
firstNameWidget(context),
fathersNameWidget(context),
grandfathersNameWidget(context),
familyNameWidget(context),
nationalityWidget(context),
genderWidget(context, locale),
mothersNameWidget(context),
emailWidget(context),
placeBirth(context),
maritalStatus(context, locale),
degreeWidget(context, locale),
occupationWidget(context),
// CustomText(
// '${AppLocalization.of(context).getTranslatedValues("Request Details")}',
// style: const TextStyle(color: primaryColor),
// ),
residentialAddressWidget(context),
CustomText(
'${AppLocalization.of(context).getTranslatedValues("Worker Passport Info2")}',
style: const TextStyle(color: primaryColor),
),
mojDocumentTypeWidget(context, locale),
placeOfIssueWidget(context),
releaseDateWidget(context),
endDateWidget(context),
hasThePassportBeenRenewed(context),
hasThePassportBeenExtended(context),
dateForExpandDate(context),
const SizedBox(height: 10),
buttonWidget(context),
],
),
),
),
),
);
},
);
}
bool isFieldEnableByType() {
if (context.read<ResidencyApplicationBloc>().applicationType ==
'first_time') {
return true;
}
return false;
}
//Fathers name
Widget lastEntryDateWidgets(BuildContext context) {
log(context.read<ResidencyApplicationBloc>().applicationType);
if (context.read<ResidencyApplicationBloc>().applicationType !=
'damage_or_loss_allowance' &&
context.read<ResidencyApplicationBloc>().applicationType !=
'modify_card_information') {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: false,
controller:
ResidencyApplicationBloc.get(context).lastEntryDateController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Last entry date")}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
return const SizedBox.shrink();
}
Widget lastExitDateWidgets(BuildContext context) {
if (context.read<ResidencyApplicationBloc>().applicationType !=
'damage_or_loss_allowance' &&
context.read<ResidencyApplicationBloc>().applicationType !=
'modify_card_information' &&
(context.read<ResidencyApplicationBloc>().applicationType !=
'first_time' &&
context.read<ResidencyApplicationBloc>().residenceStatus !=
'student_residency')) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: false,
controller:
ResidencyApplicationBloc.get(context).lastExitDateController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Last exit date")}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
} else {
return const SizedBox.shrink();
}
}
Widget dateCommencementMedicalExaminationWidget(BuildContext context) {
if (context.read<ResidencyApplicationBloc>().applicationType !=
'damage_or_loss_allowance' &&
context.read<ResidencyApplicationBloc>().applicationType ==
'modify_card_information' ||
context.read<ResidencyApplicationBloc>().applicationType ==
'first_time' &&
ResidencyApplicationBloc.get(context)
.dateCommencementMedicalExaminationController
.text
.isNotEmpty) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: false,
controller: ResidencyApplicationBloc.get(context)
.dateCommencementMedicalExaminationController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Date of commencement of medical examination")}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
return const SizedBox.shrink();
}
Widget dateCompletionMedicalExaminationWidget(BuildContext context) {
if (context.read<ResidencyApplicationBloc>().applicationType !=
'damage_or_loss_allowance' &&
context.read<ResidencyApplicationBloc>().applicationType ==
'modify_card_information' ||
context.read<ResidencyApplicationBloc>().applicationType ==
'first_time' &&
ResidencyApplicationBloc.get(context)
.dateCommencementMedicalExaminationController
.text
.isNotEmpty) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: false,
controller: ResidencyApplicationBloc.get(context)
.dateCompletionMedicalExaminationController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Date of completion of medical examination")}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
return const SizedBox.shrink();
}
Widget sponsorsNameCompanyWidget(BuildContext context) {
if (context.read<ResidencyApplicationBloc>().applicationType ==
'first_time' &&
context.read<ResidencyApplicationBloc>().residenceStatus ==
'investor_residency' ||
context.read<ResidencyApplicationBloc>().applicationType ==
'damage_or_loss_allowance') {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: false,
controller:
ResidencyApplicationBloc.get(context).sponsorsNameCompany,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Sponsors NameCompany")} *"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
} else {
return const SizedBox.shrink();
}
}
Widget theExpirationDateOfTheSponsorsAuthorizationWidget(
BuildContext context) {
if (context.read<ResidencyApplicationBloc>().applicationType ==
'first_time' &&
context.read<ResidencyApplicationBloc>().residenceStatus ==
'investor_residency') {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: false,
controller: ResidencyApplicationBloc.get(context)
.theExpirationDateOfTheSponsorsAuthorization,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expanded(
child: Text(
"${AppLocalization.of(context).getTranslatedValues("The expiration date of the sponsors authorization")} *"),
),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
} else {
return const SizedBox.shrink();
}
}
Widget fullResidentNameWidget(BuildContext context) {
if (context.read<ResidencyApplicationBloc>().applicationType !=
'first_time') {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: false,
controller: ResidencyApplicationBloc.get(context)
.fullResidentNameController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Full Resident Name")} *"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
return const SizedBox.shrink();
}
Widget previousDateExpirationWidget(BuildContext context) {
if (context.read<ResidencyApplicationBloc>().applicationType !=
'first_time' &&
context.read<ResidencyApplicationBloc>().residenceStatus !=
'student_residency') {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: false,
controller: ResidencyApplicationBloc.get(context)
.previousDateExpirationController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Previous date of expiration")}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
return const SizedBox.shrink();
}
Widget firstNameWidget(BuildContext context) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: isFieldEnableByType(),
controller:
ResidencyApplicationBloc.get(context).firstNameController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("First Name")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
Widget fathersNameWidget(BuildContext context) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: isFieldEnableByType() || enableFieldData(),
controller:
ResidencyApplicationBloc.get(context).fathersNameController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Fathers name")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
bool enableFieldData() {
if (context.read<ResidencyApplicationBloc>().applicationType ==
'modify_card_information') {
return true;
}
return false;
}
Widget grandfathersNameWidget(BuildContext context) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: isFieldEnableByType() || enableFieldData(),
controller: ResidencyApplicationBloc.get(context)
.grandfathersNameController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Grandfathers name")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
Widget familyNameWidget(BuildContext context) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: isFieldEnableByType(),
controller:
ResidencyApplicationBloc.get(context).familyNameController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Family name")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
Widget nationalityWidget(BuildContext context) {
return Column(
children: const [
NationalitiesWidget(),
SizedBox(height: 10),
],
);
// return Column(
// children: [
// SizedBox(
// width: MediaQuery.of(context).size.width * 0.9,
// child: CustomTextField(
// enabled: isFieldEnableByType(),
// controller:
// ResidencyApplicationBloc.get(context).nationalityController,
// label: Row(
// mainAxisSize: MainAxisSize.min,
// children: [
// Text(
// "${AppLocalization.of(context).getTranslatedValues("nationality")}"),
// ],
// ),
// validator: (value) {
// if (value == null || value.isEmpty) {
// return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
// }
// return null;
// },
// ),
// ),
// const SizedBox(height: 10),
// ],
// );
}
Widget genderWidget(BuildContext context, var locale) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.95,
child: CustomDropDownID(
items: getGender(locale),
labelText:
"${locale.getTranslatedValues('gender')} ${isFieldEnableByType() ? ' *' : ''}",
value: context.read<ResidencyApplicationBloc>().gender,
onChanged: getTypeEnable()
? (p0) {
context.read<ResidencyApplicationBloc>().gender =
p0.toString();
context.read<ResidencyApplicationBloc>().add(Refresh());
}
: isFieldEnableByType()
? (p0) {
context.read<ResidencyApplicationBloc>().gender =
p0.toString();
context.read<ResidencyApplicationBloc>().add(Refresh());
}
: null,
),
// CustomTextField(
// enabled: isFieldEnableByType(),
// controller: ResidencyApplicationBloc.get(context).genderController,
// label: Row(
// mainAxisSize: MainAxisSize.min,
// children: [
// Text(
// "${AppLocalization.of(context).getTranslatedValues("gender")}"),
// ],
// ),
// validator: (value) {
// if (value == null || value.isEmpty) {
// return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
// }
// return null;
// },
// ),
),
const SizedBox(height: 10),
],
);
}
List<DropdownMenuItem<String>> getGender(var locale) {
return [
DropdownMenuItem(
value: 'Please select',
child: Text("${locale.getTranslatedValues('please_select')}"),
),
DropdownMenuItem(
value: 'male',
child: Text("${locale.getTranslatedValues('male')}"),
),
DropdownMenuItem(
value: 'female',
child: Text("${locale.getTranslatedValues('female')}"),
),
];
}
Widget mothersNameWidget(BuildContext context) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: isFieldEnableByType() || enableFieldData(),
controller:
ResidencyApplicationBloc.get(context).mothersNameController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Mothers name")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
Widget emailWidget(BuildContext context) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: enableFieldData()
? true
: getTypeActive()
? true
: isFieldEnableByType(),
controller: ResidencyApplicationBloc.get(context).emailController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("email")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
bool getTypeActive() {
if (ResidencyApplicationBloc.get(context).applicationType == 'renewal' ||
ResidencyApplicationBloc.get(context).applicationType == 'first_time') {
return true;
}
return false;
}
Widget placeBirth(BuildContext context) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: isFieldEnableByType(),
controller:
ResidencyApplicationBloc.get(context).placeBirthController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Place of Birth")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
Widget maritalStatus(BuildContext context, var locale) {
return Column(
children: [
const SizedBox(height: 10),
SizedBox(
width: MediaQuery.of(context).size.width * 0.95,
child: CustomDropDownID(
items: getMaritalStatus(locale),
labelText:
"${locale.getTranslatedValues('Marital status')} ${isFieldEnableByType() ? ' *' : ''}",
value: context.read<ResidencyApplicationBloc>().maritalStatus,
onChanged: getTypeActive() || enableFieldData()
? (p0) {
context.read<ResidencyApplicationBloc>().maritalStatus =
p0.toString();
context.read<ResidencyApplicationBloc>().add(Refresh());
}
: isFieldEnableByType()
? (p0) {
context.read<ResidencyApplicationBloc>().maritalStatus =
p0.toString();
context.read<ResidencyApplicationBloc>().add(Refresh());
}
: null,
),
),
const SizedBox(height: 10),
],
);
}
List<DropdownMenuItem<String>> getMaritalStatus(var locale) {
return [
DropdownMenuItem(
value: 'Please select',
child: Text("${locale.getTranslatedValues('please_select')}"),
),
DropdownMenuItem(
value: 'single',
child: Text("${locale.getTranslatedValues('single')}"),
),
DropdownMenuItem(
value: 'maried',
child: Text("${locale.getTranslatedValues('maried')}"),
),
];
}
Widget degreeWidget(BuildContext context, var locale) {
return Column(
children: [
const SizedBox(height: 10),
SizedBox(
width: MediaQuery.of(context).size.width * 0.95,
child: CustomDropDownID(
items: getDegree(locale),
labelText:
"${locale.getTranslatedValues('degree')} ${isFieldEnableByType() ? ' *' : ''}",
value: context.read<ResidencyApplicationBloc>().degree,
onChanged: getTypeActive() || enableFieldData()
? (p0) {
context.read<ResidencyApplicationBloc>().degree =
p0.toString();
context.read<ResidencyApplicationBloc>().add(Refresh());
}
: isFieldEnableByType()
? (p0) {
context.read<ResidencyApplicationBloc>().degree =
p0.toString();
context.read<ResidencyApplicationBloc>().add(Refresh());
}
: null,
),
),
const SizedBox(height: 10),
],
);
}
List<DropdownMenuItem<String>> getDegree(var locale) {
return [
DropdownMenuItem(
value: 'Please select',
child: Text("${locale.getTranslatedValues('please_select')}"),
),
DropdownMenuItem(
value: 'notFound',
child: Text("${locale.getTranslatedValues('notFound')}"),
),
DropdownMenuItem(
value: 'diploma',
child: Text("${locale.getTranslatedValues('diploma')}"),
),
DropdownMenuItem(
value: 'Bachelors',
child: Text("${locale.getTranslatedValues('Bachelors')}"),
),
DropdownMenuItem(
value: 'otherThat',
child: Text("${locale.getTranslatedValues('otherThat')}"),
),
];
}
Widget occupationWidget(BuildContext context) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: isFieldEnableByType(),
controller:
ResidencyApplicationBloc.get(context).occupationController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Occupation")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
Widget residentialAddressWidget(BuildContext context) {
return Column(
children: [
const SizedBox(height: 10),
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: getTypeActive() ? true : isFieldEnableByType(),
controller: ResidencyApplicationBloc.get(context)
.residentialAddressController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Residential address")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
if (isFieldEnableByType() &&
context.read<ResidencyApplicationBloc>().residenceStatus ==
'student_residency')
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: getTypeEnable() ? true : isFieldEnableByType(),
controller: ResidencyApplicationBloc.get(context).universityName,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("universityName")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
if (getTypeEnable() ||
ResidencyApplicationBloc.get(context).applicationType ==
'renewal' &&
context.read<ResidencyApplicationBloc>().residenceStatus ==
'residence_of_a_spouse_dependent')
SizedBox(
width: MediaQuery.of(context).size.width * 0.90,
child: CustomDateTextField(
controller:
context.read<ResidencyApplicationBloc>().dateOfMarriage,
label:
'${AppLocalization.of(context).getTranslatedValues("date_of_marriage")} ${isFieldEnableByType() ? ' *' : ''}',
),
),
if (getTypeEnable() ||
ResidencyApplicationBloc.get(context).applicationType ==
'renewal' &&
context.read<ResidencyApplicationBloc>().residenceStatus ==
'residence_of_a_spouse_dependent')
const SizedBox(height: 10),
if (enableFieldData())
SizedBox(
width: MediaQuery.of(context).size.width * 0.90,
child: CustomTextField(
controller: ResidencyApplicationBloc.get(context)
.justificationForTheAmendmentRequest,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Justification for the amendment request")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
if (getTypeEnable()) const SizedBox(height: 10),
],
);
}
Widget mojDocumentTypeWidget(BuildContext context, var locale) {
return Column(
children: [
const SizedBox(height: 20),
SizedBox(
width: MediaQuery.of(context).size.width * 0.95,
child: CustomDropDownID(
items: getMojDocumentType(locale),
labelText:
"${locale.getTranslatedValues('moj_document_type')} ${isFieldEnableByType() ? ' *' : ''}",
value: context.read<ResidencyApplicationBloc>().mojDocumentType,
onChanged: getTypeEnable()
? (p0) {
context
.read<ResidencyApplicationBloc>()
.endDateController
.text = '';
context.read<ResidencyApplicationBloc>().mojDocumentType =
p0.toString();
context.read<ResidencyApplicationBloc>().add(Refresh());
}
: isFieldEnableByType()
? (p0) {
context
.read<ResidencyApplicationBloc>()
.endDateController
.text = '';
context
.read<ResidencyApplicationBloc>()
.mojDocumentType = p0.toString();
context.read<ResidencyApplicationBloc>().add(Refresh());
}
: null,
),
),
const SizedBox(height: 10),
],
);
}
bool getTypeEnable() {
if (context.read<ResidencyApplicationBloc>().applicationType ==
'modify_card_information') {
return true;
}
return false;
}
List<DropdownMenuItem<String>> getMojDocumentType(var locale) {
return [
DropdownMenuItem(
value: 'Please select',
child: Text("${locale.getTranslatedValues('please_select')}"),
),
DropdownMenuItem(
value: 'passport',
child: Text("${locale.getTranslatedValues('passport')}"),
),
DropdownMenuItem(
value: 'travelDocument',
child: Text("${locale.getTranslatedValues('travelDocument')}"),
),
];
}
Widget placeOfIssueWidget(BuildContext context) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: getTypeEnable() ? true : isFieldEnableByType(),
controller:
ResidencyApplicationBloc.get(context).placeOfIssueController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Place of issue")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 10),
],
);
}
Widget releaseDateWidget(BuildContext context) {
if (getTypeEnable()) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.90,
child: CustomDateTextField(
controller: context
.read<ResidencyApplicationBloc>()
.releaseDateController,
maximumDate: DateTime.now().add(const Duration(seconds: 1)),
label:
'${AppLocalization.of(context).getTranslatedValues("Release Date")} ${isFieldEnableByType() ? ' *' : ''}',
),
),
const SizedBox(height: 20),
],
);
}
return Column(
children: [
if (isFieldEnableByType())
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomDateTextField(
controller: context
.read<ResidencyApplicationBloc>()
.releaseDateController,
maximumDate: DateTime.now().add(const Duration(seconds: 1)),
label:
'${AppLocalization.of(context).getTranslatedValues("Release Date")} ${isFieldEnableByType() ? ' *' : ''}',
),
)
else
CustomTextField(
enabled: getTypeEnable() ? true : isFieldEnableByType(),
controller:
ResidencyApplicationBloc.get(context).releaseDateController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("Release Date")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
const SizedBox(height: 20),
],
);
}
DateTime getInitDate() {
if (context.read<ResidencyApplicationBloc>().mojDocumentType ==
'passport') {
return DateTime.now().toUtc().add(const Duration(days: 90));
} else {
return DateTime.now().toUtc().add(const Duration(days: 180));
}
}
Widget endDateWidget(BuildContext context) {
if (isFieldEnableByType() || enableFieldData()) {
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.90,
child: CustomDateTextField(
enabled:
context.read<ResidencyApplicationBloc>().mojDocumentType !=
'Please select',
controller:
context.read<ResidencyApplicationBloc>().endDateController,
initalDate: getInitDate(),
onComplete: () {
context.read<ResidencyApplicationBloc>().add(Refresh());
},
label:
'${AppLocalization.of(context).getTranslatedValues("End Date")} ${isFieldEnableByType() ? ' *' : ''}',
),
),
const SizedBox(height: 20),
],
);
}
return Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
child: CustomTextField(
enabled: getTypeEnable() ? true : isFieldEnableByType(),
controller: ResidencyApplicationBloc.get(context).endDateController,
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"${AppLocalization.of(context).getTranslatedValues("End Date")} ${isFieldEnableByType() ? ' *' : ''}"),
],
),
validator: (value) {
if (value == null || value.isEmpty) {
return '${AppLocalization.of(context).getTranslatedValues("this_field_is_required")}';
}
return null;
},
),
),
const SizedBox(height: 20),
],
);
}
Widget hasThePassportBeenRenewed(BuildContext context) {
if (context.read<ResidencyApplicationBloc>().applicationType !=
'damage_or_loss_allowance' &&
context.read<ResidencyApplicationBloc>().applicationType !=
'modify_card_information') {
return SizedBox(
width: MediaQuery.of(context).size.width * 0.90,
child: Row(
children: [
Expanded(
child: CustomText(
AppLocalization.of(context)
.getTranslatedValues("Has the passport been renewed"),
style: const TextStyle(fontSize: 15),
),
),
const SizedBox(
width: 10,
),
Row(
children: [
SizedBox(
height: 20,
child: Row(
children: [
CustomText(
AppLocalization.of(context)
.getTranslatedValues("yes"),
),
const SizedBox(
width: 5,
),
SizedBox(
width: 15,
height: 15,
child: Radio(
value: "yes",
groupValue: ResidencyApplicationBloc.get(context)
.radioSelected,
onChanged: isFieldEnableByType()
? (value) {
ResidencyApplicationBloc.get(context)
.radioSelected = 'yes';
context
.read<ResidencyApplicationBloc>()
.add(Refresh());
}
: null,
),
),
],
)),
const SizedBox(
width: 10,
),
SizedBox(
height: 20,
child: Row(
children: [
CustomText(
AppLocalization.of(context).getTranslatedValues("no"),
),
const SizedBox(
width: 5,
),
SizedBox(
height: 15,
width: 15,
child: Radio(
value: "no",
groupValue: ResidencyApplicationBloc.get(context)
.radioSelected,
onChanged: isFieldEnableByType()
? (value) {
ResidencyApplicationBloc.get(context)
.radioSelected = 'no';
context
.read<ResidencyApplicationBloc>()
.add(Refresh());
}
: null,
),
),
],
),
),
],
),
],
));
} else {
return const SizedBox.shrink();
}
}
Widget hasThePassportBeenExtended(BuildContext context) {
if (!isFieldEnableByType() &&
context.read<ResidencyApplicationBloc>().applicationType !=
'damage_or_loss_allowance' &&
context.read<ResidencyApplicationBloc>().applicationType !=
'modify_card_information') {
return Padding(
padding: const EdgeInsets.only(top: 10.0),
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.90,
child: Row(
children: [
CustomText(
AppLocalization.of(context)
.getTranslatedValues("Has the passport been extended?"),
style: const TextStyle(fontSize: 15),
),
const SizedBox(width: 10),
Row(
children: [
SizedBox(
height: 20,
child: Row(
children: [
CustomText(
AppLocalization.of(context)
.getTranslatedValues("yes"),
),
const SizedBox(
width: 5,
),
SizedBox(
width: 15,
height: 15,
child: Radio(
value: "yes",
groupValue: radioSelected2,
onChanged: null,
),
),
],
)),
const SizedBox(
width: 10,
),
SizedBox(
height: 20,
child: Row(
children: [
CustomText(
AppLocalization.of(context)
.getTranslatedValues("no"),
),
const SizedBox(
width: 5,
),
SizedBox(
height: 15,
width: 15,
child: Radio(
value: "no",
groupValue: radioSelected2,
onChanged: null,
),
),
],
),
),
],
),
],
)),
);
} else {
return const SizedBox.shrink();
}
}
DateTime? getEndDate() {
if (context
.read<ResidencyApplicationBloc>()
.endDateController
.text
.isEmpty) {
context.read<ResidencyApplicationBloc>().dateForExpandDate.text = '';
return null;
}
String dateString =
context.read<ResidencyApplicationBloc>().endDateController.text;
List<String> parts = dateString.split('/');
int month = int.parse(parts[1]);
int day = int.parse(parts[0]);
int year = int.parse(parts[2]);
DateTime dateTime = DateTime(year, month, day);
return dateTime;
}
Widget dateForExpandDate(BuildContext context) {
if (isFieldEnableByType() &&
ResidencyApplicationBloc.get(context).radioSelected == 'yes') {
return Padding(
padding: const EdgeInsets.only(top: 20),
child: Column(
children: [
SizedBox(
width: MediaQuery.of(context).size.width * 0.90,
child: CustomDateTextField(
enabled: context
.read<ResidencyApplicationBloc>()
.endDateController
.text
.isNotEmpty,
controller:
context.read<ResidencyApplicationBloc>().dateForExpandDate,
initalDate: getEndDate(),
label:
'${AppLocalization.of(context).getTranslatedValues("dateForExpandDate")} ${isFieldEnableByType() ? ' *' : ''}',
),
),
const SizedBox(height: 20),
],
),
);
}
return const SizedBox.shrink();
}
Widget buttonWidget(BuildContext context) => SizedBox(
width: MediaQuery.of(context).size.width * 0.85,
child: CustomButton(
onPressed: () {
if (formKey.currentState!.validate()) {
if (context.read<ResidencyApplicationBloc>().applicationType ==
'first_time') {
if (context.read<ResidencyApplicationBloc>().gender ==
'Please select' ||
context.read<ResidencyApplicationBloc>().mojDocumentType ==
'Please select' ||
context
.read<ResidencyApplicationBloc>()
.releaseDateController
.text
.isEmpty ||
context
.read<ResidencyApplicationBloc>()
.endDateController
.text
.isEmpty ||
context.read<ResidencyApplicationBloc>().maritalStatus ==
'Please select' ||
ResidencyApplicationBloc.get(context).degree ==
'Please select') {
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(AttachmentCases());
ResidencyApplicationBloc.get(context).add(StartActivities());
ResidencyApplicationBloc.get(context).add(AddStep());
}
} else {
ResidencyApplicationBloc.get(context).add(AttachmentCases());
ResidencyApplicationBloc.get(context).add(StartActivities());
ResidencyApplicationBloc.get(context).add(AddStep());
}
}
},
backgroundColor: primaryColor,
child: CustomText(
AppLocalization.of(context).getTranslatedValues('continue')),
),
);
}
Editor is loading...