FIX_TAB_HIDE/SHOW

This commit is contained in:
venbaittech 2025-07-10 18:12:44 +05:30
parent 53ec431f45
commit f6d41327d1
3 changed files with 129 additions and 80 deletions

View File

@ -150,7 +150,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
border: Border.all(color: Color(0xFFBCBCBC)),
borderRadius: BorderRadius.circular(6),
),
child: Icon(
child: const Icon(
Icons.close,
size: 25,
color: Color(0xFFBCBCBC),
@ -166,7 +166,7 @@ class _ClaimHistoryPopupState extends State<ClaimHistoryPopup> {
decoration: BoxDecoration(
color: Color(0xFFFFFFFF), // White background
borderRadius: BorderRadius.circular(12),
boxShadow: [
boxShadow: const [
BoxShadow(
color: Color(0xFFEBEBEB), // Shadow color
blurRadius: 14, // How soft the shadow is

View File

@ -169,14 +169,14 @@ class _hrDashboardState extends State<hrDashboard>
print('allowed_modules');
String? modulesString = prefs.getString('empAllowed_modules');
String? enrollmodulesString =
prefs.getString('enrollmentAllowed_modules');
if (modulesString != null || enrollmodulesString != null) {
empAllowed_modules = jsonDecode(modulesString!);
enrollmentAllowed_modules = jsonDecode(enrollmodulesString!);
// String? enrollmodulesString =
// prefs.getString('enrollmentAllowed_modules');
if (modulesString != null) {
empAllowed_modules = jsonDecode(modulesString);
// enrollmentAllowed_modules = jsonDecode(enrollmodulesString!);
print("empAllowed_modules - $empAllowed_modules"); // [2, 3, 4]
print(
"enrollmentAllowed_modules - $enrollmentAllowed_modules"); // [2, 3, 4]
// print(
// "enrollmentAllowed_modules - $enrollmentAllowed_modules"); // [2, 3, 4]
if (empAllowed_modules.contains(2)) {
print("visibleTabs.length2");
@ -215,7 +215,7 @@ class _hrDashboardState extends State<hrDashboard>
if (empAllowed_modules.contains(4)) {
tabData.add({
'icon': Icons.receipt_long,
'label': 'Claims',
'label': 'Claims', // Label Name Integrated with code (dont change)
});
// tabViews.add(ClaimsPolicies(
// empClientId: empClientId,
@ -246,9 +246,15 @@ class _hrDashboardState extends State<hrDashboard>
print('111');
if (widget.selectedIndex == 3) {
print("Process1");
_tabController.index = 3;
print("ProcessTAb - $tabData");
final claimsIndex = tabData.indexWhere((tab) => tab['label'] == 'Claims');
print('Claims tab index: $claimsIndex');
_tabController.index = claimsIndex;
// _tabController.index = 3;
setState(() {
selectedIndex = 3;
selectedIndex = claimsIndex;
// selectedIndex = 3;
isHrcode = 1;
empCodeFromHrPolcy = widget.empCodeFromHrPolicy;
});
@ -747,6 +753,7 @@ class CustomTab extends StatelessWidget {
@override
Widget build(BuildContext context) {
print("isSelected - $isSelected");
return Tab(
child: Container(
// margin: const EdgeInsets.symmetric(horizontal: 6),

View File

@ -61,6 +61,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
with TickerProviderStateMixin {
Uint8List? fileBytes;
String empCodeFromHrPolcy = '';
bool hasAnyEcardLink = false;
late String _token;
List<Map<String, dynamic>> getEmpDependenceByClintId = [];
List<Map<String, dynamic>> getCDPolicies = [];
@ -79,6 +80,9 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
dynamic clientPolicyId;
dynamic clientId;
dynamic empRefId;
String? modulesString;
final storeModuleId = 4;
bool hasModule = false;
int inceptionType = 0;
TextEditingController searchController = TextEditingController();
late ApiService apiService;
@ -99,6 +103,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
apiService = ApiService(context); // Initialize ApiService here
getCDPoliciesDetails();
print("_PreEnrollmentState 1");
print('allowed_modules');
}
Future<void> getCDPoliciesDetails() async {
@ -109,6 +115,24 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
try {
print('10');
final SharedPreferences prefs = await SharedPreferences.getInstance();
modulesString = prefs.getString('empAllowed_modules');
// modulesString = "[2,3]";
print("empmodulesString - $modulesString");
if (modulesString != null && modulesString!.trim().isNotEmpty) {
final List<int>? moduleList = modulesString
?.replaceAll('[', '')
.replaceAll(']', '')
.split(',')
.map((e) => int.tryParse(e.trim()) ?? -1) // convert to int safely
.where((id) => id != -1) // filter out invalid
.toList();
hasModule = moduleList!.contains(storeModuleId);
}
final response = widget.TokenType == "post"
? await apiService.getEmployeeAndDependenceToApi(widget.ClientId,
widget.ClientPoliyId, widget.clientBranchId, widget.Token)
@ -536,6 +560,18 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
}
Widget _buildCDDataTable(BuildContext context) {
if (_paginatedData.isNotEmpty) {
hasAnyEcardLink = _paginatedData.any(
(item) => item['ecard_download_link'] != null,
);
if (widget.TokenType == "post" && hasModule) {
print("paginatTtt - $_paginatedData");
print("📥 Any e-card link present: $hasAnyEcardLink");
}
}
if (filteredData.isEmpty) {
return SizedBox(
// height: 50,
@ -643,17 +679,18 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
),
),
),
Expanded(
flex: 3,
child: Text(
'Action',
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.black,
fontWeight: FontWeight.w600,
if (widget.TokenType != "pre" && (hasAnyEcardLink || hasModule))
Expanded(
flex: 3,
child: Text(
'Action',
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
color: Colors.black,
fontWeight: FontWeight.w600,
),
),
),
),
],
),
),
@ -796,72 +833,77 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
),
),
),
Expanded(
flex: 3,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (item['ecard_download_link'] != null)
GestureDetector(
onTap: () {
_launchURL(item['ecard_download_link']);
},
child: Container(
height: 35,
width: 35,
decoration: BoxDecoration(
color: Color(0xFFE6F5F6),
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: EdgeInsets.all(
6), // You can adjust this value
child: Image.asset(
'assets/credit_card.png',
fit: BoxFit.contain,
if (widget.TokenType != "pre" &&
(hasAnyEcardLink || hasModule))
Expanded(
flex: 3,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (item['ecard_download_link'] != null)
GestureDetector(
onTap: () {
_launchURL(item['ecard_download_link']);
},
child: Container(
height: 35,
width: 35,
decoration: BoxDecoration(
color: Color(0xFFE6F5F6),
borderRadius: BorderRadius.circular(8),
),
),
),
),
SizedBox(
width: 10,
),
GestureDetector(
onTap: () {
setState(() {
print("policytabdata - ${item['emp_code']!}");
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => hrDashboard(
selectedIndex: 3,
empCodeFromHrPolicy: item['emp_code']!,
isHrcode: 1,
child: Padding(
padding: EdgeInsets.all(
6), // You can adjust this value
child: Image.asset(
'assets/credit_card.png',
fit: BoxFit.contain,
),
),
);
});
},
child: Container(
height: 35,
width: 35,
decoration: BoxDecoration(
color: Color(0xFFE6F5F6),
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: EdgeInsets.all(
6), // You can adjust this value
child: Image.asset(
'assets/claim.png',
fit: BoxFit.contain,
),
),
SizedBox(
width: 10,
),
),
],
if (widget.TokenType == "post" && hasModule)
GestureDetector(
onTap: () {
setState(() {
print(
"policytabdata - ${item['emp_code']!}");
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => hrDashboard(
selectedIndex: 3,
empCodeFromHrPolicy:
item['emp_code']!,
isHrcode: 1,
),
),
);
});
},
child: Container(
height: 35,
width: 35,
decoration: BoxDecoration(
color: Color(0xFFE6F5F6),
borderRadius: BorderRadius.circular(8),
),
child: Padding(
padding: EdgeInsets.all(
6), // You can adjust this value
child: Image.asset(
'assets/claim.png',
fit: BoxFit.contain,
),
),
),
),
],
),
),
),
],
),
);