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 '../service/token_storage_service.dart';
|
||||||
import 'branch_card_widget.dart';
|
import 'branch_card_widget.dart';
|
||||||
|
|
||||||
|
|
||||||
class BranchSelectionPage extends StatefulWidget {
|
class BranchSelectionPage extends StatefulWidget {
|
||||||
const BranchSelectionPage({Key? key}) : super(key: key);
|
const BranchSelectionPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@ -86,15 +85,16 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
|||||||
|
|
||||||
final empAllowedModules = allowedModules['post'];
|
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'];
|
// final empAllowed_modules = decodedToken?['allowed_modules'][0]['post'];
|
||||||
// await prefs.setString('empAllowed_modules', jsonEncode(empAllowed_modules));
|
// await prefs.setString('empAllowed_modules', jsonEncode(empAllowed_modules));
|
||||||
|
|
||||||
|
|
||||||
//Pre Token Decode Details
|
//Pre Token Decode Details
|
||||||
final enrollmentEmpClientBranchId = decodedToken?['pre_branch_id'];
|
final enrollmentEmpClientBranchId = decodedToken?['pre_branch_id'];
|
||||||
await prefs.setString('enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
await prefs.setString(
|
||||||
|
'enrollmentEmpClientBranchId', enrollmentEmpClientBranchId);
|
||||||
|
|
||||||
final enrollmentEmpPrimaryId = decodedToken?['pre_hr_id'];
|
final enrollmentEmpPrimaryId = decodedToken?['pre_hr_id'];
|
||||||
await prefs.setString('enrollmentEmpPrimaryId', enrollmentEmpPrimaryId);
|
await prefs.setString('enrollmentEmpPrimaryId', enrollmentEmpPrimaryId);
|
||||||
@ -105,10 +105,10 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
|||||||
final enrollmentHrId = decodedToken?['pre_hr_id'];
|
final enrollmentHrId = decodedToken?['pre_hr_id'];
|
||||||
await prefs.setString('enrollmentHrId', enrollmentHrId);
|
await prefs.setString('enrollmentHrId', enrollmentHrId);
|
||||||
|
|
||||||
|
|
||||||
final enrollmentAllowedModules = allowedModules['pre'];
|
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'];
|
// final enrollmentAllowed_modules = decodedToken?['allowed_modules'][1]['pre'];
|
||||||
// await prefs.setString('enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules));
|
// await prefs.setString('enrollmentAllowed_modules', jsonEncode(enrollmentAllowed_modules));
|
||||||
@ -118,7 +118,6 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
|||||||
await prefs.setString('token', token!);
|
await prefs.setString('token', token!);
|
||||||
ToastHelper.showSuccessToast(context, 'Successfully Login');
|
ToastHelper.showSuccessToast(context, 'Successfully Login');
|
||||||
Navigator.pushReplacementNamed(context, 'hrDashboard');
|
Navigator.pushReplacementNamed(context, 'hrDashboard');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,21 +195,22 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 25),
|
SizedBox(height: 25),
|
||||||
|
|
||||||
Container(
|
Container(
|
||||||
height: gridHeight, // Shows approximately 3 rows
|
height: gridHeight, // Shows approximately 3 rows
|
||||||
child: branches.isEmpty
|
child: branches.isEmpty
|
||||||
? Center(
|
? Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'No branches available',
|
'No branches available',
|
||||||
style: TextStyle(fontSize: 16, color: Colors.grey),
|
style: TextStyle(
|
||||||
|
fontSize: 16, color: Colors.grey),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: GridView.builder(
|
: GridView.builder(
|
||||||
// Enable scrolling if content exceeds height
|
// Enable scrolling if content exceeds height
|
||||||
physics: ClampingScrollPhysics(),
|
physics: ClampingScrollPhysics(),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
gridDelegate:
|
||||||
|
SliverGridDelegateWithFixedCrossAxisCount(
|
||||||
crossAxisCount: crossAxisCount,
|
crossAxisCount: crossAxisCount,
|
||||||
childAspectRatio: childAspectRatio,
|
childAspectRatio: childAspectRatio,
|
||||||
crossAxisSpacing: 15,
|
crossAxisSpacing: 15,
|
||||||
@ -220,17 +220,17 @@ class _BranchSelectionPageState extends State<BranchSelectionPage> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final branch = branches[index];
|
final branch = branches[index];
|
||||||
return BranchCard(
|
return BranchCard(
|
||||||
clientName: branch['client_name'] ?? 'Unknown Client',
|
clientName: branch['client_name'] ??
|
||||||
branchName: branch['branch_name'] ?? 'Unknown Branch',
|
'Unknown Client',
|
||||||
|
branchName: branch['branch_name'] ??
|
||||||
|
'Unknown Branch',
|
||||||
isSelected: selectedIndex == index,
|
isSelected: selectedIndex == index,
|
||||||
onTap: () => _selectBranch(index),
|
onTap: () => _selectBranch(index),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(height: 24),
|
SizedBox(height: 24),
|
||||||
|
|
||||||
Center(
|
Center(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
width: 120,
|
width: 120,
|
||||||
|
|||||||
@ -336,7 +336,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
'Transaction Details - ${widget.insurerName} (${widget.cdMasterAccountNo})',
|
'Transaction Details - ${widget.insurerName} (${widget.cdMasterAccountNo})',
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 18,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Color(0xFF101010),
|
color: Color(0xFF101010),
|
||||||
),
|
),
|
||||||
@ -346,7 +346,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 10),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
@ -434,7 +434,7 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
'Export',
|
'Export',
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 16,
|
fontSize: 14,
|
||||||
color: Color(0xFFFFFFFF),
|
color: Color(0xFFFFFFFF),
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
letterSpacing: 1),
|
letterSpacing: 1),
|
||||||
@ -561,7 +561,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
'Date',
|
'Date',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -570,7 +572,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
'Record Date',
|
'Record Date',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -579,7 +583,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
'Unit',
|
'Unit',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -588,16 +594,20 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
'Policy',
|
'Policy',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 3,
|
||||||
child: Text(
|
child: Text(
|
||||||
'Endorsement No',
|
'Endorsement No',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -606,7 +616,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
'Sub Type',
|
'Sub Type',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -615,7 +627,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
'Credit',
|
'Credit',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -624,7 +638,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
'Debit',
|
'Debit',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -633,7 +649,9 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
'Balance',
|
'Balance',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -642,16 +660,20 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
'Description',
|
'Description',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
color: Color(0xFF000000), fontWeight: FontWeight.bold),
|
fontSize: 12,
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 2,
|
||||||
child: Text(
|
child: Text(
|
||||||
'User',
|
'User',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(
|
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(
|
child: Text(
|
||||||
formatDateNextLine(item['created_at']),
|
formatDateNextLine(item['created_at']),
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -691,7 +716,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
item['record_date'] ?? '-',
|
item['record_date'] ?? '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -700,7 +728,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
// 'The Kancheepuram District Consumers Operative Wholesale Stores Limited-5526',
|
// 'The Kancheepuram District Consumers Operative Wholesale Stores Limited-5526',
|
||||||
item['unit'] ?? '-',
|
item['unit'] ?? '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -711,18 +742,25 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
item['policy_type'].toString().trim().isNotEmpty &&
|
item['policy_type'].toString().trim().isNotEmpty &&
|
||||||
item['policy_no'] != null &&
|
item['policy_no'] != null &&
|
||||||
item['policy_no'].toString().trim().isNotEmpty
|
item['policy_no'].toString().trim().isNotEmpty
|
||||||
|
// ? '${item['policy_no']}'
|
||||||
? '${item['policy_type']} - ${item['policy_no']}'
|
? '${item['policy_type']} - ${item['policy_no']}'
|
||||||
: '-',
|
: '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 3,
|
||||||
child: Text(
|
child: Text(
|
||||||
item['endorsement_no'] ?? '-',
|
item['endorsement_no'] ?? '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -730,7 +768,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
item['sub_type'] ?? '-',
|
item['sub_type'] ?? '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -740,7 +781,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
? '₹${item['amount']}'
|
? '₹${item['amount']}'
|
||||||
: '-',
|
: '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -750,7 +794,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
? '₹${item['amount']}'
|
? '₹${item['amount']}'
|
||||||
: '-',
|
: '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -758,7 +805,10 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
"₹${item['balance'] ?? '-'}",
|
"₹${item['balance'] ?? '-'}",
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -766,15 +816,21 @@ class _cdTransactionDetailsState extends State<cdTransactionDetails> {
|
|||||||
child: Text(
|
child: Text(
|
||||||
item['description'] ?? '-',
|
item['description'] ?? '-',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
style: GoogleFonts.poppins(color: Color(0xFF000000)),
|
style: GoogleFonts.poppins(
|
||||||
|
color: Color(0xFF000000),
|
||||||
|
fontSize: 12,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 2,
|
||||||
child: Text(
|
child: Text(
|
||||||
item['username'] ?? '-',
|
item['username'] ?? '-',
|
||||||
textAlign: TextAlign.left,
|
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();
|
// _checkTokens();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Future<void> logout(BuildContext context) async {
|
Future<void> logout(BuildContext context) async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
// final String? hrtoken = prefs.getString('_postToken');
|
// final String? hrtoken = prefs.getString('_postToken');
|
||||||
@ -43,15 +42,21 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
|||||||
preferredSize: widget.preferredSize,
|
preferredSize: widget.preferredSize,
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: Responsive.isDesktop(context)
|
// padding: Responsive.isDesktop(context)
|
||||||
? EdgeInsets.symmetric(horizontal: 16.0)
|
// ? EdgeInsets.symmetric(horizontal: 46.0)
|
||||||
: EdgeInsets.symmetric(horizontal: 0),
|
// : EdgeInsets.symmetric(horizontal: 0),
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: MediaQuery.of(context).size.width *
|
||||||
|
(Responsive.isDesktop(context) ? 0.03 : 0.02),
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
// Logo Column
|
// Logo Column
|
||||||
Expanded(
|
// Expanded(
|
||||||
flex: Responsive.isDesktop(context) ? 3 : 9,
|
// // flex: Responsive.isDesktop(context) ? 1 : 9,
|
||||||
child: Row(
|
// child:
|
||||||
|
Row(
|
||||||
mainAxisAlignment: Responsive.isDesktop(context)
|
mainAxisAlignment: Responsive.isDesktop(context)
|
||||||
? MainAxisAlignment.spaceEvenly
|
? MainAxisAlignment.spaceEvenly
|
||||||
: MainAxisAlignment.start,
|
: MainAxisAlignment.start,
|
||||||
@ -67,26 +72,15 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
// 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)
|
// AdaptiveNavBar Column
|
||||||
|
|
||||||
|
// Expanded(
|
||||||
|
// // flex: Responsive.isDesktop(context) ? 1 : 9,
|
||||||
|
// child:
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
NavBarItem(
|
NavBarItem(
|
||||||
text: "Change Branch",
|
text: "Change Branch",
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
@ -110,15 +104,65 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
|||||||
Navigator.pushNamed(context, 'branchSelection');
|
Navigator.pushNamed(context, 'branchSelection');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
NavBarItem(
|
NavBarItem(
|
||||||
text: "Logout",
|
text: "Logout",
|
||||||
onTap: () async {
|
onTap: () => logout(context),
|
||||||
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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -491,42 +491,23 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => widget.TokenType != "post" ? excelVerify(
|
builder: (context) => widget
|
||||||
ClientId:
|
.TokenType !=
|
||||||
widget.ClientId, // <-- from map
|
"post"
|
||||||
policyTypeId: widget.policyTypeId,
|
? excelVerify(
|
||||||
ClientPoliyId: widget.ClientPoliyId,
|
ClientId: widget
|
||||||
|
.ClientId, // <-- from map
|
||||||
|
policyTypeId:
|
||||||
|
widget.policyTypeId,
|
||||||
|
ClientPoliyId:
|
||||||
|
widget.ClientPoliyId,
|
||||||
clientBranchId:
|
clientBranchId:
|
||||||
widget.clientBranchId,
|
widget.clientBranchId,
|
||||||
Token: widget.Token,
|
Token: widget.Token,
|
||||||
TokenType: widget.TokenType,
|
TokenType: widget.TokenType,
|
||||||
cardType: widget.cardType,
|
cardType: widget.cardType,
|
||||||
cardPolicyNo: widget.cardPolicyNo,
|
cardPolicyNo:
|
||||||
cardInsurer_name:
|
widget.cardPolicyNo,
|
||||||
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:
|
cardInsurer_name:
|
||||||
widget.cardInsurer_name,
|
widget.cardInsurer_name,
|
||||||
cardPolicy_name:
|
cardPolicy_name:
|
||||||
@ -542,14 +523,42 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
// ClientBranchId: widget.HrId,
|
// ClientBranchId: widget.HrId,
|
||||||
// PolicyType: widget.cardType,
|
// 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);
|
// exportToCsv(filteredData);
|
||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Color(0xFFE26728),
|
backgroundColor: Color(0xFFE26728),
|
||||||
padding: EdgeInsets.all(
|
padding:
|
||||||
10), // Internal padding
|
EdgeInsets.all(10), // Internal padding
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(
|
borderRadius: BorderRadius.circular(
|
||||||
10), // Border radius
|
10), // Border radius
|
||||||
@ -803,7 +812,6 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: _paginatedData.mapIndexed((index, item) {
|
children: _paginatedData.mapIndexed((index, item) {
|
||||||
return Container(
|
return Container(
|
||||||
|
|
||||||
// margin: const EdgeInsets.only(bottom: 8),
|
// margin: const EdgeInsets.only(bottom: 8),
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(vertical: 5, horizontal: 16),
|
const EdgeInsets.symmetric(vertical: 5, horizontal: 16),
|
||||||
@ -844,7 +852,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if(widget.policyTypeId != '6' && widget.policyTypeId != '7')
|
if (widget.policyTypeId != '6' &&
|
||||||
|
widget.policyTypeId != '7')
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -930,6 +939,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
if (widget.TokenType != "pre" && (hasAnyEcardLink || hasModule))
|
if (widget.TokenType != "pre" && (hasAnyEcardLink || hasModule))
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 3,
|
flex: 3,
|
||||||
@ -1015,7 +1025,6 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
// if (widget.TokenType != "pre" &&
|
|
||||||
// (hasAnyEcardLink || hasModule))
|
// (hasAnyEcardLink || hasModule))
|
||||||
// Expanded(
|
// Expanded(
|
||||||
// flex: 3,
|
// flex: 3,
|
||||||
@ -1093,84 +1102,207 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
// ),
|
// ),
|
||||||
|
_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),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Row(
|
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,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
|
// Dropdown for rows per page
|
||||||
DropdownButton<int>(
|
DropdownButton<int>(
|
||||||
value: _rowsPerPage,
|
value: _rowsPerPage,
|
||||||
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,
|
||||||
child: Text(
|
child: Text(' $value ',
|
||||||
' $value ',
|
style: GoogleFonts.poppins(fontSize: 15)),
|
||||||
style: GoogleFonts.poppins(fontSize: 15),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: (newValue) {
|
onChanged: (newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_rowsPerPage = newValue!;
|
_rowsPerPage = newValue!;
|
||||||
_currentPage =
|
_currentPage = 1;
|
||||||
1; // Reset to first page when rows per page changes
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Previous button
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _currentPage > 1
|
onPressed: _currentPage > 1
|
||||||
? () {
|
? () => setState(() => _currentPage--)
|
||||||
setState(() {
|
|
||||||
_currentPage--;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
: null,
|
||||||
icon: Icon(Icons.chevron_left),
|
icon: const Icon(Icons.chevron_left),
|
||||||
),
|
),
|
||||||
for (int i = 1;
|
|
||||||
i <= (filteredData.length / _rowsPerPage).ceil();
|
// First page + left ellipsis
|
||||||
i++)
|
if (!visiblePages.contains(1))
|
||||||
Padding(
|
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),
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: _currentPage == i
|
backgroundColor:
|
||||||
? Color(0xFF00A6A6)
|
_currentPage == page ? const Color(0xFF00A6A6) : Colors.grey[300],
|
||||||
: Colors.grey[300],
|
foregroundColor: _currentPage == page ? Colors.white : Colors.black,
|
||||||
foregroundColor:
|
minimumSize: const Size(36, 36),
|
||||||
_currentPage == i ? Colors.white : Colors.black,
|
|
||||||
minimumSize: Size(36, 36),
|
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
),
|
),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_currentPage = i;
|
_currentPage = page;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: Text(i.toString()),
|
child: Text(page.toString()),
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
onPressed: _currentPage <
|
|
||||||
(filteredData.length / _rowsPerPage).ceil()
|
|
||||||
? () {
|
|
||||||
setState(() {
|
|
||||||
_currentPage++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
icon: Icon(Icons.chevron_right),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,7 +109,6 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
String? selectedValue;
|
String? selectedValue;
|
||||||
String? _selectedAction;
|
String? _selectedAction;
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -174,7 +173,6 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
Future<void> getFileUploadMasterDetails() async {
|
Future<void> getFileUploadMasterDetails() async {
|
||||||
print('9');
|
print('9');
|
||||||
try {
|
try {
|
||||||
|
|
||||||
final response = await apiService.getFileUploadMastersToApi(widget.Token);
|
final response = await apiService.getFileUploadMastersToApi(widget.Token);
|
||||||
|
|
||||||
if (response['status'] == true) {
|
if (response['status'] == true) {
|
||||||
@ -210,8 +208,8 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
empPrimaryId = prefs.getString('empPrimaryId');
|
empPrimaryId = prefs.getString('empPrimaryId');
|
||||||
print('9');
|
print('9');
|
||||||
try {
|
try {
|
||||||
|
final response = await apiService.getFileListToApi(
|
||||||
final response = await apiService.getFileListToApi(empPrimaryId,widget.cardPolicyNo,widget.Token);
|
empPrimaryId, widget.cardPolicyNo, widget.Token);
|
||||||
|
|
||||||
if (response['status'] == 'success') {
|
if (response['status'] == 'success') {
|
||||||
print('getThrFileList');
|
print('getThrFileList');
|
||||||
@ -252,7 +250,6 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
try {
|
try {
|
||||||
print("PDF Downloaded");
|
print("PDF Downloaded");
|
||||||
@ -509,7 +506,8 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
Container(
|
Container(
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center, // 👈 fix alignment
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.center, // 👈 fix alignment
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 8,
|
flex: 8,
|
||||||
@ -571,10 +569,12 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
selectedKey = value;
|
selectedKey = value;
|
||||||
selectedValue = getFileUploadMasterList
|
selectedValue = getFileUploadMasterList
|
||||||
.firstWhere((item) => item['key'] == value)['value'];
|
.firstWhere((item) =>
|
||||||
|
item['key'] == value)['value'];
|
||||||
});
|
});
|
||||||
debugPrint("Selected Key: $selectedKey");
|
debugPrint("Selected Key: $selectedKey");
|
||||||
debugPrint("Selected Value: $selectedValue");
|
debugPrint(
|
||||||
|
"Selected Value: $selectedValue");
|
||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
getFileUploadMasterList,
|
getFileUploadMasterList,
|
||||||
@ -584,14 +584,12 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
@ -632,8 +630,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
// ),
|
// ),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
@ -643,30 +640,21 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
color: Colors.grey[200],
|
color: Colors.grey[200],
|
||||||
height: 180,
|
height: 180,
|
||||||
child: DragTarget(
|
child: DragTarget(
|
||||||
onAccept: (html.File
|
onAccept: (html.File droppedFile) {
|
||||||
droppedFile) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
fileName =
|
fileName = droppedFile.name;
|
||||||
droppedFile.name;
|
|
||||||
});
|
});
|
||||||
_dragAndDropFile(
|
_dragAndDropFile(droppedFile);
|
||||||
droppedFile);
|
|
||||||
},
|
},
|
||||||
builder:
|
builder: (BuildContext context,
|
||||||
(BuildContext context,
|
List<String?> candidateData,
|
||||||
List<String?>
|
List<dynamic> rejectedData) {
|
||||||
candidateData,
|
|
||||||
List<dynamic>
|
|
||||||
rejectedData) {
|
|
||||||
return Container(
|
return Container(
|
||||||
alignment:
|
alignment: Alignment.center,
|
||||||
Alignment.center,
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment
|
MainAxisAlignment.center,
|
||||||
.center,
|
|
||||||
children: [
|
children: [
|
||||||
|
|
||||||
fileName != null
|
fileName != null
|
||||||
? Column(
|
? Column(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
@ -676,8 +664,7 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
Icon(
|
Icon(
|
||||||
Icons
|
Icons
|
||||||
.upload_file, // Choose the appropriate icon
|
.upload_file, // Choose the appropriate icon
|
||||||
size:
|
size: 35,
|
||||||
35,
|
|
||||||
color: Color(
|
color: Color(
|
||||||
0xFFE26728), // Adjust the size as needed
|
0xFFE26728), // Adjust the size as needed
|
||||||
),
|
),
|
||||||
@ -694,28 +681,37 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
height:
|
height:
|
||||||
25), // Add some space between the icon and text
|
25), // Add some space between the icon and text
|
||||||
MouseRegion(
|
MouseRegion(
|
||||||
cursor:
|
cursor: SystemMouseCursors
|
||||||
SystemMouseCursors.click, // Set cursor to pointer on hover
|
.click, // Set cursor to pointer on hover
|
||||||
child:
|
child:
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap:
|
onTap: () {
|
||||||
() {
|
|
||||||
resetErrorCount();
|
resetErrorCount();
|
||||||
},
|
},
|
||||||
child:
|
child:
|
||||||
const Row(
|
const Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.center,
|
MainAxisAlignment
|
||||||
|
.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
Icons.delete_forever, // Choose the remove icon
|
Icons
|
||||||
size: 20, // Adjust the size as needed
|
.delete_forever, // Choose the remove icon
|
||||||
color: Colors.red, // Set the color of 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
|
SizedBox(
|
||||||
|
width:
|
||||||
|
1), // Add some space between the icon and text
|
||||||
Text(
|
Text(
|
||||||
'Remove',
|
'Remove',
|
||||||
style: TextStyle(fontSize: 13, color: Color(0xFF727272)),
|
style: TextStyle(
|
||||||
|
fontSize:
|
||||||
|
13,
|
||||||
|
color:
|
||||||
|
Color(0xFF727272)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -725,31 +721,37 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
)
|
)
|
||||||
: ElevatedButton(
|
: ElevatedButton(
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
print('selectedValue $selectedValue'),
|
print(
|
||||||
if(selectedValue != null){
|
'selectedValue $selectedValue'),
|
||||||
|
if (selectedValue !=
|
||||||
|
null)
|
||||||
|
{
|
||||||
_uploadFile(),
|
_uploadFile(),
|
||||||
} else {
|
|
||||||
ToastHelper.showErrorToast(context, 'Please select file action')
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ToastHelper
|
||||||
|
.showErrorToast(
|
||||||
|
context,
|
||||||
|
'Please select file action')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'Select File',
|
'Select File',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color: Colors
|
||||||
Colors.white),
|
.white),
|
||||||
),
|
),
|
||||||
style: ElevatedButton
|
style:
|
||||||
|
ElevatedButton
|
||||||
.styleFrom(
|
.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
Color(
|
Color(
|
||||||
0xFFE26728),
|
0xFFE26728),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(height: 20),
|
||||||
height: 20),
|
if (fileName == null)
|
||||||
if (fileName ==
|
|
||||||
null)
|
|
||||||
Text(
|
Text(
|
||||||
'Supported Files : XLSX')
|
'Supported Files : XLSX')
|
||||||
// Add more Text widgets for additional lines of text
|
// Add more Text widgets for additional lines of text
|
||||||
@ -899,14 +901,14 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
itemCount: _paginatedData.length + 2,
|
itemCount: _paginatedData.length + 2,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
if (index == 0) return _buildHeader();
|
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];
|
final item = _paginatedData[index - 1];
|
||||||
return _buildDataRow(item);
|
return _buildDataRow(item);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// return Column(
|
// return Column(
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
// children: [
|
// children: [
|
||||||
@ -1047,7 +1049,10 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
message: "Click to Download", // 📝 Tooltip text
|
message: "Click to Download", // 📝 Tooltip text
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () {
|
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(
|
child: Text(
|
||||||
item['file_name'] ?? '-',
|
item['file_name'] ?? '-',
|
||||||
@ -1094,13 +1099,9 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
child: const Row(
|
child: const Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(flex: 4, child: Text('File Name', style: _headerStyle)),
|
Expanded(flex: 4, child: Text('File Name', style: _headerStyle)),
|
||||||
Expanded(
|
Expanded(flex: 3, child: Text('File Action', style: _headerStyle)),
|
||||||
flex: 3, child: Text('File Action', style: _headerStyle)),
|
Expanded(flex: 2, child: Text('Created At', style: _headerStyle)),
|
||||||
Expanded(
|
Expanded(flex: 2, child: Text('Status', style: _headerStyle))
|
||||||
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) {
|
Widget _buildPagination(BuildContext context) {
|
||||||
return Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
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(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
|
// Dropdown for rows per page
|
||||||
DropdownButton<int>(
|
DropdownButton<int>(
|
||||||
value: _rowsPerPage,
|
value: _rowsPerPage,
|
||||||
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,
|
||||||
child: Text(
|
child: Text(' $value ',
|
||||||
' $value ',
|
style: GoogleFonts.poppins(fontSize: 15)),
|
||||||
style: GoogleFonts.poppins(fontSize: 15),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: (newValue) {
|
onChanged: (newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_rowsPerPage = newValue!;
|
_rowsPerPage = newValue!;
|
||||||
_currentPage =
|
_currentPage = 1;
|
||||||
1; // Reset to first page when rows per page changes
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Previous button
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _currentPage > 1
|
onPressed: _currentPage > 1
|
||||||
? () {
|
? () => setState(() => _currentPage--)
|
||||||
setState(() {
|
|
||||||
_currentPage--;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
: null,
|
||||||
icon: Icon(Icons.chevron_left),
|
icon: const Icon(Icons.chevron_left),
|
||||||
),
|
),
|
||||||
for (int i = 1;
|
|
||||||
i <= (filteredData.length / _rowsPerPage).ceil();
|
// First page + left ellipsis
|
||||||
i++)
|
if (!visiblePages.contains(1))
|
||||||
Padding(
|
Row(children: [
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
_buildPageButton(1),
|
||||||
child: ElevatedButton(
|
const Padding(
|
||||||
style: ElevatedButton.styleFrom(
|
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||||
backgroundColor: _currentPage == i
|
child: Text("..."),
|
||||||
? 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()),
|
|
||||||
),
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
// 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(
|
IconButton(
|
||||||
onPressed:
|
onPressed: _currentPage < totalPages
|
||||||
_currentPage < (filteredData.length / _rowsPerPage).ceil()
|
? () => setState(() => _currentPage++)
|
||||||
? () {
|
|
||||||
setState(() {
|
|
||||||
_currentPage++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
: null,
|
||||||
icon: Icon(Icons.chevron_right),
|
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) {
|
String formatDate(String? dateString) {
|
||||||
@ -1209,9 +1257,4 @@ class _postFileUploadState extends State<postFileUpload> {
|
|||||||
return '-';
|
return '-';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -268,7 +268,7 @@ class _ActivePolicieState extends State<ActivePolicies> {
|
|||||||
|
|
||||||
print("logicalWidth - $logicalWidth");
|
print("logicalWidth - $logicalWidth");
|
||||||
print("logicalHeight - $logicalHeight");
|
print("logicalHeight - $logicalHeight");
|
||||||
return GestureDetector(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
print("policytab - $policy");
|
print("policytab - $policy");
|
||||||
@ -277,7 +277,8 @@ class _ActivePolicieState extends State<ActivePolicies> {
|
|||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => hrPolicyDetails(
|
builder: (context) => hrPolicyDetails(
|
||||||
ClientId: policy['client_id'].toString(), // <-- from map
|
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(),
|
ClientPoliyId: policy['client_policy_id'].toString(),
|
||||||
clientBranchId: widget.empClientBranchId,
|
clientBranchId: widget.empClientBranchId,
|
||||||
Token: widget.postToken,
|
Token: widget.postToken,
|
||||||
@ -419,7 +420,7 @@ class _ActivePolicieState extends State<ActivePolicies> {
|
|||||||
|
|
||||||
Widget buildTab(String title, int index) {
|
Widget buildTab(String title, int index) {
|
||||||
final isSelected = selectedIndex == index + 1;
|
final isSelected = selectedIndex == index + 1;
|
||||||
return GestureDetector(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedIndex = index + 1;
|
selectedIndex = index + 1;
|
||||||
|
|||||||
@ -161,7 +161,7 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
List<List<String>> rows = [];
|
List<List<String>> rows = [];
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
rows.add(['Insurer Name', 'CD Account number', 'Current Balance']);
|
rows.add(['Insurer Name', 'CD Account Number', 'Current Balance']);
|
||||||
|
|
||||||
// Data rows
|
// Data rows
|
||||||
for (var item in data) {
|
for (var item in data) {
|
||||||
@ -527,7 +527,7 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(flex: 4, child: Text('Insurer Name', style: _headerStyle)),
|
Expanded(flex: 4, child: Text('Insurer Name', style: _headerStyle)),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 3, child: Text('CD Account number', style: _headerStyle)),
|
flex: 3, child: Text('CD Account Number', style: _headerStyle)),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 2, child: Text('Current Balance', style: _headerStyle)),
|
flex: 2, child: Text('Current Balance', style: _headerStyle)),
|
||||||
Expanded(flex: 1, child: Text('Actions', style: _headerStyle)),
|
Expanded(flex: 1, child: Text('Actions', style: _headerStyle)),
|
||||||
@ -554,79 +554,126 @@ class _CdPolicieState extends State<CdPolicies> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildPagination(BuildContext context) {
|
Widget _buildPagination(BuildContext context) {
|
||||||
return Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
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(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
|
// Dropdown for rows per page
|
||||||
DropdownButton<int>(
|
DropdownButton<int>(
|
||||||
value: _rowsPerPage,
|
value: _rowsPerPage,
|
||||||
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,
|
||||||
child: Text(
|
child: Text(' $value ',
|
||||||
' $value ',
|
style: GoogleFonts.poppins(fontSize: 15)),
|
||||||
style: GoogleFonts.poppins(fontSize: 15),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: (newValue) {
|
onChanged: (newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_rowsPerPage = newValue!;
|
_rowsPerPage = newValue!;
|
||||||
_currentPage =
|
_currentPage = 1;
|
||||||
1; // Reset to first page when rows per page changes
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Previous button
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _currentPage > 1
|
onPressed: _currentPage > 1
|
||||||
? () {
|
? () => setState(() => _currentPage--)
|
||||||
setState(() {
|
|
||||||
_currentPage--;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
: null,
|
||||||
icon: Icon(Icons.chevron_left),
|
icon: const Icon(Icons.chevron_left),
|
||||||
),
|
),
|
||||||
for (int i = 1;
|
|
||||||
i <= (filteredData.length / _rowsPerPage).ceil();
|
// First page + left ellipsis
|
||||||
i++)
|
if (!visiblePages.contains(1))
|
||||||
Padding(
|
Row(children: [
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
_buildPageButton(1),
|
||||||
child: ElevatedButton(
|
const Padding(
|
||||||
style: ElevatedButton.styleFrom(
|
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||||
backgroundColor: _currentPage == i
|
child: Text("..."),
|
||||||
? 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()),
|
|
||||||
),
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
// 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(
|
IconButton(
|
||||||
onPressed:
|
onPressed: _currentPage < totalPages
|
||||||
_currentPage < (filteredData.length / _rowsPerPage).ceil()
|
? () => setState(() => _currentPage++)
|
||||||
? () {
|
|
||||||
setState(() {
|
|
||||||
_currentPage++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
: null,
|
||||||
icon: Icon(Icons.chevron_right),
|
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,9 +715,12 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 4,
|
flex: 4,
|
||||||
child: Align(
|
child: Row(
|
||||||
alignment: Alignment.bottomLeft,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
child: Container(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(horizontal: 14, vertical: 4),
|
const EdgeInsets.symmetric(horizontal: 14, vertical: 4),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -725,6 +728,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
borderRadius: BorderRadius.circular(6),
|
borderRadius: BorderRadius.circular(6),
|
||||||
),
|
),
|
||||||
child: Text(item['status'] ?? '-', style: _dataBold)),
|
child: Text(item['status'] ?? '-', style: _dataBold)),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -736,7 +740,7 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
child: Text(item['ticket_created_date'] ?? '-', style: _dataBold),
|
child: Text(item['ticket_created_date'] ?? '-', style: _dataBold),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 2,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
@ -815,79 +819,126 @@ class _ClaimsPolicieState extends State<ClaimsPolicies> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget _buildPagination(BuildContext context) {
|
Widget _buildPagination(BuildContext context) {
|
||||||
return Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
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(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
|
// Dropdown for rows per page
|
||||||
DropdownButton<int>(
|
DropdownButton<int>(
|
||||||
value: _rowsPerPage,
|
value: _rowsPerPage,
|
||||||
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,
|
||||||
child: Text(
|
child: Text(' $value ',
|
||||||
' $value ',
|
style: GoogleFonts.poppins(fontSize: 15)),
|
||||||
style: GoogleFonts.poppins(fontSize: 15),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
onChanged: (newValue) {
|
onChanged: (newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_rowsPerPage = newValue!;
|
_rowsPerPage = newValue!;
|
||||||
_currentPage =
|
_currentPage = 1;
|
||||||
1; // Reset to first page when rows per page changes
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
||||||
|
// Previous button
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: _currentPage > 1
|
onPressed: _currentPage > 1
|
||||||
? () {
|
? () => setState(() => _currentPage--)
|
||||||
setState(() {
|
|
||||||
_currentPage--;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
: null,
|
||||||
icon: Icon(Icons.chevron_left),
|
icon: const Icon(Icons.chevron_left),
|
||||||
),
|
),
|
||||||
for (int i = 1;
|
|
||||||
i <= (filteredData.length / _rowsPerPage).ceil();
|
// First page + left ellipsis
|
||||||
i++)
|
if (!visiblePages.contains(1))
|
||||||
Padding(
|
Row(children: [
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
_buildPageButton(1),
|
||||||
child: ElevatedButton(
|
const Padding(
|
||||||
style: ElevatedButton.styleFrom(
|
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||||
backgroundColor: _currentPage == i
|
child: Text("..."),
|
||||||
? 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()),
|
|
||||||
),
|
),
|
||||||
|
]),
|
||||||
|
|
||||||
|
// 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(
|
IconButton(
|
||||||
onPressed:
|
onPressed: _currentPage < totalPages
|
||||||
_currentPage < (filteredData.length / _rowsPerPage).ceil()
|
? () => setState(() => _currentPage++)
|
||||||
? () {
|
|
||||||
setState(() {
|
|
||||||
_currentPage++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
: null,
|
: null,
|
||||||
icon: Icon(Icons.chevron_right),
|
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) {
|
Widget _buildName(BuildContext context) {
|
||||||
|
|||||||
@ -239,7 +239,7 @@ class _PreEnrollmentState extends State<PreEnrollment> {
|
|||||||
|
|
||||||
print("logicalWidth - $logicalWidth");
|
print("logicalWidth - $logicalWidth");
|
||||||
print("logicalHeight - $logicalHeight");
|
print("logicalHeight - $logicalHeight");
|
||||||
return GestureDetector(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
print("policytab - $policy");
|
print("policytab - $policy");
|
||||||
@ -248,7 +248,8 @@ class _PreEnrollmentState extends State<PreEnrollment> {
|
|||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => hrPolicyDetails(
|
builder: (context) => hrPolicyDetails(
|
||||||
ClientId: policy['client_id'].toString(), // <-- from map
|
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(),
|
ClientPoliyId: policy['client_policy_id'].toString(),
|
||||||
clientBranchId: widget.enrollmentClientBranchId,
|
clientBranchId: widget.enrollmentClientBranchId,
|
||||||
Token: widget.enrollToken,
|
Token: widget.enrollToken,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user