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

View File

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

View File

@ -61,6 +61,7 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
with TickerProviderStateMixin { with TickerProviderStateMixin {
Uint8List? fileBytes; Uint8List? fileBytes;
String empCodeFromHrPolcy = ''; String empCodeFromHrPolcy = '';
bool hasAnyEcardLink = false;
late String _token; late String _token;
List<Map<String, dynamic>> getEmpDependenceByClintId = []; List<Map<String, dynamic>> getEmpDependenceByClintId = [];
List<Map<String, dynamic>> getCDPolicies = []; List<Map<String, dynamic>> getCDPolicies = [];
@ -79,6 +80,9 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
dynamic clientPolicyId; dynamic clientPolicyId;
dynamic clientId; dynamic clientId;
dynamic empRefId; dynamic empRefId;
String? modulesString;
final storeModuleId = 4;
bool hasModule = false;
int inceptionType = 0; int inceptionType = 0;
TextEditingController searchController = TextEditingController(); TextEditingController searchController = TextEditingController();
late ApiService apiService; late ApiService apiService;
@ -99,6 +103,8 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
apiService = ApiService(context); // Initialize ApiService here apiService = ApiService(context); // Initialize ApiService here
getCDPoliciesDetails(); getCDPoliciesDetails();
print("_PreEnrollmentState 1"); print("_PreEnrollmentState 1");
print('allowed_modules');
} }
Future<void> getCDPoliciesDetails() async { Future<void> getCDPoliciesDetails() async {
@ -109,6 +115,24 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
try { try {
print('10'); 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" final response = widget.TokenType == "post"
? await apiService.getEmployeeAndDependenceToApi(widget.ClientId, ? await apiService.getEmployeeAndDependenceToApi(widget.ClientId,
widget.ClientPoliyId, widget.clientBranchId, widget.Token) widget.ClientPoliyId, widget.clientBranchId, widget.Token)
@ -536,6 +560,18 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
} }
Widget _buildCDDataTable(BuildContext context) { 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) { if (filteredData.isEmpty) {
return SizedBox( return SizedBox(
// height: 50, // height: 50,
@ -643,17 +679,18 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
), ),
), ),
), ),
Expanded( if (widget.TokenType != "pre" && (hasAnyEcardLink || hasModule))
flex: 3, Expanded(
child: Text( flex: 3,
'Action', child: Text(
textAlign: TextAlign.center, 'Action',
style: GoogleFonts.poppins( textAlign: TextAlign.center,
color: Colors.black, style: GoogleFonts.poppins(
fontWeight: FontWeight.w600, color: Colors.black,
fontWeight: FontWeight.w600,
),
), ),
), ),
),
], ],
), ),
), ),
@ -796,72 +833,77 @@ class _HrPolicyDetailsState extends State<hrPolicyDetails>
), ),
), ),
), ),
Expanded( if (widget.TokenType != "pre" &&
flex: 3, (hasAnyEcardLink || hasModule))
child: Row( Expanded(
mainAxisAlignment: MainAxisAlignment.center, flex: 3,
children: [ child: Row(
if (item['ecard_download_link'] != null) mainAxisAlignment: MainAxisAlignment.center,
GestureDetector( children: [
onTap: () { if (item['ecard_download_link'] != null)
_launchURL(item['ecard_download_link']); GestureDetector(
}, onTap: () {
child: Container( _launchURL(item['ecard_download_link']);
height: 35, },
width: 35, child: Container(
decoration: BoxDecoration( height: 35,
color: Color(0xFFE6F5F6), width: 35,
borderRadius: BorderRadius.circular(8), decoration: BoxDecoration(
), color: Color(0xFFE6F5F6),
child: Padding( borderRadius: BorderRadius.circular(8),
padding: EdgeInsets.all(
6), // You can adjust this value
child: Image.asset(
'assets/credit_card.png',
fit: BoxFit.contain,
), ),
), child: Padding(
), padding: EdgeInsets.all(
), 6), // You can adjust this value
SizedBox( child: Image.asset(
width: 10, 'assets/credit_card.png',
), fit: BoxFit.contain,
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,
), ),
), ),
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,
),
),
),
),
],
),
), ),
),
], ],
), ),
); );