Merge branch 'master' of bitbucket.org:jubilian/enrollment-app
This commit is contained in:
commit
fcb596621a
@ -8,7 +8,6 @@ import '../customAppBar/toastHelper.dart';
|
||||
import '../service/token_storage_service.dart';
|
||||
import 'branch_card_widget.dart';
|
||||
|
||||
|
||||
class BranchSelectionPage extends StatefulWidget {
|
||||
const BranchSelectionPage({Key? key}) : super(key: key);
|
||||
|
||||
@ -65,16 +64,16 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
|
||||
//Post Token Decode Details
|
||||
final empClientBranchId = decodedToken?['post_branch_id'];
|
||||
await prefs.setString('empClientBranchId', empClientBranchId);
|
||||
final empClientBranchId = decodedToken?['post_branch_id'];
|
||||
await prefs.setString('empClientBranchId', empClientBranchId);
|
||||
|
||||
final empPrimaryId = decodedToken?['post_hr_id'];
|
||||
final empPrimaryId = decodedToken?['post_hr_id'];
|
||||
await prefs.setString('empPrimaryId', empPrimaryId);
|
||||
|
||||
final empClientId = decodedToken?['post_client_id'];
|
||||
final empClientId = decodedToken?['post_client_id'];
|
||||
await prefs.setString('empClientId', empClientId);
|
||||
|
||||
final empHrId = decodedToken?['post_hr_id'];
|
||||
final empHrId = decodedToken?['post_hr_id'];
|
||||
await prefs.setString('empHrId', empHrId);
|
||||
|
||||
dynamic allowedModules = decodedToken?['allowed_modules'];
|
||||
@ -86,15 +85,16 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
||||
|
||||
final empAllowedModules = allowedModules['post'];
|
||||
|
||||
await prefs.setString('empAllowed_modules', jsonEncode(empAllowedModules));
|
||||
await prefs.setString(
|
||||
'empAllowed_modules', jsonEncode(empAllowedModules));
|
||||
|
||||
// final empAllowed_modules = decodedToken?['allowed_modules'][0]['post'];
|
||||
// await prefs.setString('empAllowed_modules', jsonEncode(empAllowed_modules));
|
||||
|
||||
|
||||
//Pre Token Decode Details
|
||||
final enrollmentEmpClientBranchId = decodedToken?['pre_branch_id'];
|
||||
await prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
await prefs.setString(
|
||||
'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||
|
||||
final enrollmentEmpPrimaryId = decodedToken?['pre_hr_id'];
|
||||
await prefs.setString('enrollmentEmpPrimaryId', enrollmentEmpPrimaryId);
|
||||
@ -105,20 +105,19 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
||||
final enrollmentHrId = decodedToken?['pre_hr_id'];
|
||||
await prefs.setString('enrollmentHrId', enrollmentHrId);
|
||||
|
||||
|
||||
final enrollmentAllowedModules = allowedModules['pre'];
|
||||
|
||||
await prefs.setString('enrollmentAllowed_modules', jsonEncode(enrollmentAllowedModules));
|
||||
await prefs.setString(
|
||||
'enrollmentAllowed_modules', jsonEncode(enrollmentAllowedModules));
|
||||
|
||||
// final enrollmentAllowed_modules = decodedToken?['allowed_modules'][1]['pre'];
|
||||
// await prefs.setString('enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules));
|
||||
|
||||
final token = await tokenStorage.getCurrentToken();
|
||||
print('tokenbranch - $token');
|
||||
await prefs.setString('token', token!);
|
||||
ToastHelper.showSuccessToast(context, 'Successfully Login');
|
||||
Navigator.pushReplacementNamed(context, 'hrDashboard');
|
||||
|
||||
final token = await tokenStorage.getCurrentToken();
|
||||
print('tokenbranch - $token');
|
||||
await prefs.setString('token', token!);
|
||||
ToastHelper.showSuccessToast(context, 'Successfully Login');
|
||||
Navigator.pushReplacementNamed(context, 'hrDashboard');
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,8 +164,8 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: horizontalPadding , // Inner horizontal padding
|
||||
vertical: 20, // Inner vertical padding
|
||||
horizontal: horizontalPadding, // Inner horizontal padding
|
||||
vertical: 20, // Inner vertical padding
|
||||
), // Outer padding
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
@ -182,7 +181,7 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24.0, // Inner horizontal padding
|
||||
vertical: 28.0, // Inner vertical padding
|
||||
vertical: 28.0, // Inner vertical padding
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@ -196,41 +195,42 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
||||
),
|
||||
),
|
||||
SizedBox(height: 25),
|
||||
|
||||
Container(
|
||||
height: gridHeight, // Shows approximately 3 rows
|
||||
height: gridHeight, // Shows approximately 3 rows
|
||||
child: branches.isEmpty
|
||||
? Center(
|
||||
child: Text(
|
||||
'No branches available',
|
||||
style: TextStyle(fontSize: 16, color: Colors.grey),
|
||||
),
|
||||
)
|
||||
child: Text(
|
||||
'No branches available',
|
||||
style: TextStyle(
|
||||
fontSize: 16, color: Colors.grey),
|
||||
),
|
||||
)
|
||||
: GridView.builder(
|
||||
// Enable scrolling if content exceeds height
|
||||
physics: ClampingScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: crossAxisCount,
|
||||
childAspectRatio: childAspectRatio,
|
||||
crossAxisSpacing: 15,
|
||||
mainAxisSpacing: 15,
|
||||
),
|
||||
itemCount: branches.length,
|
||||
itemBuilder: (context, index) {
|
||||
final branch = branches[index];
|
||||
return BranchCard(
|
||||
clientName: branch['client_name'] ?? 'Unknown Client',
|
||||
branchName: branch['branch_name'] ?? 'Unknown Branch',
|
||||
isSelected: selectedIndex == index,
|
||||
onTap: () => _selectBranch(index),
|
||||
);
|
||||
},
|
||||
),
|
||||
// Enable scrolling if content exceeds height
|
||||
physics: ClampingScrollPhysics(),
|
||||
padding: EdgeInsets.zero,
|
||||
gridDelegate:
|
||||
SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: crossAxisCount,
|
||||
childAspectRatio: childAspectRatio,
|
||||
crossAxisSpacing: 15,
|
||||
mainAxisSpacing: 15,
|
||||
),
|
||||
itemCount: branches.length,
|
||||
itemBuilder: (context, index) {
|
||||
final branch = branches[index];
|
||||
return BranchCard(
|
||||
clientName: branch['client_name'] ??
|
||||
'Unknown Client',
|
||||
branchName: branch['branch_name'] ??
|
||||
'Unknown Branch',
|
||||
isSelected: selectedIndex == index,
|
||||
onTap: () => _selectBranch(index),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 24),
|
||||
|
||||
Center(
|
||||
child: SizedBox(
|
||||
width: 120,
|
||||
@ -269,4 +269,4 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,7 +336,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
child: Text(
|
||||
'Transaction Details - ${widget.insurerName} (${widget.cdMasterAccountNo})',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 18,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Color(0xFF101010),
|
||||
),
|
||||
@ -346,7 +346,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -434,7 +434,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
child: Text(
|
||||
'Export',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 16,
|
||||
fontSize: 14,
|
||||
color: Color(0xFFFFFFFF),
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 1),
|
||||
@ -561,7 +561,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
'Date',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -570,7 +572,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
'Record Date',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -579,7 +583,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
'Unit',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -588,16 +594,20 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
'Policy',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(
|
||||
'Endorsement No',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -606,7 +616,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
'Sub Type',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -615,7 +627,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
'Credit',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -624,7 +638,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
'Debit',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -633,7 +649,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
'Balance',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -642,16 +660,20 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
'Description',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
flex: 2,
|
||||
child: Text(
|
||||
'User',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
||||
fontSize: 12,
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -683,7 +705,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
child: Text(
|
||||
formatDateNextLine(item['created_at']),
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -691,7 +716,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
child: Text(
|
||||
item['record_date'] ?? '-',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -700,7 +728,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
// 'The Kancheepuram District Consumers Operative Wholesale Stores Limited-5526',
|
||||
item['unit'] ?? '-',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -711,18 +742,25 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
item['policy_type'].toString().trim().isNotEmpty &&
|
||||
item['policy_no'] != null &&
|
||||
item['policy_no'].toString().trim().isNotEmpty
|
||||
// ? '${item['policy_no']}'
|
||||
? '${item['policy_type']} - ${item['policy_no']}'
|
||||
: '-',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
flex: 3,
|
||||
child: Text(
|
||||
item['endorsement_no'] ?? '-',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -730,7 +768,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
child: Text(
|
||||
item['sub_type'] ?? '-',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -740,7 +781,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
? '₹${item['amount']}'
|
||||
: '-',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -750,7 +794,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
? '₹${item['amount']}'
|
||||
: '-',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -758,7 +805,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
child: Text(
|
||||
"₹${item['balance'] ?? '-'}",
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -766,15 +816,21 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
||||
child: Text(
|
||||
item['description'] ?? '-',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
flex: 2,
|
||||
child: Text(
|
||||
item['username'] ?? '-',
|
||||
textAlign: TextAlign.left,
|
||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@ -24,7 +24,6 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
// _checkTokens();
|
||||
}
|
||||
|
||||
|
||||
Future<void> logout(BuildContext context) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
// final String? hrtoken = prefs.getString('_postToken');
|
||||
@ -43,82 +42,127 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
preferredSize: widget.preferredSize,
|
||||
child: SafeArea(
|
||||
child: Container(
|
||||
padding: Responsive.isDesktop(context)
|
||||
? EdgeInsets.symmetric(horizontal: 16.0)
|
||||
: EdgeInsets.symmetric(horizontal: 0),
|
||||
// padding: Responsive.isDesktop(context)
|
||||
// ? EdgeInsets.symmetric(horizontal: 46.0)
|
||||
// : EdgeInsets.symmetric(horizontal: 0),
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: MediaQuery.of(context).size.width *
|
||||
(Responsive.isDesktop(context) ? 0.03 : 0.02),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// Logo Column
|
||||
Expanded(
|
||||
flex: Responsive.isDesktop(context) ? 3 : 9,
|
||||
child: Row(
|
||||
mainAxisAlignment: Responsive.isDesktop(context)
|
||||
? MainAxisAlignment.spaceEvenly
|
||||
: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 10, bottom: 10),
|
||||
width: 150,
|
||||
height: 150,
|
||||
child: Image.asset(
|
||||
'assets/nhance_client_logo.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
// Expanded(
|
||||
// // flex: Responsive.isDesktop(context) ? 1 : 9,
|
||||
// child:
|
||||
Row(
|
||||
mainAxisAlignment: Responsive.isDesktop(context)
|
||||
? MainAxisAlignment.spaceEvenly
|
||||
: MainAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(top: 10, bottom: 10),
|
||||
width: 150,
|
||||
height: 150,
|
||||
child: Image.asset(
|
||||
'assets/nhance_client_logo.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
// ),
|
||||
// AdaptiveNavBar Column
|
||||
Expanded(
|
||||
flex: Responsive.isDesktop(context) ? 9 : 3,
|
||||
child: AdaptiveNavBar(
|
||||
screenWidth: sw,
|
||||
backgroundColor: Color(0xFFFFFCE5),
|
||||
leading:
|
||||
Container(), // Set an empty container as we have the logo separately
|
||||
title: Text(''),
|
||||
navBarItems: [
|
||||
// if (Responsive.isDesktop(context))
|
||||
// if (hideInactiveStatus)
|
||||
// NavBarItem(
|
||||
// text: "Inactive Policy",
|
||||
// onTap: () {
|
||||
// Navigator.pushNamed(context, 'oldPolicy');
|
||||
// },
|
||||
// ),
|
||||
// if (showBackToHR)
|
||||
NavBarItem(
|
||||
text: "Change Branch",
|
||||
onTap: () async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove('selected_branch');
|
||||
await prefs.remove('decoded_token');
|
||||
await prefs.remove('clientLogo');
|
||||
await prefs.remove('clientName');
|
||||
await prefs.remove('empAllowed_modules');
|
||||
await prefs.remove('empClientBranchId');
|
||||
await prefs.remove('empClientId');
|
||||
await prefs.remove('empEmail');
|
||||
await prefs.remove('empHrId');
|
||||
await prefs.remove('empPrimaryId');
|
||||
await prefs.remove('enrollmentAllowed_modules');
|
||||
await prefs.remove('enrollmentClient_id');
|
||||
await prefs.remove('enrollmentEmpClientBranchId');
|
||||
await prefs.remove('enrollmentEmpPrimaryId');
|
||||
await prefs.remove('enrollmentHrId');
|
||||
await prefs.remove('token');
|
||||
Navigator.pushNamed(context, 'branchSelection');
|
||||
},
|
||||
),
|
||||
NavBarItem(
|
||||
text: "Logout",
|
||||
onTap: () async {
|
||||
logout(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Expanded(
|
||||
// // flex: Responsive.isDesktop(context) ? 1 : 9,
|
||||
// child:
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
NavBarItem(
|
||||
text: "Change Branch",
|
||||
onTap: () async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove('selected_branch');
|
||||
await prefs.remove('decoded_token');
|
||||
await prefs.remove('clientLogo');
|
||||
await prefs.remove('clientName');
|
||||
await prefs.remove('empAllowed_modules');
|
||||
await prefs.remove('empClientBranchId');
|
||||
await prefs.remove('empClientId');
|
||||
await prefs.remove('empEmail');
|
||||
await prefs.remove('empHrId');
|
||||
await prefs.remove('empPrimaryId');
|
||||
await prefs.remove('enrollmentAllowed_modules');
|
||||
await prefs.remove('enrollmentClient_id');
|
||||
await prefs.remove('enrollmentEmpClientBranchId');
|
||||
await prefs.remove('enrollmentEmpPrimaryId');
|
||||
await prefs.remove('enrollmentHrId');
|
||||
await prefs.remove('token');
|
||||
Navigator.pushNamed(context, 'branchSelection');
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
NavBarItem(
|
||||
text: "Logout",
|
||||
onTap: () => logout(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
// )
|
||||
|
||||
// Expanded(
|
||||
// flex: Responsive.isDesktop(context) ? 9 : 3,
|
||||
// child: AdaptiveNavBar(
|
||||
// screenWidth: sw,
|
||||
// backgroundColor: Color(0xFFFFFCE5),
|
||||
// leading:
|
||||
// Container(), // Set an empty container as we have the logo separately
|
||||
// title: Text(''),
|
||||
// navBarItems: [
|
||||
// // if (Responsive.isDesktop(context))
|
||||
// // if (hideInactiveStatus)
|
||||
// // NavBarItem(
|
||||
// // text: "Inactive Policy",
|
||||
// // onTap: () {
|
||||
// // Navigator.pushNamed(context, 'oldPolicy');
|
||||
// // },
|
||||
// // ),
|
||||
// // if (showBackToHR)
|
||||
// NavBarItem(
|
||||
// text: "Change Branch",
|
||||
// onTap: () async {
|
||||
// final prefs = await SharedPreferences.getInstance();
|
||||
// await prefs.remove('selected_branch');
|
||||
// await prefs.remove('decoded_token');
|
||||
// await prefs.remove('clientLogo');
|
||||
// await prefs.remove('clientName');
|
||||
// await prefs.remove('empAllowed_modules');
|
||||
// await prefs.remove('empClientBranchId');
|
||||
// await prefs.remove('empClientId');
|
||||
// await prefs.remove('empEmail');
|
||||
// await prefs.remove('empHrId');
|
||||
// await prefs.remove('empPrimaryId');
|
||||
// await prefs.remove('enrollmentAllowed_modules');
|
||||
// await prefs.remove('enrollmentClient_id');
|
||||
// await prefs.remove('enrollmentEmpClientBranchId');
|
||||
// await prefs.remove('enrollmentEmpPrimaryId');
|
||||
// await prefs.remove('enrollmentHrId');
|
||||
// await prefs.remove('token');
|
||||
// Navigator.pushNamed(context, 'branchSelection');
|
||||
// },
|
||||
// ),
|
||||
// NavBarItem(
|
||||
// text: "Logout",
|
||||
// onTap: () async {
|
||||
// logout(context);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -127,3 +171,34 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class NavBarItem extends StatelessWidget {
|
||||
final String text;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const NavBarItem({
|
||||
Key? key,
|
||||
required this.text,
|
||||
this.onTap,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
onTap: onTap,
|
||||
hoverColor: const Color(0xFFF4F3E7), // subtle hover background
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
child: Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -974,4 +974,4 @@ class PolicyCard extends StatelessWidget {
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -486,90 +486,99 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
// if (widget.TokenType != "post")
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => widget.TokenType != "post" ? excelVerify(
|
||||
ClientId:
|
||||
widget.ClientId, // <-- from map
|
||||
policyTypeId: widget.policyTypeId,
|
||||
ClientPoliyId: widget.ClientPoliyId,
|
||||
clientBranchId:
|
||||
widget.clientBranchId,
|
||||
Token: widget.Token,
|
||||
TokenType: widget.TokenType,
|
||||
cardType: widget.cardType,
|
||||
cardPolicyNo: widget.cardPolicyNo,
|
||||
cardInsurer_name:
|
||||
widget.cardInsurer_name,
|
||||
cardPolicy_name:
|
||||
widget.cardPolicy_name,
|
||||
cardPolicy_ExpDate:
|
||||
widget.cardPolicy_ExpDate,
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => widget
|
||||
.TokenType !=
|
||||
"post"
|
||||
? excelVerify(
|
||||
ClientId: widget
|
||||
.ClientId, // <-- from map
|
||||
policyTypeId:
|
||||
widget.policyTypeId,
|
||||
ClientPoliyId:
|
||||
widget.ClientPoliyId,
|
||||
clientBranchId:
|
||||
widget.clientBranchId,
|
||||
Token: widget.Token,
|
||||
TokenType: widget.TokenType,
|
||||
cardType: widget.cardType,
|
||||
cardPolicyNo:
|
||||
widget.cardPolicyNo,
|
||||
cardInsurer_name:
|
||||
widget.cardInsurer_name,
|
||||
cardPolicy_name:
|
||||
widget.cardPolicy_name,
|
||||
cardPolicy_ExpDate:
|
||||
widget.cardPolicy_ExpDate,
|
||||
|
||||
// Token: widget.Token,
|
||||
// ClientId: widget.ClientId,
|
||||
// ClientPolicyId : widget.ClientPoliyId,
|
||||
// PolicyName: widget.cardPolicy_name,
|
||||
// PolicyNo: widget.cardPolicyNo,
|
||||
// ClientBranchId: widget.HrId,
|
||||
// PolicyType: widget.cardType,
|
||||
) : postFileUpload(
|
||||
ClientId:
|
||||
widget.ClientId, // <-- from map
|
||||
policyTypeId: widget.policyTypeId,
|
||||
ClientPoliyId: widget.ClientPoliyId,
|
||||
clientBranchId:
|
||||
widget.clientBranchId,
|
||||
Token: widget.Token,
|
||||
TokenType: widget.TokenType,
|
||||
cardType: widget.cardType,
|
||||
cardPolicyNo: widget.cardPolicyNo,
|
||||
cardInsurer_name:
|
||||
widget.cardInsurer_name,
|
||||
cardPolicy_name:
|
||||
widget.cardPolicy_name,
|
||||
cardPolicy_ExpDate:
|
||||
widget.cardPolicy_ExpDate,
|
||||
// Token: widget.Token,
|
||||
// ClientId: widget.ClientId,
|
||||
// ClientPolicyId : widget.ClientPoliyId,
|
||||
// PolicyName: widget.cardPolicy_name,
|
||||
// PolicyNo: widget.cardPolicyNo,
|
||||
// ClientBranchId: widget.HrId,
|
||||
// PolicyType: widget.cardType,
|
||||
)
|
||||
: postFileUpload(
|
||||
ClientId: widget
|
||||
.ClientId, // <-- from map
|
||||
policyTypeId:
|
||||
widget.policyTypeId,
|
||||
ClientPoliyId:
|
||||
widget.ClientPoliyId,
|
||||
clientBranchId:
|
||||
widget.clientBranchId,
|
||||
Token: widget.Token,
|
||||
TokenType: widget.TokenType,
|
||||
cardType: widget.cardType,
|
||||
cardPolicyNo:
|
||||
widget.cardPolicyNo,
|
||||
cardInsurer_name:
|
||||
widget.cardInsurer_name,
|
||||
cardPolicy_name:
|
||||
widget.cardPolicy_name,
|
||||
cardPolicy_ExpDate:
|
||||
widget.cardPolicy_ExpDate,
|
||||
|
||||
// Token: widget.Token,
|
||||
// ClientId: widget.ClientId,
|
||||
// ClientPolicyId : widget.ClientPoliyId,
|
||||
// PolicyName: widget.cardPolicy_name,
|
||||
// PolicyNo: widget.cardPolicyNo,
|
||||
// ClientBranchId: widget.HrId,
|
||||
// PolicyType: widget.cardType,
|
||||
)
|
||||
),
|
||||
);
|
||||
// exportToCsv(filteredData);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Color(0xFFE26728),
|
||||
padding: EdgeInsets.all(
|
||||
10), // Internal padding
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
10), // Border radius
|
||||
side: BorderSide(
|
||||
color: Colors
|
||||
.transparent, // Optional border color
|
||||
width: 1, // Border width
|
||||
),
|
||||
// Token: widget.Token,
|
||||
// ClientId: widget.ClientId,
|
||||
// ClientPolicyId : widget.ClientPoliyId,
|
||||
// PolicyName: widget.cardPolicy_name,
|
||||
// PolicyNo: widget.cardPolicyNo,
|
||||
// ClientBranchId: widget.HrId,
|
||||
// PolicyType: widget.cardType,
|
||||
)),
|
||||
);
|
||||
// exportToCsv(filteredData);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Color(0xFFE26728),
|
||||
padding:
|
||||
EdgeInsets.all(10), // Internal padding
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
10), // Border radius
|
||||
side: BorderSide(
|
||||
color: Colors
|
||||
.transparent, // Optional border color
|
||||
width: 1, // Border width
|
||||
),
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(
|
||||
'Import',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
color: Color(0xFFFFFFFF),
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 1),
|
||||
),
|
||||
elevation: 0,
|
||||
),
|
||||
child: Text(
|
||||
'Import',
|
||||
style: GoogleFonts.poppins(
|
||||
fontSize: 12,
|
||||
color: Color(0xFFFFFFFF),
|
||||
fontWeight: FontWeight.w500,
|
||||
letterSpacing: 1),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
@ -702,17 +711,17 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
),
|
||||
),
|
||||
),
|
||||
if(widget.policyTypeId != '6' && widget.policyTypeId != '7')
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
'UHID',
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w600,
|
||||
if (widget.policyTypeId != '6' && widget.policyTypeId != '7')
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
'UHID',
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
@ -803,7 +812,6 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: _paginatedData.mapIndexed((index, item) {
|
||||
return Container(
|
||||
|
||||
// margin: const EdgeInsets.only(bottom: 8),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 5, horizontal: 16),
|
||||
@ -844,17 +852,18 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
],
|
||||
),
|
||||
),
|
||||
if(widget.policyTypeId != '6' && widget.policyTypeId != '7')
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
item['uhid'] ?? '-',
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12),
|
||||
if (widget.policyTypeId != '6' &&
|
||||
widget.policyTypeId != '7')
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
item['uhid'] ?? '-',
|
||||
style: GoogleFonts.poppins(
|
||||
color: Color(0xFF000000),
|
||||
fontWeight: FontWeight.w400,
|
||||
fontSize: 12),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(
|
||||
@ -930,92 +939,92 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.TokenType != "pre" && (hasAnyEcardLink || hasModule))
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final isSelf = item['relationship'] == 'Self';
|
||||
final hasEcard = item['ecard_download_link'] != null;
|
||||
final showEcard = isSelf && hasEcard;
|
||||
final showClaim = widget.TokenType == "post" && hasModule;
|
||||
|
||||
if (widget.TokenType != "pre" && (hasAnyEcardLink || hasModule))
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final isSelf = item['relationship'] == 'Self';
|
||||
final hasEcard = item['ecard_download_link'] != null;
|
||||
final showEcard = isSelf && hasEcard;
|
||||
final showClaim = widget.TokenType == "post" && hasModule;
|
||||
|
||||
if (!showEcard && !showClaim) {
|
||||
return SizedBox(); // No icon to show
|
||||
}
|
||||
if (!showEcard && !showClaim) {
|
||||
return SizedBox(); // No icon to show
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: showEcard && !showClaim
|
||||
? MainAxisAlignment.start // Only eCard, push to right
|
||||
: MainAxisAlignment.end, // eCard + claim OR only claim
|
||||
children: [
|
||||
if (showEcard)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
getEcardDownload(item['emp_code'],item['employee_id'],item['client_policy_id'],item['policy_no']);
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
width: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE6F5F6),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
child: Image.asset(
|
||||
'assets/credit_card.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
return Row(
|
||||
mainAxisAlignment: showEcard && !showClaim
|
||||
? MainAxisAlignment.start // Only eCard, push to right
|
||||
: MainAxisAlignment.end, // eCard + claim OR only claim
|
||||
children: [
|
||||
if (showEcard)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
getEcardDownload(item['emp_code'],item['employee_id'],item['client_policy_id'],item['policy_no']);
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
width: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE6F5F6),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
child: Image.asset(
|
||||
'assets/credit_card.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
if (showEcard && showClaim) SizedBox(width: 8),
|
||||
if (showEcard && showClaim) SizedBox(width: 8),
|
||||
|
||||
if (showClaim)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => hrDashboard(
|
||||
selectedIndex: 3,
|
||||
empCodeFromHrPolicy: item['emp_code']!,
|
||||
isHrcode: 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
width: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE6F5F6),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
child: Image.asset(
|
||||
'assets/claim.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
if (showClaim)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4.0),
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => hrDashboard(
|
||||
selectedIndex: 3,
|
||||
empCodeFromHrPolicy: item['emp_code']!,
|
||||
isHrcode: 1,
|
||||
),
|
||||
|
||||
// if (widget.TokenType != "pre" &&
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
width: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFFE6F5F6),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(4),
|
||||
child: Image.asset(
|
||||
'assets/claim.png',
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
// (hasAnyEcardLink || hasModule))
|
||||
// Expanded(
|
||||
// flex: 3,
|
||||
@ -1093,85 +1102,208 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
||||
),
|
||||
),
|
||||
// ),
|
||||
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
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; // Reset to first page when rows per page changes
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _currentPage > 1
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage--;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_left),
|
||||
),
|
||||
for (int i = 1;
|
||||
i <= (filteredData.length / _rowsPerPage).ceil();
|
||||
i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _currentPage == i
|
||||
? Color(0xFF00A6A6)
|
||||
: Colors.grey[300],
|
||||
foregroundColor:
|
||||
_currentPage == i ? Colors.white : Colors.black,
|
||||
minimumSize: Size(36, 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentPage = i;
|
||||
});
|
||||
},
|
||||
child: Text(i.toString()),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _currentPage <
|
||||
(filteredData.length / _rowsPerPage).ceil()
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage++;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_right),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
_buildPagination(context)
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// 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; // Reset to first page when rows per page changes
|
||||
// });
|
||||
// },
|
||||
// ),
|
||||
// IconButton(
|
||||
// onPressed: _currentPage > 1
|
||||
// ? () {
|
||||
// setState(() {
|
||||
// _currentPage--;
|
||||
// });
|
||||
// }
|
||||
// : null,
|
||||
// icon: Icon(Icons.chevron_left),
|
||||
// ),
|
||||
// for (int i = 1;
|
||||
// i <= (filteredData.length / _rowsPerPage).ceil();
|
||||
// i++)
|
||||
// Padding(
|
||||
// padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
// child: ElevatedButton(
|
||||
// style: ElevatedButton.styleFrom(
|
||||
// backgroundColor: _currentPage == i
|
||||
// ? Color(0xFF00A6A6)
|
||||
// : Colors.grey[300],
|
||||
// foregroundColor:
|
||||
// _currentPage == i ? Colors.white : Colors.black,
|
||||
// minimumSize: Size(36, 36),
|
||||
// padding: EdgeInsets.zero,
|
||||
// ),
|
||||
// onPressed: () {
|
||||
// setState(() {
|
||||
// _currentPage = i;
|
||||
// });
|
||||
// },
|
||||
// child: Text(i.toString()),
|
||||
// ),
|
||||
// ),
|
||||
// IconButton(
|
||||
// onPressed: _currentPage <
|
||||
// (filteredData.length / _rowsPerPage).ceil()
|
||||
// ? () {
|
||||
// setState(() {
|
||||
// _currentPage++;
|
||||
// });
|
||||
// }
|
||||
// : null,
|
||||
// icon: Icon(Icons.chevron_right),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPagination(BuildContext context) {
|
||||
final totalPages = (filteredData.length / _rowsPerPage).ceil();
|
||||
const visiblePageCount = 5;
|
||||
|
||||
List<int> getVisiblePages() {
|
||||
if (totalPages <= visiblePageCount) {
|
||||
return List.generate(totalPages, (i) => i + 1);
|
||||
}
|
||||
|
||||
if (_currentPage <= 3) {
|
||||
return [1, 2, 3, 4, 5];
|
||||
} else if (_currentPage >= totalPages - 2) {
|
||||
return [
|
||||
totalPages - 4,
|
||||
totalPages - 3,
|
||||
totalPages - 2,
|
||||
totalPages - 1,
|
||||
totalPages
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
_currentPage - 2,
|
||||
_currentPage - 1,
|
||||
_currentPage,
|
||||
_currentPage + 1,
|
||||
_currentPage + 2,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
List<int> visiblePages = getVisiblePages();
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
// Dropdown for rows per page
|
||||
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;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
||||
// Previous button
|
||||
IconButton(
|
||||
onPressed: _currentPage > 1
|
||||
? () => setState(() => _currentPage--)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
|
||||
// First page + left ellipsis
|
||||
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),
|
||||
|
||||
// Right ellipsis + last page
|
||||
if (!visiblePages.contains(totalPages))
|
||||
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 _buildPageButton(int page) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
_currentPage == page ? const Color(0xFF00A6A6) : Colors.grey[300],
|
||||
foregroundColor: _currentPage == page ? Colors.white : Colors.black,
|
||||
minimumSize: const Size(36, 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentPage = page;
|
||||
});
|
||||
},
|
||||
child: Text(page.toString()),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,17 +37,17 @@ class postFileUpload extends StatefulWidget {
|
||||
final String cardPolicy_ExpDate;
|
||||
const postFileUpload(
|
||||
{Key? key,
|
||||
required this.ClientId,
|
||||
required this.policyTypeId,
|
||||
required this.ClientPoliyId,
|
||||
required this.clientBranchId,
|
||||
required this.Token,
|
||||
required this.TokenType,
|
||||
required this.cardType,
|
||||
required this.cardPolicyNo,
|
||||
required this.cardInsurer_name,
|
||||
required this.cardPolicy_name,
|
||||
required this.cardPolicy_ExpDate})
|
||||
required this.ClientId,
|
||||
required this.policyTypeId,
|
||||
required this.ClientPoliyId,
|
||||
required this.clientBranchId,
|
||||
required this.Token,
|
||||
required this.TokenType,
|
||||
required this.cardType,
|
||||
required this.cardPolicyNo,
|
||||
required this.cardInsurer_name,
|
||||
required this.cardPolicy_name,
|
||||
required this.cardPolicy_ExpDate})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -81,7 +81,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
dynamic empRefId;
|
||||
dynamic empPrimaryId;
|
||||
List<Map<String, dynamic>> getFileUploadMasterList = [];
|
||||
dynamic getThrFileList = [];
|
||||
dynamic getThrFileList = [];
|
||||
late int excelValidationStaus = 1;
|
||||
bool isSuccess = false;
|
||||
String successContent = '';
|
||||
@ -96,7 +96,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
List<dynamic> get _paginatedData {
|
||||
final startIndex = (_currentPage - 1) * _rowsPerPage;
|
||||
final endIndex =
|
||||
(_currentPage * _rowsPerPage).clamp(0, filteredData.length);
|
||||
(_currentPage * _rowsPerPage).clamp(0, filteredData.length);
|
||||
return filteredData.sublist(startIndex, endIndex);
|
||||
}
|
||||
|
||||
@ -109,7 +109,6 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
String? selectedValue;
|
||||
String? _selectedAction;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -174,7 +173,6 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
Future<void> getFileUploadMasterDetails() async {
|
||||
print('9');
|
||||
try {
|
||||
|
||||
final response = await apiService.getFileUploadMastersToApi(widget.Token);
|
||||
|
||||
if (response['status'] == true) {
|
||||
@ -210,8 +208,8 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
empPrimaryId = prefs.getString('empPrimaryId');
|
||||
print('9');
|
||||
try {
|
||||
|
||||
final response = await apiService.getFileListToApi(empPrimaryId,widget.cardPolicyNo,widget.Token);
|
||||
final response = await apiService.getFileListToApi(
|
||||
empPrimaryId, widget.cardPolicyNo, widget.Token);
|
||||
|
||||
if (response['status'] == 'success') {
|
||||
print('getThrFileList');
|
||||
@ -237,45 +235,44 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getHrFileDownload(id,file_name) async {
|
||||
// final http.Response response = await apiService.getHrFileDownloadToApi(id, widget.Token);
|
||||
final apiurl = Environment.apiUrlPost;
|
||||
final String url = '$apiurl/hrFileDownload?id=$id';
|
||||
final token = widget.Token;
|
||||
Future<void> getHrFileDownload(id, file_name) async {
|
||||
// final http.Response response = await apiService.getHrFileDownloadToApi(id, widget.Token);
|
||||
final apiurl = Environment.apiUrlPost;
|
||||
final String url = '$apiurl/hrFileDownload?id=$id';
|
||||
final token = widget.Token;
|
||||
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
// 'app-signature': 'ts-traveltool-2025-signature-123456',
|
||||
},
|
||||
);
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
'Content-Type': 'application/json',
|
||||
// 'app-signature': 'ts-traveltool-2025-signature-123456',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
print("PDF Downloaded");
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
try {
|
||||
print("PDF Downloaded");
|
||||
// ✅ Create a blob from the response body bytes
|
||||
final blob = html.Blob([response.bodyBytes]);
|
||||
|
||||
// ✅ Create a blob from the response body bytes
|
||||
final blob = html.Blob([response.bodyBytes]);
|
||||
// ✅ Generate a download URL
|
||||
final url = html.Url.createObjectUrlFromBlob(blob);
|
||||
|
||||
// ✅ Generate a download URL
|
||||
final url = html.Url.createObjectUrlFromBlob(blob);
|
||||
// ✅ Trigger file download automatically
|
||||
final anchor = html.AnchorElement(href: url)
|
||||
..setAttribute('download', '$file_name')
|
||||
..click();
|
||||
|
||||
// ✅ Trigger file download automatically
|
||||
final anchor = html.AnchorElement(href: url)
|
||||
..setAttribute('download', '$file_name')
|
||||
..click();
|
||||
|
||||
// ✅ Revoke the URL to free memory
|
||||
html.Url.revokeObjectUrl(url);
|
||||
} catch (e) {
|
||||
throw Exception('Error parsing response: $e');
|
||||
}
|
||||
} else {
|
||||
print("Download failed with status: ${response.statusCode}");
|
||||
// ✅ Revoke the URL to free memory
|
||||
html.Url.revokeObjectUrl(url);
|
||||
} catch (e) {
|
||||
throw Exception('Error parsing response: $e');
|
||||
}
|
||||
} else {
|
||||
print("Download failed with status: ${response.statusCode}");
|
||||
}
|
||||
}
|
||||
|
||||
void _uploadFile() async {
|
||||
@ -368,9 +365,9 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
empPrimaryId = prefs.getString('empPrimaryId');
|
||||
// Future.delayed(Duration(seconds: 3), () {
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
// });
|
||||
print('submit');
|
||||
print(fileBytes);
|
||||
@ -415,12 +412,12 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
// request.fields['status'] = selectedKey!;
|
||||
request.fields['created_by'] = empPrimaryId;
|
||||
request.fields['policy_id'] = widget.ClientPoliyId;
|
||||
// "client_id": 1,
|
||||
// "client_branch_id": 2,
|
||||
// "policy_no": "POL123456",
|
||||
// "file_action": ,
|
||||
// "status": "inception",
|
||||
// "created_by": 10
|
||||
// "client_id": 1,
|
||||
// "client_branch_id": 2,
|
||||
// "policy_no": "POL123456",
|
||||
// "file_action": ,
|
||||
// "status": "inception",
|
||||
// "created_by": 10
|
||||
|
||||
print('request : $request');
|
||||
// Send the request
|
||||
@ -474,9 +471,9 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
// For example, check if any field in the row contains the query
|
||||
// Adjust this logic based on your data structure
|
||||
return row['file_name']
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.contains(query.toLowerCase()) ||
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
.contains(query.toLowerCase()) ||
|
||||
row['file_action']
|
||||
.toString()
|
||||
.toLowerCase()
|
||||
@ -506,97 +503,98 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
padding: EdgeInsets.only(top: 30, bottom: 200, left: 50, right: 50),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center, // 👈 fix alignment
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 8,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.center, // 👈 fix alignment
|
||||
children: [
|
||||
// back button + texts
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: BoxConstraints(),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.arrow_back_ios,
|
||||
color: Colors.grey,
|
||||
size: 17,
|
||||
Expanded(
|
||||
flex: 8,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// back button + texts
|
||||
Row(
|
||||
children: [
|
||||
IconButton(
|
||||
padding: EdgeInsets.zero,
|
||||
constraints: BoxConstraints(),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
icon: Icon(
|
||||
Icons.arrow_back_ios,
|
||||
color: Colors.grey,
|
||||
size: 17,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${widget.cardType} - ${widget.cardPolicyNo}",
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.TokenType == 'pre'
|
||||
? "${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})"
|
||||
: "${widget.cardInsurer_name} - ${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})",
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.grey,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"${widget.cardType} - ${widget.cardPolicyNo}",
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.black,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: getFileUploadMasterList.isEmpty
|
||||
? const SizedBox() // 👈 avoid crash on first build
|
||||
: buildDropdownField<String>(
|
||||
'File Action',
|
||||
(value) {
|
||||
setState(() {
|
||||
selectedKey = value;
|
||||
selectedValue = getFileUploadMasterList
|
||||
.firstWhere((item) =>
|
||||
item['key'] == value)['value'];
|
||||
});
|
||||
debugPrint("Selected Key: $selectedKey");
|
||||
debugPrint(
|
||||
"Selected Value: $selectedValue");
|
||||
},
|
||||
false,
|
||||
getFileUploadMasterList,
|
||||
'value',
|
||||
selectedKey,
|
||||
valueKey: 'key',
|
||||
),
|
||||
),
|
||||
Text(
|
||||
widget.TokenType == 'pre'
|
||||
? "${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})"
|
||||
: "${widget.cardInsurer_name} - ${widget.cardPolicy_name} (${widget.cardPolicy_ExpDate})",
|
||||
style: GoogleFonts.poppins(
|
||||
color: Colors.grey,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: getFileUploadMasterList.isEmpty
|
||||
? const SizedBox() // 👈 avoid crash on first build
|
||||
: buildDropdownField<String>(
|
||||
'File Action',
|
||||
(value) {
|
||||
setState(() {
|
||||
selectedKey = value;
|
||||
selectedValue = getFileUploadMasterList
|
||||
.firstWhere((item) => item['key'] == value)['value'];
|
||||
});
|
||||
debugPrint("Selected Key: $selectedKey");
|
||||
debugPrint("Selected Value: $selectedValue");
|
||||
},
|
||||
false,
|
||||
getFileUploadMasterList,
|
||||
'value',
|
||||
selectedKey,
|
||||
valueKey: 'key',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
BorderRadius.circular(10), // 👈 set your desired radius
|
||||
BorderRadius.circular(10), // 👈 set your desired radius
|
||||
),
|
||||
// height: 400,
|
||||
// margin: const EdgeInsets.only(left: 40.0, right: 40.0),
|
||||
@ -632,8 +630,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
// ),
|
||||
SizedBox(height: 20),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
@ -643,113 +640,118 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
color: Colors.grey[200],
|
||||
height: 180,
|
||||
child: DragTarget(
|
||||
onAccept: (html.File
|
||||
droppedFile) {
|
||||
onAccept: (html.File droppedFile) {
|
||||
setState(() {
|
||||
fileName =
|
||||
droppedFile.name;
|
||||
fileName = droppedFile.name;
|
||||
});
|
||||
_dragAndDropFile(
|
||||
droppedFile);
|
||||
_dragAndDropFile(droppedFile);
|
||||
},
|
||||
builder:
|
||||
(BuildContext context,
|
||||
List<String?>
|
||||
candidateData,
|
||||
List<dynamic>
|
||||
rejectedData) {
|
||||
builder: (BuildContext context,
|
||||
List<String?> candidateData,
|
||||
List<dynamic> rejectedData) {
|
||||
return Container(
|
||||
alignment:
|
||||
Alignment.center,
|
||||
alignment: Alignment.center,
|
||||
child: Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.center,
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
fileName != null
|
||||
? Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons
|
||||
.upload_file, // Choose the appropriate icon
|
||||
size:
|
||||
35,
|
||||
color: Color(
|
||||
0xFFE26728), // Adjust the size as needed
|
||||
),
|
||||
SizedBox(
|
||||
height:
|
||||
15), // Add some space between the icon and text
|
||||
Text(
|
||||
'$fileName',
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
16),
|
||||
),
|
||||
SizedBox(
|
||||
height:
|
||||
25), // Add some space between the icon and text
|
||||
MouseRegion(
|
||||
cursor:
|
||||
SystemMouseCursors.click, // Set cursor to pointer on hover
|
||||
child:
|
||||
GestureDetector(
|
||||
onTap:
|
||||
() {
|
||||
resetErrorCount();
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons
|
||||
.upload_file, // Choose the appropriate icon
|
||||
size: 35,
|
||||
color: Color(
|
||||
0xFFE26728), // Adjust the size as needed
|
||||
),
|
||||
SizedBox(
|
||||
height:
|
||||
15), // Add some space between the icon and text
|
||||
Text(
|
||||
'$fileName',
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
16),
|
||||
),
|
||||
SizedBox(
|
||||
height:
|
||||
25), // Add some space between the icon and text
|
||||
MouseRegion(
|
||||
cursor: SystemMouseCursors
|
||||
.click, // Set cursor to pointer on hover
|
||||
child:
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
resetErrorCount();
|
||||
},
|
||||
child:
|
||||
const Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons
|
||||
.delete_forever, // Choose the remove icon
|
||||
size:
|
||||
20, // Adjust the size as needed
|
||||
color: Colors
|
||||
.red, // Set the color of the remove icon
|
||||
),
|
||||
SizedBox(
|
||||
width:
|
||||
1), // Add some space between the icon and text
|
||||
Text(
|
||||
'Remove',
|
||||
style: TextStyle(
|
||||
fontSize:
|
||||
13,
|
||||
color:
|
||||
Color(0xFF727272)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
: ElevatedButton(
|
||||
onPressed: () => {
|
||||
print(
|
||||
'selectedValue $selectedValue'),
|
||||
if (selectedValue !=
|
||||
null)
|
||||
{
|
||||
_uploadFile(),
|
||||
}
|
||||
else
|
||||
{
|
||||
ToastHelper
|
||||
.showErrorToast(
|
||||
context,
|
||||
'Please select file action')
|
||||
}
|
||||
},
|
||||
child:
|
||||
const Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.delete_forever, // Choose the remove icon
|
||||
size: 20, // Adjust the size as needed
|
||||
color: Colors.red, // Set the color of the remove icon
|
||||
),
|
||||
SizedBox(width: 1), // Add some space between the icon and text
|
||||
Text(
|
||||
'Remove',
|
||||
style: TextStyle(fontSize: 13, color: Color(0xFF727272)),
|
||||
),
|
||||
],
|
||||
child: Text(
|
||||
'Select File',
|
||||
style: TextStyle(
|
||||
color: Colors
|
||||
.white),
|
||||
),
|
||||
style:
|
||||
ElevatedButton
|
||||
.styleFrom(
|
||||
backgroundColor:
|
||||
Color(
|
||||
0xFFE26728),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
: ElevatedButton(
|
||||
onPressed: () => {
|
||||
print('selectedValue $selectedValue'),
|
||||
if(selectedValue != null){
|
||||
_uploadFile(),
|
||||
} else {
|
||||
ToastHelper.showErrorToast(context, 'Please select file action')
|
||||
}
|
||||
|
||||
},
|
||||
child: Text(
|
||||
'Select File',
|
||||
style: TextStyle(
|
||||
color:
|
||||
Colors.white),
|
||||
),
|
||||
style: ElevatedButton
|
||||
.styleFrom(
|
||||
backgroundColor:
|
||||
Color(
|
||||
0xFFE26728),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20),
|
||||
if (fileName ==
|
||||
null)
|
||||
SizedBox(height: 20),
|
||||
if (fileName == null)
|
||||
Text(
|
||||
'Supported Files : XLSX')
|
||||
// Add more Text widgets for additional lines of text
|
||||
@ -776,7 +778,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius:
|
||||
BorderRadius.circular(10), // 👈 set your desired radius
|
||||
BorderRadius.circular(10), // 👈 set your desired radius
|
||||
),
|
||||
// width: double.infinity, // take full width
|
||||
// height: MediaQuery.of(context).size.height * 0.8, // 80% of screen height
|
||||
@ -835,10 +837,10 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
color: Color(0x98FFFCE5), // Semi-transparent background
|
||||
child: Center(
|
||||
child: // Your GIF loader widget
|
||||
Image.asset(
|
||||
height: 60,
|
||||
width: 60,
|
||||
'assets/nhance-loader.gif'), // Adjust path to your GIF loader
|
||||
Image.asset(
|
||||
height: 60,
|
||||
width: 60,
|
||||
'assets/nhance-loader.gif'), // Adjust path to your GIF loader
|
||||
),
|
||||
),
|
||||
Align(
|
||||
@ -853,14 +855,14 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
}
|
||||
|
||||
Widget buildDropdownField<T>(
|
||||
String label,
|
||||
void Function(T?) onChanged,
|
||||
bool readOnly,
|
||||
List<Map<String, dynamic>> itemsList,
|
||||
String displayField,
|
||||
T? selectedValue, {
|
||||
String valueKey = 'id',
|
||||
}) {
|
||||
String label,
|
||||
void Function(T?) onChanged,
|
||||
bool readOnly,
|
||||
List<Map<String, dynamic>> itemsList,
|
||||
String displayField,
|
||||
T? selectedValue, {
|
||||
String valueKey = 'id',
|
||||
}) {
|
||||
return DropdownButtonFormField<T>(
|
||||
value: selectedValue,
|
||||
decoration: InputDecoration(labelText: label),
|
||||
@ -868,7 +870,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
return DropdownMenuItem<T>(
|
||||
value: item[valueKey] as T, // ✅ cast to generic type
|
||||
child:
|
||||
Text(item[displayField].toString()), // always display as String
|
||||
Text(item[displayField].toString()), // always display as String
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: readOnly ? null : onChanged,
|
||||
@ -899,14 +901,14 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
itemCount: _paginatedData.length + 2,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) return _buildHeader();
|
||||
if (index == _paginatedData.length + 1) return _buildPagination(context);
|
||||
if (index == _paginatedData.length + 1)
|
||||
return _buildPagination(context);
|
||||
|
||||
final item = _paginatedData[index - 1];
|
||||
return _buildDataRow(item);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
@ -1047,7 +1049,10 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
message: "Click to Download", // 📝 Tooltip text
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
getHrFileDownload(item['id'],item['file_name']); // ✅ Call your API/download logic
|
||||
getHrFileDownload(
|
||||
item['id'],
|
||||
item[
|
||||
'file_name']); // ✅ Call your API/download logic
|
||||
},
|
||||
child: Text(
|
||||
item['file_name'] ?? '-',
|
||||
@ -1094,13 +1099,9 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
child: const Row(
|
||||
children: [
|
||||
Expanded(flex: 4, child: Text('File Name', style: _headerStyle)),
|
||||
Expanded(
|
||||
flex: 3, child: Text('File Action', style: _headerStyle)),
|
||||
Expanded(
|
||||
flex: 2, child: Text('Created At', style: _headerStyle)),
|
||||
Expanded(
|
||||
flex: 2, child: Text('Status', style: _headerStyle))
|
||||
|
||||
Expanded(flex: 3, child: Text('File Action', style: _headerStyle)),
|
||||
Expanded(flex: 2, child: Text('Created At', style: _headerStyle)),
|
||||
Expanded(flex: 2, child: Text('Status', style: _headerStyle))
|
||||
],
|
||||
),
|
||||
);
|
||||
@ -1124,79 +1125,126 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
);
|
||||
|
||||
Widget _buildPagination(BuildContext context) {
|
||||
return Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
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; // Reset to first page when rows per page changes
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _currentPage > 1
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage--;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_left),
|
||||
),
|
||||
for (int i = 1;
|
||||
i <= (filteredData.length / _rowsPerPage).ceil();
|
||||
i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _currentPage == i
|
||||
? Color(0xFF00A6A6)
|
||||
: Colors.grey[300],
|
||||
foregroundColor:
|
||||
_currentPage == i ? Colors.white : Colors.black,
|
||||
minimumSize: Size(36, 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentPage = i;
|
||||
});
|
||||
},
|
||||
child: Text(i.toString()),
|
||||
),
|
||||
final totalPages = (filteredData.length / _rowsPerPage).ceil();
|
||||
const visiblePageCount = 5;
|
||||
|
||||
List<int> getVisiblePages() {
|
||||
if (totalPages <= visiblePageCount) {
|
||||
return List.generate(totalPages, (i) => i + 1);
|
||||
}
|
||||
|
||||
if (_currentPage <= 3) {
|
||||
return [1, 2, 3, 4, 5];
|
||||
} else if (_currentPage >= totalPages - 2) {
|
||||
return [
|
||||
totalPages - 4,
|
||||
totalPages - 3,
|
||||
totalPages - 2,
|
||||
totalPages - 1,
|
||||
totalPages
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
_currentPage - 2,
|
||||
_currentPage - 1,
|
||||
_currentPage,
|
||||
_currentPage + 1,
|
||||
_currentPage + 2,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
List<int> visiblePages = getVisiblePages();
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
// Dropdown for rows per page
|
||||
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;
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed:
|
||||
_currentPage < (filteredData.length / _rowsPerPage).ceil()
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage++;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_right),
|
||||
),
|
||||
],
|
||||
|
||||
// Previous button
|
||||
IconButton(
|
||||
onPressed: _currentPage > 1
|
||||
? () => setState(() => _currentPage--)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
|
||||
// First page + left ellipsis
|
||||
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),
|
||||
|
||||
// Right ellipsis + last page
|
||||
if (!visiblePages.contains(totalPages))
|
||||
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 _buildPageButton(int page) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
_currentPage == page ? const Color(0xFF00A6A6) : Colors.grey[300],
|
||||
foregroundColor: _currentPage == page ? Colors.white : Colors.black,
|
||||
minimumSize: const Size(36, 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentPage = page;
|
||||
});
|
||||
},
|
||||
child: Text(page.toString()),
|
||||
),
|
||||
]);
|
||||
);
|
||||
}
|
||||
|
||||
String formatDate(String? dateString) {
|
||||
@ -1209,9 +1257,4 @@ class _postFileUploadState extends State<postFileUpload> {
|
||||
return '-';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -268,7 +268,7 @@ class _ActivePolicieState extends State<ActivePolicies> {
|
||||
|
||||
print("logicalWidth - $logicalWidth");
|
||||
print("logicalHeight - $logicalHeight");
|
||||
return GestureDetector(
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
print("policytab - $policy");
|
||||
@ -277,7 +277,8 @@ class _ActivePolicieState extends State<ActivePolicies> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => hrPolicyDetails(
|
||||
ClientId: policy['client_id'].toString(), // <-- from map
|
||||
policyTypeId: policy['policy_type_id'].toString(), // <-- from map
|
||||
policyTypeId:
|
||||
policy['policy_type_id'].toString(), // <-- from map
|
||||
ClientPoliyId: policy['client_policy_id'].toString(),
|
||||
clientBranchId: widget.empClientBranchId,
|
||||
Token: widget.postToken,
|
||||
@ -419,7 +420,7 @@ class _ActivePolicieState extends State<ActivePolicies> {
|
||||
|
||||
Widget buildTab(String title, int index) {
|
||||
final isSelected = selectedIndex == index + 1;
|
||||
return GestureDetector(
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedIndex = index + 1;
|
||||
|
||||
@ -161,7 +161,7 @@ class _CdPolicieState extends State<CdPolicies> {
|
||||
List<List<String>> rows = [];
|
||||
|
||||
// Header
|
||||
rows.add(['Insurer Name', 'CD Account number', 'Current Balance']);
|
||||
rows.add(['Insurer Name', 'CD Account Number', 'Current Balance']);
|
||||
|
||||
// Data rows
|
||||
for (var item in data) {
|
||||
@ -527,7 +527,7 @@ class _CdPolicieState extends State<CdPolicies> {
|
||||
children: [
|
||||
Expanded(flex: 4, child: Text('Insurer Name', style: _headerStyle)),
|
||||
Expanded(
|
||||
flex: 3, child: Text('CD Account number', style: _headerStyle)),
|
||||
flex: 3, child: Text('CD Account Number', style: _headerStyle)),
|
||||
Expanded(
|
||||
flex: 2, child: Text('Current Balance', style: _headerStyle)),
|
||||
Expanded(flex: 1, child: Text('Actions', style: _headerStyle)),
|
||||
@ -554,79 +554,126 @@ class _CdPolicieState extends State<CdPolicies> {
|
||||
);
|
||||
|
||||
Widget _buildPagination(BuildContext context) {
|
||||
return Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
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; // Reset to first page when rows per page changes
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _currentPage > 1
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage--;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_left),
|
||||
),
|
||||
for (int i = 1;
|
||||
i <= (filteredData.length / _rowsPerPage).ceil();
|
||||
i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _currentPage == i
|
||||
? Color(0xFF00A6A6)
|
||||
: Colors.grey[300],
|
||||
foregroundColor:
|
||||
_currentPage == i ? Colors.white : Colors.black,
|
||||
minimumSize: Size(36, 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentPage = i;
|
||||
});
|
||||
},
|
||||
child: Text(i.toString()),
|
||||
),
|
||||
final totalPages = (filteredData.length / _rowsPerPage).ceil();
|
||||
const visiblePageCount = 5;
|
||||
|
||||
List<int> getVisiblePages() {
|
||||
if (totalPages <= visiblePageCount) {
|
||||
return List.generate(totalPages, (i) => i + 1);
|
||||
}
|
||||
|
||||
if (_currentPage <= 3) {
|
||||
return [1, 2, 3, 4, 5];
|
||||
} else if (_currentPage >= totalPages - 2) {
|
||||
return [
|
||||
totalPages - 4,
|
||||
totalPages - 3,
|
||||
totalPages - 2,
|
||||
totalPages - 1,
|
||||
totalPages
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
_currentPage - 2,
|
||||
_currentPage - 1,
|
||||
_currentPage,
|
||||
_currentPage + 1,
|
||||
_currentPage + 2,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
List<int> visiblePages = getVisiblePages();
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
// Dropdown for rows per page
|
||||
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;
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed:
|
||||
_currentPage < (filteredData.length / _rowsPerPage).ceil()
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage++;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_right),
|
||||
),
|
||||
],
|
||||
|
||||
// Previous button
|
||||
IconButton(
|
||||
onPressed: _currentPage > 1
|
||||
? () => setState(() => _currentPage--)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
|
||||
// First page + left ellipsis
|
||||
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),
|
||||
|
||||
// Right ellipsis + last page
|
||||
if (!visiblePages.contains(totalPages))
|
||||
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 _buildPageButton(int page) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
_currentPage == page ? const Color(0xFF00A6A6) : Colors.grey[300],
|
||||
foregroundColor: _currentPage == page ? Colors.white : Colors.black,
|
||||
minimumSize: const Size(36, 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentPage = page;
|
||||
});
|
||||
},
|
||||
child: Text(page.toString()),
|
||||
),
|
||||
]);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -715,16 +715,20 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
||||
),
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 14, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF7BD9B6),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(item['status'] ?? '-', style: _dataBold)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 14, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Color(0xFF7BD9B6),
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
),
|
||||
child: Text(item['status'] ?? '-', style: _dataBold)),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@ -736,7 +740,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
||||
child: Text(item['ticket_created_date'] ?? '-', style: _dataBold),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
flex: 2,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@ -815,79 +819,126 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
||||
);
|
||||
|
||||
Widget _buildPagination(BuildContext context) {
|
||||
return Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
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; // Reset to first page when rows per page changes
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed: _currentPage > 1
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage--;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_left),
|
||||
),
|
||||
for (int i = 1;
|
||||
i <= (filteredData.length / _rowsPerPage).ceil();
|
||||
i++)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _currentPage == i
|
||||
? Color(0xFF00A6A6)
|
||||
: Colors.grey[300],
|
||||
foregroundColor:
|
||||
_currentPage == i ? Colors.white : Colors.black,
|
||||
minimumSize: Size(36, 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentPage = i;
|
||||
});
|
||||
},
|
||||
child: Text(i.toString()),
|
||||
),
|
||||
final totalPages = (filteredData.length / _rowsPerPage).ceil();
|
||||
const visiblePageCount = 5;
|
||||
|
||||
List<int> getVisiblePages() {
|
||||
if (totalPages <= visiblePageCount) {
|
||||
return List.generate(totalPages, (i) => i + 1);
|
||||
}
|
||||
|
||||
if (_currentPage <= 3) {
|
||||
return [1, 2, 3, 4, 5];
|
||||
} else if (_currentPage >= totalPages - 2) {
|
||||
return [
|
||||
totalPages - 4,
|
||||
totalPages - 3,
|
||||
totalPages - 2,
|
||||
totalPages - 1,
|
||||
totalPages
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
_currentPage - 2,
|
||||
_currentPage - 1,
|
||||
_currentPage,
|
||||
_currentPage + 1,
|
||||
_currentPage + 2,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
List<int> visiblePages = getVisiblePages();
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
// Dropdown for rows per page
|
||||
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;
|
||||
});
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
onPressed:
|
||||
_currentPage < (filteredData.length / _rowsPerPage).ceil()
|
||||
? () {
|
||||
setState(() {
|
||||
_currentPage++;
|
||||
});
|
||||
}
|
||||
: null,
|
||||
icon: Icon(Icons.chevron_right),
|
||||
),
|
||||
],
|
||||
|
||||
// Previous button
|
||||
IconButton(
|
||||
onPressed: _currentPage > 1
|
||||
? () => setState(() => _currentPage--)
|
||||
: null,
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
|
||||
// First page + left ellipsis
|
||||
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),
|
||||
|
||||
// Right ellipsis + last page
|
||||
if (!visiblePages.contains(totalPages))
|
||||
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 _buildPageButton(int page) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor:
|
||||
_currentPage == page ? const Color(0xFF00A6A6) : Colors.grey[300],
|
||||
foregroundColor: _currentPage == page ? Colors.white : Colors.black,
|
||||
minimumSize: const Size(36, 36),
|
||||
padding: EdgeInsets.zero,
|
||||
),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_currentPage = page;
|
||||
});
|
||||
},
|
||||
child: Text(page.toString()),
|
||||
),
|
||||
]);
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildName(BuildContext context) {
|
||||
|
||||
@ -239,7 +239,7 @@ class _PreEnrollmentState extends State<PreEnrollment> {
|
||||
|
||||
print("logicalWidth - $logicalWidth");
|
||||
print("logicalHeight - $logicalHeight");
|
||||
return GestureDetector(
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
print("policytab - $policy");
|
||||
@ -248,7 +248,8 @@ class _PreEnrollmentState extends State<PreEnrollment> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => hrPolicyDetails(
|
||||
ClientId: policy['client_id'].toString(), // <-- from map
|
||||
policyTypeId: policy['policy_type_id'].toString(), // <-- from map
|
||||
policyTypeId:
|
||||
policy['policy_type_id'].toString(), // <-- from map
|
||||
ClientPoliyId: policy['client_policy_id'].toString(),
|
||||
clientBranchId: widget.enrollmentClientBranchId,
|
||||
Token: widget.enrollToken,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user