add claims live issue fix
This commit is contained in:
parent
9a61f628ee
commit
9cd64e5c03
@ -71,7 +71,6 @@ 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 = [];
|
||||||
@ -145,7 +144,6 @@ 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() {
|
||||||
@ -220,9 +218,9 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
getClaimPoliciesApi = Map<String, dynamic>.from(response['data']);
|
getClaimPoliciesApi = Map<String, dynamic>.from(response['data']);
|
||||||
departmentList = (getClaimPoliciesApi['ticket_type'] as List)
|
departmentList = (getClaimPoliciesApi['ticket_type'] as List)
|
||||||
.map<Map<String, dynamic>>((item) => {
|
.map<Map<String, dynamic>>((item) => {
|
||||||
'id': int.parse(item['ticket_type'].toString()),
|
'id': int.parse(item['ticket_type'].toString()),
|
||||||
'name': item['type_name'].toString(),
|
'name': item['type_name'].toString(),
|
||||||
})
|
})
|
||||||
.toList();
|
.toList();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -338,7 +336,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
final List<Map<String, dynamic>> members =
|
final List<Map<String, dynamic>> members =
|
||||||
List<Map<String, dynamic>>.from(response['data']);
|
List<Map<String, dynamic>>.from(response['data']);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
employeePolicyList = members.map((m) {
|
employeePolicyList = members.map((m) {
|
||||||
@ -374,6 +372,7 @@ 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;
|
||||||
@ -396,8 +395,6 @@ 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;
|
||||||
});
|
});
|
||||||
@ -553,10 +550,9 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
|
|
||||||
pdf.addPage(
|
pdf.addPage(
|
||||||
pw.Page(
|
pw.Page(
|
||||||
build: (pw.Context context) =>
|
build: (pw.Context context) => pw.Center(
|
||||||
pw.Center(
|
child: pw.Image(image, fit: pw.BoxFit.contain),
|
||||||
child: pw.Image(image, fit: pw.BoxFit.contain),
|
),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -651,9 +647,9 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
Future<void> _pickFromToDate(BuildContext context) async {
|
Future<void> _pickFromToDate(BuildContext context) async {
|
||||||
// Define the policy date range
|
// Define the policy date range
|
||||||
final DateTime policyStartDate =
|
final DateTime policyStartDate =
|
||||||
DateFormat('dd-MMM-yyyy').parse(rawPolicyStartDate);
|
DateFormat('dd-MMM-yyyy').parse(rawPolicyStartDate);
|
||||||
final DateTime policyEndDate =
|
final DateTime policyEndDate =
|
||||||
DateFormat('dd-MMM-yyyy').parse(rawPolicyEndDate);
|
DateFormat('dd-MMM-yyyy').parse(rawPolicyEndDate);
|
||||||
|
|
||||||
// Show the date range picker within the policy date limits
|
// Show the date range picker within the policy date limits
|
||||||
final DateTimeRange? pickedDateRange = await showDateRangePicker(
|
final DateTimeRange? pickedDateRange = await showDateRangePicker(
|
||||||
@ -717,45 +713,44 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Dialog(
|
return Dialog(
|
||||||
backgroundColor: Colors.white, // ✅ PURE WHITE popup
|
backgroundColor: Colors.white, // ✅ PURE WHITE popup
|
||||||
insetPadding: const EdgeInsets.all(20),
|
insetPadding: const EdgeInsets.all(20),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
),
|
),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(16),
|
borderRadius: BorderRadius.circular(16),
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: MediaQuery.of(context).size.width * 0.75, // Desktop popup width
|
width: MediaQuery.of(context).size.width * 0.75, // Desktop popup width
|
||||||
height: MediaQuery.of(context).size.height * 0.85, // 🔥 ADD THIS
|
// height: MediaQuery.of(context).size.height * 0.85,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
/// MAIN CONTENT (YOUR EXISTING UI)
|
/// MAIN CONTENT (YOUR EXISTING UI)
|
||||||
SingleChildScrollView(
|
SingleChildScrollView(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(20),
|
padding: EdgeInsets.all(20),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
/// 🔹 HEADER ROW (Title + Close)
|
/// 🔹 HEADER ROW (Title + Close)
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Raise Insurance Claim",
|
"Raise Insurance Claim",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
IconButton(
|
||||||
IconButton(
|
icon: const Icon(Icons.close),
|
||||||
icon: const Icon(Icons.close),
|
onPressed: () => Navigator.pop(context),
|
||||||
tooltip: 'Close',
|
),
|
||||||
onPressed: () => Navigator.pop(context),
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
|
||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
Form(
|
Form(
|
||||||
key: formKey,
|
key: formKey,
|
||||||
@ -765,8 +760,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
buildDropdownField(
|
buildDropdownField(
|
||||||
'Service',
|
'Service',
|
||||||
(value) {
|
(value) {
|
||||||
final selectedItem = departmentList
|
final selectedItem = departmentList.firstWhere(
|
||||||
.firstWhere(
|
|
||||||
(item) => item['id'] == value,
|
(item) => item['id'] == value,
|
||||||
orElse: () => {},
|
orElse: () => {},
|
||||||
);
|
);
|
||||||
@ -782,24 +776,21 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
departmentList,
|
departmentList,
|
||||||
'name',
|
'name',
|
||||||
serviceId,
|
serviceId,
|
||||||
isRequired: true,
|
required: true,
|
||||||
isValid: isServiceValid,
|
isValid: isServiceValid,
|
||||||
),
|
),
|
||||||
buildDropdownField(
|
buildDropdownField(
|
||||||
'Select Policy',
|
'Select Policy',
|
||||||
(value) {
|
(value) {
|
||||||
final selectedPolicy =
|
final selectedPolicy =
|
||||||
policyNumberList.firstWhere((
|
policyNumberList.firstWhere((p) => p['id'] == value);
|
||||||
p) => p['id'] == value);
|
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
// ✅ THIS is what you send to API
|
// ✅ THIS is what you send to API
|
||||||
selectedClientPolicyId =
|
selectedClientPolicyId = selectedPolicy['id'];
|
||||||
selectedPolicy['id'];
|
|
||||||
|
|
||||||
// optional
|
// optional
|
||||||
selectedPolicyTypeId =
|
selectedPolicyTypeId = selectedPolicy['policy_type_id'];
|
||||||
selectedPolicy['policy_type_id'];
|
|
||||||
policyNumberId = value;
|
policyNumberId = value;
|
||||||
|
|
||||||
isPolicyValid = true;
|
isPolicyValid = true;
|
||||||
@ -810,71 +801,54 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
policyNumberList,
|
policyNumberList,
|
||||||
'label', // 👈 DISPLAY FIELD
|
'label', // 👈 DISPLAY FIELD
|
||||||
policyNumberId,
|
policyNumberId,
|
||||||
isRequired: true,
|
required: true,
|
||||||
isValid: isPolicyValid, // 👈 Hooked to your state
|
isValid: isPolicyValid,
|
||||||
),
|
),
|
||||||
|
|
||||||
buildDropdownFieldSearch(
|
buildDropdownFieldSearch(
|
||||||
'Member Name',
|
'Member Name',
|
||||||
(value) {
|
(value) {
|
||||||
final member = employeePolicyList
|
final member = employeePolicyList.firstWhere(
|
||||||
.firstWhere(
|
|
||||||
(m) => m['id'] == value,
|
(m) => m['id'] == value,
|
||||||
);
|
);
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedMemberId = value;
|
selectedMemberId = value;
|
||||||
selectedMemberObject =
|
selectedMemberObject = member; // ✅ FULL OBJECT
|
||||||
member; // ✅ FULL OBJECT
|
|
||||||
selectedMemberName = member['name'];
|
selectedMemberName = member['name'];
|
||||||
isMemberValid = true;
|
isMemberValid = true;
|
||||||
print(
|
print('selectedMemberObject $selectedMemberObject');
|
||||||
'selectedMemberObject $selectedMemberObject');
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
employeePolicyList,
|
employeePolicyList,
|
||||||
'name',
|
'name',
|
||||||
selectedMemberId,
|
selectedMemberId,
|
||||||
isRequired: true,
|
required: true,
|
||||||
isValid: isMemberValid, // 👈 Hooked to your state
|
isValid: isMemberValid,
|
||||||
),
|
),
|
||||||
|
|
||||||
]),
|
]),
|
||||||
_row([
|
_row([
|
||||||
buildTextField('Message', messageController,
|
buildTextField('Message', messageController),
|
||||||
isRequired: false, isValid: true),
|
|
||||||
if (serviceId == 1 || serviceId == 72)...[
|
if (serviceId == 1 || serviceId == 72)...[
|
||||||
buildTextField(
|
buildTextField('Hospital Name', hospitalNameController,required: true, isValid: isHospitalNameValid),
|
||||||
'Hospital Name', hospitalNameController,
|
buildTextField('Hospital Address', hospitalAddressController,required: true, isValid: isHospitalAddressValid),
|
||||||
isRequired: true,
|
|
||||||
isValid: isHospitalNameValid),
|
|
||||||
buildTextField('Hospital Address',
|
|
||||||
hospitalAddressController,
|
|
||||||
isRequired: true,
|
|
||||||
isValid: isHospitalAddressValid),
|
|
||||||
]
|
]
|
||||||
]),
|
]),
|
||||||
|
|
||||||
if (serviceId == 1 || serviceId == 72)
|
if (serviceId == 1 || serviceId == 72)
|
||||||
_row([
|
_row([
|
||||||
buildTextField(
|
buildTextField('Hospital City', hospitalCityController,required: true, isValid: isHospitalCityValid),
|
||||||
'Hospital City', hospitalCityController,
|
buildTextField('Hospital State', hospitalStateController,required: true, isValid: isHospitalStateValid),
|
||||||
isRequired: true,
|
|
||||||
isValid: isHospitalCityValid),
|
|
||||||
buildTextField(
|
|
||||||
'Hospital State', hospitalStateController,
|
|
||||||
isRequired: true,
|
|
||||||
isValid: isHospitalStateValid),
|
|
||||||
buildTextField(
|
buildTextField(
|
||||||
'Hospital Pincode',
|
'Hospital Pincode',
|
||||||
hospitalPinCodeController,
|
hospitalPinCodeController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
isRequired: true,
|
|
||||||
isValid: isHospitalPincodeValid,
|
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
FilteringTextInputFormatter.digitsOnly,
|
FilteringTextInputFormatter.digitsOnly,
|
||||||
LengthLimitingTextInputFormatter(6),
|
LengthLimitingTextInputFormatter(6),
|
||||||
],
|
],
|
||||||
|
required: true, isValid: isHospitalPincodeValid
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
if (serviceId == 1 || serviceId == 72)
|
if (serviceId == 1 || serviceId == 72)
|
||||||
@ -883,46 +857,38 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
'Hospital Phone No',
|
'Hospital Phone No',
|
||||||
hospitalPhoneNoController,
|
hospitalPhoneNoController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
isRequired: true,
|
|
||||||
isValid: isHospitalPhoneNoValid,
|
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
FilteringTextInputFormatter.digitsOnly,
|
FilteringTextInputFormatter.digitsOnly,
|
||||||
LengthLimitingTextInputFormatter(10),
|
LengthLimitingTextInputFormatter(10),
|
||||||
],
|
],
|
||||||
|
required: true, isValid: isHospitalPhoneNoValid
|
||||||
),
|
),
|
||||||
buildDatePickerField(
|
buildDatePickerField(
|
||||||
label: 'Admit Date',
|
label: 'Admit Date',
|
||||||
selectedDate: admitDate,
|
selectedDate: admitDate,
|
||||||
allowFuture: false,
|
allowFuture: false,
|
||||||
isRequired: true,
|
|
||||||
isValid: isAdmitDateValid,
|
|
||||||
onDateSelected: (d) {
|
onDateSelected: (d) {
|
||||||
setState(() {
|
setState(() {
|
||||||
admitDate = d;
|
admitDate = d;
|
||||||
dischargeDate = null;
|
dischargeDate = null;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
required: true, isValid: isAdmitDateValid
|
||||||
),
|
),
|
||||||
buildDatePickerField(
|
buildDatePickerField(
|
||||||
label: 'Discharge Date',
|
label: 'Discharge Date',
|
||||||
selectedDate: dischargeDate,
|
selectedDate: dischargeDate,
|
||||||
allowFuture: true,
|
allowFuture: true,
|
||||||
minDate: admitDate?.add(
|
minDate: admitDate?.add(const Duration(days: 1)),
|
||||||
const Duration(days: 1)),
|
onDateSelected: (d) => setState(() => dischargeDate = d),
|
||||||
isRequired: true,
|
required: true, isValid: isDischargeDateValid
|
||||||
isValid: isDischargeDateValid,
|
|
||||||
onDateSelected: (d) =>
|
|
||||||
setState(() => dischargeDate = d),
|
|
||||||
),
|
),
|
||||||
buildTextField(
|
buildTextField(
|
||||||
'Claims Amount',
|
'Claims Amount',
|
||||||
claimAmountController,
|
claimAmountController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
isRequired: true,
|
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||||
isValid: isClaimAmountValid,
|
required: true, isValid: isClaimAmountValid
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.digitsOnly
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
|
|
||||||
@ -932,16 +898,12 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
label: 'Date of Birth',
|
label: 'Date of Birth',
|
||||||
selectedDate: birthDate,
|
selectedDate: birthDate,
|
||||||
allowFuture: false,
|
allowFuture: false,
|
||||||
isRequired: false,isValid: true,
|
onDateSelected: (d) => setState(() => birthDate = d),
|
||||||
onDateSelected: (d) =>
|
|
||||||
setState(() => birthDate = d),
|
|
||||||
),
|
),
|
||||||
buildDatePickerField(
|
buildDatePickerField(
|
||||||
label: 'Accident Date',
|
label: 'Accident Date',
|
||||||
selectedDate: accidentDate,
|
selectedDate: accidentDate,
|
||||||
allowFuture: false,
|
allowFuture: false,
|
||||||
isRequired: isAccidentService,
|
|
||||||
isValid: isAccidentDateValid,
|
|
||||||
onDateSelected: (d) {
|
onDateSelected: (d) {
|
||||||
setState(() {
|
setState(() {
|
||||||
accidentDate = d;
|
accidentDate = d;
|
||||||
@ -949,15 +911,13 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
intimationDate = null;
|
intimationDate = null;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
required: true, isValid: isAccidentDateValid
|
||||||
),
|
),
|
||||||
buildDatePickerField(
|
buildDatePickerField(
|
||||||
label: 'Date of Death',
|
label: 'Date of Death',
|
||||||
selectedDate: deathDate,
|
selectedDate: deathDate,
|
||||||
allowFuture: false,
|
allowFuture: false,
|
||||||
isRequired: false,
|
onDateSelected: (d) => setState(() => deathDate = d),
|
||||||
isValid: true,
|
|
||||||
onDateSelected: (d) =>
|
|
||||||
setState(() => deathDate = d),
|
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
if ([2, 3, 4].contains(serviceId))
|
if ([2, 3, 4].contains(serviceId))
|
||||||
@ -966,19 +926,14 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
label: 'Date of Intimation',
|
label: 'Date of Intimation',
|
||||||
selectedDate: intimationDate,
|
selectedDate: intimationDate,
|
||||||
allowFuture: false,
|
allowFuture: false,
|
||||||
isRequired: isAccidentService,
|
onDateSelected: (d) => setState(() => intimationDate = d),
|
||||||
isValid: isIntimationDateValid,
|
required: true, isValid: isIntimationDateValid
|
||||||
onDateSelected: (d) =>
|
|
||||||
setState(() => intimationDate = d),
|
|
||||||
),
|
),
|
||||||
buildTextField(
|
buildTextField(
|
||||||
'Sum Insured',
|
'Sum Insured',
|
||||||
sumInsuredController,
|
sumInsuredController,
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
isRequired: false,isValid: true,
|
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
||||||
inputFormatters: [
|
|
||||||
FilteringTextInputFormatter.digitsOnly
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
const SizedBox(),
|
const SizedBox(),
|
||||||
]),
|
]),
|
||||||
@ -992,9 +947,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
width: 120,
|
width: 120,
|
||||||
height: 42,
|
height: 42,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: isSubmitting
|
onPressed: isSubmitting ? null : sendFormDataToApi,
|
||||||
? null
|
|
||||||
: sendFormDataToApi,
|
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: const Color(0xFFE26728),
|
backgroundColor: const Color(0xFFE26728),
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
@ -1052,45 +1005,86 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 14),
|
padding: const EdgeInsets.only(bottom: 14),
|
||||||
child: Row(
|
child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: children
|
children: children
|
||||||
.map((e) => Expanded(
|
.map((e) => Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(right: 12),
|
padding: const EdgeInsets.only(right: 12),
|
||||||
child: e,
|
child: e,
|
||||||
)))
|
)))
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildTextField(String label,
|
Widget fieldLabel(String text, {bool required = false}) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 6),
|
||||||
|
child: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
text: text,
|
||||||
|
style: GoogleFonts.poppins(
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
children: required
|
||||||
|
? const [
|
||||||
|
TextSpan(
|
||||||
|
text: ' *',
|
||||||
|
style: TextStyle(color: Colors.red),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
: [],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget errorText(bool isValid) {
|
||||||
|
return SizedBox(
|
||||||
|
height: 16, // fixed height for alignment
|
||||||
|
child: isValid
|
||||||
|
? null
|
||||||
|
: const Text(
|
||||||
|
"Required",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
fontSize: 11,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Widget buildTextField(
|
||||||
|
String label,
|
||||||
TextEditingController controller, {
|
TextEditingController controller, {
|
||||||
|
bool required = false,
|
||||||
|
bool isValid = true,
|
||||||
TextInputType keyboardType = TextInputType.text,
|
TextInputType keyboardType = TextInputType.text,
|
||||||
bool isRequired = true, bool isValid = true,
|
|
||||||
List<TextInputFormatter>? inputFormatters,
|
List<TextInputFormatter>? inputFormatters,
|
||||||
}) {
|
}) {
|
||||||
return Expanded(
|
return Column(
|
||||||
child: Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
children: [
|
||||||
children: [
|
fieldLabel(label, required: required),
|
||||||
fieldLabel(label, isRequired: isRequired),
|
formBox(
|
||||||
formBox(
|
child: TextField(
|
||||||
child: TextField(
|
controller: controller,
|
||||||
controller: controller,
|
keyboardType: keyboardType,
|
||||||
keyboardType: keyboardType,
|
inputFormatters: inputFormatters,
|
||||||
inputFormatters: inputFormatters,
|
decoration: const InputDecoration(
|
||||||
decoration: const InputDecoration(
|
isDense: true,
|
||||||
isDense: true,
|
border: InputBorder.none,
|
||||||
border: InputBorder.none,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isValid) validationText(),
|
),
|
||||||
],
|
errorText(isValid),
|
||||||
),);
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Widget buildTextAreaField(String label, TextEditingController controller) {
|
Widget buildTextAreaField(String label, TextEditingController controller) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -1121,76 +1115,51 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
List<Map<String, dynamic>> itemsList,
|
List<Map<String, dynamic>> itemsList,
|
||||||
String displayField,
|
String displayField,
|
||||||
int? selectedValue, {
|
int? selectedValue, {
|
||||||
bool isRequired = true,
|
bool required = false,
|
||||||
bool isValid = 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, isRequired: isRequired),
|
fieldLabel(label, required: required),
|
||||||
formBox(
|
formBox(
|
||||||
child: DropdownButtonHideUnderline(
|
child: DropdownButtonHideUnderline(
|
||||||
child: DropdownButton<int>(
|
child: DropdownButton<int>(
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
value: selectedValue,
|
value: selectedValue,
|
||||||
hint: const Text(
|
hint: const Text('Select'),
|
||||||
'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(
|
child: Text(item[displayField]),
|
||||||
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)
|
if (required) errorText(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 required = false,
|
||||||
bool isRequired = true, // Added
|
bool isValid = true,
|
||||||
bool isValid = true, // Added
|
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
fieldLabel(label, isRequired: isRequired),
|
fieldLabel(label, required: required),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
Container(
|
Container(
|
||||||
height: 40,
|
height: 40,
|
||||||
@ -1270,12 +1239,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isValid)
|
if (required) errorText(isValid),
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 4, left: 4),
|
|
||||||
child: Text("Required",
|
|
||||||
style: GoogleFonts.poppins(color: Colors.red, fontSize: 12)),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1288,14 +1252,24 @@ 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 required = false,
|
||||||
bool isValid = true,
|
bool isValid = true,
|
||||||
}) {
|
}) {
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
fieldLabel(label, isRequired: isRequired),
|
fieldLabel(label, required: required),
|
||||||
formBox(
|
|
||||||
|
Container(
|
||||||
|
height: 42,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: const Color(0xFFF1F1F1),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
// border: required && !isValid
|
||||||
|
// ? Border.all(color: Colors.red)
|
||||||
|
// : null,
|
||||||
|
),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final DateTime now = DateTime.now();
|
final DateTime now = DateTime.now();
|
||||||
@ -1331,11 +1305,13 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (!isValid) validationText(),
|
|
||||||
|
errorText(isValid),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Widget uploadBox() {
|
// Widget uploadBox() {
|
||||||
// return Column(
|
// return Column(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
@ -1370,39 +1346,6 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget fieldLabel(String text, {bool isRequired = false}) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.only(bottom: 6),
|
|
||||||
child: RichText(
|
|
||||||
text: TextSpan(
|
|
||||||
text: text,
|
|
||||||
style: GoogleFonts.poppins(
|
|
||||||
fontSize: 12,
|
|
||||||
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 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user