diff --git a/lib-jun6-9:03.zip b/lib-jun6-9:03.zip deleted file mode 100644 index c5dc669..0000000 Binary files a/lib-jun6-9:03.zip and /dev/null differ 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/plans/list_plans.dart b/lib/Screens/plans/list_plans.dart index afae4f3..39b3e23 100644 --- a/lib/Screens/plans/list_plans.dart +++ b/lib/Screens/plans/list_plans.dart @@ -96,16 +96,19 @@ class _ListPlansState 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"); @@ -116,13 +119,15 @@ class _ListPlansState 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; }); } @@ -209,6 +214,7 @@ class _ListPlansState 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 { @@ -300,8 +306,10 @@ class _ListPlansState extends State { // print("Error fetching plan: $e"); // } - bool confirmed = - await apiService.showCancelConfirmationDialog(context, layoutColor); + bool confirmed = await apiService.showCancelConfirmationDialog( + context, + layoutColor, + ); if (confirmed) { try { @@ -318,33 +326,39 @@ class _ListPlansState 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) { @@ -374,8 +388,9 @@ class _ListPlansState 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 } @@ -384,17 +399,19 @@ class _ListPlansState 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), @@ -434,9 +451,7 @@ class _ListPlansState extends State { ), // Spacer(), - SizedBox( - width: MediaQuery.of(context).size.width * 0.23, - ), + SizedBox(width: MediaQuery.of(context).size.width * 0.23), if (isDesktop) Container( width: MediaQuery.of(context).size.width * 0.2, @@ -446,8 +461,10 @@ class _ListPlansState 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), @@ -459,22 +476,25 @@ class _ListPlansState 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) Spacer(), + // ElevatedButton( // style: ElevatedButton.styleFrom( // foregroundColor: Colors.white, @@ -495,7 +515,6 @@ class _ListPlansState extends State { // ], // ), // ), - ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: Color(0xFF114D8B), @@ -506,37 +525,46 @@ class _ListPlansState extends State { borderRadius: BorderRadius.circular(8), side: BorderSide(color: Color(0xFF114D8B), width: 2), ), - padding: isDesktop - ? EdgeInsets.symmetric(horizontal: 20, vertical: 12) - : EdgeInsets.symmetric(horizontal: 15, vertical: 10), + padding: + isDesktop + ? EdgeInsets.symmetric( + horizontal: 20, + vertical: 12, + ) + : EdgeInsets.symmetric( + horizontal: 15, + vertical: 10, + ), ), onPressed: () { if (TripPlanAction == "Plan Creation Not Allowed") { showDialog( context: context, - builder: (context) => AlertDialog( - title: Text( - "Action Not Allowed", - style: TextStyle( - fontSize: 18, fontWeight: FontWeight.bold), - ), - content: Text( - "Plan Creation Not Allowed For This User."), - actions: [ - TextButton( - onPressed: () => Navigator.pop(context), - child: Text( - "OK", - style: TextStyle(color: layoutColor), + builder: + (context) => AlertDialog( + title: Text( + "Action Not Allowed", + style: TextStyle( + fontSize: 18, + fontWeight: FontWeight.bold, + ), ), + content: Text( + "Plan Creation Not Allowed For This User.", + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: Text( + "OK", + style: TextStyle(color: layoutColor), + ), + ), + ], ), - ], - ), ); } else { - context.go('/createPlan', extra: { - 'orgId': orgId, - }); + context.go('/createPlan', extra: {'orgId': orgId}); if (!isDesktop) Navigator.pop(context); } }, @@ -544,10 +572,12 @@ class _ListPlansState extends State { mainAxisSize: MainAxisSize.min, // Ensures content fits nicely children: [ - Text("Add New Trip", - style: GoogleFonts.poppins( - fontSize: isDesktop ? 13 : 11, - )), + Text( + "Add New Trip", + style: GoogleFonts.poppins( + fontSize: isDesktop ? 13 : 11, + ), + ), SizedBox(width: 8), // spacing between icon and text Icon( Icons.add_circle_outline_rounded, @@ -571,8 +601,10 @@ class _ListPlansState 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), @@ -584,17 +616,19 @@ class _ListPlansState 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), ), ), ], @@ -605,6 +639,8 @@ class _ListPlansState 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 || @@ -615,7 +651,7 @@ class _ListPlansState extends State { padding: const EdgeInsets.all(16.0), child: Column( mainAxisSize: MainAxisSize.min, - children: const [ + children: [ // Icon(Icons.error_outline, // color: Colors.redAccent, size: 60), // SizedBox(height: 1), @@ -624,21 +660,26 @@ class _ListPlansState extends State { // fontSize: 22, // fontWeight: FontWeight.bold, // color: Colors.redAccent)), - SizedBox(height: 15), - Text("No Trips", - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20, - fontFamily: "Inter", - fontWeight: FontWeight.w600, - color: Colors.black54)), - SizedBox(height: 10), - Text("Please Create Trip", - textAlign: TextAlign.center, - style: TextStyle( - fontFamily: "Inter", - fontSize: 12, - color: Colors.grey)), + SizedBox(height: adjHgt / 4), + Text( + "No Trips Found", + textAlign: TextAlign.center, + style: GoogleFonts.poppins( + fontSize: 20, + fontWeight: FontWeight.w500, + color: Colors.black54, + ), + ), + const SizedBox(height: 10), + Text( + "Please Create Trip", + textAlign: TextAlign.center, + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w500, + color: Colors.black54, + ), + ), ], ), ), @@ -652,13 +693,16 @@ class _ListPlansState 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) { @@ -671,292 +715,401 @@ class _ListPlansState 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), - // color: plan.statusValue == - // "Partially Approved" - // ? Colors.yellow.shade100 - // : plan.statusValue == "Approved" - // ? Colors.green.shade100 - // : plan.statusValue == "Completed" - // ? Colors.green.shade500 - // : plan.statusValue == "Rejected" - // ? Colors.red.shade100 - // : Colors.grey.shade100, - borderRadius: BorderRadius.circular(10), - ), - child: Text( - plan.statusValue, - textAlign: TextAlign.center, - style: TextStyle( - color: - getStatusTextColor(plan.statusValue), - // color: (plan.statusValue == - // "Partially Approved" || - // plan.statusValue == "Approved" || - // plan.statusValue == "Rejected") - // ? Colors.black - // : plan.statusValue == "Completed" - // ? Colors.white - // : Colors.grey, - 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, - size: 14, 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: 18), - tooltip: 'View The Trip Details', - onPressed: () { - Navigator.pop( - context); // Close popup manually - ApiService.viewPlan( - context, plan.planId, - isViewMode: true, - isMyTrips: true); - }, - ), - if (plan.statusValue == - "Pending Approval" || - plan.statusValue == - "Partially Approved") - IconButton( - icon: Image.asset( - 'assets/images/IconsImg/edit.png', - width: 20, - height: 15), - tooltip: 'Edit Trip/Plans Details', - onPressed: () { - Navigator.pop(context); - ApiService.viewPlan( - context, plan.planId, - isViewMode: false, - isMyTrips: 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 Comments', - 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: "User"), - ); - }), - ], - ), + ), + 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, + ), + // color: plan.statusValue == + // "Partially Approved" + // ? Colors.yellow.shade100 + // : plan.statusValue == "Approved" + // ? Colors.green.shade100 + // : plan.statusValue == "Completed" + // ? Colors.green.shade500 + // : plan.statusValue == "Rejected" + // ? Colors.red.shade100 + // : Colors.grey.shade100, + borderRadius: BorderRadius.circular( + 10, ), ), - ], + child: Text( + plan.statusValue, + textAlign: TextAlign.center, + style: TextStyle( + color: getStatusTextColor( + plan.statusValue, + ), + // color: (plan.statusValue == + // "Partially Approved" || + // plan.statusValue == "Approved" || + // plan.statusValue == "Rejected") + // ? Colors.black + // : plan.statusValue == "Completed" + // ? Colors.white + // : Colors.grey, + 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, + size: 14, + 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: 18, + ), + tooltip: + 'View The Trip Details', + onPressed: () { + Navigator.pop( + context, + ); // Close popup manually + ApiService.viewPlan( + context, + plan.planId, + isViewMode: + true, + isMyTrips: true, + ); + }, + ), + if (plan.statusValue == + "Pending Approval" || + plan.statusValue == + "Partially Approved") + IconButton( + icon: Image.asset( + 'assets/images/IconsImg/edit.png', + width: 20, + height: 15, + ), + tooltip: + 'Edit Trip/Plans Details', + onPressed: () { + Navigator.pop( + context, + ); + ApiService.viewPlan( + context, + plan.planId, + isViewMode: + false, + isMyTrips: + 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 Comments', + 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: + "User", + ), + ); + }, + ), + ], + ), + ), + ), + ], + ), + ], + ), ), - ], - ), - ), - // 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: 15, - // height: 15), - // ), - // - // // IconButton( - // // icon: const Icon(Icons.edit, - // // color: Colors.green), - // // onPressed: () => viewPlan(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(), + // 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: 15, + // height: 15), + // ), + // + // // IconButton( + // // icon: const Icon(Icons.edit, + // // color: Colors.green), + // // onPressed: () => viewPlan(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(), ), ); }, @@ -969,8 +1122,10 @@ class _ListPlansState 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), ), @@ -987,7 +1142,9 @@ class _ListPlansState 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), @@ -996,7 +1153,8 @@ class _ListPlansState extends State { plan.statusValue, style: TextStyle( color: getStatusTextColor( - plan.statusValue), + plan.statusValue, + ), fontSize: 10, fontWeight: FontWeight.w600, ), @@ -1012,98 +1170,133 @@ class _ListPlansState extends State { color: Colors.white, padding: EdgeInsets.zero, offset: Offset(0, 30), - icon: Icon(Icons.more_vert, - size: 14, 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: 18), - tooltip: 'View The Trip Details', - onPressed: () { - Navigator.pop( - context); // Close popup manually - ApiService.viewPlan( - context, plan.planId, - isViewMode: true, - isMyTrips: true); - }, + icon: Icon( + Icons.more_vert, + size: 14, + color: Color(0xFF475569), + ), + itemBuilder: + (context) => [ + CustomPopupMenuEntry( + child: Container( + padding: EdgeInsets.symmetric( + horizontal: 8, + vertical: 8, ), - if (plan.statusValue == - "Pending Approval" || - plan.statusValue == - "Partially Approved") - IconButton( - icon: Image.asset( - 'assets/images/IconsImg/edit.png', - width: 20, - height: 15), - tooltip: 'Edit Trip/plan Details', - onPressed: () { - Navigator.pop(context); - ApiService.viewPlan( - context, plan.planId, - isViewMode: false, - isMyTrips: 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 Comments', - onPressed: () { - Navigator.pop(context); - apiService.getPdfDownload( - plan.planId); - }, - ), - IconButton( - icon: const Icon( - Icons.comment, - color: Color(0xFF475569), - size: 11, + 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, + isMyTrips: true, + ); + }, ), - tooltip: 'Trip Comments', - onPressed: () { - showDialog( - context: context, - builder: (context) => - CommentModalList( + if (plan.statusValue == + "Pending Approval" || + plan.statusValue == + "Partially Approved") + IconButton( + icon: Image.asset( + 'assets/images/IconsImg/edit.png', + width: 20, + height: 15, + ), + tooltip: + 'Edit Trip/plan Details', + onPressed: () { + Navigator.pop( + context, + ); + ApiService.viewPlan( + context, + plan.planId, + isViewMode: false, + isMyTrips: 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 Comments', + 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: "User"), - ); - }), - ], + role: "User", + ), + ); + }, + ), + ], + ), + ), ), - ), - ), - ], + ], ), ], ), @@ -1116,11 +1309,14 @@ class _ListPlansState 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, + ), + ), ], ), ], @@ -1135,24 +1331,28 @@ class _ListPlansState 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", + ), + ), ], ), ], @@ -1170,9 +1370,10 @@ class _ListPlansState extends State { ? '${plan.userName}' : '${plan.travellerName}', style: TextStyle( - fontSize: 9, - fontFamily: "Inter", - color: Colors.black87), + fontSize: 9, + fontFamily: "Inter", + color: Colors.black87, + ), ), ], ), @@ -1184,9 +1385,10 @@ class _ListPlansState extends State { Text( plan.employeeCode ?? 'No Data', style: TextStyle( - fontSize: 9, - fontFamily: "Inter", - color: Colors.black87), + fontSize: 9, + fontFamily: "Inter", + color: Colors.black87, + ), ), ], ), @@ -1207,30 +1409,35 @@ class _ListPlansState 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( // scrollDirection: Axis.vertical, @@ -1259,7 +1466,7 @@ class _ListPlansState extends State { ), ); }, - ) + ), ], ), ), diff --git a/lib/Screens/userManagement/create_user/create_user.dart b/lib/Screens/userManagement/create_user/create_user.dart index 5b7537e..cff5d90 100644 --- a/lib/Screens/userManagement/create_user/create_user.dart +++ b/lib/Screens/userManagement/create_user/create_user.dart @@ -1188,7 +1188,13 @@ class _CreateUserFormDetialsState extends State { crossAxisAlignment: CrossAxisAlignment.end, // important children: tabs.entries.map((entry) { + final targetTab = entry.key; + + print("TargetsTAb: $targetTab"); + final isSelected = selectedTab == entry.key; + print("isSelected: $isSelected"); + return GestureDetector( onTap: () { setState(() { @@ -1201,6 +1207,9 @@ class _CreateUserFormDetialsState extends State { if (isValid) { selectedTab = entry.key; } + } else if (currentTab == "office" && + targetTab == "personal") { + selectedTab = entry.key; } else if (currentTab == "office") { isValid = isValidDataTwo(userDetials); if (isValid) { @@ -1306,6 +1315,37 @@ class _CreateUserFormDetialsState extends State { ]; } + List _buildBack(isDesktop, Color layoutColor) { + return [ + MouseRegion( + cursor: + isViewMode + ? SystemMouseCursors.forbidden + : SystemMouseCursors.click, + child: TextButton( + style: ElevatedButton.styleFrom( + backgroundColor: + isViewMode ? layoutColor : layoutColor, // Keep original color + foregroundColor: + isViewMode ? Colors.white : Colors.red, // Keep original color + disabledBackgroundColor: + layoutColor, // Ensure color remains when disabled + disabledForegroundColor: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide(color: layoutColor, width: 2), + ), + padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), + ), + onPressed: handleNext, + // onPressed: + // isViewMode ? null : handleNext, // Disable when in view mode + child: Text("Next"), + ), + ), + ]; + } + List _buildSubmit(isDesktop, Color layoutColor) { return [ ElevatedButton( diff --git a/lib/main.dart b/lib/main.dart index 61e84a1..148a99a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'app.dart'; +import 'package:flutter_web_plugins/flutter_web_plugins.dart'; void main() { + setUrlStrategy(PathUrlStrategy()); runApp(const MyApp()); }