FIX_MinorTask
This commit is contained in:
parent
1fb7c324a0
commit
e1844828b8
@ -71,6 +71,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
dynamic emailId;
|
dynamic emailId;
|
||||||
List<Map<String, dynamic>> employeePolicyList = [];
|
List<Map<String, dynamic>> employeePolicyList = [];
|
||||||
String? selectedFileNames;
|
String? selectedFileNames;
|
||||||
|
|
||||||
// html.File? uploadedFile;
|
// html.File? uploadedFile;
|
||||||
// List<html.File> uploadedFiles = [];
|
// List<html.File> uploadedFiles = [];
|
||||||
List<PlatformFile> uploadedFiles = [];
|
List<PlatformFile> uploadedFiles = [];
|
||||||
@ -144,6 +145,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
bool isIntimationDateValid = true;
|
bool isIntimationDateValid = true;
|
||||||
bool isAdmitDateValid = true;
|
bool isAdmitDateValid = true;
|
||||||
bool isDischargeDateValid = true;
|
bool isDischargeDateValid = true;
|
||||||
|
bool isAccidentService = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -372,7 +374,6 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> sendFormDataToApi() async {
|
Future<void> sendFormDataToApi() async {
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
isServiceValid = serviceId != null;
|
isServiceValid = serviceId != null;
|
||||||
isPolicyValid = selectedClientPolicyId != null;
|
isPolicyValid = selectedClientPolicyId != null;
|
||||||
@ -395,6 +396,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
// ☠ Accident / Death
|
// ☠ Accident / Death
|
||||||
final isAccident = [2, 3, 4].contains(serviceId);
|
final isAccident = [2, 3, 4].contains(serviceId);
|
||||||
|
|
||||||
|
isAccidentService = isAccident ? true : false;
|
||||||
|
|
||||||
isAccidentDateValid = !isAccident || accidentDate != null;
|
isAccidentDateValid = !isAccident || accidentDate != null;
|
||||||
isIntimationDateValid = !isAccident || intimationDate != null;
|
isIntimationDateValid = !isAccident || intimationDate != null;
|
||||||
});
|
});
|
||||||
@ -550,9 +553,10 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
|
|
||||||
pdf.addPage(
|
pdf.addPage(
|
||||||
pw.Page(
|
pw.Page(
|
||||||
build: (pw.Context context) => pw.Center(
|
build: (pw.Context context) =>
|
||||||
child: pw.Image(image, fit: pw.BoxFit.contain),
|
pw.Center(
|
||||||
),
|
child: pw.Image(image, fit: pw.BoxFit.contain),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -752,236 +756,291 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
Form(
|
Form(
|
||||||
key: formKey,
|
key: formKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
_row([
|
|
||||||
buildDropdownField(
|
|
||||||
'Service',
|
|
||||||
(value) {
|
|
||||||
final selectedItem = departmentList.firstWhere(
|
|
||||||
(item) => item['id'] == value,
|
|
||||||
orElse: () => {},
|
|
||||||
);
|
|
||||||
setState(() {
|
|
||||||
serviceId = value;
|
|
||||||
serviceName = selectedItem['name'];
|
|
||||||
policyNumberId = null;
|
|
||||||
isServiceValid = true;
|
|
||||||
});
|
|
||||||
print('🔥 serviceId set to $serviceId');
|
|
||||||
filterPoliciesByService(value!);
|
|
||||||
},
|
|
||||||
departmentList,
|
|
||||||
'name',
|
|
||||||
serviceId,
|
|
||||||
),
|
|
||||||
buildDropdownField(
|
|
||||||
'Select Policy',
|
|
||||||
(value) {
|
|
||||||
final selectedPolicy =
|
|
||||||
policyNumberList.firstWhere((p) => p['id'] == value);
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
// ✅ THIS is what you send to API
|
|
||||||
selectedClientPolicyId = selectedPolicy['id'];
|
|
||||||
|
|
||||||
// optional
|
|
||||||
selectedPolicyTypeId = selectedPolicy['policy_type_id'];
|
|
||||||
policyNumberId = value;
|
|
||||||
|
|
||||||
isPolicyValid = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
getCDPoliciesDetails();
|
|
||||||
},
|
|
||||||
policyNumberList,
|
|
||||||
'label', // 👈 DISPLAY FIELD
|
|
||||||
policyNumberId,
|
|
||||||
),
|
|
||||||
|
|
||||||
buildDropdownFieldSearch(
|
|
||||||
'Member Name',
|
|
||||||
(value) {
|
|
||||||
final member = employeePolicyList.firstWhere(
|
|
||||||
(m) => m['id'] == value,
|
|
||||||
);
|
|
||||||
|
|
||||||
setState(() {
|
|
||||||
selectedMemberId = value;
|
|
||||||
selectedMemberObject = member; // ✅ FULL OBJECT
|
|
||||||
selectedMemberName = member['name'];
|
|
||||||
isMemberValid = true;
|
|
||||||
print('selectedMemberObject $selectedMemberObject');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
employeePolicyList,
|
|
||||||
'name',
|
|
||||||
selectedMemberId,
|
|
||||||
),
|
|
||||||
|
|
||||||
]),
|
|
||||||
_row([
|
|
||||||
buildTextField('Message', messageController),
|
|
||||||
if (serviceId == 1 || serviceId == 72)...[
|
|
||||||
buildTextField('Hospital Name', hospitalNameController),
|
|
||||||
buildTextField('Hospital Address', hospitalAddressController),
|
|
||||||
]
|
|
||||||
]),
|
|
||||||
|
|
||||||
if (serviceId == 1 || serviceId == 72)
|
|
||||||
_row([
|
_row([
|
||||||
buildTextField('Hospital City', hospitalCityController),
|
buildDropdownField(
|
||||||
buildTextField('Hospital State', hospitalStateController),
|
'Service',
|
||||||
buildTextField(
|
(value) {
|
||||||
'Hospital Pincode',
|
final selectedItem = departmentList
|
||||||
hospitalPinCodeController,
|
.firstWhere(
|
||||||
keyboardType: TextInputType.number,
|
(item) => item['id'] == value,
|
||||||
inputFormatters: [
|
orElse: () => {},
|
||||||
FilteringTextInputFormatter.digitsOnly,
|
);
|
||||||
LengthLimitingTextInputFormatter(6),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
if (serviceId == 1 || serviceId == 72)
|
|
||||||
_row([
|
|
||||||
buildTextField(
|
|
||||||
'Hospital Phone No',
|
|
||||||
hospitalPhoneNoController,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.digitsOnly,
|
|
||||||
LengthLimitingTextInputFormatter(10),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
buildDatePickerField(
|
|
||||||
label: 'Admit Date',
|
|
||||||
selectedDate: admitDate,
|
|
||||||
allowFuture: false,
|
|
||||||
onDateSelected: (d) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
admitDate = d;
|
serviceId = value;
|
||||||
dischargeDate = null;
|
serviceName = selectedItem['name'];
|
||||||
|
policyNumberId = null;
|
||||||
|
isServiceValid = true;
|
||||||
|
});
|
||||||
|
print('🔥 serviceId set to $serviceId');
|
||||||
|
filterPoliciesByService(value!);
|
||||||
|
},
|
||||||
|
departmentList,
|
||||||
|
'name',
|
||||||
|
serviceId,
|
||||||
|
isRequired: true,
|
||||||
|
isValid: isServiceValid,
|
||||||
|
),
|
||||||
|
buildDropdownField(
|
||||||
|
'Select Policy',
|
||||||
|
(value) {
|
||||||
|
final selectedPolicy =
|
||||||
|
policyNumberList.firstWhere((
|
||||||
|
p) => p['id'] == value);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
// ✅ THIS is what you send to API
|
||||||
|
selectedClientPolicyId =
|
||||||
|
selectedPolicy['id'];
|
||||||
|
|
||||||
|
// optional
|
||||||
|
selectedPolicyTypeId =
|
||||||
|
selectedPolicy['policy_type_id'];
|
||||||
|
policyNumberId = value;
|
||||||
|
|
||||||
|
isPolicyValid = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
getCDPoliciesDetails();
|
||||||
|
},
|
||||||
|
policyNumberList,
|
||||||
|
'label', // 👈 DISPLAY FIELD
|
||||||
|
policyNumberId,
|
||||||
|
isRequired: true,
|
||||||
|
isValid: isPolicyValid, // 👈 Hooked to your state
|
||||||
|
),
|
||||||
|
|
||||||
|
buildDropdownFieldSearch(
|
||||||
|
'Member Name',
|
||||||
|
(value) {
|
||||||
|
final member = employeePolicyList
|
||||||
|
.firstWhere(
|
||||||
|
(m) => m['id'] == value,
|
||||||
|
);
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
selectedMemberId = value;
|
||||||
|
selectedMemberObject =
|
||||||
|
member; // ✅ FULL OBJECT
|
||||||
|
selectedMemberName = member['name'];
|
||||||
|
isMemberValid = true;
|
||||||
|
print(
|
||||||
|
'selectedMemberObject $selectedMemberObject');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
employeePolicyList,
|
||||||
|
'name',
|
||||||
|
selectedMemberId,
|
||||||
|
isRequired: true,
|
||||||
|
isValid: isMemberValid, // 👈 Hooked to your state
|
||||||
),
|
),
|
||||||
buildDatePickerField(
|
|
||||||
label: 'Discharge Date',
|
]),
|
||||||
selectedDate: dischargeDate,
|
_row([
|
||||||
allowFuture: true,
|
buildTextField('Message', messageController,
|
||||||
minDate: admitDate?.add(const Duration(days: 1)),
|
isRequired: false, isValid: true),
|
||||||
onDateSelected: (d) => setState(() => dischargeDate = d),
|
if (serviceId == 1 || serviceId == 72)...[
|
||||||
),
|
buildTextField(
|
||||||
buildTextField(
|
'Hospital Name', hospitalNameController,
|
||||||
'Claims Amount',
|
isRequired: true,
|
||||||
claimAmountController,
|
isValid: isHospitalNameValid),
|
||||||
keyboardType: TextInputType.number,
|
buildTextField('Hospital Address',
|
||||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
hospitalAddressController,
|
||||||
),
|
isRequired: true,
|
||||||
|
isValid: isHospitalAddressValid),
|
||||||
|
]
|
||||||
]),
|
]),
|
||||||
|
|
||||||
if ([2, 3, 4].contains(serviceId))
|
if (serviceId == 1 || serviceId == 72)
|
||||||
_row([
|
_row([
|
||||||
buildDatePickerField(
|
buildTextField(
|
||||||
label: 'Date of Birth',
|
'Hospital City', hospitalCityController,
|
||||||
selectedDate: birthDate,
|
isRequired: true,
|
||||||
allowFuture: false,
|
isValid: isHospitalCityValid),
|
||||||
onDateSelected: (d) => setState(() => birthDate = d),
|
buildTextField(
|
||||||
),
|
'Hospital State', hospitalStateController,
|
||||||
buildDatePickerField(
|
isRequired: true,
|
||||||
label: 'Accident Date',
|
isValid: isHospitalStateValid),
|
||||||
selectedDate: accidentDate,
|
buildTextField(
|
||||||
allowFuture: false,
|
'Hospital Pincode',
|
||||||
onDateSelected: (d) {
|
hospitalPinCodeController,
|
||||||
setState(() {
|
keyboardType: TextInputType.number,
|
||||||
accidentDate = d;
|
isRequired: true,
|
||||||
deathDate = null;
|
isValid: isHospitalPincodeValid,
|
||||||
intimationDate = null;
|
inputFormatters: [
|
||||||
});
|
FilteringTextInputFormatter.digitsOnly,
|
||||||
},
|
LengthLimitingTextInputFormatter(6),
|
||||||
),
|
],
|
||||||
buildDatePickerField(
|
|
||||||
label: 'Date of Death',
|
|
||||||
selectedDate: deathDate,
|
|
||||||
allowFuture: false,
|
|
||||||
onDateSelected: (d) => setState(() => deathDate = d),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
if ([2, 3, 4].contains(serviceId))
|
|
||||||
_row([
|
|
||||||
buildDatePickerField(
|
|
||||||
label: 'Date of Intimation',
|
|
||||||
selectedDate: intimationDate,
|
|
||||||
allowFuture: false,
|
|
||||||
onDateSelected: (d) => setState(() => intimationDate = d),
|
|
||||||
),
|
|
||||||
buildTextField(
|
|
||||||
'Sum Insured',
|
|
||||||
sumInsuredController,
|
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
|
||||||
),
|
|
||||||
const SizedBox(),
|
|
||||||
]),
|
|
||||||
|
|
||||||
_row([
|
|
||||||
MultiFileUploadWidget(),
|
|
||||||
]),
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: SizedBox(
|
|
||||||
width: 120,
|
|
||||||
height: 42,
|
|
||||||
child: ElevatedButton(
|
|
||||||
onPressed: isSubmitting ? null : sendFormDataToApi,
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
backgroundColor: const Color(0xFFE26728),
|
|
||||||
shape: RoundedRectangleBorder(
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
child: isSubmitting
|
]),
|
||||||
? const SizedBox(
|
if (serviceId == 1 || serviceId == 72)
|
||||||
height: 18,
|
_row([
|
||||||
width: 18,
|
buildTextField(
|
||||||
child: CircularProgressIndicator(
|
'Hospital Phone No',
|
||||||
strokeWidth: 2,
|
hospitalPhoneNoController,
|
||||||
color: Colors.white,
|
keyboardType: TextInputType.number,
|
||||||
|
isRequired: true,
|
||||||
|
isValid: isHospitalPhoneNoValid,
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.digitsOnly,
|
||||||
|
LengthLimitingTextInputFormatter(10),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
buildDatePickerField(
|
||||||
|
label: 'Admit Date',
|
||||||
|
selectedDate: admitDate,
|
||||||
|
allowFuture: false,
|
||||||
|
isRequired: true,
|
||||||
|
isValid: isAdmitDateValid,
|
||||||
|
onDateSelected: (d) {
|
||||||
|
setState(() {
|
||||||
|
admitDate = d;
|
||||||
|
dischargeDate = null;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
buildDatePickerField(
|
||||||
|
label: 'Discharge Date',
|
||||||
|
selectedDate: dischargeDate,
|
||||||
|
allowFuture: true,
|
||||||
|
minDate: admitDate?.add(
|
||||||
|
const Duration(days: 1)),
|
||||||
|
isRequired: true,
|
||||||
|
isValid: isDischargeDateValid,
|
||||||
|
onDateSelected: (d) =>
|
||||||
|
setState(() => dischargeDate = d),
|
||||||
|
),
|
||||||
|
buildTextField(
|
||||||
|
'Claims Amount',
|
||||||
|
claimAmountController,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
isRequired: true,
|
||||||
|
isValid: isClaimAmountValid,
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.digitsOnly
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
if ([2, 3, 4].contains(serviceId))
|
||||||
|
_row([
|
||||||
|
buildDatePickerField(
|
||||||
|
label: 'Date of Birth',
|
||||||
|
selectedDate: birthDate,
|
||||||
|
allowFuture: false,
|
||||||
|
isRequired: false,isValid: true,
|
||||||
|
onDateSelected: (d) =>
|
||||||
|
setState(() => birthDate = d),
|
||||||
|
),
|
||||||
|
buildDatePickerField(
|
||||||
|
label: 'Accident Date',
|
||||||
|
selectedDate: accidentDate,
|
||||||
|
allowFuture: false,
|
||||||
|
isRequired: isAccidentService,
|
||||||
|
isValid: isAccidentDateValid,
|
||||||
|
onDateSelected: (d) {
|
||||||
|
setState(() {
|
||||||
|
accidentDate = d;
|
||||||
|
deathDate = null;
|
||||||
|
intimationDate = null;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
buildDatePickerField(
|
||||||
|
label: 'Date of Death',
|
||||||
|
selectedDate: deathDate,
|
||||||
|
allowFuture: false,
|
||||||
|
isRequired: false,
|
||||||
|
isValid: true,
|
||||||
|
onDateSelected: (d) =>
|
||||||
|
setState(() => deathDate = d),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
if ([2, 3, 4].contains(serviceId))
|
||||||
|
_row([
|
||||||
|
buildDatePickerField(
|
||||||
|
label: 'Date of Intimation',
|
||||||
|
selectedDate: intimationDate,
|
||||||
|
allowFuture: false,
|
||||||
|
isRequired: isAccidentService,
|
||||||
|
isValid: isIntimationDateValid,
|
||||||
|
onDateSelected: (d) =>
|
||||||
|
setState(() => intimationDate = d),
|
||||||
|
),
|
||||||
|
buildTextField(
|
||||||
|
'Sum Insured',
|
||||||
|
sumInsuredController,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
isRequired: false,isValid: true,
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.digitsOnly
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
_row([
|
||||||
|
MultiFileUploadWidget(),
|
||||||
|
]),
|
||||||
|
Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: SizedBox(
|
||||||
|
width: 120,
|
||||||
|
height: 42,
|
||||||
|
child: ElevatedButton(
|
||||||
|
onPressed: isSubmitting
|
||||||
|
? null
|
||||||
|
: sendFormDataToApi,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: const Color(0xFFE26728),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: isSubmitting
|
||||||
|
? const SizedBox(
|
||||||
|
height: 18,
|
||||||
|
width: 18,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
strokeWidth: 2,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: const Text(
|
||||||
|
'Send',
|
||||||
|
style: TextStyle(color: Colors.white,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
),
|
),
|
||||||
)
|
|
||||||
: const Text(
|
|
||||||
'Send',
|
|
||||||
style: TextStyle(color: Colors.white,
|
|
||||||
fontWeight: FontWeight.w600),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
/// 🔄 LOADER OVERLAY (UNCHANGED)
|
|
||||||
if (isLoading)
|
|
||||||
Container(
|
|
||||||
color: const Color(0x98FFFCE5),
|
|
||||||
child: Center(
|
|
||||||
child: Image.asset(
|
|
||||||
'assets/nhance-loader.gif',
|
|
||||||
height: 60,
|
|
||||||
width: 60,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
|
||||||
|
/// 🔄 LOADER OVERLAY (UNCHANGED)
|
||||||
|
if (isLoading)
|
||||||
|
Container(
|
||||||
|
color: const Color(0x98FFFCE5),
|
||||||
|
child: Center(
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/nhance-loader.gif',
|
||||||
|
height: 60,
|
||||||
|
width: 60,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1003,29 +1062,31 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildTextField(
|
Widget buildTextField(String label,
|
||||||
String label,
|
TextEditingController controller, {
|
||||||
TextEditingController controller, {
|
TextInputType keyboardType = TextInputType.text,
|
||||||
TextInputType keyboardType = TextInputType.text,
|
bool isRequired = true, bool isValid = true,
|
||||||
List<TextInputFormatter>? inputFormatters,
|
List<TextInputFormatter>? inputFormatters,
|
||||||
}) {
|
}) {
|
||||||
return Column(
|
return Expanded(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
child: Column(
|
||||||
children: [
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
fieldLabel(label),
|
children: [
|
||||||
formBox(
|
fieldLabel(label, isRequired: isRequired),
|
||||||
child: TextField(
|
formBox(
|
||||||
controller: controller,
|
child: TextField(
|
||||||
keyboardType: keyboardType,
|
controller: controller,
|
||||||
inputFormatters: inputFormatters,
|
keyboardType: keyboardType,
|
||||||
decoration: const InputDecoration(
|
inputFormatters: inputFormatters,
|
||||||
isDense: true,
|
decoration: const InputDecoration(
|
||||||
border: InputBorder.none,
|
isDense: true,
|
||||||
|
border: InputBorder.none,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (!isValid) validationText(),
|
||||||
],
|
],
|
||||||
);
|
),);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildTextAreaField(String label, TextEditingController controller) {
|
Widget buildTextAreaField(String label, TextEditingController controller) {
|
||||||
@ -1053,53 +1114,81 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget buildDropdownField(
|
Widget buildDropdownField(
|
||||||
String label,
|
String label,
|
||||||
void Function(int?) onChanged,
|
void Function(int?) onChanged,
|
||||||
List<Map<String, dynamic>> itemsList,
|
List<Map<String, dynamic>> itemsList,
|
||||||
String displayField,
|
String displayField,
|
||||||
int? selectedValue,
|
int? selectedValue, {
|
||||||
) {
|
bool isRequired = true,
|
||||||
|
bool isValid = true,
|
||||||
|
}) {
|
||||||
|
|
||||||
|
// Logic to calculate font size based on string length
|
||||||
|
double getDynamicFontSize(String text) {
|
||||||
|
if (text.length > 25) return 9.0;
|
||||||
|
if (text.length > 15) return 10.0;
|
||||||
|
return 12.0;
|
||||||
|
}
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
fieldLabel(label),
|
fieldLabel(label, isRequired: isRequired),
|
||||||
formBox(
|
formBox(
|
||||||
child: DropdownButtonHideUnderline(
|
child: DropdownButtonHideUnderline(
|
||||||
child: DropdownButton<int>(
|
child: DropdownButton<int>(
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: selectedValue,
|
value: selectedValue,
|
||||||
hint: const Text('Select'),
|
hint: const Text(
|
||||||
|
'Select',
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
icon: const Icon(Icons.keyboard_arrow_down),
|
icon: const Icon(Icons.keyboard_arrow_down),
|
||||||
items: itemsList.map<DropdownMenuItem<int>>((item) {
|
items: itemsList.map<DropdownMenuItem<int>>((item) {
|
||||||
|
String textValue = item[displayField].toString(); // Get the text first
|
||||||
return DropdownMenuItem<int>(
|
return DropdownMenuItem<int>(
|
||||||
value: item['id'],
|
value: item['id'],
|
||||||
child: Text(item[displayField]),
|
child: Text(
|
||||||
|
textValue,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
softWrap: false,
|
||||||
|
maxLines: 1, // Strictly keep to one line
|
||||||
|
style: TextStyle(
|
||||||
|
// Call the function here and pass the textValue
|
||||||
|
fontSize: getDynamicFontSize(textValue),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (!isValid)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4, left: 4),
|
||||||
|
child: Text(
|
||||||
|
"Required",
|
||||||
|
style: TextStyle(color: Colors.red, fontSize: 12),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget buildDropdownFieldSearch(String label,
|
||||||
Widget buildDropdownFieldSearch(
|
|
||||||
String label,
|
|
||||||
void Function(int?) onChanged,
|
void Function(int?) onChanged,
|
||||||
List<Map<String, dynamic>> itemsList,
|
List<Map<String, dynamic>> itemsList,
|
||||||
String displayField,
|
String displayField,
|
||||||
int? selectedValue,
|
int? selectedValue,
|
||||||
) {
|
{
|
||||||
|
bool isRequired = true, // Added
|
||||||
|
bool isValid = true, // Added
|
||||||
|
}) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
fieldLabel(label, isRequired: isRequired),
|
||||||
label,
|
|
||||||
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w500),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Container(
|
Container(
|
||||||
height: 40,
|
height: 40,
|
||||||
@ -1179,6 +1268,12 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (!isValid)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4, left: 4),
|
||||||
|
child: Text("Required",
|
||||||
|
style: GoogleFonts.poppins(color: Colors.red, fontSize: 12)),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1191,18 +1286,20 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
required ValueChanged<DateTime?> onDateSelected,
|
required ValueChanged<DateTime?> onDateSelected,
|
||||||
DateTime? minDate,
|
DateTime? minDate,
|
||||||
DateTime? maxDate,
|
DateTime? maxDate,
|
||||||
|
bool isRequired = true,
|
||||||
|
bool isValid = true,
|
||||||
}) {
|
}) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
fieldLabel(label),
|
fieldLabel(label, isRequired: isRequired),
|
||||||
formBox(
|
formBox(
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final DateTime now = DateTime.now();
|
final DateTime now = DateTime.now();
|
||||||
final DateTime first = minDate ?? DateTime(1980);
|
final DateTime first = minDate ?? DateTime(1980);
|
||||||
final DateTime last =
|
final DateTime last =
|
||||||
allowFuture ? (maxDate ?? DateTime(2100)) : now;
|
allowFuture ? (maxDate ?? DateTime(2100)) : now;
|
||||||
|
|
||||||
final DateTime initialDate =
|
final DateTime initialDate =
|
||||||
selectedDate ?? (first.isAfter(now) ? first : now);
|
selectedDate ?? (first.isAfter(now) ? first : now);
|
||||||
@ -1232,6 +1329,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (!isValid) validationText(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1270,19 +1368,39 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget fieldLabel(String text) {
|
Widget fieldLabel(String text, {bool isRequired = false}) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 6),
|
padding: const EdgeInsets.only(bottom: 6),
|
||||||
child: Text(
|
child: RichText(
|
||||||
text,
|
text: TextSpan(
|
||||||
style: GoogleFonts.poppins(
|
text: text,
|
||||||
fontSize: 12,
|
style: GoogleFonts.poppins(
|
||||||
fontWeight: FontWeight.w500,
|
fontSize: 12,
|
||||||
color: Colors.black,
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
if (isRequired)
|
||||||
|
const TextSpan(
|
||||||
|
text: ' *',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Widget validationText() {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 4, left: 4),
|
||||||
|
child: Text(
|
||||||
|
"Required",
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
color: Colors.red, fontSize: 12, fontWeight: FontWeight.w500),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class RaiseClaimDialog extends StatelessWidget {
|
// class RaiseClaimDialog extends StatelessWidget {
|
||||||
|
|||||||
@ -114,7 +114,14 @@ class _activePolicyExcelErrorState extends State<excelErrorScreen>
|
|||||||
|
|
||||||
// 🟢 CASE 2: Success with data
|
// 🟢 CASE 2: Success with data
|
||||||
if (response['status'] == true) {
|
if (response['status'] == true) {
|
||||||
ToastHelper.showSuccessToast(context, response['message']);
|
if (response['message'] == "Error data feteched successfully") {
|
||||||
|
// This runs if the message matches EXACTLY (including the typo 'feteched')
|
||||||
|
ToastHelper.showErrorToast(context, response['message']);
|
||||||
|
}else {
|
||||||
|
ToastHelper.showSuccessToast(context, response['message']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user