This commit is contained in:
venbaittech 2025-06-06 11:47:16 +05:30
parent 1a568f6878
commit 194af031d0
5 changed files with 1315 additions and 922 deletions

Binary file not shown.

View File

@ -69,12 +69,15 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
print("allPlans before filtering: $allPlans");
final lowerQuery = query.toLowerCase();
setState(() {
filteredPlans = allPlans.where((plan) {
filteredPlans =
allPlans.where((plan) {
return (plan.planId?.toLowerCase().contains(lowerQuery) ?? false) ||
(plan.employeeCode?.toLowerCase().contains(lowerQuery) ?? false) ||
(plan.employeeCode?.toLowerCase().contains(lowerQuery) ??
false) ||
(plan.tripTitle?.toLowerCase().contains(lowerQuery) ?? false) ||
(plan.userName?.toLowerCase().contains(lowerQuery) ?? false) ||
(plan.travellerName?.toLowerCase().contains(lowerQuery) ?? false) ||
(plan.travellerName?.toLowerCase().contains(lowerQuery) ??
false) ||
(plan.tripType?.toLowerCase().contains(lowerQuery) ?? false) ||
(plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
(plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
@ -88,11 +91,13 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
String? bodyStringColor = await getBodyColor();
setState(() {
layoutColor = layoutString != null
layoutColor =
layoutString != null
? Color(int.parse(layoutString))
: Colors.redAccent;
bodyColor = bodyStringColor != null
bodyColor =
bodyStringColor != null
? Color(int.parse(bodyStringColor))
: Colors.white;
});
@ -195,7 +200,8 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
if (response.statusCode == 200) {
final data = json.decode(response.body);
List<dynamic> plansJson = data['data'];
List<dynamic> plansJson = [];
// List<dynamic> plansJson = data['data'];
return plansJson.map((json) => Plan.fromJson(json)).toList();
} else {
throw Exception('Failed to load plans');
@ -239,8 +245,10 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
}
void deletePlan(String planId) async {
bool confirmed =
await apiService.showCancelConfirmationDialog(context, layoutColor);
bool confirmed = await apiService.showCancelConfirmationDialog(
context,
layoutColor,
);
if (confirmed) {
try {
@ -257,8 +265,10 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
}
Widget build(BuildContext context) {
return ResponsiveBuilder(builder: (context, sizingInfo) {
bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop;
return ResponsiveBuilder(
builder: (context, sizingInfo) {
bool isDesktop =
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
return Scaffold(
backgroundColor: Color(0xFFf5f5f5),
@ -267,23 +277,27 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
appBar: CustomAppBar(isDesktop: isDesktop),
drawer: CustomDrawer(isDesktop: false),
body: Padding(
padding: isDesktop
padding:
isDesktop
? EdgeInsets.symmetric(
horizontal: MediaQuery.of(context).size.width *
horizontal:
MediaQuery.of(context).size.width *
0.1, // 30% of screen width as horizontal padding
vertical: MediaQuery.of(context).size.height *
vertical:
MediaQuery.of(context).size.height *
0, // 5% of screen height as vertical padding
)
: EdgeInsets.all(0),
child: Row(
children: [
// if (isDesktop) CustomDrawer(isDesktop: true),
Expanded(child: buildGroupListLayout(isDesktop))
Expanded(child: buildGroupListLayout(isDesktop)),
],
),
),
);
});
},
);
}
Widget buildGroupListLayout(bool isDesktop) {
@ -313,8 +327,9 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
String _formatDate(String rawDate) {
try {
final dateTime = DateTime.parse(rawDate);
return DateFormat('dd, MMM yyyy HH:mm')
.format(dateTime); // 24-hour format
return DateFormat(
'dd, MMM yyyy HH:mm',
).format(dateTime); // 24-hour format
} catch (e) {
return rawDate; // fallback if parsing fails
}
@ -323,11 +338,13 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
return Container(
margin: isDesktop ? EdgeInsets.all(10.0) : null,
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 20, right: 20),
height: isDesktop
height:
isDesktop
? MediaQuery.of(context).size.height * 0.98
: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
border: isDesktop
border:
isDesktop
? Border.all(
width: 2,
color: Colors.white,
@ -382,8 +399,10 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
onChanged: filterPlans,
decoration: InputDecoration(
hintText: "Search...",
hintStyle:
TextStyle(fontSize: 12, color: Color(0xFF9E9DBD)),
hintStyle: TextStyle(
fontSize: 12,
color: Color(0xFF9E9DBD),
),
prefixIcon: Icon(
Icons.search,
color: Color(0xFF9E9DBD),
@ -395,23 +414,23 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
color: Colors.grey.shade200, width: 0.5),
color: Colors.grey.shade200,
width: 0.5,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
color: Colors.grey.shade300, width: 1),
color: Colors.grey.shade300,
width: 1,
),
),
style: TextStyle(
fontSize: 12,
fontFamily: "Inter",
),
style: TextStyle(fontSize: 12, fontFamily: "Inter"),
),
),
// SizedBox(width: 16),
Spacer(),
// ElevatedButton(
// style: ElevatedButton.styleFrom(
@ -447,8 +466,10 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
onChanged: filterPlans,
decoration: InputDecoration(
hintText: "Search...",
hintStyle:
TextStyle(fontSize: 12, color: Color(0xFF9E9DBD)),
hintStyle: TextStyle(
fontSize: 12,
color: Color(0xFF9E9DBD),
),
prefixIcon: Icon(
Icons.search,
color: Color(0xFF9E9DBD),
@ -460,17 +481,19 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
color: Colors.grey.shade200, width: 0.5),
color: Colors.grey.shade200,
width: 0.5,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: BorderSide(
color: Colors.grey.shade300, width: 1),
color: Colors.grey.shade300,
width: 1,
),
),
style: GoogleFonts.poppins(
fontSize: 12,
),
style: GoogleFonts.poppins(fontSize: 12),
),
),
],
@ -479,6 +502,8 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
FutureBuilder<List<Plan>>(
future: futurePlans,
builder: (context, snapshot) {
final adjHgt = MediaQuery.of(context).size.height;
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else if (snapshot.hasError ||
@ -490,7 +515,7 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(height: 20),
// SizedBox(height: 20),
// Icon(Icons.error_outline,
// color: Colors.redAccent, size: 60),
// SizedBox(height: 1),
@ -499,21 +524,23 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
// fontSize: 22,
// fontWeight: FontWeight.bold,
// color: Colors.redAccent)),
SizedBox(height: 20),
isDesktop
? SizedBox(
width:
MediaQuery.of(context).size.width * 5.5,
)
: SizedBox.shrink(),
SizedBox(height: adjHgt / 4),
Text("No Trips Pending For Your Approvals",
Text(
" No Trips Found",
textAlign: TextAlign.center,
style: TextStyle(
style: GoogleFonts.poppins(
fontSize: 20,
fontFamily: "Inter",
fontWeight: FontWeight.w600,
color: Colors.black54)),
fontWeight: FontWeight.w500,
color: Colors.black54,
),
),
SizedBox(height: 10),
// Text("Please Create Trip",
// textAlign: TextAlign.center,
@ -536,10 +563,13 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
List<Plan> plans =
searchController.text.isEmpty ? allPlans : filteredPlans;
plans.sort((a, b) =>
int.parse(b.planId).compareTo(int.parse(a.planId)));
plans.sort(
(a, b) =>
int.parse(b.planId).compareTo(int.parse(a.planId)),
);
List<Plan> paginatedPlans = plans
List<Plan> paginatedPlans =
plans
.skip(currentPage * itemsPerPage)
.take(itemsPerPage)
.toList();
@ -555,117 +585,174 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
columnSpacing: isDesktop ? 24.0 : 16.0,
border: TableBorder(
horizontalInside: BorderSide(
width: 0.5, color: Colors.grey.shade200),
width: 0.5,
color: Colors.grey.shade200,
),
),
columns: [
DataColumn(
label: Text(
'Trip ID',
style: GoogleFonts.poppins(
fontSize: 13, fontWeight: FontWeight.w600),
)),
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
DataColumn(
label: Text(
'Trip Name',
style: GoogleFonts.poppins(
fontSize: 13, fontWeight: FontWeight.w600),
)),
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
DataColumn(
label: Text(
'Emp Code',
style: GoogleFonts.poppins(
fontSize: 13, fontWeight: FontWeight.w600),
)),
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
DataColumn(
label: Text(
'Traveller',
style: GoogleFonts.poppins(
fontSize: 13, fontWeight: FontWeight.w600),
)),
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
DataColumn(
label: Text(
'Trip Type',
style: GoogleFonts.poppins(
fontSize: 13, fontWeight: FontWeight.w600),
)),
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
DataColumn(
label: Text(
'Created On',
style: GoogleFonts.poppins(
fontSize: 13, fontWeight: FontWeight.w600),
)),
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
DataColumn(
label: Text(
'Status',
style: GoogleFonts.poppins(
fontSize: 13, fontWeight: FontWeight.w600),
)),
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
DataColumn(
label: Text(
'Actions',
style: GoogleFonts.poppins(
fontSize: 13, fontWeight: FontWeight.w600),
)),
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
),
],
rows: paginatedPlans.map((plan) {
return DataRow(cells: [
DataCell(Text(plan.planId,
rows:
paginatedPlans.map((plan) {
return DataRow(
cells: [
DataCell(
Text(
plan.planId,
style: TextStyle(
fontSize: 13,
fontFamily: "Inter",
))),
),
),
),
DataCell(Text(plan.tripTitle,
DataCell(
Text(
plan.tripTitle,
style: TextStyle(
fontSize: 13,
fontFamily: "Inter",
),
softWrap: true,
overflow: TextOverflow.ellipsis)),
overflow: TextOverflow.ellipsis,
),
),
DataCell(Text(plan.employeeCode ?? " - ",
DataCell(
Text(
plan.employeeCode ?? " - ",
style: TextStyle(
fontSize: 13,
fontFamily: "Inter",
))),
DataCell(Text(
),
),
),
DataCell(
Text(
plan.userName.isNotEmpty
? plan.userName
: plan.travellerName,
style: TextStyle(
fontSize: 13,
fontFamily: "Inter",
))),
DataCell(Text(plan.tripType,
),
),
),
DataCell(
Text(
plan.tripType,
style: TextStyle(
fontSize: 13,
fontFamily: "Inter",
))),
DataCell(Text(_formatDate(plan.createdOn),
),
),
),
DataCell(
Text(
_formatDate(plan.createdOn),
// plan.createdOn,
style: TextStyle(
fontSize: 13,
fontFamily: "Inter",
))),
),
),
),
DataCell(
Container(
padding: const EdgeInsets.all(3),
// width:
// 150, // Set your desired fixed size (equal width and height)
width: double
width:
double
.infinity, // Set your desired fixed size (equal width and height)
height: 25,
alignment: Alignment.center,
decoration: BoxDecoration(
color: getStatusColor(plan.statusValue),
borderRadius: BorderRadius.circular(10),
color: getStatusColor(
plan.statusValue,
),
borderRadius: BorderRadius.circular(
10,
),
),
child: Text(
plan.statusValue,
textAlign: TextAlign.center,
style: TextStyle(
color:
getStatusTextColor(plan.statusValue),
color: getStatusTextColor(
plan.statusValue,
),
fontSize: 12,
fontFamily: "Inter",
fontWeight: FontWeight.w400,
@ -681,29 +768,45 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
color: Colors.white,
padding: EdgeInsets.zero,
offset: Offset(0, 30),
icon: Icon(Icons.more_vert,
color: Color(0xFF475569)),
itemBuilder: (context) => [
icon: Icon(
Icons.more_vert,
color: Color(0xFF475569),
),
itemBuilder:
(context) => [
CustomPopupMenuEntry(
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 8, vertical: 8),
padding:
EdgeInsets.symmetric(
horizontal: 8,
vertical: 8,
),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisSize:
MainAxisSize.min,
mainAxisAlignment:
MainAxisAlignment.center,
MainAxisAlignment
.center,
children: [
IconButton(
icon: Icon(
Icons.remove_red_eye,
color: Color(0xFF475569),
size: 16),
Icons
.remove_red_eye,
color: Color(
0xFF475569,
),
size: 16,
),
onPressed: () {
Navigator.pop(
context); // Close popup manually
context,
); // Close popup manually
ApiService.viewPlan(
context, plan.planId,
isViewMode: true);
context,
plan.planId,
isViewMode:
true,
);
},
),
// IconButton(
@ -720,44 +823,65 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
// ),
IconButton(
icon: Icon(
Icons.cancel_rounded,
size: 18),
Icons
.cancel_rounded,
size: 18,
),
onPressed: () {
Navigator.pop(context);
deletePlan(plan.planId);
Navigator.pop(
context,
);
deletePlan(
plan.planId,
);
},
),
IconButton(
icon: Icon(Icons.download,
color: Color(0xFF114D8B),
size: 18),
icon: Icon(
Icons.download,
color: Color(
0xFF114D8B,
),
size: 18,
),
onPressed: () {
Navigator.pop(context);
apiService.getPdfDownload(
plan.planId);
Navigator.pop(
context,
);
apiService
.getPdfDownload(
plan.planId,
);
},
),
IconButton(
icon: const Icon(
Icons.comment,
color: Color(0xFF475569),
color: Color(
0xFF475569,
),
size: 11,
),
onPressed: () {
showDialog(
context: context,
builder: (context) =>
CommentModal(
context:
context,
builder:
(
context,
) => CommentModal(
// planId: plan.planId,
planId: plan
.planId
planId:
plan.planId
.toString(),
layoutColorForUser:
layoutColor!,
role:
"Travel Agent"),
"Travel Agent",
),
);
}),
},
),
],
),
),
@ -807,7 +931,8 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
// apiService.getPdfDownload(plan.planId);
// }),
// ])),
]);
],
);
}).toList(),
),
);
@ -821,8 +946,10 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
final plan = paginatedPlans[index];
return Card(
color: Colors.white,
margin:
EdgeInsets.symmetric(horizontal: 12, vertical: 6),
margin: EdgeInsets.symmetric(
horizontal: 12,
vertical: 6,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
@ -839,7 +966,9 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: 8, vertical: 4),
horizontal: 8,
vertical: 4,
),
decoration: BoxDecoration(
color: getStatusColor(plan.statusValue),
borderRadius: BorderRadius.circular(8),
@ -848,7 +977,8 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
plan.statusValue,
style: TextStyle(
color: getStatusTextColor(
plan.statusValue),
plan.statusValue,
),
fontSize: 10,
fontWeight: FontWeight.w600,
),
@ -871,11 +1001,14 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(' ${plan.tripTitle}',
Text(
' ${plan.tripTitle}',
style: TextStyle(
fontSize: 12,
fontFamily: "Inter",
fontWeight: FontWeight.bold)),
fontWeight: FontWeight.bold,
),
),
],
),
],
@ -890,24 +1023,28 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(' ${plan.tripType}',
Text(
' ${plan.tripType}',
style: TextStyle(
fontSize: 9,
color: Colors.black87,
fontFamily: "Inter",
)),
),
),
],
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text('${_formatDate(plan.createdOn)}',
Text(
'${_formatDate(plan.createdOn)}',
style: TextStyle(
fontSize: 9,
color: Colors.black87,
fontFamily: "Inter",
)),
),
),
],
),
],
@ -927,7 +1064,8 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
style: TextStyle(
fontSize: 9,
fontFamily: "Inter",
color: Colors.black87),
color: Colors.black87,
),
),
],
),
@ -941,7 +1079,8 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
style: TextStyle(
fontSize: 9,
fontFamily: "Inter",
color: Colors.black87),
color: Colors.black87,
),
),
],
),
@ -963,14 +1102,17 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
child: isDesktop
child:
isDesktop
? (searchController.text.isNotEmpty &&
filteredPlans.isEmpty
? Center(
child: Text(
"No matches found",
style: GoogleFonts.poppins(
fontSize: 14, color: Colors.grey),
fontSize: 14,
color: Colors.grey,
),
),
)
: SingleChildScrollView(
@ -983,7 +1125,9 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
child: Text(
"No matches found",
style: GoogleFonts.poppins(
fontSize: 14, color: Colors.grey),
fontSize: 14,
color: Colors.grey,
),
),
)
: buildMobileCardView(paginatedPlans)),
@ -1016,7 +1160,7 @@ class _TravelAgentListPlansState extends State<TravelAgentListPlans> {
),
);
},
)
),
],
),
),

File diff suppressed because it is too large Load Diff

View File

@ -1188,7 +1188,13 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
crossAxisAlignment: CrossAxisAlignment.end, // important
children:
tabs.entries.map((entry) {
final targetTab = entry.key;
print("TargetsTAb: $targetTab");
final isSelected = selectedTab == entry.key;
print("isSelected: $isSelected");
return GestureDetector(
onTap: () {
setState(() {
@ -1201,6 +1207,9 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
if (isValid) {
selectedTab = entry.key;
}
} else if (currentTab == "office" &&
targetTab == "personal") {
selectedTab = entry.key;
} else if (currentTab == "office") {
isValid = isValidDataTwo(userDetials);
if (isValid) {
@ -1306,6 +1315,37 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
];
}
List<Widget> _buildBack(isDesktop, Color layoutColor) {
return [
MouseRegion(
cursor:
isViewMode
? SystemMouseCursors.forbidden
: SystemMouseCursors.click,
child: TextButton(
style: ElevatedButton.styleFrom(
backgroundColor:
isViewMode ? layoutColor : layoutColor, // Keep original color
foregroundColor:
isViewMode ? Colors.white : Colors.red, // Keep original color
disabledBackgroundColor:
layoutColor, // Ensure color remains when disabled
disabledForegroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(color: layoutColor, width: 2),
),
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
),
onPressed: handleNext,
// onPressed:
// isViewMode ? null : handleNext, // Disable when in view mode
child: Text("Next"),
),
),
];
}
List<Widget> _buildSubmit(isDesktop, Color layoutColor) {
return [
ElevatedButton(

View File

@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'app.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
void main() {
setUrlStrategy(PathUrlStrategy());
runApp(const MyApp());
}