This commit is contained in:
Surendiran 2026-02-18 10:40:34 +05:30
commit 5f49e8a4f6
10 changed files with 937 additions and 480 deletions

View File

@ -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,7 +553,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
pdf.addPage( pdf.addPage(
pw.Page( pw.Page(
build: (pw.Context context) => pw.Center( build: (pw.Context context) =>
pw.Center(
child: pw.Image(image, fit: pw.BoxFit.contain), child: pw.Image(image, fit: pw.BoxFit.contain),
), ),
), ),
@ -745,6 +749,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
), ),
IconButton( IconButton(
icon: const Icon(Icons.close), icon: const Icon(Icons.close),
tooltip: 'Close',
onPressed: () => Navigator.pop(context), onPressed: () => Navigator.pop(context),
), ),
], ],
@ -760,7 +765,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
buildDropdownField( buildDropdownField(
'Service', 'Service',
(value) { (value) {
final selectedItem = departmentList.firstWhere( final selectedItem = departmentList
.firstWhere(
(item) => item['id'] == value, (item) => item['id'] == value,
orElse: () => {}, orElse: () => {},
); );
@ -776,19 +782,24 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
departmentList, departmentList,
'name', 'name',
serviceId, serviceId,
isRequired: true,
isValid: isServiceValid,
), ),
buildDropdownField( buildDropdownField(
'Select Policy', 'Select Policy',
(value) { (value) {
final selectedPolicy = final selectedPolicy =
policyNumberList.firstWhere((p) => p['id'] == value); policyNumberList.firstWhere((
p) => p['id'] == value);
setState(() { setState(() {
// THIS is what you send to API // THIS is what you send to API
selectedClientPolicyId = selectedPolicy['id']; selectedClientPolicyId =
selectedPolicy['id'];
// optional // optional
selectedPolicyTypeId = selectedPolicy['policy_type_id']; selectedPolicyTypeId =
selectedPolicy['policy_type_id'];
policyNumberId = value; policyNumberId = value;
isPolicyValid = true; isPolicyValid = true;
@ -799,45 +810,67 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
policyNumberList, policyNumberList,
'label', // 👈 DISPLAY FIELD 'label', // 👈 DISPLAY FIELD
policyNumberId, policyNumberId,
isRequired: true,
isValid: isPolicyValid, // 👈 Hooked to your state
), ),
buildDropdownFieldSearch( buildDropdownFieldSearch(
'Member Name', 'Member Name',
(value) { (value) {
final member = employeePolicyList.firstWhere( final member = employeePolicyList
.firstWhere(
(m) => m['id'] == value, (m) => m['id'] == value,
); );
setState(() { setState(() {
selectedMemberId = value; selectedMemberId = value;
selectedMemberObject = member; // FULL OBJECT selectedMemberObject =
member; // FULL OBJECT
selectedMemberName = member['name']; selectedMemberName = member['name'];
isMemberValid = true; isMemberValid = true;
print('selectedMemberObject $selectedMemberObject'); print(
'selectedMemberObject $selectedMemberObject');
}); });
}, },
employeePolicyList, employeePolicyList,
'name', 'name',
selectedMemberId, selectedMemberId,
isRequired: true,
isValid: isMemberValid, // 👈 Hooked to your state
), ),
]), ]),
_row([ _row([
buildTextField('Message', messageController), buildTextField('Message', messageController,
isRequired: false, isValid: true),
if (serviceId == 1 || serviceId == 72)...[ if (serviceId == 1 || serviceId == 72)...[
buildTextField('Hospital Name', hospitalNameController), buildTextField(
buildTextField('Hospital Address', hospitalAddressController), 'Hospital Name', hospitalNameController,
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('Hospital City', hospitalCityController), buildTextField(
buildTextField('Hospital State', hospitalStateController), 'Hospital City', hospitalCityController,
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),
@ -850,6 +883,8 @@ 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),
@ -859,6 +894,8 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
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;
@ -870,14 +907,22 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
label: 'Discharge Date', label: 'Discharge Date',
selectedDate: dischargeDate, selectedDate: dischargeDate,
allowFuture: true, allowFuture: true,
minDate: admitDate?.add(const Duration(days: 1)), minDate: admitDate?.add(
onDateSelected: (d) => setState(() => dischargeDate = d), const Duration(days: 1)),
isRequired: true,
isValid: isDischargeDateValid,
onDateSelected: (d) =>
setState(() => dischargeDate = d),
), ),
buildTextField( buildTextField(
'Claims Amount', 'Claims Amount',
claimAmountController, claimAmountController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly], isRequired: true,
isValid: isClaimAmountValid,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly
],
), ),
]), ]),
@ -887,12 +932,16 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
label: 'Date of Birth', label: 'Date of Birth',
selectedDate: birthDate, selectedDate: birthDate,
allowFuture: false, allowFuture: false,
onDateSelected: (d) => setState(() => birthDate = d), isRequired: false,isValid: true,
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;
@ -905,7 +954,10 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
label: 'Date of Death', label: 'Date of Death',
selectedDate: deathDate, selectedDate: deathDate,
allowFuture: false, allowFuture: false,
onDateSelected: (d) => setState(() => deathDate = d), isRequired: false,
isValid: true,
onDateSelected: (d) =>
setState(() => deathDate = d),
), ),
]), ]),
if ([2, 3, 4].contains(serviceId)) if ([2, 3, 4].contains(serviceId))
@ -914,13 +966,19 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
label: 'Date of Intimation', label: 'Date of Intimation',
selectedDate: intimationDate, selectedDate: intimationDate,
allowFuture: false, allowFuture: false,
onDateSelected: (d) => setState(() => intimationDate = d), isRequired: isAccidentService,
isValid: isIntimationDateValid,
onDateSelected: (d) =>
setState(() => intimationDate = d),
), ),
buildTextField( buildTextField(
'Sum Insured', 'Sum Insured',
sumInsuredController, sumInsuredController,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly], isRequired: false,isValid: true,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly
],
), ),
const SizedBox(), const SizedBox(),
]), ]),
@ -934,7 +992,9 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
width: 120, width: 120,
height: 42, height: 42,
child: ElevatedButton( child: ElevatedButton(
onPressed: isSubmitting ? null : sendFormDataToApi, onPressed: isSubmitting
? null
: sendFormDataToApi,
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFE26728), backgroundColor: const Color(0xFFE26728),
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
@ -1003,16 +1063,17 @@ 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(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
fieldLabel(label), fieldLabel(label, isRequired: isRequired),
formBox( formBox(
child: TextField( child: TextField(
controller: controller, controller: controller,
@ -1024,8 +1085,9 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
), ),
), ),
), ),
if (!isValid) validationText(),
], ],
); ),);
} }
Widget buildTextAreaField(String label, TextEditingController controller) { Widget buildTextAreaField(String label, TextEditingController controller) {
@ -1057,49 +1119,77 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
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 +1269,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,11 +1287,13 @@ 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 {
@ -1232,6 +1330,7 @@ class _RaiseClaimDialogState extends State<RaiseClaimDialog> {
), ),
), ),
), ),
if (!isValid) validationText(),
], ],
); );
} }
@ -1270,16 +1369,36 @@ 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(
text: text,
style: GoogleFonts.poppins( style: GoogleFonts.poppins(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: Colors.black, 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),
), ),
); );
} }

View File

@ -790,12 +790,14 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
if (isAllowedSubType) if (isAllowedSubType)
_ActionIconButton( _ActionIconButton(
icon: Icons.picture_as_pdf_outlined, icon: Icons.picture_as_pdf_outlined,
toolTip: 'View Endorsement PDF',
onTap: () => getCdEndorsementDetails(item['id']), onTap: () => getCdEndorsementDetails(item['id']),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
if (isAllowedSubType && hasSplitUpFile) if (isAllowedSubType && hasSplitUpFile)
_ActionIconButton( _ActionIconButton(
icon: Icons.folder_open_outlined, icon: Icons.folder_open_outlined,
toolTip: 'View Files',
onTap: () => _launchURL(item['split_up_url']), onTap: () => _launchURL(item['split_up_url']),
), ),
], ],
@ -819,6 +821,126 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
} }
Widget _buildPagination(BuildContext context) { Widget _buildPagination(BuildContext context) {
final totalItems = filteredData.length;
// Calculate entries range
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
int endEntry = _currentPage * _rowsPerPage;
if (endEntry > totalItems) endEntry = totalItems;
// Calculate total pages
final int totalPages = (totalItems / _rowsPerPage).ceil();
const int visiblePageCount = 5;
// Helper logic for page numbers
List<int> getVisiblePages() {
if (totalPages <= visiblePageCount) {
return List.generate(totalPages, (i) => i + 1);
}
if (_currentPage <= 3) {
return [1, 2, 3, 4, 5];
}
if (_currentPage >= totalPages - 2) {
return [
totalPages - 4,
totalPages - 3,
totalPages - 2,
totalPages - 1,
totalPages
];
}
return [
_currentPage - 2,
_currentPage - 1,
_currentPage,
_currentPage + 1,
_currentPage + 2,
];
}
List<int> visiblePages = getVisiblePages();
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Standard Table Footer Layout
children: [
/// --- LEFT SIDE: ENTRY DETAILS ---
Text(
'Showing $startEntry to $endEntry of $totalItems entries',
style: GoogleFonts.poppins(
fontSize: 13,
fontWeight: FontWeight.w500,
color: const Color(0xFF666666),
),
),
/// --- RIGHT SIDE: CONTROLS ---
Row(
children: [
DropdownButton<int>(
value: _rowsPerPage,
items: [5, 10, 15, 20, 50].map((int value) {
return DropdownMenuItem<int>(
value: value,
child: Text(' $value ',
style: GoogleFonts.poppins(fontSize: 15)),
);
}).toList(),
onChanged: (newValue) {
setState(() {
_rowsPerPage = newValue!;
_currentPage = 1;
});
},
),
const SizedBox(width: 16),
IconButton(
onPressed: _currentPage > 1
? () => setState(() => _currentPage--)
: null,
icon: const Icon(Icons.chevron_left),
),
if (!visiblePages.contains(1))
Row(children: [
_buildPageButton(1),
const Padding(
padding: EdgeInsets.symmetric(horizontal: 4),
child: Text("..."),
),
]),
// Visible page buttons
for (int page in visiblePages) _buildPageButton(page),
if (!visiblePages.contains(totalPages) && totalPages > 0)
Row(children: [
const Padding(
padding: EdgeInsets.symmetric(horizontal: 4),
child: Text("..."),
),
_buildPageButton(totalPages),
]),
// Next button
IconButton(
onPressed: _currentPage < totalPages
? () => setState(() => _currentPage++)
: null,
icon: const Icon(Icons.chevron_right),
),
],
),
],
),
);
}
Widget _buildPagination_backup(BuildContext context) {
final totalPages = (filteredData.length / _rowsPerPage).ceil(); final totalPages = (filteredData.length / _rowsPerPage).ceil();
const visiblePageCount = 5; const visiblePageCount = 5;
@ -1033,16 +1155,19 @@ class _ActionIconButton extends StatelessWidget {
final IconData icon; final IconData icon;
final VoidCallback onTap; final VoidCallback onTap;
final bool enabled; final bool enabled;
final String? toolTip; // 1. Define the optional tooltip string
const _ActionIconButton({ const _ActionIconButton({
required this.icon, required this.icon,
required this.onTap, required this.onTap,
this.toolTip, // 2. Added to constructor
this.enabled = true, this.enabled = true,
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( // 3. Define the main button widget
Widget button = SizedBox(
width: 36, width: 36,
height: 36, height: 36,
child: Material( child: Material(
@ -1061,6 +1186,17 @@ class _ActionIconButton extends StatelessWidget {
), ),
), ),
); );
// 4. Wrap with Tooltip only if enabled and tooltip text exists
if (enabled && toolTip != null) {
return Tooltip(
message: toolTip!,
preferBelow: false, // Shows tooltip above the button
child: button,
);
}
return button;
} }
} }

View File

@ -810,7 +810,14 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
GestureDetector( // 1. Tooltip for the hover message
Tooltip(
message: 'View Claim History',
child:
// 2. MouseRegion for the hand pointer
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () { onTap: () {
// print('id ${item['id']}'); // print('id ${item['id']}');
// print('emp_name ${item['emp_name']}'); // print('emp_name ${item['emp_name']}');
@ -859,6 +866,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
), ),
), ),
), ),
),
),
], ],
), ),
), ),
@ -937,6 +946,12 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
); );
Widget _buildPagination(BuildContext context) { Widget _buildPagination(BuildContext context) {
// 1. Calculate the range of entries being shown
final totalItems = filteredData.length;
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
int endEntry = _currentPage * _rowsPerPage;
if (endEntry > totalItems) endEntry = totalItems;
final totalPages = (filteredData.length / _rowsPerPage).ceil(); final totalPages = (filteredData.length / _rowsPerPage).ceil();
const visiblePageCount = 5; const visiblePageCount = 5;
@ -947,7 +962,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
if (_currentPage <= 3) { if (_currentPage <= 3) {
return [1, 2, 3, 4, 5]; return [1, 2, 3, 4, 5];
} else if (_currentPage >= totalPages - 2) { }
if (_currentPage >= totalPages - 2) {
return [ return [
totalPages - 4, totalPages - 4,
totalPages - 3, totalPages - 3,
@ -955,7 +971,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
totalPages - 1, totalPages - 1,
totalPages totalPages
]; ];
} else { }
return [ return [
_currentPage - 2, _currentPage - 2,
_currentPage - 1, _currentPage - 1,
@ -963,21 +979,34 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
_currentPage + 1, _currentPage + 1,
_currentPage + 2, _currentPage + 2,
]; ];
}
} }
List<int> visiblePages = getVisiblePages(); List<int> visiblePages = getVisiblePages();
return Row( return Padding(
mainAxisAlignment: MainAxisAlignment.end, // Match this horizontal padding (16) to your Table Header padding for perfect alignment
children: [ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Pushes text to left, buttons to right
children: [
// --- LEFT SIDE: Showing Text ---
Text(
"Showing $startEntry to $endEntry of $totalItems entries",
style: GoogleFonts.poppins(
fontSize: 13,
color: const Color(0xFF585757),
fontWeight: FontWeight.w400,
),
),
// --- RIGHT SIDE: Controls ---
Row(
children: [ children: [
// Dropdown for rows per page // Dropdown for rows per page
DropdownButton<int>( DropdownButton<int>(
value: _rowsPerPage, value: _rowsPerPage,
// focusColor: Colors.transparent, // Fix: Removes the grey/blue highlight on change
items: [5, 10, 15, 20, 50].map((int value) { items: [5, 10, 15, 20, 50].map((int value) {
return DropdownMenuItem<int>( return DropdownMenuItem<int>(
value: value, value: value,
@ -1015,7 +1044,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
for (int page in visiblePages) _buildPageButton(page), for (int page in visiblePages) _buildPageButton(page),
// Right ellipsis + last page // Right ellipsis + last page
if (!visiblePages.contains(totalPages)) if (!visiblePages.contains(totalPages) && totalPages > 0)
Row(children: [ Row(children: [
const Padding( const Padding(
padding: EdgeInsets.symmetric(horizontal: 4), padding: EdgeInsets.symmetric(horizontal: 4),
@ -1033,8 +1062,8 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
), ),
], ],
), ),
),
], ],
),
); );
} }
@ -1641,11 +1670,13 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
_IconActionButton( _IconActionButton(
icon: Icons.filter_alt_outlined, icon: Icons.filter_alt_outlined,
onTap: applyFilter, onTap: applyFilter,
tooltip:"Filter"
), ),
const SizedBox(width: 12), const SizedBox(width: 12),
_IconActionButton( _IconActionButton(
icon: Icons.refresh_outlined, icon: Icons.refresh_outlined,
onTap: reset, onTap: reset,
tooltip:"Reset"
), ),
], ],
), ),
@ -1703,21 +1734,24 @@ class _ClaimsHeaderDelegate extends SliverPersistentHeaderDelegate {
bool shouldRebuild(_) => false; bool shouldRebuild(_) => false;
} }
// ================= ICON BUTTON ================= // ================= ICON BUTTON =================
class _IconActionButton extends StatelessWidget { class _IconActionButton extends StatelessWidget {
final IconData icon; final IconData icon;
final VoidCallback onTap; final VoidCallback onTap;
final String tooltip;
const _IconActionButton({ const _IconActionButton({
required this.icon, required this.icon,
required this.onTap, required this.onTap,
required this.tooltip,
}); });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return Tooltip(
message: tooltip,
preferBelow: false, // Optional: Shows tooltip above the button
child: SizedBox(
width: 40, width: 40,
height: 40, height: 40,
child: Material( child: Material(
@ -1729,6 +1763,6 @@ class _IconActionButton extends StatelessWidget {
child: Icon(icon, color: Colors.white, size: 20), child: Icon(icon, color: Colors.white, size: 20),
), ),
), ),
); ),);
} }
} }

View File

@ -796,7 +796,9 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
const SizedBox(width: 8), const SizedBox(width: 8),
/// DOWNLOAD ICON /// DOWNLOAD ICON
InkWell( Tooltip(
message: 'Download', // Added tooltip name
child: InkWell(
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
onTap: () => _launchURL(file['url']), onTap: () => _launchURL(file['url']),
child: Container( child: Container(
@ -812,6 +814,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
), ),
), ),
), ),
),
], ],
), ),
), ),
@ -866,6 +869,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
), ),
IconButton( IconButton(
icon: Icon(Icons.close), icon: Icon(Icons.close),
tooltip: 'Remove', // Built-in property
onPressed: () { onPressed: () {
_resetIRDocs(); _resetIRDocs();
setState(() => showIRDocs = false); setState(() => showIRDocs = false);
@ -972,6 +976,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
), ),
trailing: IconButton( trailing: IconButton(
icon: Icon(Icons.cancel, color: Colors.red), icon: Icon(Icons.cancel, color: Colors.red),
tooltip: 'Remove', // Built-in property
onPressed: () => removeAssignedFile(title), onPressed: () => removeAssignedFile(title),
), ),
), ),
@ -1070,6 +1075,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
fontSize: 18, fontWeight: FontWeight.w600))), fontSize: 18, fontWeight: FontWeight.w600))),
IconButton( IconButton(
icon: Icon(Icons.close), icon: Icon(Icons.close),
tooltip: 'Close', // Built-in property
onPressed: () { onPressed: () {
_resetIRDocs(); _resetIRDocs();
setState(() => showIRDocs = false); setState(() => showIRDocs = false);
@ -1139,6 +1145,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
maxLines: 1, overflow: TextOverflow.ellipsis), maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: IconButton( trailing: IconButton(
icon: Icon(Icons.cancel, color: Colors.red), icon: Icon(Icons.cancel, color: Colors.red),
tooltip: 'Remove', // Built-in property
onPressed: () => removeAssignedFile(title)), onPressed: () => removeAssignedFile(title)),
), ),
); );
@ -1234,6 +1241,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
fontSize: 16, fontWeight: FontWeight.w600))), fontSize: 16, fontWeight: FontWeight.w600))),
IconButton( IconButton(
icon: Icon(Icons.close), icon: Icon(Icons.close),
tooltip: 'Close', // Built-in property
onPressed: () { onPressed: () {
_resetIRDocs(); _resetIRDocs();
setState(() => showIRDocs = false); setState(() => showIRDocs = false);
@ -1304,6 +1312,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup>
maxLines: 1, overflow: TextOverflow.ellipsis), maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: IconButton( trailing: IconButton(
icon: Icon(Icons.cancel, color: Colors.red), icon: Icon(Icons.cancel, color: Colors.red),
tooltip: 'Remove', // Built-in property
onPressed: () => removeAssignedFile(title)), onPressed: () => removeAssignedFile(title)),
), ),
); );

View File

@ -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) {
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']); ToastHelper.showSuccessToast(context, response['message']);
}
setState(() { setState(() {
isLoading = false; isLoading = false;

View File

@ -361,7 +361,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
// Filter the original data based on the search query // Filter the original data based on the search query
setState(() { setState(() {
filteredData = originalData.where((row) { filteredData = originalData.where((row) {
final empStatus = row['emp_is_active'] == 1 ? 'active' : 'inactive'; final empStatus = row['emp_is_active'] == 1 ? 'active' : 'Inactive';
// Implement your filter logic here // Implement your filter logic here
// For example, check if any field in the row contains the query // For example, check if any field in the row contains the query
// Adjust this logic based on your data structure // Adjust this logic based on your data structure
@ -377,7 +377,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
.toString() .toString()
.toLowerCase() .toLowerCase()
.contains(query.toLowerCase()) || .contains(query.toLowerCase()) ||
row['formatted_dob'] row['formatted_dob'].replaceAll("/", "-")
.toString() .toString()
.toLowerCase() .toLowerCase()
.contains(query.toLowerCase()) || .contains(query.toLowerCase()) ||
@ -595,6 +595,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
IconButton( IconButton(
tooltip: 'Previous Page', tooltip: 'Previous Page',
onPressed: () => {Navigator.pop(context)}, onPressed: () => {Navigator.pop(context)},
// splashRadius: 20,
icon: const Icon( icon: const Icon(
Icons.arrow_back_ios, Icons.arrow_back_ios,
size: 18, size: 18,
@ -1569,27 +1570,24 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
child: Builder( child: Builder(
builder: (context) { builder: (context) {
final isSelf = item['relationship'] == 'Self'; final isSelf = item['relationship'] == 'Self';
final hasEcard = final hasEcard = item['ecard_download_link'] != null;
item['ecard_download_link'] != null;
final showEcard = isSelf && hasEcard; final showEcard = isSelf && hasEcard;
final showClaim = final showClaim = widget.TokenType == "post" && hasModule;
widget.TokenType == "post" && hasModule;
if (!showEcard && !showClaim) { if (!showEcard && !showClaim) {
return SizedBox(); // No icon to show return SizedBox(); // No icon to show
} }
return Row( return Row(
mainAxisAlignment: showEcard && !showClaim mainAxisAlignment: MainAxisAlignment.center,
? MainAxisAlignment crossAxisAlignment: CrossAxisAlignment.center,
.start // Only eCard, push to right
: MainAxisAlignment
.end, // eCard + claim OR only claim
children: [ children: [
// --- eCard Button ---
if (showEcard) if (showEcard)
Padding( Tooltip(
padding: const EdgeInsets.symmetric( message: 'Download e-Card',
horizontal: 4.0), child: MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
getEcardDownload( getEcardDownload(
@ -1603,8 +1601,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
width: 40, width: 40,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFE6F5F6), color: Color(0xFFE6F5F6),
borderRadius: borderRadius: BorderRadius.circular(8),
BorderRadius.circular(8),
), ),
child: Padding( child: Padding(
padding: EdgeInsets.all(4), padding: EdgeInsets.all(4),
@ -1616,16 +1613,16 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
), ),
), ),
), ),
if (showEcard && showClaim) ),
SizedBox(width: 8),
if (showEcard && showClaim) SizedBox(width: 8),
// --- Claim Button ---
if (showClaim) if (showClaim)
Padding( Tooltip(
padding: const EdgeInsets.symmetric( message: 'View Claims',
horizontal: 4.0),
child: MouseRegion( child: MouseRegion(
cursor: cursor: SystemMouseCursors.click,
SystemMouseCursors
.click,
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
Navigator.push( Navigator.push(
@ -1642,8 +1639,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
width: 40, width: 40,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFE6F5F6), color: Color(0xFFE6F5F6),
borderRadius: borderRadius: BorderRadius.circular(8),
BorderRadius.circular(8),
), ),
child: Padding( child: Padding(
padding: EdgeInsets.all(4), padding: EdgeInsets.all(4),
@ -1654,7 +1650,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
), ),
), ),
), ),
) ),
), ),
], ],
); );
@ -1822,6 +1818,12 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
} }
Widget _buildPagination(BuildContext context) { Widget _buildPagination(BuildContext context) {
// 1. Calculate the range of entries being shown
final totalItems = filteredData.length;
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
int endEntry = _currentPage * _rowsPerPage;
if (endEntry > totalItems) endEntry = totalItems;
final totalPages = (filteredData.length / _rowsPerPage).ceil(); final totalPages = (filteredData.length / _rowsPerPage).ceil();
const visiblePageCount = 5; const visiblePageCount = 5;
@ -1832,7 +1834,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
if (_currentPage <= 3) { if (_currentPage <= 3) {
return [1, 2, 3, 4, 5]; return [1, 2, 3, 4, 5];
} else if (_currentPage >= totalPages - 2) { }
if (_currentPage >= totalPages - 2) {
return [ return [
totalPages - 4, totalPages - 4,
totalPages - 3, totalPages - 3,
@ -1840,7 +1843,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
totalPages - 1, totalPages - 1,
totalPages totalPages
]; ];
} else { }
return [ return [
_currentPage - 2, _currentPage - 2,
_currentPage - 1, _currentPage - 1,
@ -1848,21 +1851,34 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
_currentPage + 1, _currentPage + 1,
_currentPage + 2, _currentPage + 2,
]; ];
}
} }
List<int> visiblePages = getVisiblePages(); List<int> visiblePages = getVisiblePages();
return Row( return Padding(
mainAxisAlignment: MainAxisAlignment.end, // Match this horizontal padding (16) to your Table Header padding for perfect alignment
children: [ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Pushes text to left, buttons to right
children: [
// --- LEFT SIDE: Showing Text ---
Text(
"Showing $startEntry to $endEntry of $totalItems entries",
style: GoogleFonts.poppins(
fontSize: 13,
color: const Color(0xFF585757),
fontWeight: FontWeight.w400,
),
),
// --- RIGHT SIDE: Controls ---
Row(
children: [ children: [
// Dropdown for rows per page // Dropdown for rows per page
DropdownButton<int>( DropdownButton<int>(
value: _rowsPerPage, value: _rowsPerPage,
// focusColor: Colors.transparent, // Fix: Removes the grey/blue highlight on change
items: [5, 10, 15, 20, 50].map((int value) { items: [5, 10, 15, 20, 50].map((int value) {
return DropdownMenuItem<int>( return DropdownMenuItem<int>(
value: value, value: value,
@ -1878,6 +1894,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
}, },
), ),
const SizedBox(width: 8),
// Previous button // Previous button
IconButton( IconButton(
tooltip: 'Previous Page', tooltip: 'Previous Page',
@ -1901,7 +1919,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
for (int page in visiblePages) _buildPageButton(page), for (int page in visiblePages) _buildPageButton(page),
// Right ellipsis + last page // Right ellipsis + last page
if (!visiblePages.contains(totalPages)) if (!visiblePages.contains(totalPages) && totalPages > 0)
Row(children: [ Row(children: [
const Padding( const Padding(
padding: EdgeInsets.symmetric(horizontal: 4), padding: EdgeInsets.symmetric(horizontal: 4),
@ -1919,8 +1937,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
), ),
], ],
), ),
),
], ],
),
); );
} }

View File

@ -98,6 +98,9 @@ class _postFileUploadState extends State<postFileUpload> {
String? _selectedOption; String? _selectedOption;
final List<String> _allowedExtensions = ['xlsx', 'xls']; final List<String> _allowedExtensions = ['xlsx', 'xls'];
bool showSampleButton = false;
String? currentApiValue; // To store the 'value' for the 2nd param
int _currentPage = 1; int _currentPage = 1;
int _rowsPerPage = 5; int _rowsPerPage = 5;
@ -291,6 +294,54 @@ class _postFileUploadState extends State<postFileUpload> {
} }
} }
Future<void> downloadPostSampleFile(String apiParam) async {
print("fun Sam f - in");
final post_file_name = apiParam+'_sample_file.xlsx';
print("fun Sam f - name $post_file_name" );
final apiurl = Environment.apiUrlPost;
final String url = '$apiurl/downloadSampleExcel/$apiParam';
final token = widget.Token;
final response = await http.get(
Uri.parse(url),
headers: {
'APP-SIGNATURE': 'nhance-2025-signature-T8f6gV9k5fK2wf5V5c4vId3b0J8z6cAm2x8Y',
'Authorization': 'Bearer $token',
'Content-Type': 'application/json',
// 'app-signature': 'ts-traveltool-2025-signature-123456',
},
);
if (response.statusCode == 200) {
try {
print("fun sam f - ${response.statusCode}" );
// Create a blob from the response body bytes
final blob = html.Blob([response.bodyBytes]);
// Generate a download URL
final url = html.Url.createObjectUrlFromBlob(blob);
// Trigger file download automatically
final anchor = html.AnchorElement(href: url)
..setAttribute('download', '$post_file_name')
..click();
// Revoke the URL to free memory
html.Url.revokeObjectUrl(url);
ToastHelper.showSuccessToast(context, 'File Downloaded Successfully');
} catch (e) {
print("fun sam f - fail" );
throw Exception('Error parsing response: $e');
}
} else {
ToastHelper.showErrorToast(context, 'Failed to download');
print("Download failed with status: ${response.statusCode}");
}
}
void _uploadFile() async { void _uploadFile() async {
print('Test'); print('Test');
if (kIsWeb) { if (kIsWeb) {
@ -562,11 +613,10 @@ class _postFileUploadState extends State<postFileUpload> {
constraints: const BoxConstraints(), constraints: const BoxConstraints(),
), ),
const SizedBox(width: 6), const SizedBox(width: 6),
Container( Expanded(
// color: Colors.redAccent.shade100,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, // mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
Text( Text(
"${widget.cardType} - ${widget.cardPolicyNo} " ?? "${widget.cardType} - ${widget.cardPolicyNo} " ??
@ -581,15 +631,35 @@ class _postFileUploadState extends State<postFileUpload> {
widget.TokenType == 'pre' widget.TokenType == 'pre'
? "${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})" ? "${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})"
: "${widget.cardInsurer_name} - ${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})", : "${widget.cardInsurer_name} - ${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})",
style: GoogleFonts.poppins( style: GoogleFonts.poppins(color: Colors.grey, fontSize: 12, fontWeight: FontWeight.w400),
color: Colors.grey,
fontSize: 12,
fontWeight: FontWeight.w400,
),
), ),
], ],
), ),
), ),
// Visibility toggles based on dropdown selection
Visibility(
visible: showSampleButton,
child: Padding(
padding: const EdgeInsets.only(left: 10),
child: SizedBox(
child: ElevatedButton(
onPressed: () {
// Pass the dynamic value to the function
downloadPostSampleFile(currentApiValue ?? '');
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFFE26728),
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
),
child: Text(
'Sample Excel',
style: GoogleFonts.poppins(fontSize: 14, fontWeight: FontWeight.w700, color: Colors.white),
),
),
),
),
),
], ],
), ),
SizedBox(height:20), SizedBox(height:20),
@ -606,8 +676,10 @@ class _postFileUploadState extends State<postFileUpload> {
onChanged: (val) { onChanged: (val) {
setState(() { setState(() {
selectedKey = val; selectedKey = val;
selectedValue = getFileUploadMasterList final selectedItem = getFileUploadMasterList.firstWhere((e) => e['key'] == val);
.firstWhere((e) => e['key'] == val)['value']; selectedValue = selectedItem['value'];
currentApiValue = selectedItem['key'];
showSampleButton = true;
}); });
}, },
), ),
@ -1089,6 +1161,12 @@ class _postFileUploadState extends State<postFileUpload> {
); );
Widget _buildPagination(BuildContext context) { Widget _buildPagination(BuildContext context) {
final totalItems = filteredData.length;
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
int endEntry = _currentPage * _rowsPerPage;
if (endEntry > totalItems) endEntry = totalItems;
final totalPages = (filteredData.length / _rowsPerPage).ceil(); final totalPages = (filteredData.length / _rowsPerPage).ceil();
const visiblePageCount = 5; const visiblePageCount = 5;
@ -1099,7 +1177,7 @@ class _postFileUploadState extends State<postFileUpload> {
if (_currentPage <= 3) { if (_currentPage <= 3) {
return [1, 2, 3, 4, 5]; return [1, 2, 3, 4, 5];
} else if (_currentPage >= totalPages - 2) { } if (_currentPage >= totalPages - 2) {
return [ return [
totalPages - 4, totalPages - 4,
totalPages - 3, totalPages - 3,
@ -1107,7 +1185,7 @@ class _postFileUploadState extends State<postFileUpload> {
totalPages - 1, totalPages - 1,
totalPages totalPages
]; ];
} else { }
return [ return [
_currentPage - 2, _currentPage - 2,
_currentPage - 1, _currentPage - 1,
@ -1115,7 +1193,7 @@ class _postFileUploadState extends State<postFileUpload> {
_currentPage + 1, _currentPage + 1,
_currentPage + 2, _currentPage + 2,
]; ];
}
} }
List<int> visiblePages = getVisiblePages(); List<int> visiblePages = getVisiblePages();

View File

@ -882,6 +882,8 @@ class _excelVerifyState extends State<preFileUpload> {
SizedBox( SizedBox(
width: 40, width: 40,
height: 40 , height: 40 ,
child: Tooltip(
message: 'Upload', // The text that appears on hover
child: ElevatedButton( child: ElevatedButton(
onPressed: () => null, onPressed: () => null,
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
@ -904,6 +906,7 @@ class _excelVerifyState extends State<preFileUpload> {
) )
), ),
), ),
),
const SizedBox(height: 15), const SizedBox(height: 15),
Text( Text(
fileName!, fileName!,
@ -941,6 +944,8 @@ class _excelVerifyState extends State<preFileUpload> {
SizedBox( SizedBox(
width: 40, width: 40,
height: 40 , height: 40 ,
child: Tooltip(
message: 'Upload', // The text that appears on hover
child: ElevatedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
if (!_validateDatesBeforeUpload()) return; if (!_validateDatesBeforeUpload()) return;
@ -968,6 +973,7 @@ class _excelVerifyState extends State<preFileUpload> {
) )
), ),
), ),
),
SizedBox(height: 12), SizedBox(height: 12),
Text('Upload Your Documents', Text('Upload Your Documents',
style: GoogleFonts.poppins( style: GoogleFonts.poppins(
@ -1175,7 +1181,9 @@ class _excelVerifyState extends State<preFileUpload> {
Row( Row(
children: [ children: [
if (item['file_error_status'] == '1') if (item['file_error_status'] == '1')
InkWell( Tooltip(
message: 'Info', // Added tooltip name
child:InkWell(
onTap: () async { onTap: () async {
print(item); print(item);
// return; // return;
@ -1227,10 +1235,13 @@ class _excelVerifyState extends State<preFileUpload> {
color: Colors.red, color: Colors.red,
), ),
), ),
),
SizedBox(width: 10), SizedBox(width: 10),
_buildStatusChip(item['status']), _buildStatusChip(item['status']),
SizedBox(width: 10), SizedBox(width: 10),
InkWell( Tooltip(
message: 'Download', // Added tooltip name
child:InkWell(
onTap: () { onTap: () {
getHrFileDownload(item['id'], item['file_name']); getHrFileDownload(item['id'], item['file_name']);
}, },
@ -1249,6 +1260,7 @@ class _excelVerifyState extends State<preFileUpload> {
), ),
), ),
), ),
),
], ],
), ),
/// Download /// Download
@ -1293,6 +1305,12 @@ class _excelVerifyState extends State<preFileUpload> {
} }
Widget _buildPagination(BuildContext context) { Widget _buildPagination(BuildContext context) {
// 1. Calculate the range of entries being shown
final totalItems = filteredData.length;
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
int endEntry = _currentPage * _rowsPerPage;
if (endEntry > totalItems) endEntry = totalItems;
final totalPages = (filteredData.length / _rowsPerPage).ceil(); final totalPages = (filteredData.length / _rowsPerPage).ceil();
const visiblePageCount = 5; const visiblePageCount = 5;
@ -1303,7 +1321,8 @@ class _excelVerifyState extends State<preFileUpload> {
if (_currentPage <= 3) { if (_currentPage <= 3) {
return [1, 2, 3, 4, 5]; return [1, 2, 3, 4, 5];
} else if (_currentPage >= totalPages - 2) { }
if (_currentPage >= totalPages - 2) {
return [ return [
totalPages - 4, totalPages - 4,
totalPages - 3, totalPages - 3,
@ -1311,7 +1330,7 @@ class _excelVerifyState extends State<preFileUpload> {
totalPages - 1, totalPages - 1,
totalPages totalPages
]; ];
} else { }
return [ return [
_currentPage - 2, _currentPage - 2,
_currentPage - 1, _currentPage - 1,
@ -1319,21 +1338,34 @@ class _excelVerifyState extends State<preFileUpload> {
_currentPage + 1, _currentPage + 1,
_currentPage + 2, _currentPage + 2,
]; ];
}
} }
List<int> visiblePages = getVisiblePages(); List<int> visiblePages = getVisiblePages();
return Row( return Padding(
mainAxisAlignment: MainAxisAlignment.end, // Match this horizontal padding (16) to your Table Header padding for perfect alignment
children: [ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Pushes text to left, buttons to right
children: [
// --- LEFT SIDE: Showing Text ---
Text(
"Showing $startEntry to $endEntry of $totalItems entries",
style: GoogleFonts.poppins(
fontSize: 13,
color: const Color(0xFF585757),
fontWeight: FontWeight.w400,
),
),
// --- RIGHT SIDE: Controls ---
Row(
children: [ children: [
// Dropdown for rows per page // Dropdown for rows per page
DropdownButton<int>( DropdownButton<int>(
value: _rowsPerPage, value: _rowsPerPage,
// focusColor: Colors.transparent, // Fix: Removes the grey/blue highlight on change
items: [5, 10, 15, 20, 50].map((int value) { items: [5, 10, 15, 20, 50].map((int value) {
return DropdownMenuItem<int>( return DropdownMenuItem<int>(
value: value, value: value,
@ -1371,7 +1403,7 @@ class _excelVerifyState extends State<preFileUpload> {
for (int page in visiblePages) _buildPageButton(page), for (int page in visiblePages) _buildPageButton(page),
// Right ellipsis + last page // Right ellipsis + last page
if (!visiblePages.contains(totalPages)) if (!visiblePages.contains(totalPages) && totalPages > 0)
Row(children: [ Row(children: [
const Padding( const Padding(
padding: EdgeInsets.symmetric(horizontal: 4), padding: EdgeInsets.symmetric(horizontal: 4),
@ -1389,8 +1421,8 @@ class _excelVerifyState extends State<preFileUpload> {
), ),
], ],
), ),
),
], ],
),
); );
} }

View File

@ -553,6 +553,12 @@ class _CdPolicieState extends State<CdPolicies> {
); );
Widget _buildPagination(BuildContext context) { Widget _buildPagination(BuildContext context) {
// 1. Calculate the range of entries being shown
final totalItems = filteredData.length;
final int startEntry = totalItems == 0 ? 0 : ((_currentPage - 1) * _rowsPerPage) + 1;
int endEntry = _currentPage * _rowsPerPage;
if (endEntry > totalItems) endEntry = totalItems;
final totalPages = (filteredData.length / _rowsPerPage).ceil(); final totalPages = (filteredData.length / _rowsPerPage).ceil();
const visiblePageCount = 5; const visiblePageCount = 5;
@ -563,7 +569,8 @@ class _CdPolicieState extends State<CdPolicies> {
if (_currentPage <= 3) { if (_currentPage <= 3) {
return [1, 2, 3, 4, 5]; return [1, 2, 3, 4, 5];
} else if (_currentPage >= totalPages - 2) { }
if (_currentPage >= totalPages - 2) {
return [ return [
totalPages - 4, totalPages - 4,
totalPages - 3, totalPages - 3,
@ -571,7 +578,7 @@ class _CdPolicieState extends State<CdPolicies> {
totalPages - 1, totalPages - 1,
totalPages totalPages
]; ];
} else { }
return [ return [
_currentPage - 2, _currentPage - 2,
_currentPage - 1, _currentPage - 1,
@ -579,21 +586,34 @@ class _CdPolicieState extends State<CdPolicies> {
_currentPage + 1, _currentPage + 1,
_currentPage + 2, _currentPage + 2,
]; ];
}
} }
List<int> visiblePages = getVisiblePages(); List<int> visiblePages = getVisiblePages();
return Row( return Padding(
mainAxisAlignment: MainAxisAlignment.end, // Match this horizontal padding (16) to your Table Header padding for perfect alignment
children: [ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Pushes text to left, buttons to right
children: [
// --- LEFT SIDE: Showing Text ---
Text(
"Showing $startEntry to $endEntry of $totalItems entries",
style: GoogleFonts.poppins(
fontSize: 13,
color: const Color(0xFF585757),
fontWeight: FontWeight.w400,
),
),
// --- RIGHT SIDE: Controls ---
Row(
children: [ children: [
// Dropdown for rows per page // Dropdown for rows per page
DropdownButton<int>( DropdownButton<int>(
value: _rowsPerPage, value: _rowsPerPage,
// focusColor: Colors.transparent, // Fix: Removes the grey/blue highlight on change
items: [5, 10, 15, 20, 50].map((int value) { items: [5, 10, 15, 20, 50].map((int value) {
return DropdownMenuItem<int>( return DropdownMenuItem<int>(
value: value, value: value,
@ -609,8 +629,11 @@ class _CdPolicieState extends State<CdPolicies> {
}, },
), ),
const SizedBox(width: 8),
// Previous button // Previous button
IconButton( IconButton(
tooltip: 'Previous Page',
onPressed: _currentPage > 1 onPressed: _currentPage > 1
? () => setState(() => _currentPage--) ? () => setState(() => _currentPage--)
: null, : null,
@ -631,7 +654,7 @@ class _CdPolicieState extends State<CdPolicies> {
for (int page in visiblePages) _buildPageButton(page), for (int page in visiblePages) _buildPageButton(page),
// Right ellipsis + last page // Right ellipsis + last page
if (!visiblePages.contains(totalPages)) if (!visiblePages.contains(totalPages) && totalPages > 0)
Row(children: [ Row(children: [
const Padding( const Padding(
padding: EdgeInsets.symmetric(horizontal: 4), padding: EdgeInsets.symmetric(horizontal: 4),
@ -649,8 +672,8 @@ class _CdPolicieState extends State<CdPolicies> {
), ),
], ],
), ),
),
], ],
),
); );
} }

View File

@ -203,6 +203,7 @@ class _MultiFileUploadWidgetState extends State<MultiFileUploadWidget> {
title: Text(uploaded.file.name, style: const TextStyle(fontSize: 14)), title: Text(uploaded.file.name, style: const TextStyle(fontSize: 14)),
trailing: IconButton( trailing: IconButton(
icon: const Icon(Icons.close, color: Colors.red), icon: const Icon(Icons.close, color: Colors.red),
tooltip: 'Remove', // Built-in property
onPressed: () => _removeFile(index), onPressed: () => _removeFile(index),
), ),
), ),