diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index a69436c..0625ccb 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -5,15 +5,7 @@
android:label="frontend"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
-
-
-
+
+
+
+
+
diff --git a/lib/Screens/allTrips/list_all_plans.dart b/lib/Screens/allTrips/list_all_plans.dart
index 6e8c628..536b13f 100644
--- a/lib/Screens/allTrips/list_all_plans.dart
+++ b/lib/Screens/allTrips/list_all_plans.dart
@@ -13,6 +13,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../../routes/custom_appBar.dart';
import '../../routes/custom_drawer.dart';
+import '../../routes/mainLayout.dart';
import '../../services/apiService.dart';
import '../../utils/auth_utils.dart';
import '../../utils/pagination.dart';
@@ -62,7 +63,6 @@ class _ListAllPlansState extends State {
// });
// });
});
-
// futurePlans = fetchPlans();
}
@@ -70,16 +70,20 @@ class _ListAllPlansState extends State {
print("allPlans before filtering: $allPlans");
final lowerQuery = query.toLowerCase();
setState(() {
- filteredPlans = allPlans.where((plan) {
- return (plan.planId?.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.tripType?.toLowerCase().contains(lowerQuery) ?? false) ||
- (plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
- (plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
- }).toList();
+ filteredPlans =
+ allPlans.where((plan) {
+ return (plan.planId?.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.tripType?.toLowerCase().contains(lowerQuery) ?? false) ||
+ (plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
+ (plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
+ }).toList();
+ currentPage = 0;
});
print("filteredPlans: $filteredPlans");
}
@@ -89,13 +93,15 @@ class _ListAllPlansState extends State {
String? bodyStringColor = await getBodyColor();
setState(() {
- layoutColor = layoutString != null
- ? Color(int.parse(layoutString))
- : Colors.redAccent;
+ layoutColor =
+ layoutString != null
+ ? Color(int.parse(layoutString))
+ : Colors.redAccent;
- bodyColor = bodyStringColor != null
- ? Color(int.parse(bodyStringColor))
- : Colors.white;
+ bodyColor =
+ bodyStringColor != null
+ ? Color(int.parse(bodyStringColor))
+ : Colors.white;
});
}
@@ -202,6 +208,7 @@ class _ListAllPlansState extends State {
if (response.statusCode == 200) {
final data = json.decode(response.body);
+ // List plansJson = [];
List plansJson = data['data'];
return plansJson.map((json) => Plan.fromJson(json)).toList();
} else {
@@ -246,8 +253,10 @@ class _ListAllPlansState extends State {
}
void deletePlan(String planId) async {
- bool confirmed =
- await apiService.showCancelConfirmationDialog(context, layoutColor);
+ bool confirmed = await apiService.showCancelConfirmationDialog(
+ context,
+ layoutColor,
+ );
if (confirmed) {
try {
@@ -264,35 +273,41 @@ class _ListAllPlansState extends State {
}
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),
- // backgroundColor: Color(0xFFFCFCFC),
+ return Scaffold(
+ backgroundColor: Color(0xFFf5f5f5),
+ // backgroundColor: Color(0xFFFCFCFC),
- // appBar: isDesktop ? null : const CustomAppBar(title: 'Home'),
- // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
- appBar: CustomAppBar(isDesktop: isDesktop),
- drawer: CustomDrawer(isDesktop: false),
- body: Padding(
- padding: isDesktop
- ? EdgeInsets.symmetric(
- horizontal: MediaQuery.of(context).size.width *
- 0.1, // 30% of screen width as horizontal padding
- 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))
- ],
+ // appBar: isDesktop ? null : const CustomAppBar(title: 'Home'),
+ // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
+ appBar: CustomAppBar(isDesktop: isDesktop),
+ drawer: CustomDrawer(isDesktop: false),
+ body: Padding(
+ padding:
+ isDesktop
+ ? EdgeInsets.symmetric(
+ horizontal:
+ MediaQuery.of(context).size.width *
+ 0.1, // 30% of screen width as horizontal padding
+ 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)),
+ ],
+ ),
),
- ),
- );
- });
+ );
+ },
+ );
}
Widget buildGroupListLayout(bool isDesktop) {
@@ -323,8 +338,9 @@ class _ListAllPlansState extends State {
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
}
@@ -333,17 +349,19 @@ class _ListAllPlansState extends State {
return Container(
margin: isDesktop ? EdgeInsets.all(10.0) : null,
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 20, right: 20),
- height: isDesktop
- ? MediaQuery.of(context).size.height * 0.98
- : MediaQuery.of(context).size.height,
+ height:
+ isDesktop
+ ? MediaQuery.of(context).size.height * 0.98
+ : MediaQuery.of(context).size.height,
decoration: BoxDecoration(
- border: isDesktop
- ? Border.all(
- width: 2,
- color: Colors.white,
- // color: Color(0xFFF7F7FB),
- )
- : null,
+ border:
+ isDesktop
+ ? Border.all(
+ width: 2,
+ color: Colors.white,
+ // color: Color(0xFFF7F7FB),
+ )
+ : null,
color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
// color: Color(0xFFF7F7FB),
@@ -383,9 +401,7 @@ class _ListAllPlansState extends State {
],
),
- SizedBox(
- width: 1,
- ),
+ SizedBox(width: 1),
Spacer(),
if (isDesktop)
Container(
@@ -396,8 +412,10 @@ class _ListAllPlansState extends State {
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),
@@ -409,22 +427,23 @@ class _ListAllPlansState extends State {
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),
),
),
// SizedBox(width: 16),
-
Spacer(),
// ElevatedButton(
// style: ElevatedButton.styleFrom(
@@ -522,8 +541,10 @@ class _ListAllPlansState extends State {
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),
@@ -535,17 +556,19 @@ class _ListAllPlansState extends State {
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),
),
),
],
@@ -558,6 +581,8 @@ class _ListAllPlansState extends State {
} else if (snapshot.hasError ||
!snapshot.hasData ||
snapshot.data!.isEmpty) {
+ final adjHgt = MediaQuery.of(context).size.height;
+
return Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
@@ -575,21 +600,15 @@ class _ListAllPlansState extends State {
// color: Colors.redAccent),
//
// ),
- const SizedBox(height: 15),
+ SizedBox(height: adjHgt / 4),
Text(
- "No Trips",
+ " No Trips Found",
textAlign: TextAlign.center,
style: GoogleFonts.poppins(
- fontSize: 20,
- fontWeight: FontWeight.w600,
- color: Colors.black54),
- ),
- const SizedBox(height: 10),
- Text(
- "Please Create Trip",
- textAlign: TextAlign.center,
- style: GoogleFonts.poppins(
- fontSize: 12, color: Colors.grey),
+ fontSize: 20,
+ fontWeight: FontWeight.w500,
+ color: Colors.black54,
+ ),
),
],
),
@@ -605,13 +624,16 @@ class _ListAllPlansState extends State {
List 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 paginatedPlans = plans
- .skip(currentPage * itemsPerPage)
- .take(itemsPerPage)
- .toList();
+ List paginatedPlans =
+ plans
+ .skip(currentPage * itemsPerPage)
+ .take(itemsPerPage)
+ .toList();
Widget table = LayoutBuilder(
builder: (context, constraints) {
@@ -624,216 +646,326 @@ class _ListAllPlansState extends State {
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),
- )),
- DataColumn(
- label: Text(
- 'Trip Name',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Emp Code',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Traveller',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Trip Type',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Created On',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Status',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Actions',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- ],
- rows: paginatedPlans.map((plan) {
- return DataRow(cells: [
- DataCell(Text(plan.planId,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(Text(plan.tripTitle,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ),
- softWrap: true,
- overflow: TextOverflow.ellipsis)),
- DataCell(Text(plan.employeeCode ?? " - ",
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(Text(
- plan.userName.isNotEmpty
- ? plan.userName
- : plan.travellerName,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(Text(plan.tripType,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(Text(_formatDate(plan.createdOn),
- // plan.createdOn,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(
- Container(
- 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),
- ),
- child: Text(
- plan.statusValue,
- textAlign: TextAlign.center,
- style: TextStyle(
- color:
- getStatusTextColor(plan.statusValue),
- fontSize: 12,
- fontFamily: "Inter",
- fontWeight: FontWeight.w400,
- ),
- ),
+ label: Text(
+ 'Trip ID',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
),
),
- DataCell(
- Row(
- children: [
- PopupMenuButton(
- color: Colors.white,
- padding: EdgeInsets.zero,
- offset: Offset(0, 30),
- icon: Icon(
- Icons.more_vert,
- color: Color(0xFF475569),
- size: 14,
+ ),
+ DataColumn(
+ label: Text(
+ 'Trip Name',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Emp Code',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Traveller',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Trip Type',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Created On',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Status',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Actions',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ ],
+ rows:
+ paginatedPlans.map((plan) {
+ return DataRow(
+ cells: [
+ DataCell(
+ Text(
+ plan.planId,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
),
- itemBuilder: (context) => [
- CustomPopupMenuEntry(
- child: Container(
- padding: EdgeInsets.symmetric(
- horizontal: 8, vertical: 8),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: [
- IconButton(
- icon: Icon(
- Icons.remove_red_eye,
- color: Color(0xFF475569),
- size: 18),
- onPressed: () {
- Navigator.pop(
- context); // Close popup manually
- ApiService.viewPlan(
- context, plan.planId,
- isViewMode: true);
- },
- ),
- IconButton(
- icon: Image.asset(
- 'assets/images/IconsImg/edit.png',
- width: 20,
- height: 15),
- onPressed: () {
- Navigator.pop(context);
- ApiService.viewPlan(
- context, plan.planId,
- isViewMode: false);
- },
- ),
- IconButton(
- icon: Icon(
- Icons.cancel_rounded,
- size: 18),
- onPressed: () {
- Navigator.pop(context);
- deletePlan(plan.planId);
- },
- ),
- IconButton(
- icon: Icon(Icons.download,
- color: Color(0xFF114D8B),
- size: 18),
- onPressed: () {
- Navigator.pop(context);
- apiService.getPdfDownload(
- plan.planId);
- },
- ),
- IconButton(
- icon: const Icon(
- Icons.comment,
- color: Color(0xFF475569),
- size: 11,
- ),
- onPressed: () {
- showDialog(
- context: context,
- builder: (context) =>
- CommentModalList(
- // planId: plan.planId,
- planId: plan
- .planId
- .toString(),
- layoutColorForUser:
- layoutColor!,
- role: "Admin"),
- );
- }),
- ],
- ),
+ ),
+ DataCell(
+ Text(
+ plan.tripTitle,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ softWrap: true,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ DataCell(
+ Text(
+ plan.employeeCode ?? " - ",
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ DataCell(
+ Text(
+ plan.userName.isNotEmpty
+ ? plan.userName
+ : plan.travellerName,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ DataCell(
+ Text(
+ plan.tripType,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ DataCell(
+ Text(
+ _formatDate(plan.createdOn),
+ // plan.createdOn,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ DataCell(
+ Container(
+ 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,
),
),
- ],
+ child: Text(
+ plan.statusValue,
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ color: getStatusTextColor(
+ plan.statusValue,
+ ),
+ fontSize: 12,
+ fontFamily: "Inter",
+ fontWeight: FontWeight.w400,
+ ),
+ ),
+ ),
+ ),
+ DataCell(
+ Row(
+ children: [
+ PopupMenuButton(
+ color: Colors.white,
+ padding: EdgeInsets.zero,
+ offset: Offset(0, 30),
+ icon: Icon(
+ Icons.more_vert,
+ color: Color(0xFF475569),
+ size: 14,
+ ),
+ itemBuilder:
+ (context) => [
+ CustomPopupMenuEntry(
+ child: Container(
+ padding:
+ EdgeInsets.symmetric(
+ horizontal: 8,
+ vertical: 8,
+ ),
+ child: Row(
+ mainAxisSize:
+ MainAxisSize.min,
+ mainAxisAlignment:
+ MainAxisAlignment
+ .center,
+ children: [
+ IconButton(
+ icon: Icon(
+ Icons
+ .remove_red_eye,
+ color: Color(
+ 0xFF475569,
+ ),
+ size: 18,
+ ),
+ tooltip:
+ 'View The Trip Details',
+ onPressed: () {
+ Navigator.pop(
+ context,
+ ); // Close popup manually
+ ApiService.viewPlan(
+ context,
+ plan.planId,
+ isViewMode:
+ true,
+ );
+ },
+ ),
+ IconButton(
+ icon: Image.asset(
+ 'assets/images/IconsImg/edit.png',
+ width: 20,
+ height: 15,
+ ),
+ tooltip:
+ 'Edit The Trip Details',
+ onPressed: () {
+ Navigator.pop(
+ context,
+ );
+ ApiService.viewPlan(
+ context,
+ plan.planId,
+ isViewMode:
+ false,
+ );
+ },
+ ),
+ IconButton(
+ icon: Icon(
+ Icons
+ .cancel_rounded,
+ size: 18,
+ ),
+ tooltip:
+ 'Cancellation The Trip Details',
+ onPressed: () {
+ Navigator.pop(
+ context,
+ );
+ deletePlan(
+ plan.planId,
+ );
+ },
+ ),
+ IconButton(
+ icon: Icon(
+ Icons.download,
+ color: Color(
+ 0xFF114D8B,
+ ),
+ size: 18,
+ ),
+ tooltip:
+ 'Download The Trip Details',
+ onPressed: () {
+ Navigator.pop(
+ context,
+ );
+ apiService
+ .getPdfDownload(
+ plan.planId,
+ );
+ },
+ ),
+ IconButton(
+ icon: const Icon(
+ Icons.comment,
+ color: Color(
+ 0xFF475569,
+ ),
+ size: 11,
+ ),
+ tooltip:
+ 'Trip Comments',
+ onPressed: () {
+ showDialog(
+ context:
+ context,
+ builder:
+ (
+ context,
+ ) => CommentModalList(
+ // planId: plan.planId,
+ planId:
+ plan.planId
+ .toString(),
+ layoutColorForUser:
+ layoutColor!,
+ role:
+ "Admin",
+ ),
+ );
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
),
],
- ),
- ),
- ]);
- }).toList(),
+ );
+ }).toList(),
),
);
},
@@ -846,8 +978,10 @@ class _ListAllPlansState extends State {
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),
),
@@ -872,18 +1006,23 @@ class _ListAllPlansState extends State {
children: [
Container(
padding: EdgeInsets.symmetric(
- horizontal: 8, vertical: 4),
+ horizontal: 8,
+ vertical: 4,
+ ),
decoration: BoxDecoration(
color: getStatusColor(
- plan.statusValue),
- borderRadius:
- BorderRadius.circular(8),
+ plan.statusValue,
+ ),
+ borderRadius: BorderRadius.circular(
+ 8,
+ ),
),
child: Text(
plan.statusValue,
style: TextStyle(
color: getStatusTextColor(
- plan.statusValue),
+ plan.statusValue,
+ ),
fontSize: 10,
fontWeight: FontWeight.w600,
),
@@ -912,11 +1051,14 @@ class _ListAllPlansState extends State {
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
- Text(' ${plan.tripTitle}',
- style: TextStyle(
- fontSize: 12,
- fontFamily: "Inter",
- fontWeight: FontWeight.bold)),
+ Text(
+ ' ${plan.tripTitle}',
+ style: TextStyle(
+ fontSize: 12,
+ fontFamily: "Inter",
+ fontWeight: FontWeight.bold,
+ ),
+ ),
],
),
],
@@ -931,24 +1073,28 @@ class _ListAllPlansState extends State {
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
- Text(' ${plan.tripType}',
- style: TextStyle(
- fontSize: 9,
- color: Colors.black87,
- fontFamily: "Inter",
- )),
+ Text(
+ ' ${plan.tripType}',
+ style: TextStyle(
+ fontSize: 9,
+ color: Colors.black87,
+ fontFamily: "Inter",
+ ),
+ ),
],
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
- Text('${_formatDate(plan.createdOn)}',
- style: TextStyle(
- fontSize: 9,
- color: Colors.black87,
- fontFamily: "Inter",
- )),
+ Text(
+ '${_formatDate(plan.createdOn)}',
+ style: TextStyle(
+ fontSize: 9,
+ color: Colors.black87,
+ fontFamily: "Inter",
+ ),
+ ),
],
),
],
@@ -966,9 +1112,10 @@ class _ListAllPlansState extends State {
? '${plan.userName}'
: '${plan.travellerName}',
style: TextStyle(
- fontSize: 9,
- fontFamily: "Inter",
- color: Colors.black87),
+ fontSize: 9,
+ fontFamily: "Inter",
+ color: Colors.black87,
+ ),
),
],
),
@@ -980,9 +1127,10 @@ class _ListAllPlansState extends State {
Text(
plan.employeeCode ?? 'No Data',
style: TextStyle(
- fontSize: 9,
- fontFamily: "Inter",
- color: Colors.black87),
+ fontSize: 9,
+ fontFamily: "Inter",
+ color: Colors.black87,
+ ),
),
],
),
@@ -1002,30 +1150,35 @@ class _ListAllPlansState extends State {
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
- child: isDesktop
- ? (searchController.text.isNotEmpty &&
- filteredPlans.isEmpty
- ? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14, color: Colors.grey),
- ),
- )
- : SingleChildScrollView(
- scrollDirection: Axis.vertical,
- child: table,
- ))
- : (searchController.text.isNotEmpty &&
- filteredPlans.isEmpty
- ? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14, color: Colors.grey),
- ),
- )
- : buildMobileCardView(paginatedPlans)),
+ child:
+ isDesktop
+ ? (searchController.text.isNotEmpty &&
+ filteredPlans.isEmpty
+ ? Center(
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+ )
+ : SingleChildScrollView(
+ scrollDirection: Axis.vertical,
+ child: table,
+ ))
+ : (searchController.text.isNotEmpty &&
+ filteredPlans.isEmpty
+ ? Center(
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+ )
+ : buildMobileCardView(paginatedPlans)),
// child: isDesktop
// ? SingleChildScrollView(
@@ -1055,7 +1208,7 @@ class _ListAllPlansState extends State {
),
);
},
- )
+ ),
],
),
),
diff --git a/lib/Screens/allTrips/travel_agent_list.dart b/lib/Screens/allTrips/travel_agent_list.dart
index 39523d1..ad48751 100644
--- a/lib/Screens/allTrips/travel_agent_list.dart
+++ b/lib/Screens/allTrips/travel_agent_list.dart
@@ -69,16 +69,19 @@ class _TravelAgentListPlansState extends State {
print("allPlans before filtering: $allPlans");
final lowerQuery = query.toLowerCase();
setState(() {
- filteredPlans = allPlans.where((plan) {
- return (plan.planId?.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.tripType?.toLowerCase().contains(lowerQuery) ?? false) ||
- (plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
- (plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
- }).toList();
+ filteredPlans =
+ allPlans.where((plan) {
+ return (plan.planId?.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.tripType?.toLowerCase().contains(lowerQuery) ?? false) ||
+ (plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
+ (plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
+ }).toList();
});
print("filteredPlans: $filteredPlans");
}
@@ -88,13 +91,15 @@ class _TravelAgentListPlansState extends State {
String? bodyStringColor = await getBodyColor();
setState(() {
- layoutColor = layoutString != null
- ? Color(int.parse(layoutString))
- : Colors.redAccent;
+ layoutColor =
+ layoutString != null
+ ? Color(int.parse(layoutString))
+ : Colors.redAccent;
- bodyColor = bodyStringColor != null
- ? Color(int.parse(bodyStringColor))
- : Colors.white;
+ bodyColor =
+ bodyStringColor != null
+ ? Color(int.parse(bodyStringColor))
+ : Colors.white;
});
}
@@ -195,7 +200,8 @@ class _TravelAgentListPlansState extends State {
if (response.statusCode == 200) {
final data = json.decode(response.body);
- List plansJson = data['data'];
+ List plansJson = [];
+ // List 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 {
}
void deletePlan(String planId) async {
- bool confirmed =
- await apiService.showCancelConfirmationDialog(context, layoutColor);
+ bool confirmed = await apiService.showCancelConfirmationDialog(
+ context,
+ layoutColor,
+ );
if (confirmed) {
try {
@@ -257,33 +265,39 @@ class _TravelAgentListPlansState extends State {
}
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),
- // appBar: isDesktop ? null : const CustomAppBar(title: 'Home'),
- // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
- appBar: CustomAppBar(isDesktop: isDesktop),
- drawer: CustomDrawer(isDesktop: false),
- body: Padding(
- padding: isDesktop
- ? EdgeInsets.symmetric(
- horizontal: MediaQuery.of(context).size.width *
- 0.1, // 30% of screen width as horizontal padding
- 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))
- ],
+ return Scaffold(
+ backgroundColor: Color(0xFFf5f5f5),
+ // appBar: isDesktop ? null : const CustomAppBar(title: 'Home'),
+ // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
+ appBar: CustomAppBar(isDesktop: isDesktop),
+ drawer: CustomDrawer(isDesktop: false),
+ body: Padding(
+ padding:
+ isDesktop
+ ? EdgeInsets.symmetric(
+ horizontal:
+ MediaQuery.of(context).size.width *
+ 0.1, // 30% of screen width as horizontal padding
+ 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)),
+ ],
+ ),
),
- ),
- );
- });
+ );
+ },
+ );
}
Widget buildGroupListLayout(bool isDesktop) {
@@ -313,8 +327,9 @@ class _TravelAgentListPlansState extends State {
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,17 +338,19 @@ class _TravelAgentListPlansState extends State {
return Container(
margin: isDesktop ? EdgeInsets.all(10.0) : null,
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 20, right: 20),
- height: isDesktop
- ? MediaQuery.of(context).size.height * 0.98
- : MediaQuery.of(context).size.height,
+ height:
+ isDesktop
+ ? MediaQuery.of(context).size.height * 0.98
+ : MediaQuery.of(context).size.height,
decoration: BoxDecoration(
- border: isDesktop
- ? Border.all(
- width: 2,
- color: Colors.white,
- // color: Color(0xFFF7F7FB),
- )
- : null,
+ border:
+ isDesktop
+ ? Border.all(
+ width: 2,
+ color: Colors.white,
+ // color: Color(0xFFF7F7FB),
+ )
+ : null,
color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
// color: Color(0xFFF7F7FB),
@@ -382,8 +399,10 @@ class _TravelAgentListPlansState extends State {
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 {
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 {
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 {
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 {
FutureBuilder>(
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 {
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 {
// fontSize: 22,
// fontWeight: FontWeight.bold,
// color: Colors.redAccent)),
- SizedBox(height: 20),
isDesktop
? SizedBox(
- width:
- MediaQuery.of(context).size.width * 5.5,
- )
+ width:
+ MediaQuery.of(context).size.width * 5.5,
+ )
: SizedBox.shrink(),
+ SizedBox(height: adjHgt / 4),
- Text("No Trips Pending For Your Approvals",
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 20,
- fontFamily: "Inter",
- fontWeight: FontWeight.w600,
- color: Colors.black54)),
+ Text(
+ " No Trips Found",
+ textAlign: TextAlign.center,
+ style: GoogleFonts.poppins(
+ fontSize: 20,
+ fontWeight: FontWeight.w500,
+ color: Colors.black54,
+ ),
+ ),
SizedBox(height: 10),
// Text("Please Create Trip",
// textAlign: TextAlign.center,
@@ -536,13 +563,16 @@ class _TravelAgentListPlansState extends State {
List 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 paginatedPlans = plans
- .skip(currentPage * itemsPerPage)
- .take(itemsPerPage)
- .toList();
+ List paginatedPlans =
+ plans
+ .skip(currentPage * itemsPerPage)
+ .take(itemsPerPage)
+ .toList();
Widget table = LayoutBuilder(
builder: (context, constraints) {
@@ -555,260 +585,355 @@ class _TravelAgentListPlansState extends State {
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),
- )),
- DataColumn(
- label: Text(
- 'Trip Name',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Emp Code',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Traveller',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Trip Type',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Created On',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Status',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Actions',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- ],
- rows: paginatedPlans.map((plan) {
- return DataRow(cells: [
- DataCell(Text(plan.planId,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
-
- DataCell(Text(plan.tripTitle,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ),
- softWrap: true,
- overflow: TextOverflow.ellipsis)),
-
- DataCell(Text(plan.employeeCode ?? " - ",
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(Text(
- plan.userName.isNotEmpty
- ? plan.userName
- : plan.travellerName,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(Text(plan.tripType,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- 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
- .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),
- ),
- child: Text(
- plan.statusValue,
- textAlign: TextAlign.center,
- style: TextStyle(
- color:
- getStatusTextColor(plan.statusValue),
- fontSize: 12,
- fontFamily: "Inter",
- fontWeight: FontWeight.w400,
- ),
- ),
+ label: Text(
+ 'Trip ID',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
),
),
+ ),
+ DataColumn(
+ label: Text(
+ 'Trip Name',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Emp Code',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Traveller',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Trip Type',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Created On',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Status',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Actions',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ ],
+ rows:
+ paginatedPlans.map((plan) {
+ return DataRow(
+ cells: [
+ DataCell(
+ Text(
+ plan.planId,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
- DataCell(
- Row(
- children: [
- PopupMenuButton(
- color: Colors.white,
- padding: EdgeInsets.zero,
- offset: Offset(0, 30),
- icon: Icon(Icons.more_vert,
- color: Color(0xFF475569)),
- itemBuilder: (context) => [
- CustomPopupMenuEntry(
- child: Container(
- padding: EdgeInsets.symmetric(
- horizontal: 8, vertical: 8),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: [
- IconButton(
- icon: Icon(
- Icons.remove_red_eye,
- color: Color(0xFF475569),
- size: 16),
- onPressed: () {
- Navigator.pop(
- context); // Close popup manually
- ApiService.viewPlan(
- context, plan.planId,
- isViewMode: true);
- },
- ),
- // IconButton(
- // icon: Image.asset(
- // 'assets/images/IconsImg/edit.png',
- // width: 20,
- // height: 15),
- // onPressed: () {
- // Navigator.pop(context);
- // ApiService.viewPlan(
- // context, plan.planId,
- // isViewMode: false);
- // },
- // ),
- IconButton(
- icon: Icon(
- Icons.cancel_rounded,
- size: 18),
- onPressed: () {
- Navigator.pop(context);
- deletePlan(plan.planId);
- },
- ),
- IconButton(
- icon: Icon(Icons.download,
- color: Color(0xFF114D8B),
- size: 18),
- onPressed: () {
- Navigator.pop(context);
- apiService.getPdfDownload(
- plan.planId);
- },
- ),
- IconButton(
- icon: const Icon(
- Icons.comment,
- color: Color(0xFF475569),
- size: 11,
- ),
- onPressed: () {
- showDialog(
- context: context,
- builder: (context) =>
- CommentModal(
- // planId: plan.planId,
- planId: plan
- .planId
- .toString(),
- layoutColorForUser:
- layoutColor!,
- role:
- "Travel Agent"),
- );
- }),
- ],
- ),
+ DataCell(
+ Text(
+ plan.tripTitle,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ softWrap: true,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+
+ DataCell(
+ Text(
+ plan.employeeCode ?? " - ",
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ DataCell(
+ Text(
+ plan.userName.isNotEmpty
+ ? plan.userName
+ : plan.travellerName,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ DataCell(
+ Text(
+ plan.tripType,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ 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
+ .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,
),
),
- ],
+ child: Text(
+ plan.statusValue,
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ color: getStatusTextColor(
+ plan.statusValue,
+ ),
+ fontSize: 12,
+ fontFamily: "Inter",
+ fontWeight: FontWeight.w400,
+ ),
+ ),
+ ),
),
- ],
- ),
- ),
- // DataCell(Row(children: [
- // IconButton(
- // icon: const Icon(
- // Icons.remove_red_eye,
- // color: Color(0xFF475569),
- // size: 18,
- // ),
- // onPressed: () => ApiService.viewPlan(
- // context, plan.planId,
- // isViewMode: true)),
- // GestureDetector(
- // onTap: () => ApiService.viewPlan(
- // context, plan.planId,
- // isViewMode: false),
- // child: Image.asset(
- // 'assets/images/IconsImg/edit.png',
- // width: 20,
- // height: 15),
- // ),
- // SizedBox(
- // width: 5,
- // ),
- // GestureDetector(
- // onTap: () => deletePlan(plan.planId),
- // child: Image.asset(
- // 'assets/images/IconsImg/delete.png',
- // width: 20,
- // height: 15),
- // ),
- // IconButton(
- // icon: const Icon(
- // Icons.download,
- // color: Color(0xFF475569),
- // size: 18,
- // ),
- // onPressed: () {
- // apiService.getPdfDownload(plan.planId);
- // }),
- // ])),
- ]);
- }).toList(),
+ DataCell(
+ Row(
+ children: [
+ PopupMenuButton(
+ color: Colors.white,
+ padding: EdgeInsets.zero,
+ offset: Offset(0, 30),
+ icon: Icon(
+ Icons.more_vert,
+ color: Color(0xFF475569),
+ ),
+ itemBuilder:
+ (context) => [
+ CustomPopupMenuEntry(
+ child: Container(
+ padding:
+ EdgeInsets.symmetric(
+ horizontal: 8,
+ vertical: 8,
+ ),
+ child: Row(
+ mainAxisSize:
+ MainAxisSize.min,
+ mainAxisAlignment:
+ MainAxisAlignment
+ .center,
+ children: [
+ IconButton(
+ icon: Icon(
+ Icons
+ .remove_red_eye,
+ color: Color(
+ 0xFF475569,
+ ),
+ size: 16,
+ ),
+ onPressed: () {
+ Navigator.pop(
+ context,
+ ); // Close popup manually
+ ApiService.viewPlan(
+ context,
+ plan.planId,
+ isViewMode:
+ true,
+ );
+ },
+ ),
+ // IconButton(
+ // icon: Image.asset(
+ // 'assets/images/IconsImg/edit.png',
+ // width: 20,
+ // height: 15),
+ // onPressed: () {
+ // Navigator.pop(context);
+ // ApiService.viewPlan(
+ // context, plan.planId,
+ // isViewMode: false);
+ // },
+ // ),
+ IconButton(
+ icon: Icon(
+ Icons
+ .cancel_rounded,
+ size: 18,
+ ),
+ onPressed: () {
+ Navigator.pop(
+ context,
+ );
+ deletePlan(
+ plan.planId,
+ );
+ },
+ ),
+ IconButton(
+ icon: Icon(
+ Icons.download,
+ color: Color(
+ 0xFF114D8B,
+ ),
+ size: 18,
+ ),
+ onPressed: () {
+ Navigator.pop(
+ context,
+ );
+ apiService
+ .getPdfDownload(
+ plan.planId,
+ );
+ },
+ ),
+ IconButton(
+ icon: const Icon(
+ Icons.comment,
+ color: Color(
+ 0xFF475569,
+ ),
+ size: 11,
+ ),
+ onPressed: () {
+ showDialog(
+ context:
+ context,
+ builder:
+ (
+ context,
+ ) => CommentModal(
+ // planId: plan.planId,
+ planId:
+ plan.planId
+ .toString(),
+ layoutColorForUser:
+ layoutColor!,
+ role:
+ "Travel Agent",
+ ),
+ );
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+
+ // DataCell(Row(children: [
+ // IconButton(
+ // icon: const Icon(
+ // Icons.remove_red_eye,
+ // color: Color(0xFF475569),
+ // size: 18,
+ // ),
+ // onPressed: () => ApiService.viewPlan(
+ // context, plan.planId,
+ // isViewMode: true)),
+ // GestureDetector(
+ // onTap: () => ApiService.viewPlan(
+ // context, plan.planId,
+ // isViewMode: false),
+ // child: Image.asset(
+ // 'assets/images/IconsImg/edit.png',
+ // width: 20,
+ // height: 15),
+ // ),
+ // SizedBox(
+ // width: 5,
+ // ),
+ // GestureDetector(
+ // onTap: () => deletePlan(plan.planId),
+ // child: Image.asset(
+ // 'assets/images/IconsImg/delete.png',
+ // width: 20,
+ // height: 15),
+ // ),
+ // IconButton(
+ // icon: const Icon(
+ // Icons.download,
+ // color: Color(0xFF475569),
+ // size: 18,
+ // ),
+ // onPressed: () {
+ // apiService.getPdfDownload(plan.planId);
+ // }),
+ // ])),
+ ],
+ );
+ }).toList(),
),
);
},
@@ -821,8 +946,10 @@ class _TravelAgentListPlansState extends State {
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 {
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 {
plan.statusValue,
style: TextStyle(
color: getStatusTextColor(
- plan.statusValue),
+ plan.statusValue,
+ ),
fontSize: 10,
fontWeight: FontWeight.w600,
),
@@ -871,11 +1001,14 @@ class _TravelAgentListPlansState extends State {
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
- Text(' ${plan.tripTitle}',
- style: TextStyle(
- fontSize: 12,
- fontFamily: "Inter",
- fontWeight: FontWeight.bold)),
+ Text(
+ ' ${plan.tripTitle}',
+ style: TextStyle(
+ fontSize: 12,
+ fontFamily: "Inter",
+ fontWeight: FontWeight.bold,
+ ),
+ ),
],
),
],
@@ -890,24 +1023,28 @@ class _TravelAgentListPlansState extends State {
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
- Text(' ${plan.tripType}',
- style: TextStyle(
- fontSize: 9,
- color: Colors.black87,
- fontFamily: "Inter",
- )),
+ Text(
+ ' ${plan.tripType}',
+ style: TextStyle(
+ fontSize: 9,
+ color: Colors.black87,
+ fontFamily: "Inter",
+ ),
+ ),
],
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
- Text('${_formatDate(plan.createdOn)}',
- style: TextStyle(
- fontSize: 9,
- color: Colors.black87,
- fontFamily: "Inter",
- )),
+ Text(
+ '${_formatDate(plan.createdOn)}',
+ style: TextStyle(
+ fontSize: 9,
+ color: Colors.black87,
+ fontFamily: "Inter",
+ ),
+ ),
],
),
],
@@ -925,9 +1062,10 @@ class _TravelAgentListPlansState extends State {
? '${plan.userName}'
: '${plan.travellerName}',
style: TextStyle(
- fontSize: 9,
- fontFamily: "Inter",
- color: Colors.black87),
+ fontSize: 9,
+ fontFamily: "Inter",
+ color: Colors.black87,
+ ),
),
],
),
@@ -939,9 +1077,10 @@ class _TravelAgentListPlansState extends State {
Text(
plan.employeeCode ?? 'No Data',
style: TextStyle(
- fontSize: 9,
- fontFamily: "Inter",
- color: Colors.black87),
+ fontSize: 9,
+ fontFamily: "Inter",
+ color: Colors.black87,
+ ),
),
],
),
@@ -963,30 +1102,35 @@ class _TravelAgentListPlansState extends State {
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
- child: isDesktop
- ? (searchController.text.isNotEmpty &&
- filteredPlans.isEmpty
- ? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14, color: Colors.grey),
- ),
- )
- : SingleChildScrollView(
- scrollDirection: Axis.vertical,
- child: table,
- ))
- : (searchController.text.isNotEmpty &&
- filteredPlans.isEmpty
- ? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14, color: Colors.grey),
- ),
- )
- : buildMobileCardView(paginatedPlans)),
+ child:
+ isDesktop
+ ? (searchController.text.isNotEmpty &&
+ filteredPlans.isEmpty
+ ? Center(
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+ )
+ : SingleChildScrollView(
+ scrollDirection: Axis.vertical,
+ child: table,
+ ))
+ : (searchController.text.isNotEmpty &&
+ filteredPlans.isEmpty
+ ? Center(
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+ )
+ : buildMobileCardView(paginatedPlans)),
// child: isDesktop
// ? SingleChildScrollView(
@@ -1016,7 +1160,7 @@ class _TravelAgentListPlansState extends State {
),
);
},
- )
+ ),
],
),
),
diff --git a/lib/Screens/approvals/approval_dialogs.dart b/lib/Screens/approvals/approval_dialogs.dart
index 14c145e..d8b772c 100644
--- a/lib/Screens/approvals/approval_dialogs.dart
+++ b/lib/Screens/approvals/approval_dialogs.dart
@@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
Future showApprovalDialog(
- BuildContext context, Color layoutColor) async {
+ BuildContext context,
+ Color layoutColor,
+) async {
String selectedAction = ""; // "", "accept", "reject"
String remarks = "";
@@ -24,13 +26,12 @@ Future showApprovalDialog(
Text(
"To Approve or Reject Trip",
style: TextStyle(
- fontFamily: "Inter", fontWeight: FontWeight.w500),
+ fontFamily: "Inter",
+ fontWeight: FontWeight.w500,
+ ),
),
IconButton(
- icon: const Icon(
- Icons.close,
- size: 15,
- ),
+ icon: const Icon(Icons.close, size: 15),
onPressed: () {
Navigator.pop(context, null); // Close the dialog
},
@@ -45,12 +46,14 @@ Future showApprovalDialog(
Expanded(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
- backgroundColor: selectedAction == "accept"
- ? layoutColor
- : Colors.grey.shade200,
- foregroundColor: selectedAction == "accept"
- ? Colors.white
- : Colors.black,
+ backgroundColor:
+ selectedAction == "accept"
+ ? Colors.green
+ : Colors.grey.shade200,
+ foregroundColor:
+ selectedAction == "accept"
+ ? Colors.white
+ : Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
@@ -68,12 +71,14 @@ Future showApprovalDialog(
Expanded(
child: ElevatedButton(
style: ElevatedButton.styleFrom(
- backgroundColor: selectedAction == "reject"
- ? Colors.redAccent
- : Colors.grey.shade200,
- foregroundColor: selectedAction == "reject"
- ? Colors.white
- : Colors.black,
+ backgroundColor:
+ selectedAction == "reject"
+ ? Colors.redAccent
+ : Colors.grey.shade200,
+ foregroundColor:
+ selectedAction == "reject"
+ ? Colors.white
+ : Colors.black,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
@@ -122,12 +127,16 @@ Future showApprovalDialog(
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
borderSide: const BorderSide(
- color: Colors.blueGrey, width: 0.5),
+ color: Colors.blueGrey,
+ width: 0.5,
+ ),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
- borderSide:
- BorderSide(color: Colors.blueGrey, width: 0.5),
+ borderSide: BorderSide(
+ color: Colors.blueGrey,
+ width: 0.5,
+ ),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(12),
@@ -135,7 +144,7 @@ Future showApprovalDialog(
),
),
),
- ]
+ ],
],
),
actionsAlignment: MainAxisAlignment.center,
@@ -187,94 +196,14 @@ Future showApprovalDialog(
Future showApproveDialog1(BuildContext context, Color layoutColor) {
return showDialog(
context: context,
- builder: (context) => AlertDialog(
- backgroundColor: Colors.white,
- title: const Text(
- "Confirm Approval",
- style: TextStyle(
- fontSize: 18,
- fontWeight: FontWeight.bold,
- ),
- ),
- content: const Text("Are you sure you want to approve this plan?"),
- actions: [
- ElevatedButton(
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.white,
- foregroundColor: layoutColor,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- side: BorderSide(color: layoutColor, width: 2),
- ),
- padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
- ),
- onPressed: () => Navigator.pop(context, false),
- child: const Text("Cancel"),
- ),
- ElevatedButton(
- style: ElevatedButton.styleFrom(
- backgroundColor: layoutColor,
- foregroundColor: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- side: BorderSide(color: layoutColor, width: 2),
- ),
- padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
- ),
- onPressed: () => Navigator.pop(context, true),
- child: const Text("OK"),
- ),
- ],
- ),
- );
-}
-
-/// Show confirm dialog for rejection with remarks input
-Future showRejectDialog1(
- BuildContext context, Color layoutColor) async {
- String remarks = "";
-
- final confirmed = await showDialog(
- context: context,
- builder: (context) {
- return StatefulBuilder(
- builder: (context, setState) => AlertDialog(
+ builder:
+ (context) => AlertDialog(
backgroundColor: Colors.white,
- contentPadding: const EdgeInsets.all(36),
- // title: const Text("Confirm Rejection"),
- content: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- const Text(
- "Confirm Rejection",
- style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
- ),
- const SizedBox(height: 16),
- const Text("Please enter reason for rejection."),
- const SizedBox(height: 10),
- TextField(
- maxLines: 3,
- onChanged: (value) => remarks = value,
- decoration: const InputDecoration(
- hintText: "Remarks...",
- hintStyle: TextStyle(
- fontSize: 10, // 👈 Set your desired font size here
- color: Colors.grey,
- fontFamily: "Inter", // optional if you want consistent font
- ),
- border: OutlineInputBorder(
- borderSide: BorderSide(color: Colors.blueGrey, width: 0.5),
- ),
- enabledBorder: OutlineInputBorder(
- borderSide: BorderSide(color: Colors.blueGrey, width: 0.5),
- ),
- focusedBorder: OutlineInputBorder(
- borderSide: BorderSide(color: Colors.grey, width: 1),
- ),
- ),
- ),
- ],
+ title: const Text(
+ "Confirm Approval",
+ style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
+ content: const Text("Are you sure you want to approve this plan?"),
actions: [
ElevatedButton(
style: ElevatedButton.styleFrom(
@@ -299,14 +228,102 @@ Future showRejectDialog1(
),
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
),
- onPressed: () {
- if (remarks.trim().isEmpty) return;
- Navigator.pop(context, true);
- },
+ onPressed: () => Navigator.pop(context, true),
child: const Text("OK"),
),
],
),
+ );
+}
+
+/// Show confirm dialog for rejection with remarks input
+Future showRejectDialog1(
+ BuildContext context,
+ Color layoutColor,
+) async {
+ String remarks = "";
+
+ final confirmed = await showDialog(
+ context: context,
+ builder: (context) {
+ return StatefulBuilder(
+ builder:
+ (context, setState) => AlertDialog(
+ backgroundColor: Colors.white,
+ contentPadding: const EdgeInsets.all(36),
+ // title: const Text("Confirm Rejection"),
+ content: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const Text(
+ "Confirm Rejection",
+ style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
+ ),
+ const SizedBox(height: 16),
+ const Text("Please enter reason for rejection."),
+ const SizedBox(height: 10),
+ TextField(
+ maxLines: 3,
+ onChanged: (value) => remarks = value,
+ decoration: const InputDecoration(
+ hintText: "Remarks...",
+ hintStyle: TextStyle(
+ fontSize: 10, // 👈 Set your desired font size here
+ color: Colors.grey,
+ fontFamily:
+ "Inter", // optional if you want consistent font
+ ),
+ border: OutlineInputBorder(
+ borderSide: BorderSide(
+ color: Colors.blueGrey,
+ width: 0.5,
+ ),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderSide: BorderSide(
+ color: Colors.blueGrey,
+ width: 0.5,
+ ),
+ ),
+ focusedBorder: OutlineInputBorder(
+ borderSide: BorderSide(color: Colors.grey, width: 1),
+ ),
+ ),
+ ),
+ ],
+ ),
+ actions: [
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Colors.white,
+ foregroundColor: layoutColor,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ side: BorderSide(color: layoutColor, width: 2),
+ ),
+ padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
+ ),
+ onPressed: () => Navigator.pop(context, false),
+ child: const Text("Cancel"),
+ ),
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: layoutColor,
+ foregroundColor: Colors.white,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ side: BorderSide(color: layoutColor, width: 2),
+ ),
+ padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
+ ),
+ onPressed: () {
+ if (remarks.trim().isEmpty) return;
+ Navigator.pop(context, true);
+ },
+ child: const Text("OK"),
+ ),
+ ],
+ ),
);
},
);
diff --git a/lib/Screens/approvals/approval_list.dart b/lib/Screens/approvals/approval_list.dart
index 9a1a7f0..0c464b4 100644
--- a/lib/Screens/approvals/approval_list.dart
+++ b/lib/Screens/approvals/approval_list.dart
@@ -43,8 +43,6 @@ class _ApprovalListState extends State {
List filteredPlans = [];
TextEditingController searchController = TextEditingController();
- late List plansJson;
-
@override
void initState() {
super.initState();
@@ -63,13 +61,15 @@ class _ApprovalListState extends State {
String? bodyStringColor = await getBodyColor();
setState(() {
- layoutColor = layoutString != null
- ? Color(int.parse(layoutString))
- : Colors.redAccent;
+ layoutColor =
+ layoutString != null
+ ? Color(int.parse(layoutString))
+ : Colors.redAccent;
- bodyColor = bodyStringColor != null
- ? Color(int.parse(bodyStringColor))
- : Colors.white;
+ bodyColor =
+ bodyStringColor != null
+ ? Color(int.parse(bodyStringColor))
+ : Colors.white;
});
}
@@ -186,7 +186,7 @@ class _ApprovalListState extends State {
if (response.statusCode == 200) {
final data = json.decode(response.body);
- plansJson = data['data'];
+ List plansJson = data['data'];
return plansJson.map((json) => Plan.fromJson(json)).toList();
} else {
throw Exception('Failed to load plans');
@@ -239,8 +239,10 @@ class _ApprovalListState extends State {
// print("Error fetching plan: $e");
// }
- bool confirmed =
- await apiService.showCancelConfirmationDialog(context, layoutColor);
+ bool confirmed = await apiService.showCancelConfirmationDialog(
+ context,
+ layoutColor,
+ );
if (confirmed) {
try {
@@ -282,17 +284,37 @@ class _ApprovalListState extends State {
}
}
- void viewPlanforApprover(String planId,
- {bool isViewMode = false, bool isApprover = true}) async {
+ void viewPlanforApprover(
+ String planId,
+ String? approverId,
+ String? delegaterId, {
+ bool isViewMode = false,
+ bool isApprover = true,
+ }) async {
try {
Map planData = await getViewPlan(planId);
print("ViewAAA - $planData");
- context.go('/createPlan', extra: {
- 'planData': planData,
- 'isViewMode': isViewMode,
- 'isApprover': isApprover
- });
+
+ context.replace(
+ '/approver/plans',
+ extra: {
+ 'planData': planData,
+ 'approverId': approverId,
+ 'delegaterId': delegaterId,
+ 'isViewMode': isViewMode,
+ 'isApprover': isApprover,
+ },
+ );
+
+ // context.go(
+ // '/createPlan',
+ // extra: {
+ // 'planData': planData,
+ // 'isViewMode': isViewMode,
+ // 'isApprover': isApprover,
+ // },
+ // );
} catch (e) {
print("Error fetching plan: $e");
}
@@ -314,48 +336,58 @@ class _ApprovalListState extends State {
print("allPlans before filtering: $allPlans");
final lowerQuery = query.toLowerCase();
setState(() {
- filteredPlans = allPlans.where((plan) {
- return (plan.planId?.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.tripType?.toLowerCase().contains(lowerQuery) ?? false) ||
- (plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
- (plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
- }).toList();
+ filteredPlans =
+ allPlans.where((plan) {
+ return (plan.planId?.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.tripType?.toLowerCase().contains(lowerQuery) ?? false) ||
+ (plan.createdOn?.toLowerCase().contains(lowerQuery) ?? false) ||
+ (plan.statusValue?.toLowerCase().contains(lowerQuery) ?? false);
+ }).toList();
+ currentPage = 0;
});
print("filteredPlans: $filteredPlans");
}
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),
- // appBar: isDesktop ? null : const CustomAppBar(title: 'Home'),
- // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
- appBar: CustomAppBar(isDesktop: isDesktop),
- drawer: CustomDrawer(isDesktop: false),
- body: Padding(
- padding: isDesktop
- ? EdgeInsets.symmetric(
- horizontal: MediaQuery.of(context).size.width *
- 0.1, // 30% of screen width as horizontal padding
- 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))
- ],
+ return Scaffold(
+ backgroundColor: Color(0xFFf5f5f5),
+ // appBar: isDesktop ? null : const CustomAppBar(title: 'Home'),
+ // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
+ appBar: CustomAppBar(isDesktop: isDesktop),
+ drawer: CustomDrawer(isDesktop: false),
+ body: Padding(
+ padding:
+ isDesktop
+ ? EdgeInsets.symmetric(
+ horizontal:
+ MediaQuery.of(context).size.width *
+ 0.1, // 30% of screen width as horizontal padding
+ 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)),
+ ],
+ ),
),
- ),
- );
- });
+ );
+ },
+ );
}
Widget buildGroupListLayout(bool isDesktop) {
@@ -382,11 +414,14 @@ class _ApprovalListState extends State {
// }
// }
+ final adjHgt = MediaQuery.of(context).size.height;
+
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
}
@@ -395,17 +430,19 @@ class _ApprovalListState extends State {
return Container(
margin: isDesktop ? EdgeInsets.all(10.0) : null,
padding: const EdgeInsets.only(top: 15, bottom: 15, left: 20, right: 20),
- height: isDesktop
- ? MediaQuery.of(context).size.height * 0.98
- : MediaQuery.of(context).size.height,
+ height:
+ isDesktop
+ ? MediaQuery.of(context).size.height * 0.98
+ : MediaQuery.of(context).size.height,
decoration: BoxDecoration(
- border: isDesktop
- ? Border.all(
- width: 2,
- color: Colors.white,
- // color: Color(0xFFF7F7FB),
- )
- : null,
+ border:
+ isDesktop
+ ? Border.all(
+ width: 2,
+ color: Colors.white,
+ // color: Color(0xFFF7F7FB),
+ )
+ : null,
color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
// color: Color(0xFFF7F7FB),
@@ -443,9 +480,7 @@ class _ApprovalListState extends State {
],
),
if (isDesktop)
- SizedBox(
- width: MediaQuery.of(context).size.width * 0.23,
- ),
+ SizedBox(width: MediaQuery.of(context).size.width * 0.23),
if (isDesktop)
Container(
@@ -456,8 +491,10 @@ class _ApprovalListState extends State {
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),
@@ -469,69 +506,72 @@ class _ApprovalListState extends State {
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),
),
),
// SizedBox(width: 16),
],
),
- if (!isDesktop)
- SizedBox(
- height: 5,
- ),
+ if (!isDesktop) SizedBox(height: 5),
isDesktop
? SizedBox.shrink()
: Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- Container(
- width: MediaQuery.of(context).size.width * 0.8,
- height: 35,
- child: TextField(
- controller: searchController,
- onChanged: filterPlans,
- decoration: InputDecoration(
- hintText: "Search...",
- hintStyle: TextStyle(
- fontSize: 12, color: Color(0xFF9E9DBD)),
- prefixIcon: Icon(
- Icons.search,
- color: Color(0xFF9E9DBD),
- size: 18,
- ),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- enabledBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- borderSide: BorderSide(
- color: Colors.grey.shade200, width: 0.5),
- ),
- focusedBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- borderSide: BorderSide(
- color: Colors.grey.shade300, width: 1),
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Container(
+ width: MediaQuery.of(context).size.width * 0.8,
+ height: 35,
+ child: TextField(
+ controller: searchController,
+ onChanged: filterPlans,
+ decoration: InputDecoration(
+ hintText: "Search...",
+ hintStyle: TextStyle(
+ fontSize: 12,
+ color: Color(0xFF9E9DBD),
+ ),
+ prefixIcon: Icon(
+ Icons.search,
+ color: Color(0xFF9E9DBD),
+ size: 18,
+ ),
+ border: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ borderSide: BorderSide(
+ color: Colors.grey.shade200,
+ width: 0.5,
),
),
- style: GoogleFonts.poppins(
- fontSize: 12,
+ focusedBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ borderSide: BorderSide(
+ color: Colors.grey.shade300,
+ width: 1,
+ ),
),
),
+ style: GoogleFonts.poppins(fontSize: 12),
),
- // SizedBox(width: 16),
- ],
- ),
+ ),
+ // SizedBox(width: 16),
+ ],
+ ),
const SizedBox(height: 10),
FutureBuilder>(
@@ -547,7 +587,9 @@ class _ApprovalListState extends State {
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
- children: const [
+ mainAxisAlignment: MainAxisAlignment.center,
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
// Icon(Icons.error_outline,
// color: Colors.redAccent, size: 60),
// SizedBox(height: 1),
@@ -556,14 +598,18 @@ class _ApprovalListState extends State {
// fontSize: 22,
// fontWeight: FontWeight.bold,
// color: Colors.redAccent)),
- SizedBox(height: 15),
- Text("No Trips Pending For Your Approvals",
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 20,
- fontFamily: "Inter",
- fontWeight: FontWeight.w600,
- color: Colors.black54)),
+ SizedBox(height: adjHgt / 4),
+ Text(
+ " No Trips Pending For Your Approvals",
+
+ textAlign: TextAlign.center,
+ style: GoogleFonts.poppins(
+ fontSize: 20,
+ // fontFamily: "Inter",
+ fontWeight: FontWeight.w500,
+ color: Colors.black54,
+ ),
+ ),
],
),
),
@@ -579,303 +625,414 @@ class _ApprovalListState extends State {
List 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 paginatedPlans = plans
- .skip(currentPage * itemsPerPage)
- .take(itemsPerPage)
- .toList();
+ List paginatedPlans =
+ plans
+ .skip(currentPage * itemsPerPage)
+ .take(itemsPerPage)
+ .toList();
Widget table = LayoutBuilder(
builder: (context, constraints) {
double minWidth = isDesktop ? constraints.maxWidth : 1300;
return ConstrainedBox(
- constraints: BoxConstraints(
- minWidth: minWidth,
- ),
+ constraints: BoxConstraints(minWidth: minWidth),
child: DataTable(
dividerThickness: 0.5,
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),
- )),
- DataColumn(
- label: Text(
- 'Trip Name',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Emp Code',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Traveller',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Trip Type',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Created On',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Status',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Actions',
- style: GoogleFonts.poppins(
- fontSize: 13, fontWeight: FontWeight.w600),
- )),
- ],
- rows: paginatedPlans.map((plan) {
- return DataRow(cells: [
- DataCell(Text(plan.planId,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Archivo",
- ))),
-
- DataCell(Text(plan.tripTitle,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ),
- softWrap: true,
- overflow: TextOverflow.ellipsis)),
- DataCell(Text(plan.employeeCode ?? " - ",
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(Text(
- plan.userName.isNotEmpty
- ? plan.userName
- : plan.travellerName,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(Text(plan.tripType,
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
-
- DataCell(Text(
-
- // plan.createdOn,
- _formatDate(plan.createdOn),
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(
- Container(
- 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(8),
- ),
-
- child: Text(
- plan.statusValue,
- textAlign: TextAlign.center,
- style: TextStyle(
- color:
- getStatusTextColor(plan.statusValue),
- fontSize: 12,
- fontFamily: "Inter",
- fontWeight: FontWeight.w400,
- ),
- ),
+ label: Text(
+ 'Trip ID',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
),
),
-
- DataCell(
- Row(
- children: [
- PopupMenuButton(
- color: Colors.white,
- padding: EdgeInsets.zero,
- offset: Offset(0, 30),
- icon: Icon(
- Icons.more_vert,
- color: Color(0xFF475569),
- size: 14,
+ ),
+ DataColumn(
+ label: Text(
+ 'Trip Name',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Emp Code',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Traveller',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Trip Type',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Created On',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Status',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Actions',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ ],
+ rows:
+ paginatedPlans.map((plan) {
+ return DataRow(
+ cells: [
+ DataCell(
+ Text(
+ plan.planId,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Archivo",
+ ),
),
- itemBuilder: (context) => [
- CustomPopupMenuEntry(
- child: Container(
- padding: EdgeInsets.symmetric(
- horizontal: 8, vertical: 8),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: [
- IconButton(
- icon: Icon(
- Icons.remove_red_eye,
- color:
- Color(0xFF475569),
- size: 18),
- onPressed: () {
- Navigator.pop(
- context); // Close popup manually
- viewPlanforApprover(
- plan.planId,
- isViewMode: true,
- isApprover: true);
- }),
- IconButton(
- icon: Image.asset(
- 'assets/images/IconsImg/edit.png',
- width: 20,
- height: 15),
- onPressed: () {
- print(
- "Approver Edit : ${plan.approverId}");
- print(
- "Approver Edit2 : ${plan.delegaterId}");
- Navigator.pop(context);
- ApiService
- .viewPlanForApprover(
- context,
- plan.planId,
- plan.approverId,
- plan.delegaterId,
- isViewMode: false,
- isApprover: true);
- },
- ),
- IconButton(
- icon: Icon(
- Icons.cancel_rounded,
- size: 18),
- onPressed: () {
- Navigator.pop(context);
- deletePlan(plan.planId);
- },
- ),
- IconButton(
- icon: Icon(Icons.download,
- color: Color(0xFF114D8B),
- size: 18),
- onPressed: () {
- Navigator.pop(context);
- apiService.getPdfDownload(
- plan.planId);
- },
- ),
- IconButton(
- icon: const Icon(
- Icons.comment,
- color: Color(0xFF475569),
- size: 11,
- ),
- onPressed: () {
- showDialog(
- context: context,
- builder: (context) =>
- CommentModalList(
- // planId: plan.planId,
- planId: plan
- .planId
- .toString(),
- layoutColorForUser:
- layoutColor!,
- role:
- "Approver"),
- );
- }),
- ],
- ),
+ ),
+
+ DataCell(
+ Text(
+ plan.tripTitle,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ softWrap: true,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ DataCell(
+ Text(
+ plan.employeeCode ?? " - ",
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ DataCell(
+ Text(
+ plan.userName.isNotEmpty
+ ? plan.userName
+ : plan.travellerName,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ DataCell(
+ Text(
+ plan.tripType,
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+
+ DataCell(
+ Text(
+ // plan.createdOn,
+ _formatDate(plan.createdOn),
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ ),
+ ),
+ DataCell(
+ Container(
+ 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(
+ 8,
),
),
- ],
+
+ child: Text(
+ plan.statusValue,
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ color: getStatusTextColor(
+ plan.statusValue,
+ ),
+ fontSize: 12,
+ fontFamily: "Inter",
+ fontWeight: FontWeight.w400,
+ ),
+ ),
+ ),
),
+
+ DataCell(
+ Row(
+ children: [
+ PopupMenuButton(
+ color: Colors.white,
+ padding: EdgeInsets.zero,
+ offset: Offset(0, 30),
+ icon: Icon(
+ Icons.more_vert,
+ color: Color(0xFF475569),
+ size: 14,
+ ),
+ itemBuilder:
+ (context) => [
+ CustomPopupMenuEntry(
+ child: Container(
+ padding:
+ EdgeInsets.symmetric(
+ horizontal: 8,
+ vertical: 8,
+ ),
+ child: Row(
+ mainAxisSize:
+ MainAxisSize.min,
+ mainAxisAlignment:
+ MainAxisAlignment
+ .center,
+ children: [
+ IconButton(
+ icon: Icon(
+ Icons
+ .remove_red_eye,
+ color: Color(
+ 0xFF475569,
+ ),
+ size: 18,
+ ),
+ tooltip:
+ 'View The Trip Details',
+ onPressed: () {
+ Navigator.pop(
+ context,
+ ); // Close popup manually
+ viewPlanforApprover(
+ plan.planId,
+ plan.approverId,
+ plan.delegaterId,
+ isViewMode:
+ true,
+ isApprover:
+ true,
+ );
+ },
+ ),
+ IconButton(
+ icon: Image.asset(
+ 'assets/images/IconsImg/edit.png',
+ width: 20,
+ height: 15,
+ ),
+ tooltip:
+ 'Edit The Trip Details',
+ onPressed: () {
+ print(
+ "Approver Edit : ${plan.approverId}",
+ );
+ print(
+ "Approver Edit2 : ${plan.delegaterId}",
+ );
+ Navigator.pop(
+ context,
+ );
+ ApiService.viewPlanForApprover(
+ context,
+ plan.planId,
+ plan.approverId,
+ plan.delegaterId,
+ isViewMode:
+ false,
+ isApprover:
+ true,
+ );
+ },
+ ),
+ IconButton(
+ icon: Icon(
+ Icons
+ .cancel_rounded,
+ size: 18,
+ ),
+ tooltip:
+ 'Cancellation The Trip Details',
+ onPressed: () {
+ Navigator.pop(
+ context,
+ );
+ deletePlan(
+ plan.planId,
+ );
+ },
+ ),
+ IconButton(
+ icon: Icon(
+ Icons.download,
+ color: Color(
+ 0xFF114D8B,
+ ),
+ size: 18,
+ ),
+ tooltip:
+ 'Download The Trip Details',
+ onPressed: () {
+ Navigator.pop(
+ context,
+ );
+ apiService
+ .getPdfDownload(
+ plan.planId,
+ );
+ },
+ ),
+ IconButton(
+ icon: const Icon(
+ Icons.comment,
+ color: Color(
+ 0xFF475569,
+ ),
+ size: 11,
+ ),
+ tooltip:
+ 'Approver Comment',
+ onPressed: () {
+ showDialog(
+ context:
+ context,
+ builder:
+ (
+ context,
+ ) => CommentModalList(
+ // planId: plan.planId,
+ planId:
+ plan.planId
+ .toString(),
+ layoutColorForUser:
+ layoutColor!,
+ role:
+ "Approver",
+ ),
+ );
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ // DataCell(Row(children: [
+ // IconButton(
+ // icon: const Icon(
+ // Icons.remove_red_eye,
+ // color: Color(0xFF475569),
+ // size: 18,
+ // ),
+ // onPressed: () => viewPlanforApprover(
+ // plan.planId,
+ // isViewMode: true,
+ // isApprover: true)),
+ //
+ // GestureDetector(
+ // onTap: () => ApiService.viewPlanForApprover(
+ // context, plan.planId,
+ // isViewMode: false, isApprover: true),
+ // child: Image.asset(
+ // 'assets/images/IconsImg/edit.png',
+ // width: 20,
+ // height: 15),
+ // ),
+ //
+ // // IconButton(
+ // // icon: const Icon(Icons.edit,
+ // // color: Colors.green),
+ // // onPressed: () => viewPlanforApprover(plan.planId,
+ // // isViewMode: false) ),
+ //
+ // SizedBox(
+ // width: 5,
+ // ),
+ // GestureDetector(
+ // onTap: () => deletePlan(plan.planId),
+ // child: Image.asset(
+ // 'assets/images/IconsImg/delete.png',
+ // width: 20,
+ // height: 15),
+ // ),
+ //
+ // IconButton(
+ // icon: const Icon(
+ // Icons.download,
+ // color: Color(0xFF475569),
+ // size: 18,
+ // ),
+ // onPressed: () {
+ // apiService.getPdfDownload(plan.planId);
+ // }),
+ // ])),
],
- ),
- ),
- // DataCell(Row(children: [
- // IconButton(
- // icon: const Icon(
- // Icons.remove_red_eye,
- // color: Color(0xFF475569),
- // size: 18,
- // ),
- // onPressed: () => viewPlanforApprover(
- // plan.planId,
- // isViewMode: true,
- // isApprover: true)),
- //
- // GestureDetector(
- // onTap: () => ApiService.viewPlanForApprover(
- // context, plan.planId,
- // isViewMode: false, isApprover: true),
- // child: Image.asset(
- // 'assets/images/IconsImg/edit.png',
- // width: 20,
- // height: 15),
- // ),
- //
- // // IconButton(
- // // icon: const Icon(Icons.edit,
- // // color: Colors.green),
- // // onPressed: () => viewPlanforApprover(plan.planId,
- // // isViewMode: false) ),
- //
- // SizedBox(
- // width: 5,
- // ),
- // GestureDetector(
- // onTap: () => deletePlan(plan.planId),
- // child: Image.asset(
- // 'assets/images/IconsImg/delete.png',
- // width: 20,
- // height: 15),
- // ),
- //
- // IconButton(
- // icon: const Icon(
- // Icons.download,
- // color: Color(0xFF475569),
- // size: 18,
- // ),
- // onPressed: () {
- // apiService.getPdfDownload(plan.planId);
- // }),
- // ])),
- ]);
- }).toList(),
+ );
+ }).toList(),
),
);
},
@@ -888,8 +1045,10 @@ class _ApprovalListState extends State {
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),
),
@@ -906,7 +1065,9 @@ class _ApprovalListState extends State {
children: [
Container(
padding: EdgeInsets.symmetric(
- horizontal: 8, vertical: 4),
+ horizontal: 8,
+ vertical: 4,
+ ),
decoration: BoxDecoration(
color: getStatusColor(plan.statusValue),
borderRadius: BorderRadius.circular(8),
@@ -915,7 +1076,8 @@ class _ApprovalListState extends State {
plan.statusValue,
style: TextStyle(
color: getStatusTextColor(
- plan.statusValue),
+ plan.statusValue,
+ ),
fontSize: 10,
fontWeight: FontWeight.w600,
),
@@ -930,92 +1092,126 @@ class _ApprovalListState extends State {
color: Color(0xFF475569),
size: 14,
),
- itemBuilder: (context) => [
- CustomPopupMenuEntry(
- child: Container(
- padding: EdgeInsets.symmetric(
- horizontal: 8, vertical: 8),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- mainAxisAlignment:
- MainAxisAlignment.center,
- children: [
- IconButton(
- icon: Icon(
+ itemBuilder:
+ (context) => [
+ CustomPopupMenuEntry(
+ child: Container(
+ padding: EdgeInsets.symmetric(
+ horizontal: 8,
+ vertical: 8,
+ ),
+ child: Row(
+ mainAxisSize:
+ MainAxisSize.min,
+ mainAxisAlignment:
+ MainAxisAlignment.center,
+ children: [
+ IconButton(
+ icon: Icon(
Icons.remove_red_eye,
- color:
- Color(0xFF475569),
- size: 18),
- onPressed: () {
- Navigator.pop(
- context); // Close popup manually
- viewPlanforApprover(
+ color: Color(
+ 0xFF475569,
+ ),
+ size: 18,
+ ),
+ tooltip:
+ 'View The Trip Details',
+ onPressed: () {
+ Navigator.pop(
+ context,
+ ); // Close popup manually
+ viewPlanforApprover(
plan.planId,
+ plan.approverId,
+ plan.delegaterId,
isViewMode: true,
- isApprover: true);
- }),
- IconButton(
- icon: Image.asset(
- 'assets/images/IconsImg/edit.png',
- width: 20,
- height: 15),
- onPressed: () {
- Navigator.pop(context);
- ApiService
- .viewPlanForApprover(
- context,
- plan.planId,
- plan.approverId,
- plan.delegaterId,
- isViewMode: false,
- isApprover: true);
- },
- ),
- IconButton(
- icon: Icon(
- Icons.cancel_rounded,
- size: 18),
- onPressed: () {
- Navigator.pop(context);
- deletePlan(plan.planId);
- },
- ),
- IconButton(
- icon: Icon(Icons.download,
- color: Color(0xFF114D8B),
- size: 18),
- onPressed: () {
- Navigator.pop(context);
- apiService.getPdfDownload(
- plan.planId);
- },
- ),
- IconButton(
- icon: const Icon(
- Icons.comment,
- color: Color(0xFF475569),
- size: 11,
+ isApprover: true,
+ );
+ },
),
- onPressed: () {
- showDialog(
- context: context,
- builder: (context) =>
- CommentModalList(
+ IconButton(
+ icon: Image.asset(
+ 'assets/images/IconsImg/edit.png',
+ width: 20,
+ height: 15,
+ ),
+ tooltip:
+ 'Edit The Trip Details',
+ onPressed: () {
+ Navigator.pop(context);
+ ApiService.viewPlanForApprover(
+ context,
+ plan.planId,
+ plan.approverId,
+ plan.delegaterId,
+ isViewMode: false,
+ isApprover: true,
+ );
+ },
+ ),
+ IconButton(
+ icon: Icon(
+ Icons.cancel_rounded,
+ size: 18,
+ ),
+ tooltip:
+ 'Cancellation The Trip Details',
+ onPressed: () {
+ Navigator.pop(context);
+ deletePlan(plan.planId);
+ },
+ ),
+ IconButton(
+ icon: Icon(
+ Icons.download,
+ color: Color(
+ 0xFF114D8B,
+ ),
+ size: 18,
+ ),
+ tooltip:
+ 'Download The Trip Details',
+ onPressed: () {
+ Navigator.pop(context);
+ apiService
+ .getPdfDownload(
+ plan.planId,
+ );
+ },
+ ),
+ IconButton(
+ icon: const Icon(
+ Icons.comment,
+ color: Color(
+ 0xFF475569,
+ ),
+ size: 11,
+ ),
+ tooltip: 'Trip Comments',
+ onPressed: () {
+ showDialog(
+ context: context,
+ builder:
+ (
+ context,
+ ) => CommentModalList(
// planId: plan.planId,
- planId: plan
- .planId
- .toString(),
+ planId:
+ plan.planId
+ .toString(),
layoutColorForUser:
layoutColor!,
role:
- "Approver"),
- );
- }),
- ],
+ "Approver",
+ ),
+ );
+ },
+ ),
+ ],
+ ),
+ ),
),
- ),
- ),
- ],
+ ],
),
],
),
@@ -1028,11 +1224,14 @@ class _ApprovalListState extends State {
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
- Text(' ${plan.tripTitle}',
- style: TextStyle(
- fontSize: 12,
- fontFamily: "Inter",
- fontWeight: FontWeight.bold)),
+ Text(
+ ' ${plan.tripTitle}',
+ style: TextStyle(
+ fontSize: 12,
+ fontFamily: "Inter",
+ fontWeight: FontWeight.bold,
+ ),
+ ),
],
),
],
@@ -1047,24 +1246,28 @@ class _ApprovalListState extends State {
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
- Text(' ${plan.tripType}',
- style: TextStyle(
- fontSize: 9,
- color: Colors.black87,
- fontFamily: "Inter",
- )),
+ Text(
+ ' ${plan.tripType}',
+ style: TextStyle(
+ fontSize: 9,
+ color: Colors.black87,
+ fontFamily: "Inter",
+ ),
+ ),
],
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
- Text('${_formatDate(plan.createdOn)}',
- style: TextStyle(
- fontSize: 9,
- color: Colors.black87,
- fontFamily: "Inter",
- )),
+ Text(
+ '${_formatDate(plan.createdOn)}',
+ style: TextStyle(
+ fontSize: 9,
+ color: Colors.black87,
+ fontFamily: "Inter",
+ ),
+ ),
],
),
],
@@ -1082,9 +1285,10 @@ class _ApprovalListState extends State {
? '${plan.userName}'
: '${plan.travellerName}',
style: TextStyle(
- fontSize: 9,
- fontFamily: "Inter",
- color: Colors.black87),
+ fontSize: 9,
+ fontFamily: "Inter",
+ color: Colors.black87,
+ ),
),
],
),
@@ -1096,9 +1300,10 @@ class _ApprovalListState extends State {
Text(
plan.employeeCode ?? 'No Data',
style: TextStyle(
- fontSize: 9,
- fontFamily: "Inter",
- color: Colors.black87),
+ fontSize: 9,
+ fontFamily: "Inter",
+ color: Colors.black87,
+ ),
),
],
),
@@ -1119,30 +1324,35 @@ class _ApprovalListState extends State {
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(
- child: isDesktop
- ? (searchController.text.isNotEmpty &&
- filteredPlans.isEmpty
- ? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14, color: Colors.grey),
- ),
- )
- : SingleChildScrollView(
- scrollDirection: Axis.vertical,
- child: table,
- ))
- : (searchController.text.isNotEmpty &&
- filteredPlans.isEmpty
- ? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14, color: Colors.grey),
- ),
- )
- : buildMobileCardView(paginatedPlans)),
+ child:
+ isDesktop
+ ? (searchController.text.isNotEmpty &&
+ filteredPlans.isEmpty
+ ? Center(
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+ )
+ : SingleChildScrollView(
+ scrollDirection: Axis.vertical,
+ child: table,
+ ))
+ : (searchController.text.isNotEmpty &&
+ filteredPlans.isEmpty
+ ? Center(
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+ )
+ : buildMobileCardView(paginatedPlans)),
// child: isDesktop
// ? SingleChildScrollView(
@@ -1172,7 +1382,7 @@ class _ApprovalListState extends State {
),
);
},
- )
+ ),
],
),
),
diff --git a/lib/Screens/authentication/login/login_widget.dart b/lib/Screens/authentication/login/login_widget.dart
index 5ccf7d7..e8a72fd 100644
--- a/lib/Screens/authentication/login/login_widget.dart
+++ b/lib/Screens/authentication/login/login_widget.dart
@@ -11,12 +11,14 @@ import 'package:go_router/go_router.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';
+import '../../../services/apiService.dart';
+
class LoginWidget extends StatefulWidget {
final bool isDesktop;
final bool isTablet;
const LoginWidget({Key? key, required this.isDesktop, required this.isTablet})
- : super(key: key);
+ : super(key: key);
@override
_LoginWidgetState createState() => _LoginWidgetState();
@@ -25,6 +27,9 @@ class LoginWidget extends StatefulWidget {
enum LoginStep { login, forgotEmail, otpReset }
class _LoginWidgetState extends State {
+ final ApiService apiService = ApiService();
+ bool _moved = false;
+
final _formKey = GlobalKey();
final TextEditingController _emailController = TextEditingController();
final TextEditingController _passwordController = TextEditingController();
@@ -39,6 +44,17 @@ class _LoginWidgetState extends State {
// 🔹 Login Step Enum and State Variable
LoginStep _loginStep = LoginStep.login;
+ @override
+ void initState() {
+ super.initState();
+
+ Future.delayed(Duration(milliseconds: 300), () {
+ setState(() {
+ _moved = true;
+ });
+ });
+ }
+
@override
void dispose() {
_emailController.dispose();
@@ -54,15 +70,18 @@ class _LoginWidgetState extends State {
final parts = token.split('.');
if (parts.length != 3) throw Exception('Invalid token format');
- final payload = json
- .decode(utf8.decode(base64Url.decode(base64Url.normalize(parts[1]))));
+ final payload = json.decode(
+ utf8.decode(base64Url.decode(base64Url.normalize(parts[1]))),
+ );
final userData = payload['data'];
final prefs = await SharedPreferences.getInstance();
await prefs.setString('auth_token', token);
await prefs.setString(
- 'user_data', jsonEncode(userData)); // Store full user data
+ 'user_data',
+ jsonEncode(userData),
+ ); // Store full user data
if (userData != null) {
final pref = await SharedPreferences.getInstance();
@@ -75,6 +94,8 @@ class _LoginWidgetState extends State {
print("userData11 - ${userData['role']}");
print("userData12 - $userRole");
}
+
+ await apiService.getOrganizationData();
} catch (e) {
print('Error decoding token: $e');
}
@@ -89,7 +110,7 @@ class _LoginWidgetState extends State {
Uri.parse(url),
headers: {
'Content-Type': 'application/json',
- 'Accept': 'application/json'
+ 'Accept': 'application/json',
},
body: jsonEncode({
'email': _emailController.text.trim(),
@@ -135,6 +156,8 @@ class _LoginWidgetState extends State {
backgroundColor: Colors.red,
),
);
+ _emailController.clear();
+ _passwordController.clear();
// Fluttertoast.showToast(
// msg: "Login Failed: $errorMessage",
// toastLength: Toast.LENGTH_LONG,
@@ -145,9 +168,9 @@ class _LoginWidgetState extends State {
// );
}
} catch (e) {
- ScaffoldMessenger.of(context).showSnackBar(
- SnackBar(content: Text("Error: $e")),
- );
+ ScaffoldMessenger.of(
+ context,
+ ).showSnackBar(SnackBar(content: Text("Error: $e")));
}
}
}
@@ -175,19 +198,27 @@ class _LoginWidgetState extends State {
// _clearAllFields();
});
ScaffoldMessenger.of(context).showSnackBar(
- SnackBar(content: Text("OTP sent to your email")),
+ SnackBar(
+ content: Text("OTP sent to your email"),
+ backgroundColor: Colors.green,
+ ),
);
} else {
print(response);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
- content:
- Text("${jsonDecode(response.body)['messages']['error']}")),
+ content: Text(
+ "${jsonDecode(response.body)['messages']['error']}",
+ ),
+
+ backgroundColor: Colors.red,
+ ),
);
}
} catch (e) {
- ScaffoldMessenger.of(context)
- .showSnackBar(SnackBar(content: Text("Error: $e")));
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(content: Text("Error: $e"), backgroundColor: Colors.red),
+ );
}
} else if (!_isForgotPassword && _showOtpResetFields) {
print('22');
@@ -214,20 +245,32 @@ class _LoginWidgetState extends State {
_clearAllFields();
});
ScaffoldMessenger.of(context).showSnackBar(
- SnackBar(content: Text("Password reset successfully")),
+ SnackBar(
+ content: Text("Password reset successfully"),
+ backgroundColor: Colors.green,
+ ),
);
} else {
print('23');
print('otp wrong');
+ final responseBody = json.decode(response.body);
+ final errorMessage =
+ responseBody['messages']?['error'] ?? 'An unknown error occurred';
+ print(errorMessage);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
- content: Text(
- "Reset failed: ${jsonDecode(response.body)['message']}")),
+ content: Text(
+ "Reset failed: $errorMessage",
+ // "Reset failed: ${jsonDecode(response.body)['message']}",
+ ),
+ backgroundColor: Colors.red,
+ ),
);
}
} catch (e) {
- ScaffoldMessenger.of(context)
- .showSnackBar(SnackBar(content: Text("Error: $e")));
+ ScaffoldMessenger.of(context).showSnackBar(
+ SnackBar(content: Text("Error: $e"), backgroundColor: Colors.red),
+ );
}
} else {
// Login flow
@@ -255,15 +298,15 @@ class _LoginWidgetState extends State {
}
@override
-
/// Layout
Widget build(BuildContext context) {
double formWidth = widget.isTablet ? 400 : 300;
return Container(
// color: Color(0xFF114D8B),
- color: Color(0xFFf5f5f5),
+ color: Colors.white,
+ // color: Color(0xFFf5f5f5),
padding: const EdgeInsets.all(10),
child: Row(
children: [
@@ -272,21 +315,14 @@ class _LoginWidgetState extends State {
flex: 2,
child: Container(
decoration: BoxDecoration(
- // image: DecorationImage(
- // image: AssetImage(
- // 'assets/images/login/login_travel.png',
- // ),
- // // fit: BoxFit.fill
- // fit: BoxFit.contain
- // // fit: BoxFit.cover, // or BoxFit.contain, BoxFit.fill, etc.
- // ),
color: Color(0xFFE6F0FA),
// color: Color(0xFFF0F7FF),
// color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(250), // Rounded top-left corner
- bottomRight:
- Radius.circular(250), // Rounded bottom-left corner
+ bottomRight: Radius.circular(
+ 250,
+ ), // Rounded bottom-left corner
),
),
// child: Padding(
@@ -305,24 +341,29 @@ class _LoginWidgetState extends State {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Image.asset(
- 'assets/images/login/logoNew.jpg',
+ // Image.asset(
+ // 'assets/images/login/logoNew.jpg',
+ // width: 200, // Optional: control size
+ // height: 100,
+ // fit: BoxFit.contain,
+ // ),
+ Container(
width: 200, // Optional: control size
height: 100,
- fit: BoxFit.contain,
),
Expanded(
child: Container(
child: Align(
- // alignment: Alignment.bottomRight,
- child: Image.asset(
- 'assets/images/login/login_travel.png',
- // width: 200, // Optional: control size
- // height: 100,
- fit: BoxFit.contain,
- )),
+ // alignment: Alignment.bottomRight,
+ child: Image.asset(
+ 'assets/images/login/login_travel.png',
+ // width: 200, // Optional: control size
+ // height: 100,
+ fit: BoxFit.contain,
+ ),
+ ),
),
- )
+ ),
],
),
),
@@ -332,17 +373,15 @@ class _LoginWidgetState extends State {
child: Container(
decoration: BoxDecoration(
// color: Colors.white,
-
borderRadius: BorderRadius.only(
topLeft: Radius.circular(25), // Rounded top-left corner
bottomLeft: Radius.circular(25), // Rounded bottom-left corner
),
),
- child: Center(
- child: Padding(
- padding: const EdgeInsets.all(40),
- child: _buildForm(width: formWidth), // Fixed form width
- ),
+
+ child: Padding(
+ padding: const EdgeInsets.all(10),
+ child: _buildForm(width: formWidth), // Fixed form width
),
),
),
@@ -353,436 +392,587 @@ class _LoginWidgetState extends State {
/// **Reusable Login Form**
Widget _buildForm({required double width}) {
- return SizedBox(
- width: width,
- child: Form(
- key: _formKey,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- "Sign In",
- style: GoogleFonts.poppins(
- fontSize: 18,
- fontWeight: FontWeight.w500,
- color: Color(0xFF212121)),
- ),
- const SizedBox(height: 2),
- Text(
- "Welcome To TripApprovalTool",
- style: GoogleFonts.poppins(
- fontSize: 11,
- fontWeight: FontWeight.w400,
- color: Color(0xFF212121)),
- ),
- const SizedBox(height: 18),
-
- /// **Email Field**
- if (!_isForgotPassword && !_showOtpResetFields) ...[
- _buildLabel("Email Address"),
- TextFormField(
- controller: _emailController,
- style: GoogleFonts.poppins(
- fontWeight: FontWeight.w600, fontSize: 11),
- decoration:
- _inputDecoration("Enter your email address").copyWith(
- prefixIcon: Icon(
- Icons.email_outlined,
- size: 16,
- ),
- ),
- validator: (value) =>
- value == null || value.isEmpty ? 'Required Email' : null,
- ),
-
- const SizedBox(height: 16),
-
- /// **Password Field**
- _buildLabel("Password"),
- TextFormField(
- controller: _passwordController,
- style: GoogleFonts.poppins(
- fontWeight: FontWeight.w600, fontSize: 11),
- obscureText: _obscureText,
- decoration: _inputDecoration("Enter your password").copyWith(
- prefixIcon: Icon(
- Icons.key,
- size: 16,
- ),
- suffixIcon: IconButton(
- icon: Icon(
- _obscureText ? Icons.visibility_off : Icons.visibility,
- color: Color(0xFF12B24B),
- size: 16,
- ),
- onPressed: () =>
- setState(() => _obscureText = !_obscureText),
- ),
- ),
- validator: (value) =>
- value == null || value.isEmpty ? 'Required Password' : null,
- ),
-
- const SizedBox(height: 20),
-
- /// **Login Button**
+ return Column(
+ children: [
+ // width: width,
+ // Row(
+ // mainAxisAlignment: MainAxisAlignment.end,
+ // children: [
+ //
+ // ],
+ // ),
+ Expanded(
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
Row(
+ mainAxisAlignment: MainAxisAlignment.center,
+ crossAxisAlignment: CrossAxisAlignment.center,
children: [
- Expanded(
- child: ElevatedButton(
- onPressed: () => _login(context),
- style: ElevatedButton.styleFrom(
- backgroundColor: Color(0xFF12B24B), // Button color
- foregroundColor: Colors.white, // Text color
- padding: const EdgeInsets.symmetric(
- horizontal: 24, vertical: 12),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(18)),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 24, vertical: 10),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- "Sign In",
+ SizedBox(
+ width: width,
+ child: Form(
+ key: _formKey,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Image.asset(
+ 'assets/images/login/logoNew.jpg',
+ width: 180, // Optional: control size
+ height: 70,
+ fit: BoxFit.contain,
+ ),
+ const SizedBox(height: 2),
+ Text(
+ "Sign In",
+ style: GoogleFonts.poppins(
+ fontSize: widget.isDesktop ? 20 : 18,
+ fontWeight: FontWeight.w700,
+ color: Colors.green,
+ // color: Color(0xFF212121),
+ ),
+ ),
+ const SizedBox(height: 5),
+ Text(
+ "Welcome To TripApprovalTool",
+ style: GoogleFonts.poppins(
+ fontSize: 11,
+ fontWeight: FontWeight.w400,
+
+ color: Color(0xFF212121),
+ ),
+ ),
+ const SizedBox(height: 10),
+
+ /// **Email Field**
+ if (!_isForgotPassword && !_showOtpResetFields) ...[
+ _buildLabel("Email Address"),
+ TextFormField(
+ controller: _emailController,
style: GoogleFonts.poppins(
- fontWeight: FontWeight.w800, fontSize: 15),
+ fontWeight: FontWeight.w600,
+ fontSize: 11,
+ ),
+ decoration: _inputDecoration(
+ "Enter your email address",
+ ).copyWith(
+ prefixIcon: Icon(
+ Icons.email_outlined,
+ size: 16,
+ ),
+ ),
+ validator:
+ (value) =>
+ value == null || value.isEmpty
+ ? 'Required Email'
+ : null,
),
- SizedBox(
- width: 3,
- ),
- Icon(
- Icons.arrow_forward_sharp,
- color: Colors.white,
- )
- ],
- ),
- ),
- ),
- ),
- ],
- ),
- ] else if (_isForgotPassword && !_showOtpResetFields) ...[
- _buildLabel("Email Address"),
- TextFormField(
- controller: _emailController,
- style: GoogleFonts.poppins(
- fontWeight: FontWeight.w600, fontSize: 11),
- decoration:
- _inputDecoration("Enter your email address").copyWith(
- prefixIcon: Icon(
- Icons.email_outlined,
- size: 16,
- ),
- ),
- validator: (value) =>
- value == null || value.isEmpty ? 'Required Email' : null,
- ),
- const SizedBox(height: 20),
- Row(
- children: [
- Expanded(
- child: ElevatedButton(
- onPressed: () => _onSubmit(context),
- style: ElevatedButton.styleFrom(
- backgroundColor: Color(0xFF12B24B), // Button color
- foregroundColor: Colors.white, // Text color
- padding: const EdgeInsets.symmetric(
- horizontal: 24, vertical: 12),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(18)),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 24, vertical: 10),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- "Submit",
+
+ const SizedBox(height: 10),
+
+ /// **Password Field**
+ _buildLabel("Password"),
+ // TextFormField(
+ // controller: _passwordController,
+ // style: GoogleFonts.poppins(
+ // fontWeight: FontWeight.w600,
+ // fontSize: 11,
+ // ),
+ // obscureText: _obscureText,
+ //
+ // decoration: _inputDecoration(
+ // "Enter your password",
+ // ).copyWith(
+ // prefixIcon: Icon(Icons.key, size: 16),
+ // suffixIcon: IconButton(
+ // icon: Icon(
+ // _obscureText
+ // ? Icons.visibility_off
+ // : Icons.visibility,
+ // color: Color(0xFF12B24B),
+ // size: 16,
+ // ),
+ //
+ // onPressed:
+ // () => setState(
+ // () => _obscureText = !_obscureText,
+ // ),
+ // ),
+ // ),
+ //
+ // validator:
+ // (value) =>
+ // value == null || value.isEmpty
+ // ? 'Required Password'
+ // : null,
+ // ),
+ TextFormField(
+ controller: _passwordController,
style: GoogleFonts.poppins(
- fontWeight: FontWeight.w800, fontSize: 15),
+ fontWeight: FontWeight.w600,
+ fontSize: 11,
+ ),
+ obscureText: _obscureText,
+ textInputAction: TextInputAction.done,
+ decoration: _inputDecoration(
+ "Enter your password",
+ ).copyWith(
+ prefixIcon: Icon(Icons.key, size: 16),
+ suffixIcon: IconButton(
+ icon: Icon(
+ _obscureText
+ ? Icons.visibility_off
+ : Icons.visibility,
+ color: Color(0xFF12B24B),
+ size: 16,
+ ),
+ onPressed:
+ () => setState(
+ () => _obscureText = !_obscureText,
+ ),
+ ),
+ ),
+ onFieldSubmitted: (_) {
+ if (_formKey.currentState!.validate()) {
+ _login(context);
+ }
+ },
+ validator:
+ (value) =>
+ value == null || value.isEmpty
+ ? 'Required Password'
+ : null,
),
- SizedBox(
- width: 3,
+ const SizedBox(height: 10),
+
+ /// **Login Button**
+ Row(
+ children: [
+ Expanded(
+ child: ElevatedButton(
+ onPressed: () => _login(context),
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Color(
+ 0xFF12B24B,
+ ), // Button color
+ foregroundColor:
+ Colors.white, // Text color
+ padding: const EdgeInsets.symmetric(
+ horizontal: 24,
+ vertical: 12,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(18),
+ ),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 24,
+ vertical: 5,
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ "Sign In",
+ style: GoogleFonts.poppins(
+ fontWeight: FontWeight.w800,
+ fontSize: 13.5,
+ ),
+ ),
+ SizedBox(width: 3),
+ Icon(
+ Icons.arrow_forward_sharp,
+ color: Colors.white,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ],
),
- Icon(
- Icons.arrow_forward_sharp,
- color: Colors.white,
- )
- ],
- ),
- ),
- ),
- ),
- ],
- ),
- ] else ...[
- _buildLabel("Email Address"),
- TextFormField(
- controller: _emailController,
- readOnly: true,
- style: GoogleFonts.poppins(
- fontWeight: FontWeight.w600, fontSize: 11),
- decoration:
- _inputDecoration("Enter your email address").copyWith(
- prefixIcon: Icon(
- Icons.email_outlined,
- size: 16,
- ),
- ),
- validator: (value) =>
- value == null || value.isEmpty ? 'Required Email' : null,
- ),
- const SizedBox(height: 16),
- _buildLabel("OTP"),
- TextFormField(
- controller: _otpController,
- style: GoogleFonts.poppins(
- fontWeight: FontWeight.w600, fontSize: 11),
- decoration: _inputDecoration("Enter your OTP").copyWith(
- prefixIcon: Icon(
- Icons.email_outlined,
- size: 16,
- ),
- ),
- validator: (value) =>
- value == null || value.isEmpty ? 'Required OTP' : null,
- ),
- const SizedBox(height: 16),
- _buildLabel("New Password"),
- TextFormField(
- controller: _newPasswordController,
- style: GoogleFonts.poppins(
- fontWeight: FontWeight.w600, fontSize: 11),
- obscureText: _obscureText,
- decoration:
- _inputDecoration("Enter your new password").copyWith(
- prefixIcon: Icon(
- Icons.key,
- size: 16,
- ),
- suffixIcon: IconButton(
- icon: Icon(
- _obscureText ? Icons.visibility_off : Icons.visibility,
- color: Color(0xFF12B24B),
- size: 16,
- ),
- onPressed: () =>
- setState(() => _obscureText = !_obscureText),
- ),
- ),
- validator: (value) => value == null || value.isEmpty
- ? 'Required New Password'
- : null,
- ),
- const SizedBox(height: 16),
- _buildLabel("Confirm Password"),
- TextFormField(
- controller: _confirmPasswordController,
- style: GoogleFonts.poppins(
- fontWeight: FontWeight.w600, fontSize: 11),
- obscureText: _obscureText,
- decoration:
- _inputDecoration("Enter your confirm password").copyWith(
- prefixIcon: Icon(
- Icons.key,
- size: 16,
- ),
- suffixIcon: IconButton(
- icon: Icon(
- _obscureText ? Icons.visibility_off : Icons.visibility,
- color: Color(0xFF12B24B),
- size: 16,
- ),
- onPressed: () =>
- setState(() => _obscureText = !_obscureText),
- ),
- ),
- validator: (value) {
- if (value == null || value.isEmpty) {
- return 'Required New Password';
- }
- if (value != _newPasswordController.text) {
- return 'Passwords do not match';
- }
- return null;
- },
- ),
- const SizedBox(height: 20),
- Row(
- children: [
- Expanded(
- child: ElevatedButton(
- onPressed: () {
- if (!_formKey.currentState!.validate()) return;
- setState(() {
- _isForgotPassword = false;
- _showOtpResetFields = true;
- _passwordController.clear();
- });
- _onSubmit(context);
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: Color(0xFF12B24B), // Button color
- foregroundColor: Colors.white, // Text color
- padding: const EdgeInsets.symmetric(
- horizontal: 24, vertical: 12),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(18)),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 24, vertical: 10),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- "Submit",
+ ] else if (_isForgotPassword &&
+ !_showOtpResetFields) ...[
+ _buildLabel("Email Address"),
+ TextFormField(
+ controller: _emailController,
style: GoogleFonts.poppins(
- fontWeight: FontWeight.w800, fontSize: 15),
+ fontWeight: FontWeight.w600,
+ fontSize: 11,
+ ),
+ decoration: _inputDecoration(
+ "Enter your email address",
+ ).copyWith(
+ prefixIcon: Icon(
+ Icons.email_outlined,
+ size: 16,
+ ),
+ ),
+ validator:
+ (value) =>
+ value == null || value.isEmpty
+ ? 'Required Email'
+ : null,
),
- SizedBox(
- width: 3,
+ const SizedBox(height: 10),
+ Row(
+ children: [
+ Expanded(
+ child: ElevatedButton(
+ onPressed: () => _onSubmit(context),
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Color(
+ 0xFF12B24B,
+ ), // Button color
+ foregroundColor:
+ Colors.white, // Text color
+ padding: const EdgeInsets.symmetric(
+ horizontal: 24,
+ vertical: 12,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(18),
+ ),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 24,
+ vertical: 5,
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ "Submit",
+ style: GoogleFonts.poppins(
+ fontWeight: FontWeight.w800,
+ fontSize: 13.5,
+ ),
+ ),
+ SizedBox(width: 3),
+ Icon(
+ Icons.arrow_forward_sharp,
+ color: Colors.white,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ] else ...[
+ _buildLabel("Email Address"),
+ TextFormField(
+ controller: _emailController,
+ readOnly: true,
+ style: GoogleFonts.poppins(
+ fontWeight: FontWeight.w600,
+ fontSize: 11,
+ ),
+ decoration: _inputDecoration(
+ "Enter your email address",
+ ).copyWith(
+ prefixIcon: Icon(
+ Icons.email_outlined,
+ size: 16,
+ ),
+ ),
+ validator:
+ (value) =>
+ value == null || value.isEmpty
+ ? 'Required Email'
+ : null,
+ ),
+ const SizedBox(height: 10),
+ _buildLabel("OTP"),
+ TextFormField(
+ controller: _otpController,
+ style: GoogleFonts.poppins(
+ fontWeight: FontWeight.w600,
+ fontSize: 11,
+ ),
+ decoration: _inputDecoration(
+ "Enter your OTP",
+ ).copyWith(
+ prefixIcon: Icon(
+ Icons.email_outlined,
+ size: 16,
+ ),
+ ),
+ validator:
+ (value) =>
+ value == null || value.isEmpty
+ ? 'Required OTP'
+ : null,
+ ),
+ const SizedBox(height: 10),
+ _buildLabel("New Password"),
+ TextFormField(
+ controller: _newPasswordController,
+ style: GoogleFonts.poppins(
+ fontWeight: FontWeight.w600,
+ fontSize: 11,
+ ),
+ obscureText: _obscureText,
+ decoration: _inputDecoration(
+ "Enter your new password",
+ ).copyWith(
+ prefixIcon: Icon(Icons.key, size: 16),
+ suffixIcon: IconButton(
+ icon: Icon(
+ _obscureText
+ ? Icons.visibility_off
+ : Icons.visibility,
+ color: Color(0xFF12B24B),
+ size: 16,
+ ),
+ onPressed:
+ () => setState(
+ () => _obscureText = !_obscureText,
+ ),
+ ),
+ ),
+ validator:
+ (value) =>
+ value == null || value.isEmpty
+ ? 'Required New Password'
+ : null,
+ ),
+ const SizedBox(height: 10),
+ _buildLabel("Confirm Password"),
+ TextFormField(
+ controller: _confirmPasswordController,
+ style: GoogleFonts.poppins(
+ fontWeight: FontWeight.w600,
+ fontSize: 11,
+ ),
+ obscureText: _obscureText,
+ decoration: _inputDecoration(
+ "Enter your confirm password",
+ ).copyWith(
+ prefixIcon: Icon(Icons.key, size: 16),
+ suffixIcon: IconButton(
+ icon: Icon(
+ _obscureText
+ ? Icons.visibility_off
+ : Icons.visibility,
+ color: Color(0xFF12B24B),
+ size: 16,
+ ),
+ onPressed:
+ () => setState(
+ () => _obscureText = !_obscureText,
+ ),
+ ),
+ ),
+ validator: (value) {
+ if (value == null || value.isEmpty) {
+ return 'Required New Password';
+ }
+ if (value != _newPasswordController.text) {
+ return 'Passwords do not match';
+ }
+ return null;
+ },
+ ),
+ const SizedBox(height: 10),
+ Row(
+ children: [
+ Expanded(
+ child: ElevatedButton(
+ onPressed: () {
+ if (!_formKey.currentState!.validate())
+ return;
+ setState(() {
+ _isForgotPassword = false;
+ _showOtpResetFields = true;
+ _passwordController.clear();
+ });
+ _onSubmit(context);
+ },
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Color(
+ 0xFF12B24B,
+ ), // Button color
+ foregroundColor:
+ Colors.white, // Text color
+ padding: const EdgeInsets.symmetric(
+ horizontal: 24,
+ vertical: 12,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(18),
+ ),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 24,
+ vertical: 10,
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ "Submit",
+ style: GoogleFonts.poppins(
+ fontWeight: FontWeight.w800,
+ fontSize: 13.5,
+ ),
+ ),
+ SizedBox(width: 3),
+ Icon(
+ Icons.arrow_forward_sharp,
+ color: Colors.white,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ],
),
- Icon(
- Icons.arrow_forward_sharp,
- color: Colors.white,
- )
],
- ),
+ const SizedBox(height: 10),
+ if (!_isForgotPassword && !_showOtpResetFields)
+ Center(
+ child: TextButton(
+ onPressed: () {
+ setState(() {
+ _isForgotPassword = true;
+ _showOtpResetFields = false;
+ _passwordController.clear();
+ });
+ },
+ child: Text(
+ "Forgot Password",
+ style: GoogleFonts.poppins(
+ fontSize: 11,
+ fontWeight: FontWeight.w300,
+
+ color: Color(0xFF212121), // Text color
+ decoration:
+ TextDecoration
+ .underline, // Underline the text
+ ),
+ ),
+ ),
+ ),
+ if (_isForgotPassword || _showOtpResetFields)
+ Center(
+ child: TextButton(
+ onPressed: () {
+ setState(() {
+ _isForgotPassword = false;
+ _showOtpResetFields = false;
+ _clearAllFields();
+ });
+ },
+ child: Text(
+ "Back to Login",
+ style: GoogleFonts.poppins(
+ fontSize: 11,
+ fontWeight: FontWeight.w300,
+
+ color: Color(0xFF212121), // Text color
+ decoration:
+ TextDecoration
+ .underline, // Underline the text
+ ),
+ ),
+ ),
+ ),
+
+ const SizedBox(height: 10),
+ if (!_isForgotPassword && !_showOtpResetFields)
+ Row(
+ children: [
+ Expanded(
+ child: ElevatedButton(
+ onPressed: () {
+ handleMS();
+ },
+ style: ElevatedButton.styleFrom(
+ backgroundColor:
+ Colors.white, // Button color
+ foregroundColor:
+ Colors.black, // Text color
+ padding: const EdgeInsets.symmetric(
+ horizontal: 24,
+ vertical: 5,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(18),
+ side: BorderSide(
+ color: Colors.black, // Border color
+ width: 0.5, // Border width
+ ),
+ ),
+ ),
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 24,
+ vertical: 3,
+ ),
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ Text(
+ "Sign In With Microsoft",
+ style: GoogleFonts.poppins(
+ fontWeight: FontWeight.w500,
+ fontSize: 13,
+ ),
+ ),
+ SizedBox(width: 3),
+ Image.asset(
+ 'assets/images/login/microsoft.png',
+ width: 30, // Optional: control size
+ height: 30,
+ fit: BoxFit.contain,
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ // Row(
+ // mainAxisAlignment: MainAxisAlignment.center,
+ // children: [
+ // Container(
+ // width: 30, // Adjust size
+ // height: 30,
+ // decoration: BoxDecoration(
+ // // Background color
+ // shape: BoxShape.rectangle,
+ // borderRadius: BorderRadius.all(Radius.circular(15)),
+ // border: Border.all(
+ // color: Color(0xFF9E9DBD), width: 1), // Grey outline
+ // ),
+ //
+ // child: Center(
+ // child: Image.asset(
+ // 'assets/images/login/VectorG.png',
+ // width: 20, // Optional: control size
+ // height: 20,
+ // fit: BoxFit.contain,
+ // )),
+ // ),
+ // ],
+ // ),
+ ],
),
),
),
],
),
],
- const SizedBox(height: 20),
- if (!_isForgotPassword && !_showOtpResetFields)
- Center(
- child: TextButton(
- onPressed: () {
- setState(() {
- _isForgotPassword = true;
- _showOtpResetFields = false;
- _passwordController.clear();
- });
- },
- child: Text(
- "Forgot Password",
- style: GoogleFonts.poppins(
- fontSize: 11,
- fontWeight: FontWeight.w300,
-
- color: Color(0xFF212121), // Text color
- decoration:
- TextDecoration.underline, // Underline the text
- ),
- ),
- ),
- ),
- if (_isForgotPassword || _showOtpResetFields)
- Center(
- child: TextButton(
- onPressed: () {
- setState(() {
- _isForgotPassword = false;
- _showOtpResetFields = false;
- _clearAllFields();
- });
- },
- child: Text(
- "Back to Login",
- style: GoogleFonts.poppins(
- fontSize: 11,
- fontWeight: FontWeight.w300,
-
- color: Color(0xFF212121), // Text color
- decoration:
- TextDecoration.underline, // Underline the text
- ),
- ),
- ),
- ),
-
- const SizedBox(height: 20),
- if (!_isForgotPassword && !_showOtpResetFields)
- Row(
- children: [
- Expanded(
- child: ElevatedButton(
- onPressed: () {
- handleMS();
- },
- style: ElevatedButton.styleFrom(
- backgroundColor: Colors.white, // Button color
- foregroundColor: Colors.black, // Text color
- padding: const EdgeInsets.symmetric(
- horizontal: 24, vertical: 5),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(18),
- side: BorderSide(
- color: Colors.black, // Border color
- width: 0.5, // Border width
- ),
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 24, vertical: 5),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- "Sign In With Microsoft",
- style: GoogleFonts.poppins(
- fontWeight: FontWeight.w500, fontSize: 14),
- ),
- SizedBox(
- width: 3,
- ),
- Image.asset(
- 'assets/images/login/microsoft.png',
- width: 30, // Optional: control size
- height: 30,
- fit: BoxFit.contain,
- ),
- ],
- ),
- ),
- ),
- ),
- ],
- ),
- // Row(
- // mainAxisAlignment: MainAxisAlignment.center,
- // children: [
- // Container(
- // width: 30, // Adjust size
- // height: 30,
- // decoration: BoxDecoration(
- // // Background color
- // shape: BoxShape.rectangle,
- // borderRadius: BorderRadius.all(Radius.circular(15)),
- // border: Border.all(
- // color: Color(0xFF9E9DBD), width: 1), // Grey outline
- // ),
- //
- // child: Center(
- // child: Image.asset(
- // 'assets/images/login/VectorG.png',
- // width: 20, // Optional: control size
- // height: 20,
- // fit: BoxFit.contain,
- // )),
- // ),
- // ],
- // ),
- ],
+ ),
),
- ),
+ ],
);
}
@@ -795,9 +985,10 @@ class _LoginWidgetState extends State {
child: Text(
text,
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF212121)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF212121),
+ ),
),
),
);
@@ -826,8 +1017,10 @@ class _LoginWidgetState extends State {
final url = '$apiUrl/auth/mslogin';
print(url);
try {
- final response = await http
- .get(Uri.parse(url), headers: {'Content-Type': 'application/json'});
+ final response = await http.get(
+ Uri.parse(url),
+ headers: {'Content-Type': 'application/json'},
+ );
print("inside try method");
if (response.statusCode == 200) {
final authUrl = json.decode(response.body)['auth_url'];
diff --git a/lib/Screens/costCenter/costCenterDetails.dart b/lib/Screens/costCenter/costCenterDetails.dart
index 0068d63..12d24d3 100644
--- a/lib/Screens/costCenter/costCenterDetails.dart
+++ b/lib/Screens/costCenter/costCenterDetails.dart
@@ -19,13 +19,14 @@ class CostCenterData extends StatefulWidget {
final int? costcenterId; // <-- Add this
final Map? costcenterData;
- const CostCenterData(
- {super.key,
- required this.isDesktop,
- this.layoutColor,
- required this.fetchGetCostCenter,
- this.costcenterId,
- this.costcenterData});
+ const CostCenterData({
+ super.key,
+ required this.isDesktop,
+ this.layoutColor,
+ required this.fetchGetCostCenter,
+ this.costcenterId,
+ this.costcenterData,
+ });
@override
CostCenterDataState createState() => CostCenterDataState();
@@ -49,10 +50,7 @@ class CostCenterDataState extends State {
int? costcenterDataId;
late String isActive = "1";
- List dataHeader = [
- "name",
- "description",
- ];
+ List dataHeader = ["name", "description"];
Map costcenterDetails() {
final data = {
@@ -69,7 +67,6 @@ class CostCenterDataState extends State {
void initState() {
super.initState();
-
apiData = null;
for (var field in dataHeader) {
controllers[field] = TextEditingController();
@@ -110,7 +107,6 @@ class CostCenterDataState extends State {
});
}
-
void toggleStatus() {
setState(() {
isActive = isActive == "1" ? "0" : "1";
@@ -171,7 +167,9 @@ class CostCenterDataState extends State {
apiUrldata = '$apiUrl/api/updateCostCenter/$costcenterDataId';
costcenterData["cost_center_id"] = costcenterDataId.toString();
costcenterData["updated_by"] = userId;
- (costcenterData.containsKey("created_by")) ? costcenterData.remove("created_by") : '' ;
+ (costcenterData.containsKey("created_by"))
+ ? costcenterData.remove("created_by")
+ : '';
} else {
print("for add CostCenter id - null");
apiUrldata = '$apiUrl/api/createCostCenter';
@@ -193,10 +191,10 @@ class CostCenterDataState extends State {
};
final body = jsonEncode(costcenterData);
- final response = costcenterDataId != null
- ? await http.put(uri, headers: headers, body: body)
- : await http.post(uri, headers: headers, body: body);
-
+ final response =
+ costcenterDataId != null
+ ? await http.put(uri, headers: headers, body: body)
+ : await http.post(uri, headers: headers, body: body);
switch (response.statusCode) {
case 200:
@@ -217,7 +215,6 @@ class CostCenterDataState extends State {
print("Failed to submit costcenter. Status: ${response.statusCode}");
print("Error: ${response.body}");
}
-
} catch (e) {
print(" Error submitting plan: $e");
}
@@ -225,7 +222,6 @@ class CostCenterDataState extends State {
@override
Widget build(BuildContext context) {
-
return AlertDialog(
backgroundColor: Colors.white,
contentPadding: const EdgeInsets.fromLTRB(34, 30, 34, 30),
@@ -238,27 +234,27 @@ class CostCenterDataState extends State {
Row(
children: [
Text(
- (costcenterDataId != null) ? 'Edit CostCenter' : 'Create CostCenter',
+ (costcenterDataId != null)
+ ? 'Edit CostCenter'
+ : 'Create CostCenter',
style: GoogleFonts.poppins(fontSize: 15, color: Colors.black),
),
const Spacer(),
],
),
const SizedBox(height: 2),
- Divider(
- thickness: 0.2,
- color: Colors.blueGrey.shade100,
- ),
+ Divider(thickness: 0.2, color: Colors.blueGrey.shade100),
const SizedBox(height: 5),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Name",
+ "Name *",
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
+ ),
),
SizedBox(height: 5),
CustomTextFieldForexWrapper(
@@ -266,19 +262,20 @@ class CostCenterDataState extends State {
isDesktop: widget.isDesktop,
color: Colors.transparent,
child: SizedBox(
- height: 40,
- child: TextField(
- controller: controllers["name"],
- focusNode: focusNodes["name"],
- style: const TextStyle(fontSize: 12),
- decoration: const InputDecoration(
- labelText: "Name",
- labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
- floatingLabelBehavior: FloatingLabelBehavior.never,
- border: InputBorder.none,
- contentPadding: EdgeInsets.symmetric(vertical: 16),
- ),
- )),
+ height: 40,
+ child: TextField(
+ controller: controllers["name"],
+ focusNode: focusNodes["name"],
+ style: const TextStyle(fontSize: 12),
+ decoration: const InputDecoration(
+ labelText: "Name",
+ labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
+ floatingLabelBehavior: FloatingLabelBehavior.never,
+ border: InputBorder.none,
+ contentPadding: EdgeInsets.symmetric(vertical: 16),
+ ),
+ ),
+ ),
),
if (errorMessages["name"] != null) ...[
SizedBox(height: 5), // Space before error message
@@ -289,18 +286,17 @@ class CostCenterDataState extends State {
],
],
),
- SizedBox(
- height: 15,
- ),
+ SizedBox(height: 15),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Description",
+ "Description *",
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
+ ),
),
SizedBox(height: 5),
CustomTextFieldForexWrapper(
@@ -334,41 +330,37 @@ class CostCenterDataState extends State {
],
],
),
- SizedBox(
- height: 15,
- ),
+ SizedBox(height: 15),
if (costcenterDataId != null)
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- "Change Status ",
- style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ "Change Status ",
+ style: GoogleFonts.poppins(
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
),
- Tooltip(
- message:
- isActive == "1" ? "Tap to deactivate" : "Tap to activate",
- child: GestureDetector(
- onTap: toggleStatus,
- child: Text(
- isActive == "1" ? "Active" : "Inactive",
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- color: isActive == "1" ? Colors.green : Colors.red,
- ),
+ ),
+ Tooltip(
+ message:
+ isActive == "1" ? "Tap to deactivate" : "Tap to activate",
+ child: GestureDetector(
+ onTap: toggleStatus,
+ child: Text(
+ isActive == "1" ? "Active" : "Inactive",
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ color: isActive == "1" ? Colors.green : Colors.grey,
),
),
- )
- ],
- ),
- if (costcenterDataId != null)
- SizedBox(
- height: 15,
+ ),
+ ),
+ ],
),
+ if (costcenterDataId != null) SizedBox(height: 15),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
@@ -405,16 +397,20 @@ class CostCenterDataState extends State {
borderRadius: BorderRadius.circular(8),
),
),
- child: Text('Save',
- style: GoogleFonts.poppins(
- fontSize: 11, color: Colors.white)),
+ child: Text(
+ 'Save',
+ style: GoogleFonts.poppins(
+ fontSize: 11,
+ color: Colors.white,
+ ),
+ ),
),
),
],
- )
+ ),
// : SizedBox.shrink(),
],
),
);
}
-}
\ No newline at end of file
+}
diff --git a/lib/Screens/costCenter/costCenter_list.dart b/lib/Screens/costCenter/costCenter_list.dart
index 79b102d..af92cdb 100644
--- a/lib/Screens/costCenter/costCenter_list.dart
+++ b/lib/Screens/costCenter/costCenter_list.dart
@@ -25,7 +25,7 @@ class CostCenterList extends StatefulWidget {
class CostCenterListState extends State {
final GlobalKey costCenterListKey =
- GlobalKey();
+ GlobalKey();
final ApiService apiService = ApiService();
late Future> futureCostCenter;
@@ -67,13 +67,15 @@ class CostCenterListState extends State {
String? bodyStringColor = await getBodyColor();
setState(() {
- layoutColor = layoutString != null
- ? Color(int.parse(layoutString))
- : Colors.redAccent;
+ layoutColor =
+ layoutString != null
+ ? Color(int.parse(layoutString))
+ : Colors.redAccent;
- bodyColor = bodyStringColor != null
- ? Color(int.parse(bodyStringColor))
- : Colors.white;
+ bodyColor =
+ bodyStringColor != null
+ ? Color(int.parse(bodyStringColor))
+ : Colors.white;
});
}
@@ -97,8 +99,7 @@ class CostCenterListState extends State {
}
Future> fetchGetCostCenter() async {
-
- final String apiUrlData = '$apiUrl/api/getCostCenterMaster';
+ final String apiUrlData = '$apiUrl/api/getCostCenterMaster?for=table_view';
final String? token = await getToken();
@@ -143,51 +144,60 @@ class CostCenterListState extends State {
print("all before filtering: $query");
final lowerQuery = query.toLowerCase();
setState(() {
- filteredCostCenter = allCostCenter.where((object) {
- final isActiveStatus =
- object['is_active'] == "1" ? "active" : "inactive";
- return (object['cost_center_id']?.toLowerCase().contains(lowerQuery) ??
- false) ||
- (object['name']?.toLowerCase().contains(lowerQuery) ??
- false) ||
- (object['description']?.toLowerCase().contains(lowerQuery) ?? false) ||
- (isActiveStatus.contains(lowerQuery));
- }).toList();
+ filteredCostCenter =
+ allCostCenter.where((object) {
+ final isActiveStatus =
+ object['is_active'] == "1" ? "active" : "inactive";
+ return (object['cost_center_id']?.toLowerCase().contains(
+ lowerQuery,
+ ) ??
+ false) ||
+ (object['name']?.toLowerCase().contains(lowerQuery) ?? false) ||
+ (object['description']?.toLowerCase().contains(lowerQuery) ??
+ false) ||
+ (isActiveStatus.contains(lowerQuery));
+ }).toList();
+ currentPage = 0;
});
print("filteredCostCenter: $filteredCostCenter");
-
}
@override
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),
- // appBar: isDesktop ? null : const CustomAppBar(title: 'User Management'),
- // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
- appBar: CustomAppBar(isDesktop: isDesktop),
- drawer: CustomDrawer(isDesktop: false),
- body: Padding(
- padding: isDesktop
- ? EdgeInsets.symmetric(
- horizontal: MediaQuery.of(context).size.width *
- 0.1, // 30% of screen width as horizontal padding
- 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),
- // const Expanded(child: Center(child: Text("User Page Content"))),
- Expanded(child: buildGroupList(isDesktop)),
- ],
+ return Scaffold(
+ backgroundColor: Color(0xFFf5f5f5),
+ // appBar: isDesktop ? null : const CustomAppBar(title: 'User Management'),
+ // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
+ appBar: CustomAppBar(isDesktop: isDesktop),
+ drawer: CustomDrawer(isDesktop: false),
+ body: Padding(
+ padding:
+ isDesktop
+ ? EdgeInsets.symmetric(
+ horizontal:
+ MediaQuery.of(context).size.width *
+ 0.1, // 30% of screen width as horizontal padding
+ 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),
+ // const Expanded(child: Center(child: Text("User Page Content"))),
+ Expanded(child: buildGroupList(isDesktop)),
+ ],
+ ),
),
- ),
- );
- });
+ );
+ },
+ );
}
Widget buildGroupList(bool isDesktop) {
@@ -215,98 +225,103 @@ class CostCenterListState extends State {
// ? EdgeInsets.all(10.0)
// : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0),
// padding: const EdgeInsets.all(10),
- height: isDesktop
- ? MediaQuery.of(context).size.height * 0.98
- : MediaQuery.of(context).size.height,
+ height:
+ isDesktop
+ ? MediaQuery.of(context).size.height * 0.98
+ : MediaQuery.of(context).size.height,
child: Padding(
+ padding: const EdgeInsets.all(10.0),
+ child: Container(
+ color: Colors.white,
padding: const EdgeInsets.all(10.0),
- child: Container(
- color: Colors.white,
- padding: const EdgeInsets.all(10.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ // Divider(
+ // thickness: 0.2, // how "thick" the line is
+ // color: Colors.grey, // optional
+ // ),
+ Row(
+ // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- // Divider(
- // thickness: 0.2, // how "thick" the line is
- // color: Colors.grey, // optional
- // ),
Row(
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Row(
- children: [
- Text(
- 'CostCenter Details',
- style: GoogleFonts.poppins(
- fontSize: isDesktop ? 16 : 14,
- fontWeight: FontWeight.w600,
- color: Colors.black,
- ),
- ),
- ],
+ Text(
+ 'Cost Center Details',
+ style: GoogleFonts.poppins(
+ fontSize: isDesktop ? 16 : 14,
+ fontWeight: FontWeight.w600,
+ color: Colors.black,
+ ),
),
- if (isDesktop)
- SizedBox(
- width: MediaQuery.of(context).size.width * 0.16,
- ),
+ ],
+ ),
+ if (isDesktop)
+ SizedBox(width: MediaQuery.of(context).size.width * 0.16),
- if (isDesktop)
- Container(
- width: MediaQuery.of(context).size.width * 0.2,
- height: 40,
- child: TextField(
- controller: searchController,
- onChanged: filterCostCenter,
- decoration: InputDecoration(
- hintText: "Search ...",
- hintStyle: TextStyle(
- fontSize: 12, color: Color(0xFF9E9DBD)),
- prefixIcon: Icon(
- Icons.search,
- color: Color(0xFF9E9DBD),
- size: 18,
- ),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- enabledBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- borderSide: BorderSide(
- color: Colors.grey.shade200, width: 0.5),
- ),
- focusedBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- borderSide: BorderSide(
- color: Colors.grey.shade300, width: 1),
- ),
+ if (isDesktop)
+ Container(
+ width: MediaQuery.of(context).size.width * 0.2,
+ height: 40,
+ child: TextField(
+ controller: searchController,
+ onChanged: filterCostCenter,
+ decoration: InputDecoration(
+ hintText: "Search ...",
+ hintStyle: TextStyle(
+ fontSize: 12,
+ color: Color(0xFF9E9DBD),
+ ),
+ prefixIcon: Icon(
+ Icons.search,
+ color: Color(0xFF9E9DBD),
+ size: 18,
+ ),
+ border: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ borderSide: BorderSide(
+ color: Colors.grey.shade200,
+ width: 0.5,
),
- style: GoogleFonts.poppins(
- fontSize: 12,
+ ),
+ focusedBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ borderSide: BorderSide(
+ color: Colors.grey.shade300,
+ width: 1,
),
),
),
- // SizedBox(width: 16),
- Spacer(),
+ style: GoogleFonts.poppins(fontSize: 12),
+ ),
+ ),
+ // SizedBox(width: 16),
+ Spacer(),
- ElevatedButton(
- style: ElevatedButton.styleFrom(
- backgroundColor: Color(0xFF114D8B),
- foregroundColor: Colors.white,
- disabledBackgroundColor: Color(0xFF114D8B),
- disabledForegroundColor: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- side:
- BorderSide(color: Color(0xFF114D8B), width: 2),
- ),
- padding: EdgeInsets.symmetric(
- horizontal: 20, vertical: 12),
- ),
- onPressed: () async {
- showDialog(
- context: context,
- builder: (context) => CostCenterData(
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Color(0xFF114D8B),
+ foregroundColor: Colors.white,
+ disabledBackgroundColor: Color(0xFF114D8B),
+ disabledForegroundColor: Colors.white,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ side: BorderSide(color: Color(0xFF114D8B), width: 2),
+ ),
+ padding: EdgeInsets.symmetric(
+ horizontal: 20,
+ vertical: 12,
+ ),
+ ),
+ onPressed: () async {
+ showDialog(
+ context: context,
+ builder:
+ (context) => CostCenterData(
isDesktop: isDesktop,
layoutColor: layoutColor!,
fetchGetCostCenter: refreshData,
@@ -314,37 +329,34 @@ class CostCenterListState extends State {
// role:
// "Travel Agent"
),
- );
- },
- child: Row(
- mainAxisSize:
+ );
+ },
+ child: Row(
+ mainAxisSize:
MainAxisSize.min, // Ensures content fits nicely
- children: [
- Text(
- "Add CostCenter",
- style: GoogleFonts.poppins(
- fontSize: isDesktop ? 13 : 11,
- ),
- ),
- SizedBox(width: 8), // spacing between icon and text
- Icon(
- Icons.add_circle_outline_rounded,
- size: 15,
- color: Colors.white,
- ),
- ],
+ children: [
+ Text(
+ "Add CostCenter",
+ style: GoogleFonts.poppins(
+ fontSize: isDesktop ? 13 : 11,
+ ),
),
- ),
- ],
- ),
-
- if (!isDesktop)
- SizedBox(
- height: 5,
+ SizedBox(width: 8), // spacing between icon and text
+ Icon(
+ Icons.add_circle_outline_rounded,
+ size: 15,
+ color: Colors.white,
+ ),
+ ],
),
- isDesktop
- ? SizedBox.shrink()
- : Row(
+ ),
+ ],
+ ),
+
+ if (!isDesktop) SizedBox(height: 5),
+ isDesktop
+ ? SizedBox.shrink()
+ : Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
@@ -356,7 +368,9 @@ class CostCenterListState extends State {
decoration: InputDecoration(
hintText: "Search ...",
hintStyle: TextStyle(
- fontSize: 12, color: Color(0xFF9E9DBD)),
+ fontSize: 12,
+ color: Color(0xFF9E9DBD),
+ ),
prefixIcon: Icon(
Icons.search,
color: Color(0xFF9E9DBD),
@@ -368,470 +382,535 @@ class CostCenterListState extends State {
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),
),
),
// SizedBox(width: 16),
],
),
- const SizedBox(height: 10),
- FutureBuilder>(
- future: futureCostCenter,
- builder: (context, snapshot) {
- if (snapshot.connectionState == ConnectionState.waiting) {
- return const Center(child: CircularProgressIndicator());
- } else if (snapshot.hasError ||
- !snapshot.hasData ||
- snapshot.data!.isEmpty) {
- return Center(
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- // const Icon(Icons.error_outline,
- // color: Colors.redAccent, size: 60),
- // const SizedBox(height: 16),
- // Text(
- // "Oops!",
- // style: GoogleFonts.poppins(
- // fontSize: 20,
- // fontWeight: FontWeight.bold,
- // color: Colors.redAccent),
- // ),
- const SizedBox(height: 8),
- Text(
- "No CostCenter Available ",
- textAlign: TextAlign.center,
- style: GoogleFonts.poppins(
- fontSize: 20,
- fontWeight: FontWeight.bold,
- color: Colors.grey),
- ),
- const SizedBox(height: 20),
- Text(
- "Please Create CostCenter Details",
- textAlign: TextAlign.center,
- style: GoogleFonts.poppins(
- fontSize: 16, color: Colors.grey),
- ),
- const SizedBox(height: 20),
- ],
+ const SizedBox(height: 10),
+ FutureBuilder>(
+ future: futureCostCenter,
+ builder: (context, snapshot) {
+ if (snapshot.connectionState == ConnectionState.waiting) {
+ return const Center(child: CircularProgressIndicator());
+ } else if (snapshot.hasError ||
+ !snapshot.hasData ||
+ snapshot.data!.isEmpty) {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ // const Icon(Icons.error_outline,
+ // color: Colors.redAccent, size: 60),
+ // const SizedBox(height: 16),
+ // Text(
+ // "Oops!",
+ // style: GoogleFonts.poppins(
+ // fontSize: 20,
+ // fontWeight: FontWeight.bold,
+ // color: Colors.redAccent),
+ // ),
+ const SizedBox(height: 8),
+ Text(
+ "No CostCenter Available ",
+ textAlign: TextAlign.center,
+ style: GoogleFonts.poppins(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ color: Colors.grey,
+ ),
),
- ),
- );
- }
- /* Here collect the list to displayed the data in table or card Used */
- List object =
- filteredCostCenter.isNotEmpty ? filteredCostCenter : allCostCenter;
+ const SizedBox(height: 20),
+ Text(
+ "Please Create CostCenter Details",
+ textAlign: TextAlign.center,
+ style: GoogleFonts.poppins(
+ fontSize: 16,
+ color: Colors.grey,
+ ),
+ ),
+ const SizedBox(height: 20),
+ ],
+ ),
+ ),
+ );
+ }
+ /* Here collect the list to displayed the data in table or card Used */
+ List object =
+ filteredCostCenter.isNotEmpty
+ ? filteredCostCenter
+ : allCostCenter;
- /* List is Sorting here */
- object.sort((a, b) {
- DateTime dateA = DateTime.parse(a['created_on']);
- DateTime dateB = DateTime.parse(b['created_on']);
+ /* List is Sorting here */
+ object.sort((a, b) {
+ DateTime dateA = DateTime.parse(a['created_on']);
+ DateTime dateB = DateTime.parse(b['created_on']);
- return dateB
- .compareTo(dateA); // Descending: newest first
- });
+ return dateB.compareTo(dateA); // Descending: newest first
+ });
- /* For pagination for list ... */
- List paginatedCostCenter = object
+ /* For pagination for list ... */
+ List paginatedCostCenter =
+ object
.skip(currentPage * itemsPerPage)
.take(itemsPerPage)
.toList();
- /* Table ... */
- Widget table = LayoutBuilder(
- builder: (context, constraints) {
- double minWidth =
- isDesktop ? constraints.maxWidth : 1300;
+ /* Table ... */
+ Widget table = LayoutBuilder(
+ builder: (context, constraints) {
+ double minWidth = isDesktop ? constraints.maxWidth : 1300;
- return ConstrainedBox(
- constraints: BoxConstraints(minWidth: minWidth),
- child: DataTable(
- dividerThickness: 0.5,
- columnSpacing: isDesktop ? 24.0 : 16.0,
- border: TableBorder(
- horizontalInside: BorderSide(
- width: 0.5, color: Colors.grey.shade200),
+ return ConstrainedBox(
+ constraints: BoxConstraints(minWidth: minWidth),
+ child: DataTable(
+ dividerThickness: 0.5,
+ columnSpacing: isDesktop ? 24.0 : 16.0,
+ border: TableBorder(
+ horizontalInside: BorderSide(
+ width: 0.5,
+ color: Colors.grey.shade200,
+ ),
+ ),
+ columns: [
+ DataColumn(
+ label: Text(
+ 'Name',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
),
- columns: [
- DataColumn(
- label: Text(
- 'Name',
- style: GoogleFonts.poppins(
- fontSize: 13,
- fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Description',
- style: GoogleFonts.poppins(
- fontSize: 13,
- fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Status',
- style: GoogleFonts.poppins(
- fontSize: 13,
- fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Actions',
- style: GoogleFonts.poppins(
- fontSize: 13,
- fontWeight: FontWeight.w600),
- )),
- ],
- rows: paginatedCostCenter.map((tableObject) {
- String costcenterId = tableObject['cost_center_id']
- .toString(); // Get user ID
- bool isSelected = selectedCostCenterId == costcenterId;
+ ),
+ DataColumn(
+ label: Text(
+ 'Description',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Status',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Actions',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ ],
+ rows:
+ paginatedCostCenter.map((tableObject) {
+ String costcenterId =
+ tableObject['cost_center_id']
+ .toString(); // Get user ID
+ bool isSelected =
+ selectedCostCenterId == costcenterId;
- return DataRow(cells: [
- DataCell(Text(tableObject['name'] ?? '',
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(Text(tableObject['description'] ?? 'N/A',
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
+ return DataRow(
+ cells: [
+ DataCell(
+ Text(
+ tableObject['name'] ?? '',
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
),
- softWrap: true,
- overflow: TextOverflow.ellipsis)),
- DataCell(
- Text(
- tableObject['is_active'] == "1"
- ? 'Active'
- : 'Inactive',
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- color: tableObject['is_active'] == "1" ? Colors.green : Colors.red,
- ),
- softWrap: true,
- overflow: TextOverflow.ellipsis,
),
- ),
- DataCell(
- // UserActionsMenu(
- // user: forex,
- // getUserDetails: (id) =>
- // apiService.getSingleUser(id),
- // ),
+ DataCell(
+ Text(
+ tableObject['description'] ?? 'N/A',
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ softWrap: true,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ DataCell(
+ Text(
+ tableObject['is_active'] == "1"
+ ? 'Active'
+ : 'Inactive',
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ color:
+ tableObject['is_active'] == "1"
+ ? Colors.green
+ : Colors.grey,
+ ),
+ softWrap: true,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ DataCell(
+ // UserActionsMenu(
+ // user: forex,
+ // getUserDetails: (id) =>
+ // apiService.getSingleUser(id),
+ // ),
+ GestureDetector(
+ child: Tooltip(
+ message: 'Edit CostCenter Details',
+ child: Image.asset(
+ 'assets/images/IconsImg/edit.png',
+ width: 20,
+ height: 15,
+ ),
+ ),
+ onTap: () async {
+ // final userId = getUserId(user['user_id']);
+ // final usersData = await getUserDetails(userId);
+ //
+ final costcenterId = int.tryParse(
+ tableObject['cost_center_id']
+ .toString(),
+ );
+
+ if (costcenterId != null) {
+ print(
+ "Table cell - costcenter Id -- $costcenterId",
+ );
+ final data = await apiService
+ .getCostCenterDetailsFind(
+ costcenterId,
+ );
+ print("CostCenterId -- $data");
+
+ showDialog(
+ context: context,
+ builder:
+ (context) => CostCenterData(
+ isDesktop: isDesktop,
+ costcenterId:
+ costcenterId, // Pass the ID
+ costcenterData: data,
+ layoutColor: layoutColor!,
+ // fetchGetForex: fetchGetForex,
+ fetchGetCostCenter:
+ refreshData,
+ // role:
+ // "Travel Agent"
+ ),
+ );
+ } else {
+ print("Invalid ID");
+ }
+ },
+ ),
+ ),
+ ],
+ );
+ }).toList(),
+ ),
+ );
+ },
+ );
+
+ /* Card ... */
+ Widget buildMobileCardView(List paginatedUser) {
+ return ListView.builder(
+ itemCount: paginatedUser.length,
+ itemBuilder: (context, index) {
+ final cardObject = paginatedUser[index];
+ return Card(
+ color: Colors.white,
+ margin: EdgeInsets.symmetric(
+ horizontal: 12,
+ vertical: 6,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ elevation: 3,
+ child: Padding(
+ padding: const EdgeInsets.all(12.0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ // Status and Employee Code
+ Row(
+ mainAxisAlignment:
+ MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ cardObject['name'] ?? 'N/A',
+ style: GoogleFonts.poppins(
+ fontSize: 10,
+ color: Colors.black87,
+ fontWeight: FontWeight.w700,
+ ),
+ ),
+
GestureDetector(
- child: Image.asset(
+ child: Tooltip(
+ message: 'Edit CostCenter Details',
+ child: Image.asset(
'assets/images/IconsImg/edit.png',
width: 20,
- height: 15),
+ height: 15,
+ ),
+ ),
onTap: () async {
// final userId = getUserId(user['user_id']);
// final usersData = await getUserDetails(userId);
//
final costcenterId = int.tryParse(
- tableObject['cost_center_id']
- .toString());
+ cardObject['cost_center_id']
+ .toString(),
+ );
if (costcenterId != null) {
- print("Table cell - costcenter Id -- $costcenterId");
- final data = await apiService.getCostCenterDetailsFind(costcenterId);
+ print(
+ "costcenterId -- $costcenterId",
+ );
+ final data = await apiService
+ .getCostCenterDetailsFind(
+ costcenterId,
+ );
print("CostCenterId -- $data");
showDialog(
context: context,
- builder: (context) => CostCenterData(
- isDesktop: isDesktop,
- costcenterId: costcenterId, // Pass the ID
- costcenterData: data,
- layoutColor: layoutColor!,
- // fetchGetForex: fetchGetForex,
- fetchGetCostCenter: refreshData,
- // role:
- // "Travel Agent"
- ),
+ builder:
+ (context) => CostCenterData(
+ isDesktop: isDesktop,
+ costcenterId:
+ costcenterId, // Pass the ID
+ costcenterData: data,
+ layoutColor: layoutColor!,
+ // fetchGetCostCenter: fetchGetCostCenter,
+ fetchGetCostCenter:
+ refreshData,
+ // role:
+ // "Travel Agent"
+ ),
);
} else {
print("Invalid ID");
}
},
),
- ),
- ]);
- }).toList(),
- ),
- );
- },
- );
-
- /* Card ... */
- Widget buildMobileCardView(List paginatedUser) {
- return ListView.builder(
- itemCount: paginatedUser.length,
- itemBuilder: (context, index) {
- final cardObject = paginatedUser[index];
- return Card(
- color: Colors.white,
- margin: EdgeInsets.symmetric(
- horizontal: 12, vertical: 6),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- elevation: 3,
- child: Padding(
- padding: const EdgeInsets.all(12.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Status and Employee Code
- Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: [
- Text(
- cardObject['name'] ?? 'N/A',
- style: GoogleFonts.poppins(
- fontSize: 10,
- color: Colors.black87,
- fontWeight: FontWeight.w700),
- ),
-
- GestureDetector(
- child: Image.asset(
- 'assets/images/IconsImg/edit.png',
- width: 20,
- height: 15),
- onTap: () async {
- // final userId = getUserId(user['user_id']);
- // final usersData = await getUserDetails(userId);
- //
- final costcenterId = int.tryParse(
- cardObject['cost_center_id']
- .toString());
-
- if (costcenterId != null) {
- print("costcenterId -- $costcenterId");
- final data = await apiService
- .getCostCenterDetailsFind(costcenterId);
- print("CostCenterId -- $data");
-
- showDialog(
- context: context,
- builder: (context) => CostCenterData(
- isDesktop: isDesktop,
- costcenterId:costcenterId, // Pass the ID
- costcenterData:data,
- layoutColor:layoutColor!,
- // fetchGetCostCenter: fetchGetCostCenter,
- fetchGetCostCenter: refreshData,
- // role:
- // "Travel Agent"
- ),
- );
- } else {
- print("Invalid ID");
- }
- },
- ),
- // PopupMenuButton(
- // color: Colors.white,
- // padding: EdgeInsets.zero,
- // offset: Offset(0, 30),
- // icon: Icon(
- // Icons.more_vert,
- // color: Color(0xFF475569),
- // size: 14,
- // ),
- // itemBuilder: (context) => [
- // CustomPopupMenuEntry(
- // child: Container(
- // padding: EdgeInsets.symmetric(
- // horizontal: 8, vertical: 8),
- // child: Row(
- // mainAxisSize:
- // MainAxisSize.min,
- // mainAxisAlignment:
- // MainAxisAlignment.center,
- // children: [
- // IconButton(
- // icon: Icon(
- // Icons
- // .remove_red_eye,
- // color: Color(
- // 0xFF475569),
- // size: 18),
- // onPressed: () {
- // print(
- // "USerDAta - $user");
- // // dynamic usersData = apiService
- // // .getSingleUser(user[
- // // 'user_id']
- // // is String
- // // ? int.parse(user[
- // // 'user_id'])
- // // : user[
- // // 'user_id']);
- // //
- // // print(
- // // "USerDAta - $usersData");
- //
- // context.go(
- // "/CreateUserDetails",
- // extra: {
- // "selectedUser":
- // user,
- // "isViewMode": true
- // },
- // );
- // }),
- // IconButton(
- // icon: Image.asset(
- // 'assets/images/IconsImg/edit.png',
- // width: 20,
- // height: 15),
- // onPressed: () {
- // context.go(
- // "/CreateUserDetails",
- // extra: {
- // "selectedUser":
- // user,
- // "isViewMode": false
- // },
- // );
- // },
- // ),
- // ],
- // ),
- // ),
- // ),
- // ],
- // ),
- ],
- ),
-
- SizedBox(height: 2),
- // Trip Id and Trip Name
- // Name
- Row(
- children: [
- Column(
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: [
- Text(
- cardObject['description'] ?? '',
- style: GoogleFonts.poppins(
- fontSize: 10,
- color: Colors.black87),
- ),
- ],
- ),
- SizedBox(
- width: 10,
- ),
- Column(
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: [
- Text(
- cardObject['description'] ?? '',
- style: GoogleFonts.poppins(
- fontSize: 10,
- color: Colors.black87),
- ),
- ],
- ),
- ],
- ),
- // Actions
- // Actions
+ // PopupMenuButton(
+ // color: Colors.white,
+ // padding: EdgeInsets.zero,
+ // offset: Offset(0, 30),
+ // icon: Icon(
+ // Icons.more_vert,
+ // color: Color(0xFF475569),
+ // size: 14,
+ // ),
+ // itemBuilder: (context) => [
+ // CustomPopupMenuEntry(
+ // child: Container(
+ // padding: EdgeInsets.symmetric(
+ // horizontal: 8, vertical: 8),
+ // child: Row(
+ // mainAxisSize:
+ // MainAxisSize.min,
+ // mainAxisAlignment:
+ // MainAxisAlignment.center,
+ // children: [
+ // IconButton(
+ // icon: Icon(
+ // Icons
+ // .remove_red_eye,
+ // color: Color(
+ // 0xFF475569),
+ // size: 18),
+ // onPressed: () {
+ // print(
+ // "USerDAta - $user");
+ // // dynamic usersData = apiService
+ // // .getSingleUser(user[
+ // // 'user_id']
+ // // is String
+ // // ? int.parse(user[
+ // // 'user_id'])
+ // // : user[
+ // // 'user_id']);
+ // //
+ // // print(
+ // // "USerDAta - $usersData");
+ //
+ // context.go(
+ // "/CreateUserDetails",
+ // extra: {
+ // "selectedUser":
+ // user,
+ // "isViewMode": true
+ // },
+ // );
+ // }),
+ // IconButton(
+ // icon: Image.asset(
+ // 'assets/images/IconsImg/edit.png',
+ // width: 20,
+ // height: 15),
+ // onPressed: () {
+ // context.go(
+ // "/CreateUserDetails",
+ // extra: {
+ // "selectedUser":
+ // user,
+ // "isViewMode": false
+ // },
+ // );
+ // },
+ // ),
+ // ],
+ // ),
+ // ),
+ // ),
+ // ],
+ // ),
],
),
- ),
- );
- },
- );
- }
-
- return Expanded(
- child: Column(
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(
- child: isDesktop
- ? (searchController.text.isNotEmpty &&
- filteredCostCenter.isEmpty
- ? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14,
- color: Colors.grey),
- ),
- )
- : SingleChildScrollView(
- scrollDirection: Axis.vertical,
- child: table,
- ))
- : (searchController.text.isNotEmpty &&
- filteredCostCenter.isEmpty
- ? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14,
- color: Colors.grey),
- ),
- )
- : buildMobileCardView(paginatedCostCenter)),
- ),
- // Expanded(
- // child: isDesktop
- // ? SingleChildScrollView(
- // scrollDirection: Axis.vertical,
- // child: table, // <-- your existing table
- // )
- // : buildMobileCardView(paginatedCostCenter),
- // ),
- PaginationControls(
- currentPage: currentPage,
- itemsPerPage: itemsPerPage,
- totalItems: object.length,
- activeColor: layoutColor, // your theme color
- onPageChanged: (page) {
- setState(() {
- currentPage = page;
- });
- },
- onItemsPerPageChanged: (items) {
- setState(() {
- itemsPerPage = items;
- currentPage = 0;
- });
- },
+ SizedBox(height: 2),
+ // Trip Id and Trip Name
+ // Name
+ Row(
+ children: [
+ Column(
+ crossAxisAlignment:
+ CrossAxisAlignment.start,
+ children: [
+ Text(
+ cardObject['description'] ?? '',
+ style: GoogleFonts.poppins(
+ fontSize: 10,
+ color: Colors.black87,
+ ),
+ ),
+ ],
+ ),
+ SizedBox(width: 10),
+ Column(
+ crossAxisAlignment:
+ CrossAxisAlignment.start,
+ children: [
+ Text(
+ cardObject['description'] ?? '',
+ style: GoogleFonts.poppins(
+ fontSize: 10,
+ color: Colors.black87,
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ // Actions
+ // Actions
+ ],
),
- ],
+ ),
+ );
+ },
+ );
+ }
+
+ return Expanded(
+ child: Column(
+ // mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Expanded(
+ child:
+ isDesktop
+ ? (searchController.text.isNotEmpty &&
+ filteredCostCenter.isEmpty
+ ? Center(
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+ )
+ : SingleChildScrollView(
+ scrollDirection: Axis.vertical,
+ child: table,
+ ))
+ : (searchController.text.isNotEmpty &&
+ filteredCostCenter.isEmpty
+ ? Center(
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
+ ),
+ )
+ : buildMobileCardView(
+ paginatedCostCenter,
+ )),
),
- );
- },
- )
- ]),
- )),
+ // Expanded(
+ // child: isDesktop
+ // ? SingleChildScrollView(
+ // scrollDirection: Axis.vertical,
+ // child: table, // <-- your existing table
+ // )
+ // : buildMobileCardView(paginatedCostCenter),
+ // ),
+ PaginationControls(
+ currentPage: currentPage,
+ itemsPerPage: itemsPerPage,
+ totalItems: object.length,
+ activeColor: layoutColor, // your theme color
+ onPageChanged: (page) {
+ setState(() {
+ currentPage = page;
+ });
+ },
+ onItemsPerPageChanged: (items) {
+ setState(() {
+ itemsPerPage = items;
+ currentPage = 0;
+ });
+ },
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
);
}
-}
\ No newline at end of file
+}
diff --git a/lib/Screens/dashboard/status_dashboard.dart b/lib/Screens/dashboard/status_dashboard.dart
index 23227f1..9ec8522 100644
--- a/lib/Screens/dashboard/status_dashboard.dart
+++ b/lib/Screens/dashboard/status_dashboard.dart
@@ -195,65 +195,78 @@ class StatusDashboardState extends State {
appBar: CustomAppBar(isDesktop: isDesktop),
drawer: CustomDrawer(isDesktop: false),
body: Padding(
- padding: isDesktop
- ? EdgeInsets.symmetric(
- horizontal: MediaQuery.of(context).size.width *
- 0.1, // 30% of screen width as horizontal padding
- vertical: 10, // 5% of screen height as vertical padding
- )
- : EdgeInsets.all(0),
- child:Container(
- // padding: const EdgeInsets.all(10.0),
- decoration: BoxDecoration(
- color: isDesktop ? Colors.white : const Color(0xFFFCFCFC),
- borderRadius: BorderRadius.circular(12), // 👈 Set your desired radius
- ),
- // color: isDesktop ? Colors.white : Color(0xFFFCFCFC),
- child: Row(
- children: [
- Expanded(
- child: Padding(
- padding: const EdgeInsets.all(30.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Wrap(
- spacing: 10,
- runSpacing: 10,
- children: typeBasedCount.map((item) {
- double cardWidth = isDesktop
- ? (MediaQuery.of(context).size.width * 0.75 - 10) / 2 // 80% width padding adjusted
- : MediaQuery.of(context).size.width - 24; // full width with padding
+ padding: isDesktop
+ ? EdgeInsets.symmetric(
+ horizontal: MediaQuery.of(context).size.width * 0.1, // 30% of screen width as horizontal padding
+ vertical: 10, // 5% of screen height as vertical padding
+ )
+ : EdgeInsets.all(0),
+ child : LayoutBuilder(
+ builder: (context, constraints) {
+ return SingleChildScrollView(
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ minHeight: constraints.maxHeight,
+ ),
+ child: IntrinsicHeight( // Only needed if child layout depends on height
+ child: Container(
+ decoration: BoxDecoration(
+ color: isDesktop ? Colors.white : const Color(0xFFFCFCFC),
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Row(
+ children: [
+ Expanded(
+ child: Padding(
+ padding: const EdgeInsets.all(30.0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Wrap(
+ spacing: 10,
+ runSpacing: 10,
+ children: typeBasedCount.map((item) {
+ double cardWidth = isDesktop
+ ? (MediaQuery.of(context).size.width * 0.75 - 10) / 2 // 80% width padding adjusted
+ : MediaQuery.of(context).size.width - 24; // full width with padding
- return SizedBox(
- width: cardWidth,
- child: buildInfoCard(item['value'], item['count'], cardWidth),
- );
- }).toList(),
+ return SizedBox(
+ width: cardWidth,
+ child: buildInfoCard(item['value'], item['count'], cardWidth),
+ );
+ }).toList(),
+ ),
+ const SizedBox(height: 20),
+ Wrap(
+ spacing: 10,
+ runSpacing: 10,
+ children: statusBasedCount.map((item) {
+ double cardWidth = isDesktop
+ ? (MediaQuery.of(context).size.width * 0.90 - 50) / 6 // desktop layout: 6 cards per row
+ : MediaQuery.of(context).size.width - 24; // mobile: full width
+
+ return SizedBox(
+ width: cardWidth,
+ child: buildInfoCard(item['value'], item['count'], cardWidth),
+ );
+ }).toList(),
+ ),
+
+ ],
+ ),
+ ),
+ ),
+ ],
+ ),
),
- const SizedBox(height: 20),
- Wrap(
- spacing: 10,
- runSpacing: 10,
- children: statusBasedCount.map((item) {
- double cardWidth = isDesktop
- ? (MediaQuery.of(context).size.width * 0.90 - 50) / 6 // desktop layout: 6 cards per row
- : MediaQuery.of(context).size.width - 24; // mobile: full width
-
- return SizedBox(
- width: cardWidth,
- child: buildInfoCard(item['value'], item['count'], cardWidth),
- );
- }).toList(),
- ),
-
- ],
+ ),
),
- ),
- ),
- ],
- ),
- )
+ );
+ },
+ )
+
+
+
),
);
});
diff --git a/lib/Screens/department/departmentDetails.dart b/lib/Screens/department/departmentDetails.dart
index 078e395..faa0ca3 100644
--- a/lib/Screens/department/departmentDetails.dart
+++ b/lib/Screens/department/departmentDetails.dart
@@ -19,13 +19,14 @@ class DepartmentData extends StatefulWidget {
final int? departmentId; // <-- Add this
final Map? departmentData;
- const DepartmentData(
- {super.key,
- required this.isDesktop,
- this.layoutColor,
- required this.fetchGetDepartment,
- this.departmentId,
- this.departmentData});
+ const DepartmentData({
+ super.key,
+ required this.isDesktop,
+ this.layoutColor,
+ required this.fetchGetDepartment,
+ this.departmentId,
+ this.departmentData,
+ });
@override
DepartmentDataState createState() => DepartmentDataState();
@@ -49,10 +50,7 @@ class DepartmentDataState extends State {
int? departmentDataId;
late String isActive = "1";
- List dataHeader = [
- "name",
- "description",
- ];
+ List dataHeader = ["name", "description"];
Map departmentDetails() {
final data = {
@@ -69,7 +67,6 @@ class DepartmentDataState extends State {
void initState() {
super.initState();
-
apiData = null;
for (var field in dataHeader) {
controllers[field] = TextEditingController();
@@ -110,7 +107,6 @@ class DepartmentDataState extends State {
});
}
-
void toggleStatus() {
setState(() {
isActive = isActive == "1" ? "0" : "1";
@@ -171,7 +167,9 @@ class DepartmentDataState extends State {
apiUrldata = '$apiUrl/api/updateDepartment/$departmentDataId';
departmentData["department_id"] = departmentDataId.toString();
departmentData["updated_by"] = userId;
- (departmentData.containsKey("created_by")) ? departmentData.remove("created_by") : '' ;
+ (departmentData.containsKey("created_by"))
+ ? departmentData.remove("created_by")
+ : '';
} else {
print("for add Department id - null");
apiUrldata = '$apiUrl/api/createDepartment';
@@ -193,10 +191,10 @@ class DepartmentDataState extends State {
};
final body = jsonEncode(departmentData);
- final response = departmentDataId != null
- ? await http.put(uri, headers: headers, body: body)
- : await http.post(uri, headers: headers, body: body);
-
+ final response =
+ departmentDataId != null
+ ? await http.put(uri, headers: headers, body: body)
+ : await http.post(uri, headers: headers, body: body);
switch (response.statusCode) {
case 200:
@@ -217,7 +215,6 @@ class DepartmentDataState extends State {
print("Failed to submit department. Status: ${response.statusCode}");
print("Error: ${response.body}");
}
-
} catch (e) {
print(" Error submitting plan: $e");
}
@@ -225,7 +222,6 @@ class DepartmentDataState extends State {
@override
Widget build(BuildContext context) {
-
return AlertDialog(
backgroundColor: Colors.white,
contentPadding: const EdgeInsets.fromLTRB(34, 30, 34, 30),
@@ -238,27 +234,27 @@ class DepartmentDataState extends State {
Row(
children: [
Text(
- (departmentDataId != null) ? 'Edit Department' : 'Create Department',
+ (departmentDataId != null)
+ ? 'Edit Department'
+ : 'Create Department',
style: GoogleFonts.poppins(fontSize: 15, color: Colors.black),
),
const Spacer(),
],
),
const SizedBox(height: 2),
- Divider(
- thickness: 0.2,
- color: Colors.blueGrey.shade100,
- ),
+ Divider(thickness: 0.2, color: Colors.blueGrey.shade100),
const SizedBox(height: 5),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Name",
+ "Name *",
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
+ ),
),
SizedBox(height: 5),
CustomTextFieldForexWrapper(
@@ -266,19 +262,20 @@ class DepartmentDataState extends State {
isDesktop: widget.isDesktop,
color: Colors.transparent,
child: SizedBox(
- height: 40,
- child: TextField(
- controller: controllers["name"],
- focusNode: focusNodes["name"],
- style: const TextStyle(fontSize: 12),
- decoration: const InputDecoration(
- labelText: "Name",
- labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
- floatingLabelBehavior: FloatingLabelBehavior.never,
- border: InputBorder.none,
- contentPadding: EdgeInsets.symmetric(vertical: 16),
- ),
- )),
+ height: 40,
+ child: TextField(
+ controller: controllers["name"],
+ focusNode: focusNodes["name"],
+ style: const TextStyle(fontSize: 12),
+ decoration: const InputDecoration(
+ labelText: "Name",
+ labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
+ floatingLabelBehavior: FloatingLabelBehavior.never,
+ border: InputBorder.none,
+ contentPadding: EdgeInsets.symmetric(vertical: 16),
+ ),
+ ),
+ ),
),
if (errorMessages["name"] != null) ...[
SizedBox(height: 5), // Space before error message
@@ -289,18 +286,17 @@ class DepartmentDataState extends State {
],
],
),
- SizedBox(
- height: 15,
- ),
+ SizedBox(height: 15),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Description",
+ "Description *",
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
+ ),
),
SizedBox(height: 5),
CustomTextFieldForexWrapper(
@@ -334,41 +330,37 @@ class DepartmentDataState extends State {
],
],
),
- SizedBox(
- height: 15,
- ),
+ SizedBox(height: 15),
if (departmentDataId != null)
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- "Change Status ",
- style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ "Change Status ",
+ style: GoogleFonts.poppins(
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
),
- Tooltip(
- message:
- isActive == "1" ? "Tap to deactivate" : "Tap to activate",
- child: GestureDetector(
- onTap: toggleStatus,
- child: Text(
- isActive == "1" ? "Active" : "Inactive",
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- color: isActive == "1" ? Colors.green : Colors.red,
- ),
+ ),
+ Tooltip(
+ message:
+ isActive == "1" ? "Tap to deactivate" : "Tap to activate",
+ child: GestureDetector(
+ onTap: toggleStatus,
+ child: Text(
+ isActive == "1" ? "Active" : "Inactive",
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ color: isActive == "1" ? Colors.green : Colors.red,
),
),
- )
- ],
- ),
- if (departmentDataId != null)
- SizedBox(
- height: 15,
+ ),
+ ),
+ ],
),
+ if (departmentDataId != null) SizedBox(height: 15),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
@@ -405,16 +397,20 @@ class DepartmentDataState extends State {
borderRadius: BorderRadius.circular(8),
),
),
- child: Text('Save',
- style: GoogleFonts.poppins(
- fontSize: 11, color: Colors.white)),
+ child: Text(
+ 'Save',
+ style: GoogleFonts.poppins(
+ fontSize: 11,
+ color: Colors.white,
+ ),
+ ),
),
),
],
- )
+ ),
// : SizedBox.shrink(),
],
),
);
}
-}
\ No newline at end of file
+}
diff --git a/lib/Screens/department/department_list.dart b/lib/Screens/department/department_list.dart
index 63e0965..f7b63b1 100644
--- a/lib/Screens/department/department_list.dart
+++ b/lib/Screens/department/department_list.dart
@@ -67,13 +67,15 @@ class DepartmentListState extends State {
String? bodyStringColor = await getBodyColor();
setState(() {
- layoutColor = layoutString != null
- ? Color(int.parse(layoutString))
- : Colors.redAccent;
+ layoutColor =
+ layoutString != null
+ ? Color(int.parse(layoutString))
+ : Colors.redAccent;
- bodyColor = bodyStringColor != null
- ? Color(int.parse(bodyStringColor))
- : Colors.white;
+ bodyColor =
+ bodyStringColor != null
+ ? Color(int.parse(bodyStringColor))
+ : Colors.white;
});
}
@@ -97,7 +99,7 @@ class DepartmentListState extends State {
}
Future> fetchGetDepartment() async {
- final String apiUrlData = '$apiUrl/api/getDepartmentList';
+ final String apiUrlData = '$apiUrl/api/getDepartmentList?for=table_view';
final String? token = await getToken();
@@ -141,50 +143,60 @@ class DepartmentListState extends State {
print("all before filtering: $query");
final lowerQuery = query.toLowerCase();
setState(() {
- filteredDepartment = allDepartment.where((object) {
- final isActiveStatus =
- object['is_active'] == "1" ? "active" : "inactive";
- return (object['department_id']?.toLowerCase().contains(lowerQuery) ??
- false) ||
- (object['name']?.toLowerCase().contains(lowerQuery) ?? false) ||
- (object['description']?.toLowerCase().contains(lowerQuery) ??
- false) ||
- (isActiveStatus.contains(lowerQuery));
- }).toList();
+ filteredDepartment =
+ allDepartment.where((object) {
+ final isActiveStatus =
+ object['is_active'] == "1" ? "active" : "inactive";
+ return (object['department_id']?.toLowerCase().contains(
+ lowerQuery,
+ ) ??
+ false) ||
+ (object['name']?.toLowerCase().contains(lowerQuery) ?? false) ||
+ (object['description']?.toLowerCase().contains(lowerQuery) ??
+ false) ||
+ (isActiveStatus.contains(lowerQuery));
+ }).toList();
+ currentPage = 0;
});
print("filteredDepartment: $filteredDepartment");
}
@override
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),
- // appBar: isDesktop ? null : const CustomAppBar(title: 'User Management'),
- // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
- appBar: CustomAppBar(isDesktop: isDesktop),
- drawer: CustomDrawer(isDesktop: false),
- body: Padding(
- padding: isDesktop
- ? EdgeInsets.symmetric(
- horizontal: MediaQuery.of(context).size.width *
- 0.1, // 30% of screen width as horizontal padding
- 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),
- // const Expanded(child: Center(child: Text("User Page Content"))),
- Expanded(child: buildGroupList(isDesktop)),
- ],
+ return Scaffold(
+ backgroundColor: Color(0xFFf5f5f5),
+ // appBar: isDesktop ? null : const CustomAppBar(title: 'User Management'),
+ // drawer: isDesktop ? null : CustomDrawer(isDesktop: false),
+ appBar: CustomAppBar(isDesktop: isDesktop),
+ drawer: CustomDrawer(isDesktop: false),
+ body: Padding(
+ padding:
+ isDesktop
+ ? EdgeInsets.symmetric(
+ horizontal:
+ MediaQuery.of(context).size.width *
+ 0.1, // 30% of screen width as horizontal padding
+ 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),
+ // const Expanded(child: Center(child: Text("User Page Content"))),
+ Expanded(child: buildGroupList(isDesktop)),
+ ],
+ ),
),
- ),
- );
- });
+ );
+ },
+ );
}
Widget buildGroupList(bool isDesktop) {
@@ -212,98 +224,103 @@ class DepartmentListState extends State {
// ? EdgeInsets.all(10.0)
// : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0),
// padding: const EdgeInsets.all(10),
- height: isDesktop
- ? MediaQuery.of(context).size.height * 0.98
- : MediaQuery.of(context).size.height,
+ height:
+ isDesktop
+ ? MediaQuery.of(context).size.height * 0.98
+ : MediaQuery.of(context).size.height,
child: Padding(
+ padding: const EdgeInsets.all(10.0),
+ child: Container(
+ color: Colors.white,
padding: const EdgeInsets.all(10.0),
- child: Container(
- color: Colors.white,
- padding: const EdgeInsets.all(10.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ // Divider(
+ // thickness: 0.2, // how "thick" the line is
+ // color: Colors.grey, // optional
+ // ),
+ Row(
+ // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- // Divider(
- // thickness: 0.2, // how "thick" the line is
- // color: Colors.grey, // optional
- // ),
Row(
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Row(
- children: [
- Text(
- 'Department Details',
- style: GoogleFonts.poppins(
- fontSize: isDesktop ? 16 : 14,
- fontWeight: FontWeight.w600,
- color: Colors.black,
- ),
- ),
- ],
+ Text(
+ 'Department Details',
+ style: GoogleFonts.poppins(
+ fontSize: isDesktop ? 16 : 14,
+ fontWeight: FontWeight.w600,
+ color: Colors.black,
+ ),
),
- if (isDesktop)
- SizedBox(
- width: MediaQuery.of(context).size.width * 0.16,
- ),
+ ],
+ ),
+ if (isDesktop)
+ SizedBox(width: MediaQuery.of(context).size.width * 0.16),
- if (isDesktop)
- Container(
- width: MediaQuery.of(context).size.width * 0.2,
- height: 40,
- child: TextField(
- controller: searchController,
- onChanged: filterDepartment,
- decoration: InputDecoration(
- hintText: "Search ...",
- hintStyle: TextStyle(
- fontSize: 12, color: Color(0xFF9E9DBD)),
- prefixIcon: Icon(
- Icons.search,
- color: Color(0xFF9E9DBD),
- size: 18,
- ),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- enabledBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- borderSide: BorderSide(
- color: Colors.grey.shade200, width: 0.5),
- ),
- focusedBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- borderSide: BorderSide(
- color: Colors.grey.shade300, width: 1),
- ),
+ if (isDesktop)
+ Container(
+ width: MediaQuery.of(context).size.width * 0.2,
+ height: 40,
+ child: TextField(
+ controller: searchController,
+ onChanged: filterDepartment,
+ decoration: InputDecoration(
+ hintText: "Search ...",
+ hintStyle: TextStyle(
+ fontSize: 12,
+ color: Color(0xFF9E9DBD),
+ ),
+ prefixIcon: Icon(
+ Icons.search,
+ color: Color(0xFF9E9DBD),
+ size: 18,
+ ),
+ border: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ borderSide: BorderSide(
+ color: Colors.grey.shade200,
+ width: 0.5,
),
- style: GoogleFonts.poppins(
- fontSize: 12,
+ ),
+ focusedBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ borderSide: BorderSide(
+ color: Colors.grey.shade300,
+ width: 1,
),
),
),
- // SizedBox(width: 16),
- Spacer(),
+ style: GoogleFonts.poppins(fontSize: 12),
+ ),
+ ),
+ // SizedBox(width: 16),
+ Spacer(),
- ElevatedButton(
- style: ElevatedButton.styleFrom(
- backgroundColor: Color(0xFF114D8B),
- foregroundColor: Colors.white,
- disabledBackgroundColor: Color(0xFF114D8B),
- disabledForegroundColor: Colors.white,
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(8),
- side:
- BorderSide(color: Color(0xFF114D8B), width: 2),
- ),
- padding: EdgeInsets.symmetric(
- horizontal: 20, vertical: 12),
- ),
- onPressed: () async {
- showDialog(
- context: context,
- builder: (context) => DepartmentData(
+ ElevatedButton(
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Color(0xFF114D8B),
+ foregroundColor: Colors.white,
+ disabledBackgroundColor: Color(0xFF114D8B),
+ disabledForegroundColor: Colors.white,
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ side: BorderSide(color: Color(0xFF114D8B), width: 2),
+ ),
+ padding: EdgeInsets.symmetric(
+ horizontal: 20,
+ vertical: 12,
+ ),
+ ),
+ onPressed: () async {
+ showDialog(
+ context: context,
+ builder:
+ (context) => DepartmentData(
isDesktop: isDesktop,
layoutColor: layoutColor!,
fetchGetDepartment: refreshData,
@@ -311,338 +328,380 @@ class DepartmentListState extends State {
// role:
// "Travel Agent"
),
- );
- },
- child: Row(
- mainAxisSize:
- MainAxisSize.min, // Ensures content fits nicely
- children: [
- Text(
- "Add Department",
- style: GoogleFonts.poppins(
- fontSize: isDesktop ? 13 : 11,
+ );
+ },
+ child: Row(
+ mainAxisSize:
+ MainAxisSize.min, // Ensures content fits nicely
+ children: [
+ Text(
+ "Add Department",
+ style: GoogleFonts.poppins(
+ fontSize: isDesktop ? 13 : 11,
+ ),
+ ),
+ SizedBox(width: 8), // spacing between icon and text
+ Icon(
+ Icons.add_circle_outline_rounded,
+ size: 15,
+ color: Colors.white,
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+
+ if (!isDesktop) SizedBox(height: 5),
+ isDesktop
+ ? SizedBox.shrink()
+ : Row(
+ mainAxisAlignment: MainAxisAlignment.start,
+ children: [
+ Container(
+ width: MediaQuery.of(context).size.width * 0.8,
+ height: 35,
+ child: TextField(
+ controller: searchController,
+ onChanged: filterDepartment,
+ decoration: InputDecoration(
+ hintText: "Search ...",
+ hintStyle: TextStyle(
+ fontSize: 12,
+ color: Color(0xFF9E9DBD),
+ ),
+ prefixIcon: Icon(
+ Icons.search,
+ color: Color(0xFF9E9DBD),
+ size: 18,
+ ),
+ border: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ enabledBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ borderSide: BorderSide(
+ color: Colors.grey.shade200,
+ width: 0.5,
),
),
- SizedBox(width: 8), // spacing between icon and text
- Icon(
- Icons.add_circle_outline_rounded,
- size: 15,
- color: Colors.white,
+ focusedBorder: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(12),
+ borderSide: BorderSide(
+ color: Colors.grey.shade300,
+ width: 1,
+ ),
),
+ ),
+ style: GoogleFonts.poppins(fontSize: 12),
+ ),
+ ),
+ // SizedBox(width: 16),
+ ],
+ ),
+ const SizedBox(height: 10),
+ FutureBuilder>(
+ future: futureDepartment,
+ builder: (context, snapshot) {
+ if (snapshot.connectionState == ConnectionState.waiting) {
+ return const Center(child: CircularProgressIndicator());
+ } else if (snapshot.hasError ||
+ !snapshot.hasData ||
+ snapshot.data!.isEmpty) {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.all(16.0),
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ // const Icon(Icons.error_outline,
+ // color: Colors.redAccent, size: 60),
+ // const SizedBox(height: 16),
+ // Text(
+ // "Oops!",
+ // style: GoogleFonts.poppins(
+ // fontSize: 20,
+ // fontWeight: FontWeight.bold,
+ // color: Colors.redAccent),
+ // ),
+ const SizedBox(height: 8),
+ Text(
+ "No Department Available ",
+ textAlign: TextAlign.center,
+ style: GoogleFonts.poppins(
+ fontSize: 20,
+ fontWeight: FontWeight.bold,
+ color: Colors.grey,
+ ),
+ ),
+ const SizedBox(height: 20),
+ Text(
+ "Please Create Department Details",
+ textAlign: TextAlign.center,
+ style: GoogleFonts.poppins(
+ fontSize: 16,
+ color: Colors.grey,
+ ),
+ ),
+ const SizedBox(height: 20),
],
),
),
- ],
- ),
-
- if (!isDesktop)
- SizedBox(
- height: 5,
- ),
- isDesktop
- ? SizedBox.shrink()
- : Row(
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- Container(
- width: MediaQuery.of(context).size.width * 0.8,
- height: 35,
- child: TextField(
- controller: searchController,
- onChanged: filterDepartment,
- decoration: InputDecoration(
- hintText: "Search ...",
- hintStyle: TextStyle(
- fontSize: 12, color: Color(0xFF9E9DBD)),
- prefixIcon: Icon(
- Icons.search,
- color: Color(0xFF9E9DBD),
- size: 18,
- ),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- enabledBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- borderSide: BorderSide(
- color: Colors.grey.shade200,
- width: 0.5),
- ),
- focusedBorder: OutlineInputBorder(
- borderRadius: BorderRadius.circular(12),
- borderSide: BorderSide(
- color: Colors.grey.shade300, width: 1),
- ),
- ),
- style: GoogleFonts.poppins(
- fontSize: 12,
- ),
- ),
- ),
- // SizedBox(width: 16),
- ],
- ),
- const SizedBox(height: 10),
- FutureBuilder>(
- future: futureDepartment,
- builder: (context, snapshot) {
- if (snapshot.connectionState == ConnectionState.waiting) {
- return const Center(child: CircularProgressIndicator());
- } else if (snapshot.hasError ||
- !snapshot.hasData ||
- snapshot.data!.isEmpty) {
- return Center(
- child: Padding(
- padding: const EdgeInsets.all(16.0),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- // const Icon(Icons.error_outline,
- // color: Colors.redAccent, size: 60),
- // const SizedBox(height: 16),
- // Text(
- // "Oops!",
- // style: GoogleFonts.poppins(
- // fontSize: 20,
- // fontWeight: FontWeight.bold,
- // color: Colors.redAccent),
- // ),
- const SizedBox(height: 8),
- Text(
- "No Department Available ",
- textAlign: TextAlign.center,
- style: GoogleFonts.poppins(
- fontSize: 20,
- fontWeight: FontWeight.bold,
- color: Colors.grey),
- ),
- const SizedBox(height: 20),
- Text(
- "Please Create Department Details",
- textAlign: TextAlign.center,
- style: GoogleFonts.poppins(
- fontSize: 16, color: Colors.grey),
- ),
- const SizedBox(height: 20),
- ],
- ),
- ),
- );
- }
- /* Here collect the list to displayed the data in table or card Used */
- List object = filteredDepartment.isNotEmpty
+ );
+ }
+ /* Here collect the list to displayed the data in table or card Used */
+ List object =
+ filteredDepartment.isNotEmpty
? filteredDepartment
: allDepartment;
- /* List is Sorting here */
- object.sort((a, b) {
- DateTime dateA = DateTime.parse(a['created_on']);
- DateTime dateB = DateTime.parse(b['created_on']);
+ /* List is Sorting here */
+ object.sort((a, b) {
+ DateTime dateA = DateTime.parse(a['created_on']);
+ DateTime dateB = DateTime.parse(b['created_on']);
- return dateB
- .compareTo(dateA); // Descending: newest first
- });
+ return dateB.compareTo(dateA); // Descending: newest first
+ });
- /* For pagination for list ... */
- List paginatedDepartment = object
+ /* For pagination for list ... */
+ List paginatedDepartment =
+ object
.skip(currentPage * itemsPerPage)
.take(itemsPerPage)
.toList();
- /* Table ... */
- Widget table = LayoutBuilder(
- builder: (context, constraints) {
- double minWidth =
- isDesktop ? constraints.maxWidth : 1300;
+ /* Table ... */
+ Widget table = LayoutBuilder(
+ builder: (context, constraints) {
+ double minWidth = isDesktop ? constraints.maxWidth : 1300;
- return ConstrainedBox(
- constraints: BoxConstraints(minWidth: minWidth),
- child: DataTable(
- dividerThickness: 0.5,
- columnSpacing: isDesktop ? 24.0 : 16.0,
- border: TableBorder(
- horizontalInside: BorderSide(
- width: 0.5, color: Colors.grey.shade200),
+ return ConstrainedBox(
+ constraints: BoxConstraints(minWidth: minWidth),
+ child: DataTable(
+ dividerThickness: 0.5,
+ columnSpacing: isDesktop ? 24.0 : 16.0,
+ border: TableBorder(
+ horizontalInside: BorderSide(
+ width: 0.5,
+ color: Colors.grey.shade200,
+ ),
+ ),
+ columns: [
+ DataColumn(
+ label: Text(
+ 'Name',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
),
- columns: [
- DataColumn(
- label: Text(
- 'Name',
- style: GoogleFonts.poppins(
- fontSize: 13,
- fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Description',
- style: GoogleFonts.poppins(
- fontSize: 13,
- fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Status',
- style: GoogleFonts.poppins(
- fontSize: 13,
- fontWeight: FontWeight.w600),
- )),
- DataColumn(
- label: Text(
- 'Actions',
- style: GoogleFonts.poppins(
- fontSize: 13,
- fontWeight: FontWeight.w600),
- )),
- ],
- rows: paginatedDepartment.map((tableObject) {
+ ),
+ DataColumn(
+ label: Text(
+ 'Description',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Status',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ DataColumn(
+ label: Text(
+ 'Actions',
+ style: GoogleFonts.poppins(
+ fontSize: 13,
+ fontWeight: FontWeight.w600,
+ ),
+ ),
+ ),
+ ],
+ rows:
+ paginatedDepartment.map((tableObject) {
String departmentId =
tableObject['department_id']
.toString(); // Get user ID
bool isSelected =
selectedDepartmentId == departmentId;
- return DataRow(cells: [
- DataCell(Text(tableObject['name'] ?? '',
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ))),
- DataCell(
- Text(tableObject['description'] ?? 'N/A',
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- ),
- softWrap: true,
- overflow: TextOverflow.ellipsis)),
- DataCell(
- Text(
- tableObject['is_active'] == "1"
- ? 'Active'
- : 'Inactive',
- style: TextStyle(
- fontSize: 13,
- fontFamily: "Inter",
- color: tableObject['is_active'] == "1"
- ? Colors.green
- : Colors.red,
+ return DataRow(
+ cells: [
+ DataCell(
+ Text(
+ tableObject['name'] ?? '',
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
),
- softWrap: true,
- overflow: TextOverflow.ellipsis,
),
- ),
- DataCell(
- // UserActionsMenu(
- // user: forex,
- // getUserDetails: (id) =>
- // apiService.getSingleUser(id),
- // ),
+ DataCell(
+ Text(
+ tableObject['description'] ?? 'N/A',
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ ),
+ softWrap: true,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ DataCell(
+ Text(
+ tableObject['is_active'] == "1"
+ ? 'Active'
+ : 'Inactive',
+ style: TextStyle(
+ fontSize: 13,
+ fontFamily: "Inter",
+ color:
+ tableObject['is_active'] == "1"
+ ? Colors.green
+ : Colors.grey,
+ ),
+ softWrap: true,
+ overflow: TextOverflow.ellipsis,
+ ),
+ ),
+ DataCell(
+ // UserActionsMenu(
+ // user: forex,
+ // getUserDetails: (id) =>
+ // apiService.getSingleUser(id),
+ // ),
+ GestureDetector(
+ child: Tooltip(
+ message: 'Edit Department Details',
+ child: Image.asset(
+ 'assets/images/IconsImg/edit.png',
+ width: 20,
+ height: 15,
+ ),
+ ),
+ onTap: () async {
+ // final userId = getUserId(user['user_id']);
+ // final usersData = await getUserDetails(userId);
+ //
+ final departmentId = int.tryParse(
+ tableObject['department_id']
+ .toString(),
+ );
+
+ if (departmentId != null) {
+ print(
+ "Table cell - department Id -- $departmentId",
+ );
+ final data = await apiService
+ .getDepartmentDetailsFind(
+ departmentId,
+ );
+ print("DepartmentId -- $data");
+
+ showDialog(
+ context: context,
+ builder:
+ (context) => DepartmentData(
+ isDesktop: isDesktop,
+ departmentId:
+ departmentId, // Pass the ID
+ departmentData: data,
+ layoutColor: layoutColor!,
+ // fetchGetForex: fetchGetForex,
+ fetchGetDepartment:
+ refreshData,
+ // role:
+ // "Travel Agent"
+ ),
+ );
+ } else {
+ print("Invalid ID");
+ }
+ },
+ ),
+ ),
+ ],
+ );
+ }).toList(),
+ ),
+ );
+ },
+ );
+
+ /* Card ... */
+ Widget buildMobileCardView(List paginatedUser) {
+ return ListView.builder(
+ itemCount: paginatedUser.length,
+ itemBuilder: (context, index) {
+ final cardObject = paginatedUser[index];
+ return Card(
+ color: Colors.white,
+ margin: EdgeInsets.symmetric(
+ horizontal: 12,
+ vertical: 6,
+ ),
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(12),
+ ),
+ elevation: 3,
+ child: Padding(
+ padding: const EdgeInsets.all(12.0),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ // Status and Employee Code
+ Row(
+ mainAxisAlignment:
+ MainAxisAlignment.spaceBetween,
+ children: [
+ Text(
+ cardObject['name'] ?? 'N/A',
+ style: GoogleFonts.poppins(
+ fontSize: 10,
+ color: Colors.black87,
+ fontWeight: FontWeight.w700,
+ ),
+ ),
+
GestureDetector(
- child: Image.asset(
+ child: Tooltip(
+ message: 'Edit Department Details',
+ child: Image.asset(
'assets/images/IconsImg/edit.png',
width: 20,
- height: 15),
+ height: 15,
+ ),
+ ),
onTap: () async {
// final userId = getUserId(user['user_id']);
// final usersData = await getUserDetails(userId);
//
final departmentId = int.tryParse(
- tableObject['department_id']
- .toString());
+ cardObject['department_id']
+ .toString(),
+ );
if (departmentId != null) {
print(
- "Table cell - department Id -- $departmentId");
+ "departmentId -- $departmentId",
+ );
final data = await apiService
.getDepartmentDetailsFind(
- departmentId);
+ departmentId,
+ );
print("DepartmentId -- $data");
showDialog(
context: context,
- builder: (context) =>
- DepartmentData(
- isDesktop: isDesktop,
- departmentId:
- departmentId, // Pass the ID
- departmentData: data,
- layoutColor: layoutColor!,
- // fetchGetForex: fetchGetForex,
- fetchGetDepartment: refreshData,
- // role:
- // "Travel Agent"
- ),
- );
- } else {
- print("Invalid ID");
- }
- },
- ),
- ),
- ]);
- }).toList(),
- ),
- );
- },
- );
-
- /* Card ... */
- Widget buildMobileCardView(List paginatedUser) {
- return ListView.builder(
- itemCount: paginatedUser.length,
- itemBuilder: (context, index) {
- final cardObject = paginatedUser[index];
- return Card(
- color: Colors.white,
- margin: EdgeInsets.symmetric(
- horizontal: 12, vertical: 6),
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12),
- ),
- elevation: 3,
- child: Padding(
- padding: const EdgeInsets.all(12.0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- // Status and Employee Code
- Row(
- mainAxisAlignment:
- MainAxisAlignment.spaceBetween,
- children: [
- Text(
- cardObject['name'] ?? 'N/A',
- style: GoogleFonts.poppins(
- fontSize: 10,
- color: Colors.black87,
- fontWeight: FontWeight.w700),
- ),
-
- GestureDetector(
- child: Image.asset(
- 'assets/images/IconsImg/edit.png',
- width: 20,
- height: 15),
- onTap: () async {
- // final userId = getUserId(user['user_id']);
- // final usersData = await getUserDetails(userId);
- //
- final departmentId = int.tryParse(
- cardObject['department_id']
- .toString());
-
- if (departmentId != null) {
- print(
- "departmentId -- $departmentId");
- final data = await apiService
- .getDepartmentDetailsFind(
- departmentId);
- print("DepartmentId -- $data");
-
- showDialog(
- context: context,
- builder: (context) =>
- DepartmentData(
+ builder:
+ (context) => DepartmentData(
isDesktop: isDesktop,
departmentId:
departmentId, // Pass the ID
@@ -654,197 +713,203 @@ class DepartmentListState extends State {
// role:
// "Travel Agent"
),
- );
- } else {
- print("Invalid ID");
- }
- },
- ),
- // PopupMenuButton(
- // color: Colors.white,
- // padding: EdgeInsets.zero,
- // offset: Offset(0, 30),
- // icon: Icon(
- // Icons.more_vert,
- // color: Color(0xFF475569),
- // size: 14,
- // ),
- // itemBuilder: (context) => [
- // CustomPopupMenuEntry(
- // child: Container(
- // padding: EdgeInsets.symmetric(
- // horizontal: 8, vertical: 8),
- // child: Row(
- // mainAxisSize:
- // MainAxisSize.min,
- // mainAxisAlignment:
- // MainAxisAlignment.center,
- // children: [
- // IconButton(
- // icon: Icon(
- // Icons
- // .remove_red_eye,
- // color: Color(
- // 0xFF475569),
- // size: 18),
- // onPressed: () {
- // print(
- // "USerDAta - $user");
- // // dynamic usersData = apiService
- // // .getSingleUser(user[
- // // 'user_id']
- // // is String
- // // ? int.parse(user[
- // // 'user_id'])
- // // : user[
- // // 'user_id']);
- // //
- // // print(
- // // "USerDAta - $usersData");
- //
- // context.go(
- // "/CreateUserDetails",
- // extra: {
- // "selectedUser":
- // user,
- // "isViewMode": true
- // },
- // );
- // }),
- // IconButton(
- // icon: Image.asset(
- // 'assets/images/IconsImg/edit.png',
- // width: 20,
- // height: 15),
- // onPressed: () {
- // context.go(
- // "/CreateUserDetails",
- // extra: {
- // "selectedUser":
- // user,
- // "isViewMode": false
- // },
- // );
- // },
- // ),
- // ],
- // ),
- // ),
- // ),
- // ],
- // ),
- ],
+ );
+ } else {
+ print("Invalid ID");
+ }
+ },
),
-
- SizedBox(height: 2),
- // Trip Id and Trip Name
- // Name
- Row(
- children: [
- Column(
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: [
- Text(
- cardObject['description'] ?? '',
- style: GoogleFonts.poppins(
- fontSize: 10,
- color: Colors.black87),
- ),
- ],
- ),
- SizedBox(
- width: 10,
- ),
- Column(
- crossAxisAlignment:
- CrossAxisAlignment.start,
- children: [
- Text(
- cardObject['description'] ?? '',
- style: GoogleFonts.poppins(
- fontSize: 10,
- color: Colors.black87),
- ),
- ],
- ),
- ],
- ),
- // Actions
- // Actions
+ // PopupMenuButton(
+ // color: Colors.white,
+ // padding: EdgeInsets.zero,
+ // offset: Offset(0, 30),
+ // icon: Icon(
+ // Icons.more_vert,
+ // color: Color(0xFF475569),
+ // size: 14,
+ // ),
+ // itemBuilder: (context) => [
+ // CustomPopupMenuEntry(
+ // child: Container(
+ // padding: EdgeInsets.symmetric(
+ // horizontal: 8, vertical: 8),
+ // child: Row(
+ // mainAxisSize:
+ // MainAxisSize.min,
+ // mainAxisAlignment:
+ // MainAxisAlignment.center,
+ // children: [
+ // IconButton(
+ // icon: Icon(
+ // Icons
+ // .remove_red_eye,
+ // color: Color(
+ // 0xFF475569),
+ // size: 18),
+ // onPressed: () {
+ // print(
+ // "USerDAta - $user");
+ // // dynamic usersData = apiService
+ // // .getSingleUser(user[
+ // // 'user_id']
+ // // is String
+ // // ? int.parse(user[
+ // // 'user_id'])
+ // // : user[
+ // // 'user_id']);
+ // //
+ // // print(
+ // // "USerDAta - $usersData");
+ //
+ // context.go(
+ // "/CreateUserDetails",
+ // extra: {
+ // "selectedUser":
+ // user,
+ // "isViewMode": true
+ // },
+ // );
+ // }),
+ // IconButton(
+ // icon: Image.asset(
+ // 'assets/images/IconsImg/edit.png',
+ // width: 20,
+ // height: 15),
+ // onPressed: () {
+ // context.go(
+ // "/CreateUserDetails",
+ // extra: {
+ // "selectedUser":
+ // user,
+ // "isViewMode": false
+ // },
+ // );
+ // },
+ // ),
+ // ],
+ // ),
+ // ),
+ // ),
+ // ],
+ // ),
],
),
- ),
- );
- },
- );
- }
- return Expanded(
- child: Column(
- // mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Expanded(
- child: isDesktop
+ SizedBox(height: 2),
+ // Trip Id and Trip Name
+ // Name
+ Row(
+ children: [
+ Column(
+ crossAxisAlignment:
+ CrossAxisAlignment.start,
+ children: [
+ Text(
+ cardObject['description'] ?? '',
+ style: GoogleFonts.poppins(
+ fontSize: 10,
+ color: Colors.black87,
+ ),
+ ),
+ ],
+ ),
+ SizedBox(width: 10),
+ Column(
+ crossAxisAlignment:
+ CrossAxisAlignment.start,
+ children: [
+ Text(
+ cardObject['description'] ?? '',
+ style: GoogleFonts.poppins(
+ fontSize: 10,
+ color: Colors.black87,
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ // Actions
+ // Actions
+ ],
+ ),
+ ),
+ );
+ },
+ );
+ }
+
+ return Expanded(
+ child: Column(
+ // mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Expanded(
+ child:
+ isDesktop
? (searchController.text.isNotEmpty &&
filteredDepartment.isEmpty
? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14,
- color: Colors.grey),
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
),
- )
+ ),
+ )
: SingleChildScrollView(
- scrollDirection: Axis.vertical,
- child: table,
- ))
+ scrollDirection: Axis.vertical,
+ child: table,
+ ))
: (searchController.text.isNotEmpty &&
filteredDepartment.isEmpty
? Center(
- child: Text(
- "No matches found",
- style: GoogleFonts.poppins(
- fontSize: 14,
- color: Colors.grey),
+ child: Text(
+ "No matches found",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
),
- )
+ ),
+ )
: buildMobileCardView(
- paginatedDepartment)),
- ),
- // Expanded(
- // child: isDesktop
- // ? SingleChildScrollView(
- // scrollDirection: Axis.vertical,
- // child: table, // <-- your existing table
- // )
- // : buildMobileCardView(paginatedDepartment),
- // ),
- PaginationControls(
- currentPage: currentPage,
- itemsPerPage: itemsPerPage,
- totalItems: object.length,
- activeColor: layoutColor, // your theme color
- onPageChanged: (page) {
- setState(() {
- currentPage = page;
- });
- },
- onItemsPerPageChanged: (items) {
- setState(() {
- itemsPerPage = items;
- currentPage = 0;
- });
- },
- ),
- ],
+ paginatedDepartment,
+ )),
),
- );
- },
- )
- ]),
- )),
+ // Expanded(
+ // child: isDesktop
+ // ? SingleChildScrollView(
+ // scrollDirection: Axis.vertical,
+ // child: table, // <-- your existing table
+ // )
+ // : buildMobileCardView(paginatedDepartment),
+ // ),
+ PaginationControls(
+ currentPage: currentPage,
+ itemsPerPage: itemsPerPage,
+ totalItems: object.length,
+ activeColor: layoutColor, // your theme color
+ onPageChanged: (page) {
+ setState(() {
+ currentPage = page;
+ });
+ },
+ onItemsPerPageChanged: (items) {
+ setState(() {
+ itemsPerPage = items;
+ currentPage = 0;
+ });
+ },
+ ),
+ ],
+ ),
+ );
+ },
+ ),
+ ],
+ ),
+ ),
+ ),
);
}
}
diff --git a/lib/Screens/dialog/user_selection_dialog.dart b/lib/Screens/dialog/user_selection_dialog.dart
index 9427b0c..5dc4955 100644
--- a/lib/Screens/dialog/user_selection_dialog.dart
+++ b/lib/Screens/dialog/user_selection_dialog.dart
@@ -100,11 +100,13 @@ class _UserSelectionDialogState extends State {
}
} else {
throw Exception(
- "Unexpected response format: Expected a List but got ${responseBody.runtimeType}");
+ "Unexpected response format: Expected a List but got ${responseBody.runtimeType}",
+ );
}
} else {
throw Exception(
- 'Failed to load users. Status Code: ${response.statusCode}');
+ 'Failed to load users. Status Code: ${response.statusCode}',
+ );
}
} catch (e) {
print("Error fetching users: $e");
@@ -138,56 +140,63 @@ class _UserSelectionDialogState extends State {
List travellerList = responseBody['data'];
setState(() {
- _traveller = travellerList
- .map((user) => SearchTraveler.fromJson(user))
- .toList();
+ _traveller =
+ travellerList
+ .map((user) => SearchTraveler.fromJson(user))
+ .toList();
_filteredTraveller = List.from(_traveller);
});
print("Users fetched: ${_users.length}");
for (var travvelr in _traveller) {
print(
- "${travvelr.firstName} ${travvelr.lastName} ${travvelr.mobileNo}");
+ "${travvelr.firstName} ${travvelr.lastName} ${travvelr.mobileNo}",
+ );
}
} else {
throw Exception(
- "Unexpected response format: Expected a List but got ${responseBody.runtimeType}");
+ "Unexpected response format: Expected a List but got ${responseBody.runtimeType}",
+ );
}
} else {
throw Exception(
- 'Failed to load users. Status Code: ${response.statusCode}');
+ 'Failed to load users. Status Code: ${response.statusCode}',
+ );
}
} catch (e) {
print("Error fetching traveller: $e");
}
}
- void _filterUsers1(String query) {
- print("Filtering users...");
- setState(() {
- if (query.isEmpty) {
- _filteredUsers = List.from(_users);
- } else {
- _filteredUsers = _users.where((user) {
- List searchFields = [
- "${user.firstName} ${user.lastName}".toLowerCase(),
- user.email.toLowerCase() ?? "",
- user.userId.toLowerCase() ?? "",
- user.mobileNo ?? "",
- user.alternateMobileNo ?? ""
- ];
-
- return searchFields
- .any((field) => field.contains(query.toLowerCase()));
- }).toList();
- }
- });
-
- print("Filtered Users:");
- for (var user in _filteredUsers) {
- print("${user.firstName} ${user.lastName}");
- }
- }
+ // void _filterUsers1(String query) {
+ // print("Filtering users...");
+ // setState(() {
+ // if (query.isEmpty) {
+ // _filteredUsers = List.from(_users);
+ // } else {
+ // _filteredUsers =
+ // _users.where((user) {
+ // List searchFields = [
+ // "${user.firstName} ${user.lastName}".toLowerCase(),
+ // user.email.toLowerCase() ?? "",
+ // user.empCode?.toLowerCase() ?? "",
+ // user.userId.toLowerCase() ?? "",
+ // user.mobileNo ?? "",
+ // user.alternateMobileNo ?? "",
+ // ];
+ //
+ // return searchFields.any(
+ // (field) => field.contains(query.toLowerCase()),
+ // );
+ // }).toList();
+ // }
+ // });
+ //
+ // print("Filtered Users:");
+ // for (var user in _filteredUsers) {
+ // print("${user.firstName} ${user.lastName}");
+ // }
+ // }
void _filterUsers(String query) {
print("Filtering _filterUsersTravellers...");
@@ -200,19 +209,23 @@ class _UserSelectionDialogState extends State {
];
} else {
_filteredList = [
- ..._users.where((user) {
- print("usersLLL : ${user}");
+ ..._users
+ .where((user) {
+ print("usersLLL : ${user}");
- List searchFields = [
- "${user.firstName} ${user.lastName}".toLowerCase(),
- user.email.toLowerCase() ?? "",
- user.userId.toLowerCase() ?? "",
- user.mobileNo ?? "",
- user.alternateMobileNo ?? ""
- ];
- return searchFields
- .any((field) => field.contains(query.toLowerCase()));
- }).map((user) => {"type": "user", "data": user}),
+ List searchFields = [
+ "${user.firstName} ${user.lastName}".toLowerCase(),
+ user.email.toLowerCase() ?? "",
+ user.userId.toLowerCase() ?? "",
+ user.mobileNo ?? "",
+ user.alternateMobileNo ?? "",
+ user.empCode?.toLowerCase() ?? "",
+ ];
+ return searchFields.any(
+ (field) => field.contains(query.toLowerCase()),
+ );
+ })
+ .map((user) => {"type": "user", "data": user}),
];
}
});
@@ -221,7 +234,8 @@ class _UserSelectionDialogState extends State {
for (var item in _filteredList) {
var user = item["data"];
print(
- "${item["type"].toUpperCase()} - ${user.firstName} ${user.lastName}");
+ "${item["type"].toUpperCase()} - ${user.firstName} ${user.lastName}",
+ );
}
}
@@ -236,16 +250,19 @@ class _UserSelectionDialogState extends State {
];
} else {
_filteredList = [
- ..._traveller.where((traveller) {
- List searchFields = [
- "${traveller.firstName} ${traveller.lastName}".toLowerCase(),
- traveller.email.toLowerCase() ?? "",
- traveller.travellerId.toLowerCase() ?? "",
- traveller.mobileNo ?? "",
- ];
- return searchFields
- .any((field) => field.contains(query.toLowerCase()));
- }).map((traveller) => {"type": "traveller", "data": traveller}),
+ ..._traveller
+ .where((traveller) {
+ List searchFields = [
+ "${traveller.firstName} ${traveller.lastName}".toLowerCase(),
+ traveller.email.toLowerCase() ?? "",
+ traveller.travellerId.toLowerCase() ?? "",
+ traveller.mobileNo ?? "",
+ ];
+ return searchFields.any(
+ (field) => field.contains(query.toLowerCase()),
+ );
+ })
+ .map((traveller) => {"type": "traveller", "data": traveller}),
];
}
});
@@ -254,7 +271,8 @@ class _UserSelectionDialogState extends State {
for (var item in _filteredList) {
var user = item["data"];
print(
- "${item["type"].toUpperCase()} - ${user.firstName} ${user.lastName}");
+ "${item["type"].toUpperCase()} - ${user.firstName} ${user.lastName}",
+ );
}
}
@@ -266,32 +284,39 @@ class _UserSelectionDialogState extends State {
if (query.isEmpty) {
_filteredList = [
..._users.map((user) => {"type": "user", "data": user}),
- ..._traveller
- .map((traveller) => {"type": "traveller", "data": traveller}),
+ ..._traveller.map(
+ (traveller) => {"type": "traveller", "data": traveller},
+ ),
];
} else {
_filteredList = [
- ..._users.where((user) {
- List searchFields = [
- "${user.firstName} ${user.lastName}".toLowerCase(),
- user.email.toLowerCase() ?? "",
- user.userId.toLowerCase() ?? "",
- user.mobileNo ?? "",
- user.alternateMobileNo ?? ""
- ];
- return searchFields
- .any((field) => field.contains(query.toLowerCase()));
- }).map((user) => {"type": "user", "data": user}),
- ..._traveller.where((traveller) {
- List searchFields = [
- "${traveller.firstName} ${traveller.lastName}".toLowerCase(),
- traveller.email.toLowerCase() ?? "",
- traveller.travellerId.toLowerCase() ?? "",
- traveller.mobileNo ?? "",
- ];
- return searchFields
- .any((field) => field.contains(query.toLowerCase()));
- }).map((traveller) => {"type": "traveller", "data": traveller}),
+ ..._users
+ .where((user) {
+ List searchFields = [
+ "${user.firstName} ${user.lastName}".toLowerCase(),
+ user.email.toLowerCase() ?? "",
+ user.userId.toLowerCase() ?? "",
+ user.mobileNo ?? "",
+ user.alternateMobileNo ?? "",
+ ];
+ return searchFields.any(
+ (field) => field.contains(query.toLowerCase()),
+ );
+ })
+ .map((user) => {"type": "user", "data": user}),
+ ..._traveller
+ .where((traveller) {
+ List searchFields = [
+ "${traveller.firstName} ${traveller.lastName}".toLowerCase(),
+ traveller.email.toLowerCase() ?? "",
+ traveller.travellerId.toLowerCase() ?? "",
+ traveller.mobileNo ?? "",
+ ];
+ return searchFields.any(
+ (field) => field.contains(query.toLowerCase()),
+ );
+ })
+ .map((traveller) => {"type": "traveller", "data": traveller}),
];
}
});
@@ -300,7 +325,8 @@ class _UserSelectionDialogState extends State {
for (var item in _filteredList) {
var user = item["data"];
print(
- "${item["type"].toUpperCase()} - ${user.firstName} ${user.lastName}");
+ "${item["type"].toUpperCase()} - ${user.firstName} ${user.lastName}",
+ );
}
}
@@ -324,10 +350,14 @@ class _UserSelectionDialogState extends State {
MainAxisSize.min, // Ensures content doesn't expand unnecessarily
children: [
widget.title == "Others"
- ? Text("Please Select Other User",
- style: GoogleFonts.poppins(fontSize: 14))
- : Text("Please Select Other Employee",
- style: GoogleFonts.poppins(fontSize: 14)),
+ ? Text(
+ "Please Select Other User",
+ style: GoogleFonts.poppins(fontSize: 14),
+ )
+ : Text(
+ "Please Select Other Employee",
+ style: GoogleFonts.poppins(fontSize: 14),
+ ),
SizedBox(height: 10),
// Search Field
@@ -344,11 +374,14 @@ class _UserSelectionDialogState extends State {
style: GoogleFonts.poppins(fontSize: 12),
decoration: InputDecoration(
hintText: "Search for a user",
- hintStyle:
- GoogleFonts.poppins(fontSize: 14, color: Colors.grey),
+ hintStyle: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Colors.grey,
+ ),
prefixIcon: Icon(Icons.search),
- border:
- OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
+ border: OutlineInputBorder(
+ borderRadius: BorderRadius.circular(8),
+ ),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.grey.shade200, width: 1),
// borderSide: BorderSide(color: Color(0xFFF5F5F5), width: 2),
@@ -366,9 +399,13 @@ class _UserSelectionDialogState extends State {
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
- Text("or create a new traveler",
- style: GoogleFonts.poppins(
- fontSize: 14, color: Color(0xFF575A74))),
+ Text(
+ "or create a new traveler",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: Color(0xFF575A74),
+ ),
+ ),
TextButton(
onPressed: () {
setState(() {
@@ -376,9 +413,13 @@ class _UserSelectionDialogState extends State {
_searchController.clear();
});
},
- child: Text("Create",
- style: GoogleFonts.poppins(
- fontSize: 14, color: widget.layoutColorForUser)),
+ child: Text(
+ "Create",
+ style: GoogleFonts.poppins(
+ fontSize: 14,
+ color: widget.layoutColorForUser,
+ ),
+ ),
),
],
),
@@ -389,17 +430,20 @@ class _UserSelectionDialogState extends State {
// User List or Message
_searchController.text.isNotEmpty
? SizedBox(
- height: 300, // Limit height to avoid overflow
- // child: _filteredUsers.isEmpty
- child: _filteredList.isEmpty
- ? Center(
+ height: 300, // Limit height to avoid overflow
+ // child: _filteredUsers.isEmpty
+ child:
+ _filteredList.isEmpty
+ ? Center(
child: Text(
"No users found",
style: GoogleFonts.poppins(
- fontSize: 14, color: Colors.grey),
+ fontSize: 14,
+ color: Colors.grey,
+ ),
),
)
- : ListView.builder(
+ : ListView.builder(
// itemCount: _filteredUsers.length,
itemCount: _filteredList.length,
itemBuilder: (context, index) {
@@ -411,7 +455,8 @@ class _UserSelectionDialogState extends State {
item["type"]; // "user" or "traveller"
if (user is Map) {
print(
- "userLsirer - ${jsonEncode(user)}"); // pretty JSON-like string
+ "userLsirer - ${jsonEncode(user)}",
+ ); // pretty JSON-like string
} else {
print("userLsirer - $user"); // fallback
}
@@ -420,37 +465,42 @@ class _UserSelectionDialogState extends State {
"${user.firstName ?? "Unknown"} ${user.lastName ?? ""}",
style: GoogleFonts.poppins(fontSize: 11),
),
- subtitle: userType == "user"
- ? Text(
- "Employee ID: ${user.empCode ?? ""} ",
- // "Employee ID: ${userType == "user" ? user.userId : user.travellerId}",
- style:
- GoogleFonts.poppins(fontSize: 10),
- )
- : Text(
- "Mobile : ${user.mobileNo ?? ""} ",
- // "Employee ID: ${userType == "user" ? user.userId : user.travellerId}",
- style:
- GoogleFonts.poppins(fontSize: 10),
- ),
+ subtitle:
+ userType == "user"
+ ? Text(
+ "Employee ID: ${user.empCode ?? ""} ",
+ // "Employee ID: ${userType == "user" ? user.userId : user.travellerId}",
+ style: GoogleFonts.poppins(
+ fontSize: 10,
+ ),
+ )
+ : Text(
+ "Mobile : ${user.mobileNo ?? ""} ",
+ // "Employee ID: ${userType == "user" ? user.userId : user.travellerId}",
+ style: GoogleFonts.poppins(
+ fontSize: 10,
+ ),
+ ),
onTap: () {
String selectedUser =
"${user.firstName ?? "Unknown"} ${user.lastName ?? ""}";
setState(() {
_searchController.text = selectedUser;
- userIdSelected = userType == "user"
- ? user.userId
- : user.travellerId;
+ userIdSelected =
+ userType == "user"
+ ? user.userId
+ : user.travellerId;
isTraveller = userType == "traveller";
});
print(
- "Selected: $selectedUser, ID: ${userType == "user" ? user.userId : user.travellerId},"
- " isTraveller: $userIdSelected");
+ "Selected: $selectedUser, ID: ${userType == "user" ? user.userId : user.travellerId},"
+ " isTraveller: $userIdSelected",
+ );
},
);
},
),
- )
+ )
: SizedBox.shrink(),
// Traveler Form
@@ -462,10 +512,16 @@ class _UserSelectionDialogState extends State {
padding: const EdgeInsets.all(16.0),
child: TravelerForm(
formKey: _formKey,
- onSubmit: (String fullName, String travellerId,
- bool isTraveller) {
- widget.onSubmit(fullName, travellerId,
- isTraveller); // Pass the data up
+ onSubmit: (
+ String fullName,
+ String travellerId,
+ bool isTraveller,
+ ) {
+ widget.onSubmit(
+ fullName,
+ travellerId,
+ isTraveller,
+ ); // Pass the data up
},
firstNameController: TextEditingController(),
lastNameController: TextEditingController(),
@@ -487,7 +543,9 @@ class _UserSelectionDialogState extends State {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(
- color: widget.layoutColorForUser, width: 2),
+ color: widget.layoutColorForUser,
+ width: 2,
+ ),
),
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
),
@@ -508,15 +566,21 @@ class _UserSelectionDialogState extends State {
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(
- color: widget.layoutColorForUser, width: 2),
+ color: widget.layoutColorForUser,
+ width: 2,
+ ),
),
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
),
onPressed: () {
print(
- "Submitting: ${_searchController.text}, ID: $userIdSelected");
+ "Submitting: ${_searchController.text}, ID: $userIdSelected",
+ );
widget.onSubmit(
- _searchController.text, userIdSelected, isTraveller);
+ _searchController.text,
+ userIdSelected,
+ isTraveller,
+ );
Navigator.pop(context);
},
child: Text(
@@ -542,14 +606,15 @@ class TravelerForm extends StatefulWidget {
final GlobalKey formKey;
final void Function(String, String, bool) onSubmit;
- TravelerForm(
- {required this.formKey,
- required this.orgId,
- required this.firstNameController,
- required this.lastNameController,
- required this.emailController,
- required this.mobileController,
- required this.onSubmit});
+ TravelerForm({
+ required this.formKey,
+ required this.orgId,
+ required this.firstNameController,
+ required this.lastNameController,
+ required this.emailController,
+ required this.mobileController,
+ required this.onSubmit,
+ });
@override
_TravelerFormState createState() => _TravelerFormState();
@@ -582,8 +647,9 @@ class _TravelerFormState extends State {
if (value == null || value.isEmpty) {
return 'Email is required';
}
- if (!RegExp(r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$')
- .hasMatch(value)) {
+ if (!RegExp(
+ r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
+ ).hasMatch(value)) {
return 'Enter a valid email address';
}
return null;
@@ -642,7 +708,8 @@ class _TravelerFormState extends State {
String lastName = travellerData["last_name"];
print(
- "Traveller Added: ID: $travellerId, Name: $firstName $lastName");
+ "Traveller Added: ID: $travellerId, Name: $firstName $lastName",
+ );
// // Pass data to callback
// widget.onSubmit("$firstName $lastName", travellerId, true);
@@ -658,21 +725,22 @@ class _TravelerFormState extends State {
SnackBar(
content: Text(
"Traveller added successfully!",
- style:
- GoogleFonts.poppins(color: Colors.white), // ✅ Set text color
+ style: GoogleFonts.poppins(
+ color: Colors.white,
+ ), // ✅ Set text color
),
backgroundColor: Colors.green,
),
);
} else {
- ScaffoldMessenger.of(context).showSnackBar(
- SnackBar(content: Text("Error: ${response.body}")),
- );
+ ScaffoldMessenger.of(
+ context,
+ ).showSnackBar(SnackBar(content: Text("Error: ${response.body}")));
}
} catch (e) {
- ScaffoldMessenger.of(context).showSnackBar(
- SnackBar(content: Text("Failed to connect to server.")),
- );
+ ScaffoldMessenger.of(
+ context,
+ ).showSnackBar(SnackBar(content: Text("Failed to connect to server.")));
}
}
@@ -697,8 +765,10 @@ class _TravelerFormState extends State {
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
- Text("Create Traveler",
- style: GoogleFonts.poppins(color: Colors.black54)),
+ Text(
+ "Create Traveler",
+ style: GoogleFonts.poppins(color: Colors.black54),
+ ),
SizedBox(height: 7),
Expanded(
child: SingleChildScrollView(
@@ -714,13 +784,17 @@ class _TravelerFormState extends State {
onPressed: () {
widget.formKey.currentState?.reset();
},
- child: Text("Clear",
- style: GoogleFonts.poppins(color: Colors.grey)),
+ child: Text(
+ "Clear",
+ style: GoogleFonts.poppins(color: Colors.grey),
+ ),
),
TextButton(
onPressed: () => _onSubmit(context),
- child: Text("Add",
- style: GoogleFonts.poppins(color: Color(0xFF114D8B))),
+ child: Text(
+ "Add",
+ style: GoogleFonts.poppins(color: Color(0xFF114D8B)),
+ ),
),
],
),
diff --git a/lib/Screens/forex/forexDetails.dart b/lib/Screens/forex/forexDetails.dart
index 9839ec7..44c60bc 100644
--- a/lib/Screens/forex/forexDetails.dart
+++ b/lib/Screens/forex/forexDetails.dart
@@ -21,13 +21,14 @@ class ForexData extends StatefulWidget {
final int? forexId; // <-- Add this
final Map? forexData;
- const ForexData(
- {super.key,
- required this.isDesktop,
- this.layoutColor,
- required this.fetchGetForex,
- this.forexId,
- this.forexData});
+ const ForexData({
+ super.key,
+ required this.isDesktop,
+ this.layoutColor,
+ required this.fetchGetForex,
+ this.forexId,
+ this.forexData,
+ });
@override
ForexDataState createState() => ForexDataState();
@@ -61,7 +62,7 @@ class ForexDataState extends State {
"currency",
"perdiemAmount",
"cash",
- "card"
+ "card",
];
Map forex_Detials() {
@@ -197,7 +198,7 @@ class ForexDataState extends State {
"currency",
"perdiemAmount",
"cash_percentage",
- "card_percentage"
+ "card_percentage",
];
// Check validation for each field
@@ -273,9 +274,10 @@ class ForexDataState extends State {
};
final body = jsonEncode(forexData);
- final response = forexDataId != null
- ? await http.put(uri, headers: headers, body: body)
- : await http.post(uri, headers: headers, body: body);
+ final response =
+ forexDataId != null
+ ? await http.put(uri, headers: headers, body: body)
+ : await http.post(uri, headers: headers, body: body);
// final response = await http.post(
// Uri.parse(apiUrldata),
@@ -326,7 +328,7 @@ class ForexDataState extends State {
// Map country codes to country names
countryMap = {
for (var item in countryList)
- item['country_code'] as String: item['country_name'] as String
+ item['country_code'] as String: item['country_name'] as String,
};
// Extract only country codes for processing
@@ -355,21 +357,19 @@ class ForexDataState extends State {
],
),
const SizedBox(height: 2),
- Divider(
- thickness: 0.2,
- color: Colors.blueGrey.shade100,
- ),
+ Divider(thickness: 0.2, color: Colors.blueGrey.shade100),
const SizedBox(height: 5),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Country",
+ "Country *",
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
+ ),
),
SizedBox(height: 5),
CustomTextFieldForexWrapper(
@@ -381,18 +381,19 @@ class ForexDataState extends State {
selectedItem: countryMap[selectedCountry],
popupProps: PopupProps.menu(
showSearchBox: true, // Enables search functionality
- menuProps: const MenuProps(
- backgroundColor: Colors.white,
- ),
+ menuProps: const MenuProps(backgroundColor: Colors.white),
constraints: BoxConstraints(maxHeight: 250),
- itemBuilder: (context, item, isSelected) => Padding(
- padding: const EdgeInsets.symmetric(
- horizontal: 8.0, vertical: 6.0),
- child: Text(
- item,
- style: GoogleFonts.poppins(fontSize: 11.5),
- ),
- ),
+ itemBuilder:
+ (context, item, isSelected) => Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 8.0,
+ vertical: 6.0,
+ ),
+ child: Text(
+ item,
+ style: GoogleFonts.poppins(fontSize: 11.5),
+ ),
+ ),
searchFieldProps: TextFieldProps(
decoration: InputDecoration(
hintText: "Search Country...",
@@ -405,25 +406,25 @@ class ForexDataState extends State {
dropdownDecoratorProps: DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
border: InputBorder.none,
- contentPadding: EdgeInsets.symmetric(
- horizontal: 1,
+ contentPadding: EdgeInsets.symmetric(horizontal: 1),
+ ),
+ ),
+ dropdownBuilder:
+ (context, selectedItem) => Align(
+ // Center-align selected item
+ alignment: Alignment.centerLeft,
+ child: Text(
+ selectedItem ?? "Select Country",
+ style: GoogleFonts.poppins(fontSize: 11),
+ ),
),
- ),
- ),
- dropdownBuilder: (context, selectedItem) => Align(
- // Center-align selected item
- alignment: Alignment.centerLeft,
- child: Text(
- selectedItem ?? "Select Country",
- style: GoogleFonts.poppins(fontSize: 11),
- ),
- ),
onChanged: (String? newValue) {
setState(() {
// Find the country_code based on selected country_name
- selectedCountry = countryMap.entries
- .firstWhere((entry) => entry.value == newValue)
- .key;
+ selectedCountry =
+ countryMap.entries
+ .firstWhere((entry) => entry.value == newValue)
+ .key;
selectedCountryName = newValue;
});
},
@@ -444,11 +445,12 @@ class ForexDataState extends State {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Currency",
+ "Currency *",
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
+ ),
),
SizedBox(height: 5),
CustomTextFieldForexWrapper(
@@ -459,18 +461,19 @@ class ForexDataState extends State {
// ? MediaQuery.of(context).size.width * 0.330
// : MediaQuery.of(context).size.width * 0.66,
child: SizedBox(
- height: 40,
- child: TextField(
- controller: controllers["currency"],
- style: const TextStyle(fontSize: 12),
- decoration: const InputDecoration(
- labelText: "Currency",
- labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
- floatingLabelBehavior: FloatingLabelBehavior.never,
- border: InputBorder.none,
- contentPadding: EdgeInsets.symmetric(vertical: 16),
- ),
- )),
+ height: 40,
+ child: TextField(
+ controller: controllers["currency"],
+ style: const TextStyle(fontSize: 12),
+ decoration: const InputDecoration(
+ labelText: "Currency",
+ labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
+ floatingLabelBehavior: FloatingLabelBehavior.never,
+ border: InputBorder.none,
+ contentPadding: EdgeInsets.symmetric(vertical: 16),
+ ),
+ ),
+ ),
),
if (errorMessages["currency"] != null) ...[
SizedBox(height: 5), // Space before error message
@@ -481,11 +484,9 @@ class ForexDataState extends State {
],
],
),
- // if (isDesktop)SizedBox(width: 8,) else SizedBox(height: 8,),
- SizedBox(
- height: 10,
- ),
+ // if (isDesktop)SizedBox(width: 8,) else SizedBox(height: 8,),
+ SizedBox(height: 10),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -493,38 +494,43 @@ class ForexDataState extends State {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Cash (%)",
+ "Cash (%) *",
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
+ ),
),
SizedBox(height: 5),
CustomTextFieldForexWrapper(
isFocused: false,
isDesktop: widget.isDesktop,
color: Colors.transparent,
- width: widget.isDesktop
- ? MediaQuery.of(context).size.width * 0.09
- : MediaQuery.of(context).size.width * 0.66,
+ width:
+ widget.isDesktop
+ ? MediaQuery.of(context).size.width * 0.09
+ : MediaQuery.of(context).size.width * 0.66,
child: SizedBox(
- height: 40,
- child: TextField(
- controller: controllers["cash"],
- keyboardType: TextInputType.number,
- inputFormatters: [
- FilteringTextInputFormatter.digitsOnly,
- ],
- style: const TextStyle(fontSize: 12),
- decoration: const InputDecoration(
- labelText: "Cash",
- labelStyle:
- TextStyle(fontSize: 11, color: Colors.grey),
- floatingLabelBehavior: FloatingLabelBehavior.never,
- border: InputBorder.none,
- contentPadding: EdgeInsets.symmetric(vertical: 16),
+ height: 40,
+ child: TextField(
+ controller: controllers["cash"],
+ keyboardType: TextInputType.number,
+ inputFormatters: [
+ FilteringTextInputFormatter.digitsOnly,
+ ],
+ style: const TextStyle(fontSize: 12),
+ decoration: const InputDecoration(
+ labelText: "Cash",
+ labelStyle: TextStyle(
+ fontSize: 11,
+ color: Colors.grey,
),
- )),
+ floatingLabelBehavior: FloatingLabelBehavior.never,
+ border: InputBorder.none,
+ contentPadding: EdgeInsets.symmetric(vertical: 16),
+ ),
+ ),
+ ),
),
if (errorMessages["cash_percentage"] != null) ...[
SizedBox(height: 5), // Space before error message
@@ -540,38 +546,43 @@ class ForexDataState extends State {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Card (%)",
+ "Card (%) *",
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
+ ),
),
SizedBox(height: 5),
CustomTextFieldForexWrapper(
isFocused: false,
isDesktop: widget.isDesktop,
color: Colors.transparent,
- width: widget.isDesktop
- ? MediaQuery.of(context).size.width * 0.09
- : MediaQuery.of(context).size.width * 0.66,
+ width:
+ widget.isDesktop
+ ? MediaQuery.of(context).size.width * 0.09
+ : MediaQuery.of(context).size.width * 0.66,
child: SizedBox(
- height: 40,
- child: TextField(
- controller: controllers["card"],
- keyboardType: TextInputType.number,
- inputFormatters: [
- FilteringTextInputFormatter.digitsOnly,
- ],
- style: const TextStyle(fontSize: 12),
- decoration: const InputDecoration(
- labelText: "Card",
- labelStyle:
- TextStyle(fontSize: 11, color: Colors.grey),
- floatingLabelBehavior: FloatingLabelBehavior.never,
- border: InputBorder.none,
- contentPadding: EdgeInsets.symmetric(vertical: 16),
+ height: 40,
+ child: TextField(
+ controller: controllers["card"],
+ keyboardType: TextInputType.number,
+ inputFormatters: [
+ FilteringTextInputFormatter.digitsOnly,
+ ],
+ style: const TextStyle(fontSize: 12),
+ decoration: const InputDecoration(
+ labelText: "Card",
+ labelStyle: TextStyle(
+ fontSize: 11,
+ color: Colors.grey,
),
- )),
+ floatingLabelBehavior: FloatingLabelBehavior.never,
+ border: InputBorder.none,
+ contentPadding: EdgeInsets.symmetric(vertical: 16),
+ ),
+ ),
+ ),
),
if (errorMessages["card_percentage"] != null) ...[
SizedBox(height: 5), // Space before error message
@@ -581,21 +592,20 @@ class ForexDataState extends State {
),
],
],
- )
+ ),
],
),
- SizedBox(
- height: 10,
- ),
+ SizedBox(height: 10),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
- "Perdiem Amount",
+ "Perdiem Amount *",
style: GoogleFonts.poppins(
- fontSize: 12,
- fontWeight: FontWeight.w600,
- color: Color(0xFF575A74)),
+ fontSize: 12,
+ fontWeight: FontWeight.w600,
+ color: Color(0xFF575A74),
+ ),
),
SizedBox(height: 5),
CustomTextFieldForexWrapper(
@@ -603,18 +613,19 @@ class ForexDataState extends State {
isDesktop: widget.isDesktop,
color: Colors.transparent,
child: SizedBox(
- height: 40,
- child: TextField(
- controller: controllers["perdiemAmount"],
- style: const TextStyle(fontSize: 12),
- decoration: const InputDecoration(
- labelText: "Perdiem Amount",
- labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
- floatingLabelBehavior: FloatingLabelBehavior.never,
- border: InputBorder.none,
- contentPadding: EdgeInsets.symmetric(vertical: 16),
- ),
- )),
+ height: 40,
+ child: TextField(
+ controller: controllers["perdiemAmount"],
+ style: const TextStyle(fontSize: 12),
+ decoration: const InputDecoration(
+ labelText: "Perdiem Amount",
+ labelStyle: TextStyle(fontSize: 11, color: Colors.grey),
+ floatingLabelBehavior: FloatingLabelBehavior.never,
+ border: InputBorder.none,
+ contentPadding: EdgeInsets.symmetric(vertical: 16),
+ ),
+ ),
+ ),
),
if (errorMessages["perdiemAmount"] != null) ...[
SizedBox(height: 5), // Space before error message
@@ -625,9 +636,7 @@ class ForexDataState extends State {
],
],
),
- SizedBox(
- height: 15,
- ),
+ SizedBox(height: 15),
if (forexDataId != null)
Row(
@@ -636,9 +645,10 @@ class ForexDataState extends State