enrollment-app/lib/customAppBar/customAppBar.dart
2025-07-05 10:40:41 +05:30

112 lines
3.8 KiB
Dart
Executable File

import 'package:flutter/material.dart';
import 'package:adaptive_navbar/adaptive_navbar.dart';
import 'package:nhancepolicy/customAppBar/toastHelper.dart';
import 'package:nhancepolicy/responsive.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:nhancepolicy/responsive.dart';
class CustomAppBar extends StatefulWidget implements PreferredSizeWidget {
@override
_CustomAppBarState createState() => _CustomAppBarState();
@override
Size get preferredSize => Size.fromHeight(kToolbarHeight);
}
class _CustomAppBarState extends State<CustomAppBar> {
bool showBackToHR = false;
// bool isLoading = true; // Add a loading state
// bool hideInactiveStatus = true;
@override
void initState() {
super.initState();
// _checkTokens();
}
Future<void> logout(BuildContext context) async {
final prefs = await SharedPreferences.getInstance();
// final String? hrtoken = prefs.getString('_postToken');
// final String? token = prefs.getString('enrollToken');
prefs.clear();
Navigator.pushNamed(context, 'hrLogin');
}
@override
Widget build(BuildContext context) {
final sw = MediaQuery.of(context).size.width;
return Scaffold(
backgroundColor: Color(0xFFFFFCE5), // Set background color for AppBar
appBar: PreferredSize(
preferredSize: widget.preferredSize,
child: SafeArea(
child: Container(
padding: Responsive.isDesktop(context)
? EdgeInsets.symmetric(horizontal: 16.0)
: EdgeInsets.symmetric(horizontal: 0),
child: Row(
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,
),
),
],
),
),
// 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: "Back To HR",
// onTap: () {
// // hrLogout(context);
// },
// ),
NavBarItem(
text: "Logout",
onTap: () async {
logout(context);
},
),
],
),
),
],
),
),
),
),
);
}
}