latest commit 06-06-2025

This commit is contained in:
vadivelJ96 2025-06-06 12:04:50 +05:30
parent ef79391915
commit f663fd776f
2 changed files with 283 additions and 269 deletions

View File

@ -1267,7 +1267,12 @@ class CreateNewPlansState extends State<CreateNewPlan> {
), ),
); );
return ResponsiveBuilder( return
FocusTraversalGroup(
policy: OrderedTraversalPolicy(), // 👈 more predictable tab order
descendantsAreFocusable: true,
child: ResponsiveBuilder(
builder: (context, sizingInfo) { builder: (context, sizingInfo) {
bool isMobile = sizingInfo.isMobile; bool isMobile = sizingInfo.isMobile;
bool isDesktop = bool isDesktop =
@ -1627,7 +1632,11 @@ class CreateNewPlansState extends State<CreateNewPlan> {
// ], // ],
// ) // )
}, },
); )
// replace with your full form column
);
} }
// String? getSelectedCostCenterName() { // String? getSelectedCostCenterName() {

View File

@ -284,292 +284,297 @@ class _CustomAppBarState extends State<CustomAppBar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppBar( return
backgroundColor: Colors.white, FocusTraversalGroup(
surfaceTintColor: Colors.white, descendantsAreFocusable: false,
// elevation: 3, child:
automaticallyImplyLeading: !widget.isDesktop, AppBar(
iconTheme: IconThemeData( backgroundColor: Colors.white,
color: layoutColor, // 👈 Set your desired icon color here surfaceTintColor: Colors.white,
), // elevation: 3,
automaticallyImplyLeading: !widget.isDesktop,
iconTheme: IconThemeData(
color: layoutColor, // 👈 Set your desired icon color here
),
titleSpacing: 0, titleSpacing: 0,
title: title:
!widget.isDesktop !widget.isDesktop
? Text('') ? Text('')
: Padding( : Padding(
padding: EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width * 0.05,
),
child: Row(
children: [
Padding(
padding: const EdgeInsets.all(10),
// padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 10),
child:
selectedOrg?['logo'] != null
? SizedBox(
height: 50,
child: ClipRect(
child: Image.network(
selectedOrg!['logo'],
width: 130, //130
height: 80, //80
fit: BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const CircleAvatar(
radius: 20,
backgroundColor: Colors.redAccent,
child: Icon(Icons.error, size: 10),
);
},
),
),
)
: const CircleAvatar(
radius: 20,
// backgroundColor: Colors.white,
child: Icon(
Icons.add_a_photo,
size: 10,
color: Colors.grey,
),
),
),
SizedBox(width: MediaQuery.of(context).size.width * 0.18),
Container(
width: MediaQuery.of(context).size.width * 0.35,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (userData?["role"] == "Org Admin" ||
userData?["role"] == "Travel Admin")
buildNavItem(
"Dashboard",
() => handleTabChange(
TabSelection.dashboard,
'/StatusDashboard',
),
layoutColor!,
isSelected: selectedTab == TabSelection.dashboard,
icon: Icons.dashboard,
// icon: Icons.insights_outlined,
),
if (userData?["role"] == "Org Admin" ||
userData?["role"] == "Travel Admin")
const SizedBox(width: 20),
if (userData?["role"] == "Org Admin" ||
userData?["role"] == "Travel Admin")
buildNavItem(
"All Trips",
() => handleTabChange(
TabSelection.allTrips,
'/listAllPlan',
),
layoutColor!,
isSelected: selectedTab == TabSelection.allTrips,
icon: Icons.format_list_bulleted_rounded,
// icon: Icons.insights_outlined,
),
if (userDetails["role"] != "Travel Agent")
const SizedBox(width: 20),
if (userData?["role"] == "Travel Agent")
buildNavItem(
"Trips",
() => handleTabChange(
TabSelection.myTrips,
'/listTravelAgentPlan',
),
layoutColor!,
// () => context.go('/listTravelAgentPlan'),
isSelected: selectedTab == TabSelection.myTrips,
icon: Icons.shopping_bag_outlined,
// icon: Icons.request_page_outlined,
),
if (userData?["role"] != "Travel Agent") // for others
buildNavItem(
"My Trips",
() => handleTabChange(
TabSelection.myTrips,
'/listPlan',
),
layoutColor!,
// () => context.go('/listPlan'),
isSelected: selectedTab == TabSelection.myTrips,
icon: Icons.shopping_bag_outlined,
),
const SizedBox(width: 20),
if (userData?["role"] != "Travel Agent")
buildNavItem(
"My Approvals",
() => handleTabChange(
TabSelection.myApprovals,
'/ApprovalList',
),
layoutColor!,
// () => context.go('/ApprovalList'),
isSelected:
selectedTab == TabSelection.myApprovals,
icon: Icons.verified_outlined,
),
],
),
),
Spacer(),
],
),
),
actions: [
Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width * 0.05, horizontal: MediaQuery.of(context).size.width * 0.05,
), ),
child: Row( child: Row(
children: [ children: [
Padding( // if (userData?["role"] != "User")
padding: const EdgeInsets.all(10), Builder(
builder:
(context) => PopupMenuButton<String>(
color: Colors.white,
padding: EdgeInsets.zero,
offset: const Offset(0, 50), // 👈 shift it 50 pixels down
onSelected: (String value) {
switch (value) {
case '/OrganizationSettings':
context.go('/OrganizationSettings');
break;
// case '/OrganizationSetup':
// context.go('/OrganizationSetup');
// break;
case '/listUser':
context.go('/listUser');
break;
// case '/group':
// context.go('/group');
// break;
// case '/department':
// context.go('/department');
// break;
// case '/PolicyList':
// context.go('/PolicyList');
// case '/getPerdiem':
// context.go('/getPerdiem');
// case '/templateList':
// context.go('/templateList');
// case '/template':
// context.go('/template');
// padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 10), case '/CreateUserDetails':
child: context.go(
selectedOrg?['logo'] != null "/CreateUserDetails",
? SizedBox( extra: {
height: 50, "selectedUser": profileUserDetails,
child: ClipRect( "isEditProfile": true,
child: Image.network( "isViewMode": false,
selectedOrg!['logo'],
width: 130, //130
height: 80, //80
fit: BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const CircleAvatar(
radius: 20,
backgroundColor: Colors.redAccent,
child: Icon(Icons.error, size: 10),
);
}, },
);
case '/logout':
context.go('/');
break;
}
},
// itemBuilder: (BuildContext context) =>
// menuItems.map(buildMenuItem).toList(),
itemBuilder: (BuildContext context) {
// final isUser = userData?["role"] == "User";
final role = userData?["role"];
List<Map<String, dynamic>> filteredItems;
if (role == "User") {
filteredItems =
menuItems
.where(
(item) =>
item['value'] == '/CreateUserDetails' ||
item['value'] == '/logout',
)
.toList();
} else if (role == "Travel Agent") {
filteredItems =
menuItems
.where((item) => item['value'] == '/logout')
.toList();
} else {
filteredItems = menuItems;
}
// Create a new list starting with role display and divider
return [
PopupMenuItem<String>(
enabled: false, // Not clickable
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
userData?["role"] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
const Divider(), // 👈 Divider after role
],
), ),
), ),
) ...filteredItems
: const CircleAvatar( .map(buildMenuItem)
radius: 20, .toList(), // 👈 then normal items
// backgroundColor: Colors.white, ];
child: Icon( },
Icons.add_a_photo,
size: 10,
color: Colors.grey,
),
),
),
SizedBox(width: MediaQuery.of(context).size.width * 0.18),
Container(
width: MediaQuery.of(context).size.width * 0.35,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (userData?["role"] == "Org Admin" ||
userData?["role"] == "Travel Admin")
buildNavItem(
"Dashboard",
() => handleTabChange(
TabSelection.dashboard,
'/StatusDashboard',
),
layoutColor!,
isSelected: selectedTab == TabSelection.dashboard,
icon: Icons.dashboard,
// icon: Icons.insights_outlined,
),
if (userData?["role"] == "Org Admin" ||
userData?["role"] == "Travel Admin")
const SizedBox(width: 20),
if (userData?["role"] == "Org Admin" ||
userData?["role"] == "Travel Admin")
buildNavItem(
"All Trips",
() => handleTabChange(
TabSelection.allTrips,
'/listAllPlan',
),
layoutColor!,
isSelected: selectedTab == TabSelection.allTrips,
icon: Icons.format_list_bulleted_rounded,
// icon: Icons.insights_outlined,
),
if (userDetails["role"] != "Travel Agent")
const SizedBox(width: 20),
if (userData?["role"] == "Travel Agent")
buildNavItem(
"Trips",
() => handleTabChange(
TabSelection.myTrips,
'/listTravelAgentPlan',
),
layoutColor!,
// () => context.go('/listTravelAgentPlan'),
isSelected: selectedTab == TabSelection.myTrips,
icon: Icons.shopping_bag_outlined,
// icon: Icons.request_page_outlined,
),
if (userData?["role"] != "Travel Agent") // for others
buildNavItem(
"My Trips",
() => handleTabChange(
TabSelection.myTrips,
'/listPlan',
),
layoutColor!,
// () => context.go('/listPlan'),
isSelected: selectedTab == TabSelection.myTrips,
icon: Icons.shopping_bag_outlined,
),
const SizedBox(width: 20),
if (userData?["role"] != "Travel Agent")
buildNavItem(
"My Approvals",
() => handleTabChange( child: MouseRegion(
TabSelection.myApprovals, cursor: SystemMouseCursors.click,
'/ApprovalList', child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
userData?["name"] ?? "N/A",
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.black,
),
// style: const TextStyle(
// fontSize: 14,
// fontWeight: FontWeight.w500,
// fontFamily: "Roboto",
// color: Colors.black,
// ),
),
const Icon(
Icons.arrow_drop_down,
size: 20,
color: Colors.black87,
),
],
), ),
layoutColor!,
// () => context.go('/ApprovalList'),
isSelected:
selectedTab == TabSelection.myApprovals,
icon: Icons.verified_outlined,
), ),
], ),
),
), ),
Spacer(), const SizedBox(width: 8),
], ],
), ),
), ),
actions: [
Padding(
padding: EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width * 0.05,
),
child: Row(
children: [
// if (userData?["role"] != "User")
Builder(
builder:
(context) => PopupMenuButton<String>(
color: Colors.white,
padding: EdgeInsets.zero,
offset: const Offset(0, 50), // 👈 shift it 50 pixels down
onSelected: (String value) {
switch (value) {
case '/OrganizationSettings':
context.go('/OrganizationSettings');
break;
// case '/OrganizationSetup':
// context.go('/OrganizationSetup');
// break;
case '/listUser':
context.go('/listUser');
break;
// case '/group':
// context.go('/group');
// break;
// case '/department':
// context.go('/department');
// break;
// case '/PolicyList':
// context.go('/PolicyList');
// case '/getPerdiem':
// context.go('/getPerdiem');
// case '/templateList':
// context.go('/templateList');
// case '/template':
// context.go('/template');
case '/CreateUserDetails':
context.go(
"/CreateUserDetails",
extra: {
"selectedUser": profileUserDetails,
"isEditProfile": true,
"isViewMode": false,
},
);
case '/logout':
context.go('/');
break;
}
},
// itemBuilder: (BuildContext context) =>
// menuItems.map(buildMenuItem).toList(),
itemBuilder: (BuildContext context) {
// final isUser = userData?["role"] == "User";
final role = userData?["role"];
List<Map<String, dynamic>> filteredItems;
if (role == "User") {
filteredItems =
menuItems
.where(
(item) =>
item['value'] == '/CreateUserDetails' ||
item['value'] == '/logout',
)
.toList();
} else if (role == "Travel Agent") {
filteredItems =
menuItems
.where((item) => item['value'] == '/logout')
.toList();
} else {
filteredItems = menuItems;
}
// Create a new list starting with role display and divider
return [
PopupMenuItem<String>(
enabled: false, // Not clickable
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
userData?["role"] ?? '',
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
const Divider(), // 👈 Divider after role
],
),
),
...filteredItems
.map(buildMenuItem)
.toList(), // 👈 then normal items
];
},
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
userData?["name"] ?? "N/A",
style: GoogleFonts.poppins(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Colors.black,
),
// style: const TextStyle(
// fontSize: 14,
// fontWeight: FontWeight.w500,
// fontFamily: "Roboto",
// color: Colors.black,
// ),
),
const Icon(
Icons.arrow_drop_down,
size: 20,
color: Colors.black87,
),
],
),
),
),
),
const SizedBox(width: 8),
], ],
), bottom: PreferredSize(
), preferredSize: Size.fromHeight(1),
], child: Container(
bottom: PreferredSize( height: 1,
preferredSize: Size.fromHeight(1), // color: Colors.grey.shade200, // Set the color of the bottom border
child: Container( color: layoutColor, // Set the color of the bottom border
height: 1, ),
// color: Colors.grey.shade200, // Set the color of the bottom border ),
color: layoutColor, // Set the color of the bottom border )
), );
),
);
} }
@override @override