diff --git a/lib/Screens/itnerary_list/miscellaneous_list.dart b/lib/Screens/itnerary_list/miscellaneous_list.dart index 306244c..e9a2279 100644 --- a/lib/Screens/itnerary_list/miscellaneous_list.dart +++ b/lib/Screens/itnerary_list/miscellaneous_list.dart @@ -9,14 +9,15 @@ class MiscellaneousListWidget extends StatelessWidget { final Function(String, bool) onAddNew; final bool isViewMode; - const MiscellaneousListWidget( - {super.key, - required this.miscellaneousList, - required this.onOpen, - required this.onDeleteMiscellaneous, - required this.apiData, - required this.onAddNew, - required this.isViewMode}); + const MiscellaneousListWidget({ + super.key, + required this.miscellaneousList, + required this.onOpen, + required this.onDeleteMiscellaneous, + required this.apiData, + required this.onAddNew, + required this.isViewMode, + }); @override Widget build(BuildContext context) { @@ -34,16 +35,18 @@ class MiscellaneousListWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ MouseRegion( - cursor: isViewMode - ? SystemMouseCursors.forbidden - : SystemMouseCursors.click, + cursor: + isViewMode + ? SystemMouseCursors.forbidden + : SystemMouseCursors.click, child: GestureDetector( - onTap: isViewMode - ? null - : () { - print("New data"); - onAddNew("Miscellaneous", true); - }, + onTap: + isViewMode + ? null + : () { + print("New data"); + onAddNew("Miscellaneous", true); + }, child: Row( mainAxisSize: MainAxisSize.min, // Ensures content fits nicely @@ -57,7 +60,7 @@ class MiscellaneousListWidget extends StatelessWidget { Icons.add_circle_sharp, size: 30, color: Color(0xFF114D8B), - ) + ), ], ), ), @@ -95,7 +98,7 @@ class MiscellaneousListWidget extends StatelessWidget { ), const SizedBox(height: 16), // Scroll behavior based on device - _buildData(context, isDesktop) + _buildData(context, isDesktop), ], ), ), @@ -173,7 +176,8 @@ class MiscellaneousListWidget extends StatelessWidget { ), SizedBox(width: 10), GestureDetector( - onTap: () => onOpen(true, item, "Miscellaneous"), + // onTap: () => onOpen(true, item, "Miscellaneous"), + onTap: () => onDeleteMiscellaneous(item), child: Tooltip( message: 'Delete Miscellaneous Details', child: Image.asset( @@ -185,68 +189,65 @@ class MiscellaneousListWidget extends StatelessWidget { ), ], ), - Divider( - color: Colors.blueGrey.shade50, - ), + Divider(color: Colors.blueGrey.shade50), SizedBox(height: 4), isDesktop ? Row( - children: [ - Expanded( - flex: 2, - child: Text( - "Special Request", - style: GoogleFonts.poppins( - fontSize: 11, - ), - )), - Expanded( - flex: 3, - child: Text( - " Comments", - style: GoogleFonts.poppins( - fontSize: 11, - ), - )), - ], - ) + children: [ + Expanded( + flex: 2, + child: Text( + "Special Request", + style: GoogleFonts.poppins(fontSize: 11), + ), + ), + Expanded( + flex: 3, + child: Text( + " Comments", + style: GoogleFonts.poppins(fontSize: 11), + ), + ), + ], + ) : SizedBox.shrink(), isDesktop ? Row( - children: [ - Expanded( - flex: 2, - child: Text( - getRequestValue( - item["special_request"]?.toString()), - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - ), + children: [ + Expanded( + flex: 2, + child: Text( + getRequestValue( + item["special_request"]?.toString(), + ), + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, ), ), - Expanded( - flex: 3, - child: Text( - item["comments"], - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - ), + ), + Expanded( + flex: 3, + child: Text( + item["comments"], + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, ), ), - ], - ) + ), + ], + ) : Column( - children: [ - _buildRow( - "Special Request:", - getRequestValue( - item["special_request"]?.toString())), - SizedBox(width: 10), - _buildRow("Comments:", item["comments"] ?? "N/A"), - ], - ), + children: [ + _buildRow( + "Special Request:", + getRequestValue(item["special_request"]?.toString()), + ), + SizedBox(width: 10), + _buildRow("Comments:", item["comments"] ?? "N/A"), + ], + ), ], ), ), @@ -275,31 +276,35 @@ class MiscellaneousListWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: exceedsLimit - ? Tooltip( - message: wrapText(value, 50), - decoration: BoxDecoration( - color: Colors.grey.shade200, // Black background - borderRadius: BorderRadius.circular(6), - ), - textStyle: - TextStyle(color: Colors.black), // Tooltip text color - padding: EdgeInsets.all(8), - preferBelow: false, - child: Text(value.substring(0, limit) + "...", + child: + exceedsLimit + ? Tooltip( + message: wrapText(value, 50), + decoration: BoxDecoration( + color: Colors.grey.shade200, // Black background + borderRadius: BorderRadius.circular(6), + ), + textStyle: TextStyle( + color: Colors.black, + ), // Tooltip text color + padding: EdgeInsets.all(8), + preferBelow: false, + child: Text( + value.substring(0, limit) + "...", style: GoogleFonts.poppins( fontSize: 12, fontWeight: FontWeight.w600, ), - overflow: TextOverflow.ellipsis), - ) - : Text( - value, - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, + overflow: TextOverflow.ellipsis, + ), + ) + : Text( + value, + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, + ), ), - ), ), ], ); @@ -326,36 +331,36 @@ class MiscellaneousListWidget extends StatelessWidget { children: [ Text( title, - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - ), + style: GoogleFonts.poppins(fontSize: 12, fontWeight: FontWeight.w600), ), SizedBox(width: 8), Expanded( - child: exceedsLimit - ? Tooltip( - message: wrapText(value, 50), - decoration: BoxDecoration( - color: Colors.grey.shade200, // Black background - borderRadius: BorderRadius.circular(6), - ), - textStyle: TextStyle( - color: Colors.black, fontSize: 12), // Tooltip text color - padding: EdgeInsets.all(8), - preferBelow: false, - child: Text( - value.substring(0, limit) + "...", - overflow: TextOverflow.ellipsis, - ), - ) - : Text(value), + child: + exceedsLimit + ? Tooltip( + message: wrapText(value, 50), + decoration: BoxDecoration( + color: Colors.grey.shade200, // Black background + borderRadius: BorderRadius.circular(6), + ), + textStyle: TextStyle( + color: Colors.black, + fontSize: 12, + ), // Tooltip text color + padding: EdgeInsets.all(8), + preferBelow: false, + child: Text( + value.substring(0, limit) + "...", + overflow: TextOverflow.ellipsis, + ), + ) + : Text(value), ), ], ); } -// + // // Widget _buildData(BuildContext context) { // return Container( // width: MediaQuery.of(context).size.width, diff --git a/lib/Screens/itnerary_list/taxi_list.dart b/lib/Screens/itnerary_list/taxi_list.dart index e438d73..8059f4d 100644 --- a/lib/Screens/itnerary_list/taxi_list.dart +++ b/lib/Screens/itnerary_list/taxi_list.dart @@ -11,14 +11,15 @@ class TaxiListWidget extends StatelessWidget { final Function(String, bool) onAddNew; final bool isViewMode; - const TaxiListWidget( - {super.key, - required this.taxiList, - required this.apiData, - required this.onOpen, - required this.onDeleteTaxi, - required this.onAddNew, - required this.isViewMode}); + const TaxiListWidget({ + super.key, + required this.taxiList, + required this.apiData, + required this.onOpen, + required this.onDeleteTaxi, + required this.onAddNew, + required this.isViewMode, + }); @override Widget build(BuildContext context) { @@ -36,17 +37,19 @@ class TaxiListWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ MouseRegion( - cursor: isViewMode - ? SystemMouseCursors.forbidden - : SystemMouseCursors.click, + cursor: + isViewMode + ? SystemMouseCursors.forbidden + : SystemMouseCursors.click, child: GestureDetector( - onTap: isViewMode - ? null - : () { - print("New data"); - onAddNew("Taxi", true); - }, + onTap: + isViewMode + ? null + : () { + print("New data"); + onAddNew("Taxi", true); + }, child: Row( mainAxisSize: MainAxisSize.min, // Ensures content fits nicely @@ -60,7 +63,7 @@ class TaxiListWidget extends StatelessWidget { Icons.add_circle_sharp, size: 30, color: Color(0xFF114D8B), - ) + ), ], ), ), @@ -99,9 +102,9 @@ class TaxiListWidget extends StatelessWidget { ], ), const SizedBox(height: 16), - // Scroll behavior based on device - _buildData(context, isDesktop) + // Scroll behavior based on device + _buildData(context, isDesktop), ], ), ), @@ -187,8 +190,11 @@ class TaxiListWidget extends StatelessWidget { if (hour == 24 && minute == 0) { // 24:00 is treated as 00:00 on the next day - dateTime = DateTime(now.year, now.month, now.day) - .add(const Duration(days: 1)); + dateTime = DateTime( + now.year, + now.month, + now.day, + ).add(const Duration(days: 1)); } else { if (hour < 0 || hour > 23 || minute < 0 || minute > 59) { throw FormatException("Invalid hour or minute"); @@ -238,11 +244,12 @@ class TaxiListWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.end, children: [ Text( - "${getRequestForTaxiClass(item["car_type"]!.toString())} For ${item["no_of_passengers"]!} Passenger", - style: GoogleFonts.poppins( - fontSize: 13, - fontWeight: FontWeight.w800, - )), + "${getRequestForTaxiClass(item["car_type"]!.toString())} For ${item["no_of_passengers"]!} Passenger", + style: GoogleFonts.poppins( + fontSize: 13, + fontWeight: FontWeight.w800, + ), + ), Spacer(), GestureDetector( onTap: () => onOpen(true, item, "Taxi"), @@ -257,7 +264,7 @@ class TaxiListWidget extends StatelessWidget { ), SizedBox(width: 10), GestureDetector( - onTap: () => (item), + onTap: () => onDeleteTaxi(item), child: Tooltip( message: 'Delete Taxi Details', child: Image.asset( @@ -269,108 +276,104 @@ class TaxiListWidget extends StatelessWidget { ), ], ), - Divider( - color: Colors.blueGrey.shade50, - ), + Divider(color: Colors.blueGrey.shade50), SizedBox(height: 4), isDesktop ? Row( - children: [ - Expanded( - flex: 2, - child: Text( - "City", - style: GoogleFonts.poppins( - fontSize: 11, - ), - )), - Expanded( - flex: 2, - child: Text( - " Location", - style: GoogleFonts.poppins( - fontSize: 11, - ), - )), - Expanded( - flex: 2, - child: Text( - " Date", - style: GoogleFonts.poppins( - fontSize: 11, - ), - )), - Expanded( - flex: 2, - child: Text( - "Comments", - style: GoogleFonts.poppins( - fontSize: 11, - ), - )), - ], - ) + children: [ + Expanded( + flex: 2, + child: Text( + "City", + style: GoogleFonts.poppins(fontSize: 11), + ), + ), + Expanded( + flex: 2, + child: Text( + " Location", + style: GoogleFonts.poppins(fontSize: 11), + ), + ), + Expanded( + flex: 2, + child: Text( + " Date", + style: GoogleFonts.poppins(fontSize: 11), + ), + ), + Expanded( + flex: 2, + child: Text( + "Comments", + style: GoogleFonts.poppins(fontSize: 11), + ), + ), + ], + ) : SizedBox.shrink(), SizedBox(height: 4), isDesktop ? Row( - children: [ - Expanded( - flex: 2, - child: Text( - "${item["destination_city"]}", - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - ), + children: [ + Expanded( + flex: 2, + child: Text( + "${item["destination_city"]}", + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, ), ), - SizedBox(width: 10), - Expanded( - flex: 2, - child: Text( - "${item["location_of_pickup"]}", - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - ), + ), + SizedBox(width: 10), + Expanded( + flex: 2, + child: Text( + "${item["location_of_pickup"]}", + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, ), ), - SizedBox(width: 10), - Expanded( - flex: 2, - child: Text( - "${formatDate(item["date"]!)} ${formatTime(item["time"]!)}", - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - ), + ), + SizedBox(width: 10), + Expanded( + flex: 2, + child: Text( + "${formatDate(item["date"]!)} ${formatTime(item["time"]!)}", + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, ), ), - SizedBox(width: 10), - Expanded( - flex: 2, - child: _buildComments( - " Comments:", item["comments"] ?? "N/A"), + ), + SizedBox(width: 10), + Expanded( + flex: 2, + child: _buildComments( + " Comments:", + item["comments"] ?? "N/A", ), - ], - ) + ), + ], + ) : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _buildRow("City:", item["destination_city"]), - SizedBox(width: 10), - _buildRow("Pickup:", item["location_of_pickup"]!), - SizedBox(width: 10), - _buildDateTimeRow( - "Date:", - formatDate(item["date"]!), - formatTime(item["time"]!), - ), - _buildRow("TaxiFor:", item["car_required_for"]!), - _buildRow("Comments:", item["comments"] ?? "N/A"), - ], - ) + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildRow("City:", item["destination_city"]), + SizedBox(width: 10), + _buildRow("Pickup:", item["location_of_pickup"]!), + SizedBox(width: 10), + _buildDateTimeRow( + "Date:", + formatDate(item["date"]!), + formatTime(item["time"]!), + ), + _buildRow("TaxiFor:", item["car_required_for"]!), + _buildRow("Comments:", item["comments"] ?? "N/A"), + ], + ), ], ), ), @@ -399,31 +402,35 @@ class TaxiListWidget extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( - child: exceedsLimit - ? Tooltip( - message: wrapText(value, 50), - decoration: BoxDecoration( - color: Colors.grey.shade200, // Black background - borderRadius: BorderRadius.circular(6), - ), - textStyle: - TextStyle(color: Colors.black), // Tooltip text color - padding: EdgeInsets.all(8), - preferBelow: false, - child: Text(value.substring(0, limit) + "...", + child: + exceedsLimit + ? Tooltip( + message: wrapText(value, 50), + decoration: BoxDecoration( + color: Colors.grey.shade200, // Black background + borderRadius: BorderRadius.circular(6), + ), + textStyle: TextStyle( + color: Colors.black, + ), // Tooltip text color + padding: EdgeInsets.all(8), + preferBelow: false, + child: Text( + value.substring(0, limit) + "...", style: GoogleFonts.poppins( fontSize: 12, fontWeight: FontWeight.w600, ), - overflow: TextOverflow.ellipsis), - ) - : Text( - value, - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, + overflow: TextOverflow.ellipsis, + ), + ) + : Text( + value, + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, + ), ), - ), ), ], ); @@ -450,34 +457,30 @@ class TaxiListWidget extends StatelessWidget { children: [ Text( title, - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 12, - ), + style: TextStyle(fontWeight: FontWeight.w600, fontSize: 12), ), SizedBox(width: 8), Expanded( - child: exceedsLimit - ? Tooltip( - message: wrapText(value, 50), - decoration: BoxDecoration( - color: Colors.grey.shade200, // Black background - borderRadius: BorderRadius.circular(6), - ), - textStyle: - TextStyle(color: Colors.black), // Tooltip text color - padding: EdgeInsets.all(8), - preferBelow: false, - child: Text(value.substring(0, limit) + "...", + child: + exceedsLimit + ? Tooltip( + message: wrapText(value, 50), + decoration: BoxDecoration( + color: Colors.grey.shade200, // Black background + borderRadius: BorderRadius.circular(6), + ), + textStyle: TextStyle( + color: Colors.black, + ), // Tooltip text color + padding: EdgeInsets.all(8), + preferBelow: false, + child: Text( + value.substring(0, limit) + "...", style: TextStyle(fontSize: 12), - overflow: TextOverflow.ellipsis), - ) - : Text( - value, - style: GoogleFonts.poppins( - fontSize: 12, - ), - ), + overflow: TextOverflow.ellipsis, + ), + ) + : Text(value, style: GoogleFonts.poppins(fontSize: 12)), ), ], ); @@ -489,19 +492,11 @@ class TaxiListWidget extends StatelessWidget { children: [ Text( title, - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - ), + style: GoogleFonts.poppins(fontSize: 12, fontWeight: FontWeight.w600), ), SizedBox(width: 8), Expanded( - child: Text( - "$date, $time", - style: GoogleFonts.poppins( - fontSize: 12, - ), - ), + child: Text("$date, $time", style: GoogleFonts.poppins(fontSize: 12)), ), ], ); diff --git a/lib/Screens/plans/create_plans.dart b/lib/Screens/plans/create_plans.dart index 3323f17..3e86000 100644 --- a/lib/Screens/plans/create_plans.dart +++ b/lib/Screens/plans/create_plans.dart @@ -55,51 +55,68 @@ class _CreatePlansState 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; }); } @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: Colors.white, - backgroundColor: Color(0xFFf5f5f5), - // backgroundColor: Color(0xFFFCFCFC), - 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( + return Scaffold( + // backgroundColor: Colors.white, + backgroundColor: Color(0xFFf5f5f5), + // backgroundColor: Color(0xFFFCFCFC), + 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: buildUserTable( - isDesktop, context, bodyColor, layoutColor)), - ], + isDesktop, + context, + bodyColor, + layoutColor, + ), + ), + ], + ), ), - ), - ); - }); + ); + }, + ); } Widget buildUserTable( - bool isDesktop, context, Color? bodyColor, Color layoutColor) { + bool isDesktop, + context, + Color? bodyColor, + Color layoutColor, + ) { final args = GoRouterState.of(context).extra as Map? ?? {}; // final planData = args?['planData']; final bool isViewMode = args?['isViewMode'] ?? false; @@ -166,9 +183,10 @@ class _CreatePlansState extends State { // : 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, // decoration: BoxDecoration( // border: isDesktop // ? Border.all( @@ -188,77 +206,91 @@ class _CreatePlansState extends State { child: Padding( padding: EdgeInsets.all(10.0), child: CreateNewPlan( - key: _createPlanKey, - bodyColor: bodyColor, - layoutColor: layoutColor, - isDesktop: isDesktop, - selectedPlanData: planData, - isViewMode: isViewMode, - isApprover: isApprover, - approverId: approverId, - delegaterId: delegaterId), + key: _createPlanKey, + bodyColor: bodyColor, + layoutColor: layoutColor, + isDesktop: isDesktop, + selectedPlanData: planData, + isViewMode: isViewMode, + isApprover: isApprover, + approverId: approverId, + delegaterId: delegaterId, + ), ), ), ), ), Container( - padding: const EdgeInsets.all(10), - color: Colors.white, - child: isDesktop - ? Row( + padding: const EdgeInsets.all(10), + color: Colors.white, + child: + isDesktop + ? Row( mainAxisAlignment: MainAxisAlignment.end, // children: [Text("Button")], children: _buildSubmit( - isDesktop, isViewMode, layoutColor, isApprover), + isDesktop, + isViewMode, + layoutColor, + isApprover, + ), ) - : Row( + : Row( mainAxisAlignment: MainAxisAlignment.center, children: _buildSubmit( - isDesktop, isViewMode, layoutColor, isApprover), - )) + isDesktop, + isViewMode, + layoutColor, + isApprover, + ), + ), + ), ], ), ); } List _buildSubmit( - isDesktop, bool isViewMode, Color layoutColor, bool isApprover) { + isDesktop, + bool isViewMode, + Color layoutColor, + bool isApprover, + ) { return [ ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - foregroundColor: layoutColor ?? Colors.blueAccent, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide(color: layoutColor, width: 2), - ), - padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + foregroundColor: layoutColor ?? Colors.blueAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide(color: layoutColor, width: 2), ), - onPressed: () { - final currentUri = GoRouterState.of(context) - .uri - .toString(); // ✅ safer than `.location` - print("currentUri - $currentUri"); + padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), + ), + onPressed: () { + final currentUri = + GoRouterState.of( + context, + ).uri.toString(); // ✅ safer than `.location` + print("currentUri - $currentUri"); - if (currentUri == "/allTrips/trips") { - context.go('/listAllPlan'); - } else if (currentUri == "/createPlan") { - context.go('/listPlan'); - } else { - isApprover - ? context.go('/approvallist') - : context.go('/listPlan'); - } - }, - child: Text("Cancel")), - SizedBox( - width: 20, + if (currentUri == "/allTrips/trips") { + context.go('/listAllPlan'); + } else if (currentUri == "/createPlan") { + context.go('/listPlan'); + } else { + isApprover ? context.go('/approvallist') : context.go('/listPlan'); + } + }, + child: Text("Cancel"), ), + SizedBox(width: 20), MouseRegion( - cursor: isViewMode - ? SystemMouseCursors.forbidden - : SystemMouseCursors.click, + cursor: + isViewMode + ? SystemMouseCursors.forbidden + : SystemMouseCursors.click, child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: @@ -274,15 +306,16 @@ class _CreatePlansState extends State { ), padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), ), - onPressed: isViewMode - ? null - : () { - _createPlanKey.currentState?.handleSubmit(); - }, // Disable when in view mode + onPressed: + isViewMode + ? null + : () { + _createPlanKey.currentState?.handleSubmit(); + }, // Disable when in view mode child: Text("Submit"), ), - ) + ), ]; } } @@ -402,31 +435,31 @@ class CreateNewPlansState extends State { //Getter Method Map get planData => { - "org_id": orgId, - "user_id": planUsrId, - "traveller_id": planTravlrId, - "trip_title": _tripTitleController.text, - "trip_type": _selectedTripType, - "cost_center_id": selectedCostCenterId, - "is_billable": _selectedIsBillable, - "purpose_of_travel": selectedPurpose, - "description": _descriptionController.text, - "functional_department": selectedFuncDept, - "so_number": "12345", - "created_by": selfId, - "updated_by": selfId, - "is_active": "1", - "flight": flightList, - "accomodation": accommodationList, - "bus": busList, - "taxi": taxiList, - "train": trainList, - "visa": visaList, - "forex": forexList, - "insurance": insuranceList, - "miscellaneous": miscellaneousList, - // "status_value": statusValue, - }; + "org_id": orgId, + "user_id": planUsrId, + "traveller_id": planTravlrId, + "trip_title": _tripTitleController.text, + "trip_type": _selectedTripType, + "cost_center_id": selectedCostCenterId, + "is_billable": _selectedIsBillable, + "purpose_of_travel": selectedPurpose, + "description": _descriptionController.text, + "functional_department": selectedFuncDept, + "so_number": "12345", + "created_by": selfId, + "updated_by": selfId, + "is_active": "1", + "flight": flightList, + "accomodation": accommodationList, + "bus": busList, + "taxi": taxiList, + "train": trainList, + "visa": visaList, + "forex": forexList, + "insurance": insuranceList, + "miscellaneous": miscellaneousList, + // "status_value": statusValue, + }; void handleItineraryUpdate(String type, List> newList) { setState(() { @@ -552,7 +585,8 @@ class CreateNewPlansState extends State { if (widget.selectedPlanData['plan_status'] != null) { planStatusList = List>.from( - widget.selectedPlanData['plan_status'] ?? []); + widget.selectedPlanData['plan_status'] ?? [], + ); } // @@ -568,28 +602,38 @@ class CreateNewPlansState extends State { // Assign lists from selectedPlanData, ensuring they are properly formatted flightList = List>.from( - widget.selectedPlanData['flight'] ?? []); + widget.selectedPlanData['flight'] ?? [], + ); accommodationList = List>.from( - widget.selectedPlanData['accomodation'] ?? []); + widget.selectedPlanData['accomodation'] ?? [], + ); busList = List>.from( - widget.selectedPlanData['bus'] ?? []); + widget.selectedPlanData['bus'] ?? [], + ); taxiList = List>.from( - widget.selectedPlanData['taxi'] ?? []); + widget.selectedPlanData['taxi'] ?? [], + ); trainList = List>.from( - widget.selectedPlanData['train'] ?? []); + widget.selectedPlanData['train'] ?? [], + ); visaList = List>.from( - widget.selectedPlanData['visa'] ?? []); + widget.selectedPlanData['visa'] ?? [], + ); forexList = List>.from( - widget.selectedPlanData['forex'] ?? []); + widget.selectedPlanData['forex'] ?? [], + ); insuranceList = List>.from( - widget.selectedPlanData['insurance'] ?? []); + widget.selectedPlanData['insurance'] ?? [], + ); miscellaneousList = List>.from( - widget.selectedPlanData['miscellaneous'] ?? []); + widget.selectedPlanData['miscellaneous'] ?? [], + ); }); if (widget.selectedPlanData['trip_type'] != null) { - int? tripId = - int.tryParse(widget.selectedPlanData['trip_type'].toString()); + int? tripId = int.tryParse( + widget.selectedPlanData['trip_type'].toString(), + ); fetchTrainFlightClass(tripId!); } @@ -654,13 +698,14 @@ class CreateNewPlansState extends State { // Create a blob from the response body final blob = html.Blob([response.bodyBytes]); -// Generate a download URL for the blob + // Generate a download URL for the blob final url = html.Url.createObjectUrlFromBlob(blob); // Create a link element to trigger the download - final anchor = html.AnchorElement(href: url) - ..setAttribute('download', 'trip_plan_$selectedPlanId.pdf') - ..click(); + final anchor = + html.AnchorElement(href: url) + ..setAttribute('download', 'trip_plan_$selectedPlanId.pdf') + ..click(); // Revoke the download URL to free up resources html.Url.revokeObjectUrl(url); @@ -793,7 +838,8 @@ class CreateNewPlansState extends State { if (!data.containsKey('data') || data['data'] is! Map) { throw Exception( - "Invalid response format: 'data' field is missing or not a Map"); + "Invalid response format: 'data' field is missing or not a Map", + ); } Map plansJson = @@ -838,7 +884,8 @@ class CreateNewPlansState extends State { if (!data.containsKey('data') || data['data'] is! List) { throw Exception( - "Invalid response format: 'data' field is missing or not a List"); + "Invalid response format: 'data' field is missing or not a List", + ); } List plansJson = data['data']; // 'data' is a Map, not a List @@ -857,7 +904,7 @@ class CreateNewPlansState extends State { apiCostData = plansJson; costCenterMap = { for (var item in apiCostData!) - item['department_id'].toString(): item['name'].toString() + item['department_id'].toString(): item['name'].toString(), }; costCenterIds = costCenterMap.keys.toList(); @@ -903,7 +950,8 @@ class CreateNewPlansState extends State { if (!data.containsKey('data') || data['data'] is! List) { throw Exception( - "Invalid response format: 'data' field is missing or not a List"); + "Invalid response format: 'data' field is missing or not a List", + ); } List plansJson = data['data']; // 'data' is a Map, not a List @@ -928,9 +976,10 @@ class CreateNewPlansState extends State { } Future fetchTrainFlightClass(int tripId) async { - final userId = (planUsrId?.toString().isNotEmpty == true) - ? planUsrId.toString() - : (planTravlrId?.toString().isNotEmpty == true) + final userId = + (planUsrId?.toString().isNotEmpty == true) + ? planUsrId.toString() + : (planTravlrId?.toString().isNotEmpty == true) ? planTravlrId.toString() : ''; @@ -959,7 +1008,8 @@ class CreateNewPlansState extends State { if (!data.containsKey('data') || data['data'] is! Map) { throw Exception( - "Invalid response format: 'data' field is missing or not a Map"); + "Invalid response format: 'data' field is missing or not a Map", + ); } Map plansJson = @@ -1019,8 +1069,9 @@ class CreateNewPlansState extends State { miscellaneousList, ]; - bool anyServiceSelected = - serviceLists.any((list) => list != null && list.isNotEmpty); + bool anyServiceSelected = serviceLists.any( + (list) => list != null && list.isNotEmpty, + ); if (!anyServiceSelected) { // validationErrors["services"] = "Please select at least one service"; @@ -1054,7 +1105,10 @@ class CreateNewPlansState extends State { } Future callRejectAPI( - String planId, String userId, String remarks) async { + String planId, + String userId, + String remarks, + ) async { await postToAPI( endpoint: '/api/plans/rejectPlan', data: { @@ -1099,8 +1153,15 @@ class CreateNewPlansState extends State { print("Call viewPlanForApprover"); ApiService.viewPlanForApprover( - context, data['plan_id'], data['approverId'], data['delegaterId'], - isViewMode: false, isApprover: true); + context, + data['plan_id'], + data['approverId'], + data['delegaterId'], + isViewMode: false, + isApprover: true, + ); + + context.go('/approvallist'); } else { print("$methodName failed. Status: ${response.statusCode}"); print("Error: ${response.body}"); @@ -1112,7 +1173,7 @@ class CreateNewPlansState extends State { void handleSubmit() { setState(() { - if (validateForm()) { + if (validateForm() && temporaryMessage == null) { // if (selectedPlanId != null && selectedPlanId!.isNotEmpty) { // planData['plan_id'] = selectedPlanId; // Add plan_id for update // } @@ -1122,11 +1183,13 @@ class CreateNewPlansState extends State { // "${planData['traveller_id']}," // " ${selectedPlanId}, " // " "); + postPlanData(planData); - final currentUri = GoRouterState.of(context) - .uri - .toString(); // ✅ safer than `.location` + final currentUri = + GoRouterState.of( + context, + ).uri.toString(); // ✅ safer than `.location` print("currentUri - $currentUri"); if (currentUri == "/allTrips/trips") { @@ -1189,280 +1252,286 @@ class CreateNewPlansState extends State { ), ); - return ResponsiveBuilder(builder: (context, sizingInfo) { - bool isMobile = sizingInfo.isMobile; - bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; + return ResponsiveBuilder( + builder: (context, sizingInfo) { + bool isMobile = sizingInfo.isMobile; + bool isDesktop = + sizingInfo.deviceScreenType == DeviceScreenType.desktop; - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - ResponsiveBuilder(builder: (context, sizingInfo) { - bool isDesktop = sizingInfo.deviceScreenType == - DeviceScreenType.desktop; + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + ResponsiveBuilder( + builder: (context, sizingInfo) { + bool isDesktop = + sizingInfo.deviceScreenType == + DeviceScreenType.desktop; - return Container( - padding: const EdgeInsets.all(5), - child: isDesktop - ? Row( - crossAxisAlignment: CrossAxisAlignment.start, - // mainAxisAlignment: MainAxisAlignment.end, - children: [ - _buildTripName(isDesktop), - if (isDesktop) Spacer(), - ..._buildApproverControls(isDesktop), - - // Text( - // widget.isViewMode - // ? "View Plan" - // : (selectedPlanId != null && - // selectedPlanId!.isNotEmpty - // ? "Update Plan" - // : "New Plan"), - // style: TextStyle(fontSize: 18), - // ), - // Spacer(), - - if (statusValue != "") - ..._buildPlanPdf(isDesktop) - ], - ) - : Column( - children: [ - Row( - // crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.end, - children: [ - ..._buildApproverControls(isDesktop), - if (statusValue != "") - ..._buildPlanPdf(isDesktop) - ], - ), - Row( + return Container( + padding: const EdgeInsets.all(5), + child: + isDesktop + ? Row( crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisAlignment: MainAxisAlignment.end, children: [ _buildTripName(isDesktop), + if (isDesktop) Spacer(), + ..._buildApproverControls(isDesktop), + + // Text( + // widget.isViewMode + // ? "View Plan" + // : (selectedPlanId != null && + // selectedPlanId!.isNotEmpty + // ? "Update Plan" + // : "New Plan"), + // style: TextStyle(fontSize: 18), + // ), + // Spacer(), + if (statusValue != "") + ..._buildPlanPdf(isDesktop), ], ) - ], - )); - }), - // if (isStatusExpanded) - // Container( - // margin: isDesktop - // ? const EdgeInsets.only(left: 0, top: 0) - // : const EdgeInsets.only(left: 5, top: 2), - // padding: const EdgeInsets.all(12), - // width: isDesktop - // ? MediaQuery.of(context).size.width * 0.2 - // : MediaQuery.of(context).size.width, - // decoration: BoxDecoration( - // color: Color(0xFFF5F5F5), - // border: Border.all( - // // color: Colors.grey.shade300, - // color: Colors.white, - // width: 0.2), - // borderRadius: BorderRadius.circular(8), - // // boxShadow: [ - // // BoxShadow( - // // // color: Colors.grey.withAlpha(20), - // // color: Colors.grey.withAlpha(20), - // // spreadRadius: 1.5, - // // blurRadius: 7, - // // offset: Offset(0, 4), // shadow direction: bottom - // // ), - // // ], - // ), - // child: Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // if (!hasApprovals) - // Center( - // child: Text( - // "--- No Approvals ---", - // style: TextStyle( - // fontFamily: "Archivo", - // fontSize: 11, - // fontWeight: FontWeight.w500, - // color: Colors.black87, - // ), - // )), - // for (int i = 0; i < planStatusList.length; i++) ...[ - // if (planStatusList[i].entries.any((entry) => - // entry.key.contains('status') && - // entry.value != null && - // entry.value.toString().isNotEmpty)) ...[ - // _buildApprovalItem( - // "Approver ${i + 1}", - // planStatusList[i] - // .entries - // .firstWhere( - // (entry) => entry.key.contains('status'), - // orElse: () => MapEntry('', ''), - // ) - // .value - // .toString(), - // ), - // SizedBox(height: 6), - // ], - // ], - // ], - // ), - // ), - if (isApproverRejected) - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const Padding( - padding: EdgeInsets.only(top: 4, left: 8), - child: Text("Remarks : ", + : Column( + children: [ + Row( + // crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.end, + children: [ + ..._buildApproverControls( + isDesktop, + ), + if (statusValue != "") + ..._buildPlanPdf(isDesktop), + ], + ), + Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [_buildTripName(isDesktop)], + ), + ], + ), + ); + }, + ), + // if (isStatusExpanded) + // Container( + // margin: isDesktop + // ? const EdgeInsets.only(left: 0, top: 0) + // : const EdgeInsets.only(left: 5, top: 2), + // padding: const EdgeInsets.all(12), + // width: isDesktop + // ? MediaQuery.of(context).size.width * 0.2 + // : MediaQuery.of(context).size.width, + // decoration: BoxDecoration( + // color: Color(0xFFF5F5F5), + // border: Border.all( + // // color: Colors.grey.shade300, + // color: Colors.white, + // width: 0.2), + // borderRadius: BorderRadius.circular(8), + // // boxShadow: [ + // // BoxShadow( + // // // color: Colors.grey.withAlpha(20), + // // color: Colors.grey.withAlpha(20), + // // spreadRadius: 1.5, + // // blurRadius: 7, + // // offset: Offset(0, 4), // shadow direction: bottom + // // ), + // // ], + // ), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // if (!hasApprovals) + // Center( + // child: Text( + // "--- No Approvals ---", + // style: TextStyle( + // fontFamily: "Archivo", + // fontSize: 11, + // fontWeight: FontWeight.w500, + // color: Colors.black87, + // ), + // )), + // for (int i = 0; i < planStatusList.length; i++) ...[ + // if (planStatusList[i].entries.any((entry) => + // entry.key.contains('status') && + // entry.value != null && + // entry.value.toString().isNotEmpty)) ...[ + // _buildApprovalItem( + // "Approver ${i + 1}", + // planStatusList[i] + // .entries + // .firstWhere( + // (entry) => entry.key.contains('status'), + // orElse: () => MapEntry('', ''), + // ) + // .value + // .toString(), + // ), + // SizedBox(height: 6), + // ], + // ], + // ], + // ), + // ), + if (isApproverRejected) + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Padding( + padding: EdgeInsets.only(top: 4, left: 8), + child: Text( + "Remarks : ", style: TextStyle( - fontFamily: "Archivo", - fontWeight: FontWeight.w600, - fontSize: 11)), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.only( - top: 0), // tweak if needed - child: TextFormField( - controller: _remarksController, - style: TextStyle( - fontFamily: "Archivo", - fontWeight: FontWeight.w600, - fontSize: 11), - decoration: InputDecoration( - hintText: "Please enter remarks...", - hintStyle: GoogleFonts.poppins( - fontSize: 13, color: Colors.grey), - border: InputBorder.none, - isDense: true, + fontFamily: "Archivo", + fontWeight: FontWeight.w600, + fontSize: 11, ), - maxLines: null, ), ), - ), - ], - ), + Expanded( + child: Padding( + padding: const EdgeInsets.only( + top: 0, + ), // tweak if needed + child: TextFormField( + controller: _remarksController, + style: TextStyle( + fontFamily: "Archivo", + fontWeight: FontWeight.w600, + fontSize: 11, + ), + decoration: InputDecoration( + hintText: "Please enter remarks...", + hintStyle: GoogleFonts.poppins( + fontSize: 13, + color: Colors.grey, + ), + border: InputBorder.none, + isDense: true, + ), + maxLines: null, + ), + ), + ), + ], + ), - // if (widget.isApprover || isStatusExpanded) + // if (widget.isApprover || isStatusExpanded) + Divider(thickness: 0.1, color: Colors.blueGrey), + if (widget.isApprover) SizedBox(height: 5), - Divider( - thickness: 0.1, - color: Colors.blueGrey, - ), - if (widget.isApprover) - SizedBox( - height: 5, - ), - - Text( - "Planning This Trip For*", // Your label - style: GoogleFonts.poppins( + Text( + "Planning This Trip For*", // Your label + style: GoogleFonts.poppins( fontSize: 12, fontWeight: FontWeight.w600, - color: Color(0xFF575A74)), - ), - SizedBox(height: 6), - isDesktop - ? SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: _buildPlanTrip(isDesktop), - ), - ) - : Row( - children: _buildPlanTrip(isDesktop), - ), - SizedBox(height: 7), - // Text( - // otherUserName ?? userName ?? " ", // Your label - // - // style: GoogleFonts.poppins( - // fontSize: 11, - // fontWeight: FontWeight.w400, - // color: widget.layoutColor, - // ), - // ), - - Text.rich( - TextSpan( - text: "Trip Planned User : ", // Static text - style: GoogleFonts.poppins( - fontSize: 11, - fontWeight: FontWeight.w400, - color: Color(0xFF212121), - // color: Color(0xFF575A74), // Default color + color: Color(0xFF575A74), ), - children: [ - TextSpan( - text: otherUserName ?? - userName ?? - " ", // Dynamic username - style: GoogleFonts.poppins( - fontSize: 11, - fontWeight: FontWeight.w400, - color: widget - .layoutColor, // Change this to any color - // color: Colors.blueAccent, // Change this to any color - ), - ), - ], ), - ), - SizedBox(height: 5), - ], + SizedBox(height: 6), + isDesktop + ? SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row(children: _buildPlanTrip(isDesktop)), + ) + : Row(children: _buildPlanTrip(isDesktop)), + SizedBox(height: 7), + + // Text( + // otherUserName ?? userName ?? " ", // Your label + // + // style: GoogleFonts.poppins( + // fontSize: 11, + // fontWeight: FontWeight.w400, + // color: widget.layoutColor, + // ), + // ), + Text.rich( + TextSpan( + text: "Trip Planned User : ", // Static text + style: GoogleFonts.poppins( + fontSize: 11, + fontWeight: FontWeight.w400, + color: Color(0xFF212121), + // color: Color(0xFF575A74), // Default color + ), + children: [ + TextSpan( + text: + otherUserName ?? + userName ?? + " ", // Dynamic username + style: GoogleFonts.poppins( + fontSize: 11, + fontWeight: FontWeight.w400, + color: + widget + .layoutColor, // Change this to any color + // color: Colors.blueAccent, // Change this to any color + ), + ), + ], + ), + ), + SizedBox(height: 5), + ], + ), ), - ), - ], - ), - // Padding( - // padding: const EdgeInsets.all(8.0), - // child: Divider( - // color: Color(0xFFE6E7F5), // Change color - // thickness: 0.5, - // ), - // ), + ], + ), - SizedBox(height: 10), + // Padding( + // padding: const EdgeInsets.all(8.0), + // child: Divider( + // color: Color(0xFFE6E7F5), // Change color + // thickness: 0.5, + // ), + // ), + SizedBox(height: 10), - // Row( - // children: [ - // Expanded( - // child: - // ), - // ], - // ), + // Row( + // children: [ + // Expanded( + // child: + // ), + // ], + // ), + isDesktop + ? Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: _buildTripRow(isMobile), + ) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: _buildTripRow(isMobile), + ), + SizedBox(height: 15), - isDesktop - ? Row( + isDesktop + ? Row( crossAxisAlignment: CrossAxisAlignment.start, - children: _buildTripRow(isMobile)) - : Column( + children: _buildCostCenter(isDesktop), + ) + : Column( crossAxisAlignment: CrossAxisAlignment.start, - children: _buildTripRow(isMobile)), - SizedBox( - height: 15, - ), - - isDesktop - ? Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: _buildCostCenter(isDesktop)) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: _buildCostCenter(isDesktop)), - SizedBox( - height: 8, - ), - isDesktop - ? Row( + children: _buildCostCenter(isDesktop), + ), + SizedBox(height: 8), + isDesktop + ? Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ // _buildNonDescriptionColumn(), @@ -1470,7 +1539,7 @@ class CreateNewPlansState extends State { _buildDescriptionColumn(isDesktop), ], ) - : Column( + : Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // _buildNonDescriptionColumn(), @@ -1478,74 +1547,72 @@ class CreateNewPlansState extends State { _buildDescriptionColumn(isDesktop), ], ), - // Padding( - // padding: const EdgeInsets.all(8.0), - // child: Divider( - // color: Color(0xFFE6E7F5), // Change color - // thickness: 0.5, - // ), - // ), - SizedBox( - height: 20, - ), + // Padding( + // padding: const EdgeInsets.all(8.0), + // child: Divider( + // color: Color(0xFFE6E7F5), // Change color + // thickness: 0.5, + // ), + // ), + SizedBox(height: 20), - if (temporaryMessage != null) - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - // validationErrors["services"]!, - temporaryMessage!, - style: GoogleFonts.poppins( + if (temporaryMessage != null) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + // validationErrors["services"]!, + temporaryMessage!, + style: GoogleFonts.poppins( color: Colors.red, - fontSize: 10, - fontWeight: FontWeight.bold), - ), + fontSize: 12, + fontWeight: FontWeight.w400, + ), + ), + ], + ), + + if (temporaryMessage != null) SizedBox(height: 10), + Row( + children: [ + Expanded( + child: DynamicItinerary( + key: dynamicItineraryKey, + flightScreenKey: flightScreenKey, + tripTypeNotifier: flightTripTypeNotifier, + hasAction: hasAction, + tripType: _selectedTripType, + apiData: apiData, + apiDataForClass: apiDataForClass, + apiCountryData: apiCountryData, + onItineraryUpdate: handleItineraryUpdate, + loginUser: selfId, + selectedPlanData: planData, + isViewMode: widget.isViewMode, + ), + ), // Wrap with Expanded if needed ], ), + SizedBox(height: 15), + ], + ); - if (temporaryMessage != null) - SizedBox( - height: 10, - ), - Row( - children: [ - Expanded( - child: DynamicItinerary( - key: dynamicItineraryKey, - flightScreenKey: flightScreenKey, - tripTypeNotifier: flightTripTypeNotifier, - hasAction: hasAction, - tripType: _selectedTripType, - apiData: apiData, - apiDataForClass: apiDataForClass, - apiCountryData: apiCountryData, - onItineraryUpdate: handleItineraryUpdate, - loginUser: selfId, - selectedPlanData: planData, - isViewMode: widget.isViewMode, - )), // Wrap with Expanded if needed - ], - ), - SizedBox(height: 15), - ], - ); - - // Row( - // children: [ - // isDesktop - // ? Row( - // mainAxisAlignment: MainAxisAlignment.end, - // children: _buildSubmit(isDesktop), - // ) - // : Row( - // mainAxisAlignment: MainAxisAlignment.center, - // children: _buildSubmit(isDesktop), - // ) - // ], - // ) - }); + // Row( + // children: [ + // isDesktop + // ? Row( + // mainAxisAlignment: MainAxisAlignment.end, + // children: _buildSubmit(isDesktop), + // ) + // : Row( + // mainAxisAlignment: MainAxisAlignment.center, + // children: _buildSubmit(isDesktop), + // ) + // ], + // ) + }, + ); } String? getSelectedCostCenterName() { @@ -1558,6 +1625,23 @@ class CreateNewPlansState extends State { /// Extracted helper function /// + /// + /// + + final List> allTripTypes = [ + {"dropdown_key": "1", "dropdown_value": "Domestic"}, + {"dropdown_key": "2", "dropdown_value": "International"}, + ]; + + List> getFilteredTripTypes() { + if (!showDomestic && !showInternational) return []; + + return allTripTypes.where((item) { + if (item['dropdown_key'] == "1" && showDomestic) return true; + if (item['dropdown_key'] == "2" && showInternational) return true; + return false; + }).toList(); + } List _buildTripRow(bool isMobile) { List purposeList = apiData?['plan_is_billable'] ?? []; @@ -1575,9 +1659,10 @@ class CreateNewPlansState extends State { "Trip Type *", // Your label style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74)), + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), ), SizedBox(height: 5), @@ -1591,13 +1676,13 @@ class CreateNewPlansState extends State { popupProps: PopupProps.menu( showSearchBox: false, // Optionally enable search fit: FlexFit.loose, - menuProps: const MenuProps( - backgroundColor: Colors.white, - ), + menuProps: const MenuProps(backgroundColor: Colors.white), itemBuilder: (context, item, isSelected) { return Padding( padding: const EdgeInsets.symmetric( - horizontal: 10, vertical: 8), + horizontal: 10, + vertical: 8, + ), child: Text( item['dropdown_value'] ?? '', style: GoogleFonts.poppins( @@ -1612,22 +1697,28 @@ class CreateNewPlansState extends State { dropdownSearchDecoration: InputDecoration( border: InputBorder.none, // No underline - contentPadding: - EdgeInsets.symmetric(horizontal: 10, vertical: 5), + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), ), ), dropdownBuilder: (context, selectedItem) { if (selectedItem == null || selectedItem.isEmpty) { return Text( "Select Trip Type", - style: - GoogleFonts.poppins(color: Colors.grey, fontSize: 13), + style: GoogleFonts.poppins( + color: Colors.grey, + fontSize: 13, + ), ); } return Text( selectedItem['dropdown_value'] ?? '', - style: - GoogleFonts.poppins(fontSize: 12, color: Colors.black), + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), ); }, selectedItem: tripTypeList.firstWhere( @@ -1635,30 +1726,36 @@ class CreateNewPlansState extends State { orElse: () => {}, ), itemAsString: (item) => item['dropdown_value'] ?? '', - items: [ - {"dropdown_key": "1", "dropdown_value": "Domestic"}, - {"dropdown_key": "2", "dropdown_value": "International"}, - ].map>((item) { - return Map.from(item); - }).toList(), - onChanged: widget.isViewMode - ? null - : (Map? newItem) { - if (newItem != null) { - setState(() { - _selectedTripType = - newItem['dropdown_key'].toString(); - // Notify FlightScreen - flightTripTypeNotifier.value = _selectedTripType; - print( - "flightTripTypeNotifier- ${flightTripTypeNotifier.value}"); - fetchTrainFlightClass( - int.parse(_selectedTripType!)); - dynamicItineraryKey.currentState - ?.updateSelectedServices(); - }); - } - }, + items: getFilteredTripTypes(), + + // items: + // [ + // {"dropdown_key": "1", "dropdown_value": "Domestic"}, + // {"dropdown_key": "2", "dropdown_value": "International"}, + // ].map>((item) { + // return Map.from(item); + // }).toList(), + onChanged: + widget.isViewMode + ? null + : (Map? newItem) { + if (newItem != null) { + setState(() { + _selectedTripType = + newItem['dropdown_key'].toString(); + // Notify FlightScreen + flightTripTypeNotifier.value = _selectedTripType; + print( + "flightTripTypeNotifier- ${flightTripTypeNotifier.value}", + ); + fetchTrainFlightClass( + int.parse(_selectedTripType!), + ); + dynamicItineraryKey.currentState + ?.updateSelectedServices(); + }); + } + }, ), ), ), @@ -1677,161 +1774,183 @@ class CreateNewPlansState extends State { padding: EdgeInsets.only(top: 4), child: Text( validationErrors["trip_type"]!, - style: GoogleFonts.poppins(fontSize: 12, color: Colors.black), + style: GoogleFonts.poppins(fontSize: 12, color: Colors.red), ), ), ], ), - SizedBox( - width: 25, - height: 5, - ), + SizedBox(width: 25, height: 5), // SizedBox( // width: 25, // height: 5, // ), - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Is Billable ", // Your label + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Is Billable ", // Your label style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74))), - SizedBox(height: 5), + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), + ), + SizedBox(height: 5), - CustomTextFieldWrapper( - width: - widget.isDesktop ? MediaQuery.of(context).size.width * 0.2 : null, - isFocused: false, - isDesktop: widget.isDesktop, - child: SizedBox( - height: 35, - width: double.infinity, - child: DropdownSearch>( - popupProps: PopupProps.menu( - showSearchBox: false, - fit: FlexFit.loose, - menuProps: const MenuProps( - backgroundColor: Colors.white, - ), - itemBuilder: (context, item, isSelected) { - return Padding( - padding: - const EdgeInsets.symmetric(horizontal: 10, vertical: 8), - child: Text(item['dropdown_value'] ?? '', + CustomTextFieldWrapper( + width: + widget.isDesktop + ? MediaQuery.of(context).size.width * 0.2 + : null, + isFocused: false, + isDesktop: widget.isDesktop, + child: SizedBox( + height: 35, + width: double.infinity, + child: DropdownSearch>( + popupProps: PopupProps.menu( + showSearchBox: false, + fit: FlexFit.loose, + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: (context, item, isSelected) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 8, + ), + child: Text( + item['dropdown_value'] ?? '', style: GoogleFonts.poppins( fontSize: 12, color: Colors.black, - )), + ), + ), + ); + }, + ), + dropdownDecoratorProps: const DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + ), + ), + selectedItem: purposeList + .cast>() + .firstWhere( + (item) => item['dropdown_key'] == _selectedIsBillable, + orElse: () => {}, + ), + dropdownButtonProps: const DropdownButtonProps( + icon: Icon(Icons.arrow_drop_down), + ), + // itemAsString: (item) => item['dropdown_value'] ?? '', + // items: purposeList.cast>(), + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select Billable", // fallback text + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.grey, + ), + ); + } + return Text( + selectedItem['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), ); }, - ), - dropdownDecoratorProps: const DropDownDecoratorProps( - dropdownSearchDecoration: InputDecoration( - border: InputBorder.none, - contentPadding: - EdgeInsets.symmetric(horizontal: 10, vertical: 5), - ), - ), - selectedItem: purposeList.cast>().firstWhere( - (item) => item['dropdown_key'] == _selectedIsBillable, - orElse: () => {}, - ), - dropdownButtonProps: const DropdownButtonProps( - icon: Icon(Icons.arrow_drop_down), - ), - // itemAsString: (item) => item['dropdown_value'] ?? '', - // items: purposeList.cast>(), - dropdownBuilder: (context, selectedItem) { - if (selectedItem == null || selectedItem.isEmpty) { - return Text("Select Billable", // fallback text - style: GoogleFonts.poppins( - fontSize: 12, color: Colors.grey)); - } - return Text(selectedItem['dropdown_value'] ?? '', - style: - GoogleFonts.poppins(fontSize: 12, color: Colors.black)); - }, - items: purposeList.map>((item) { - return Map.from( - item); // Ensuring each item is properly cast - }).toList(), - onChanged: widget.isViewMode - ? null - : (Map? newItem) { - if (newItem != null) { - setState(() { - _selectedIsBillable = - newItem['dropdown_key'].toString(); - }); - } - }, + items: + purposeList.map>((item) { + return Map.from( + item, + ); // Ensuring each item is properly cast + }).toList(), + onChanged: + widget.isViewMode + ? null + : (Map? newItem) { + if (newItem != null) { + setState(() { + _selectedIsBillable = + newItem['dropdown_key'].toString(); + }); + } + }, + ), ), ), - ), - // Row( - // children: purposeList.map((item) { - // final isSelected = - // _selectedIsBillable == item['dropdown_key'].toString(); - // - // return Padding( - // padding: const EdgeInsets.symmetric(horizontal: 5), - // child: CustomTextFieldWrapper( - // color: Color(0xFFF5F5F5), - // padding: - // const EdgeInsets.symmetric(horizontal: 10, vertical: 4), - // layoutColor: widget.layoutColor, - // width: item['dropdown_key'] == 'some_key' ? 185 : 125, - // borderRadius: BorderRadius.circular(25), - // isFocused: isSelected, - // isDesktop: widget.isDesktop, - // child: GestureDetector( - // onTap: widget.isViewMode - // ? null - // : () { - // setState(() { - // _selectedIsBillable = - // item['dropdown_key'].toString(); - // }); - // print("SELECBILL - $_selectedIsBillable"); - // }, - // child: Row( - // mainAxisSize: MainAxisSize.min, - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // item['dropdown_value'] ?? '', - // style: TextStyle( - // color: isSelected ? Colors.white : Colors.black, - // fontWeight: isSelected ? FontWeight.w500 : null, - // fontSize: 13), - // ), - // const SizedBox(width: 8), - // Container( - // width: 16, - // height: 16, - // decoration: BoxDecoration( - // borderRadius: BorderRadius.circular(4), - // border: Border.all( - // color: isSelected ? Colors.white : Colors.black, - // width: isSelected ? 2 : 1, - // ), - // ), - // child: isSelected - // ? Icon(Icons.rectangle, - // size: 8, color: Colors.white) - // : null, - // ), - // ], - // ), - // ), - // ), - // ); - // }).toList(), - // ), - ]) + // Row( + // children: purposeList.map((item) { + // final isSelected = + // _selectedIsBillable == item['dropdown_key'].toString(); + // + // return Padding( + // padding: const EdgeInsets.symmetric(horizontal: 5), + // child: CustomTextFieldWrapper( + // color: Color(0xFFF5F5F5), + // padding: + // const EdgeInsets.symmetric(horizontal: 10, vertical: 4), + // layoutColor: widget.layoutColor, + // width: item['dropdown_key'] == 'some_key' ? 185 : 125, + // borderRadius: BorderRadius.circular(25), + // isFocused: isSelected, + // isDesktop: widget.isDesktop, + // child: GestureDetector( + // onTap: widget.isViewMode + // ? null + // : () { + // setState(() { + // _selectedIsBillable = + // item['dropdown_key'].toString(); + // }); + // print("SELECBILL - $_selectedIsBillable"); + // }, + // child: Row( + // mainAxisSize: MainAxisSize.min, + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // item['dropdown_value'] ?? '', + // style: TextStyle( + // color: isSelected ? Colors.white : Colors.black, + // fontWeight: isSelected ? FontWeight.w500 : null, + // fontSize: 13), + // ), + // const SizedBox(width: 8), + // Container( + // width: 16, + // height: 16, + // decoration: BoxDecoration( + // borderRadius: BorderRadius.circular(4), + // border: Border.all( + // color: isSelected ? Colors.white : Colors.black, + // width: isSelected ? 2 : 1, + // ), + // ), + // child: isSelected + // ? Icon(Icons.rectangle, + // size: 8, color: Colors.white) + // : null, + // ), + // ], + // ), + // ), + // ), + // ); + // }).toList(), + // ), + ], + ), ]; } @@ -1844,80 +1963,99 @@ class CreateNewPlansState extends State { // List purposeList = apiData?['plan_purpose_of_travel'] ?? []; List> purposeList = List>.from( - apiData?['plan_purpose_of_travel'] ?? []); + apiData?['plan_purpose_of_travel'] ?? [], + ); - List> dropdownItems = purposeList - .map((item) => DropdownMenuItem( - // value: item['dropdown_key'], - value: item['dropdown_key']?.toString(), - // value: item['dropdown_key'].toString(), - child: Text(item['dropdown_value']), - )) - .toList(); + List> dropdownItems = + purposeList + .map( + (item) => DropdownMenuItem( + // value: item['dropdown_key'], + value: item['dropdown_key']?.toString(), + // value: item['dropdown_key'].toString(), + child: Text(item['dropdown_value']), + ), + ) + .toList(); if (dropdownItems.isEmpty) { dropdownItems.add( DropdownMenuItem( // value: null, value: "1", - child: Text("No options available", - style: GoogleFonts.poppins(color: Colors.grey)), + child: Text( + "No options available", + style: GoogleFonts.poppins(color: Colors.grey), + ), ), ); } - selectedPurpose ??= dropdownItems.isNotEmpty - ? dropdownItems.first.value.toString() - : "No options"; + selectedPurpose ??= + dropdownItems.isNotEmpty + ? dropdownItems.first.value.toString() + : "No options"; print( - "Dropdown Purpose List: ${dropdownItems.map((e) => e.value).toList()}"); + "Dropdown Purpose List: ${dropdownItems.map((e) => e.value).toList()}", + ); print("Selected Purpose: $selectedPurpose"); // 'plan_functional_department' Starts --------------------------------------------- // List funcDeptList = apiData?['plan_functional_department'] ?? []; List> funcDeptList = List>.from( - apiData?['plan_functional_department'] ?? []); + apiData?['plan_functional_department'] ?? [], + ); - List> dropdownFuncDeptItems = funcDeptList - .map((item) => DropdownMenuItem( - // value: item['dropdown_key'], - value: item['dropdown_key']?.toString(), - child: Text(item['dropdown_value']), - )) - .toList(); + List> dropdownFuncDeptItems = + funcDeptList + .map( + (item) => DropdownMenuItem( + // value: item['dropdown_key'], + value: item['dropdown_key']?.toString(), + child: Text(item['dropdown_value']), + ), + ) + .toList(); if (dropdownFuncDeptItems.isEmpty) { dropdownFuncDeptItems.add( DropdownMenuItem( // value: null, value: "1", - child: Text("No options available", - style: TextStyle(color: Colors.grey)), + child: Text( + "No options available", + style: TextStyle(color: Colors.grey), + ), ), ); } // selectedFuncDept ??= dropdownFuncDeptItems.isNotEmpty ? dropdownFuncDeptItems.first.value.toString() : null; - selectedFuncDept ??= dropdownFuncDeptItems.isNotEmpty - ? dropdownFuncDeptItems.first.value.toString() - : "No options"; + selectedFuncDept ??= + dropdownFuncDeptItems.isNotEmpty + ? dropdownFuncDeptItems.first.value.toString() + : "No options"; print( - "Dropdown Functional Department List: ${dropdownFuncDeptItems.map((e) => e.value).toList()}"); + "Dropdown Functional Department List: ${dropdownFuncDeptItems.map((e) => e.value).toList()}", + ); print("Selected Functional Department: $selectedFuncDept"); return [ Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Cost Center *", // Your label + Text( + "Cost Center *", // Your label - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74))), + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), + ), SizedBox(height: 5), CustomTextFieldWrapper( isFocused: false, // Dropdown doesn't use focus @@ -1925,87 +2063,99 @@ class CreateNewPlansState extends State { child: SizedBox( height: 35, width: double.infinity, - child: apiCostData == null - ? Center( - child: Transform.scale( - scale: 0.5, - child: CircularProgressIndicator(), - ), - ) - : DropdownSearch( - selectedItem: costCenterMap[selectedCostCenterId], - enabled: !widget.isViewMode, - popupProps: PopupProps.menu( - showSearchBox: true, - fit: FlexFit.loose, - constraints: BoxConstraints(maxHeight: 250), - searchFieldProps: TextFieldProps( - decoration: InputDecoration( - hintText: "Search Cost Center...", - // hintStyle: TextStyle(fontSize: 13, color: Colors.grey), - hintStyle: GoogleFonts.poppins( - fontSize: 13, color: Colors.grey), - contentPadding: - EdgeInsets.symmetric(horizontal: 10), + child: + apiCostData == null + ? Center( + child: Transform.scale( + scale: 0.5, + child: CircularProgressIndicator(), + ), + ) + : DropdownSearch( + selectedItem: costCenterMap[selectedCostCenterId], + enabled: !widget.isViewMode, + popupProps: PopupProps.menu( + showSearchBox: true, + fit: FlexFit.loose, + constraints: BoxConstraints(maxHeight: 250), + searchFieldProps: TextFieldProps( + decoration: InputDecoration( + hintText: "Search Cost Center...", + // hintStyle: TextStyle(fontSize: 13, color: Colors.grey), + hintStyle: GoogleFonts.poppins( + fontSize: 13, + color: Colors.grey, + ), + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + ), + ), + style: GoogleFonts.poppins(fontSize: 13), ), - style: GoogleFonts.poppins(fontSize: 13), + menuProps: MenuProps(backgroundColor: Colors.white), + itemBuilder: + (context, item, isSelected) => Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8.0, + vertical: 6.0, + ), + child: Text( + item, + style: GoogleFonts.poppins( + fontSize: 13, + ), // 👈 Set your desired text size here + ), + ), ), - menuProps: MenuProps( - backgroundColor: Colors.white, - ), - itemBuilder: (context, item, isSelected) => Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8.0, vertical: 6.0), - child: Text( - item, - style: GoogleFonts.poppins( - fontSize: 13, - ), // 👈 Set your desired text size here + + items: costCenterMap.values.toList(), // just names + dropdownDecoratorProps: DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + // contentPadding: EdgeInsets.symmetric(horizontal: 1), + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), ), ), - ), - items: costCenterMap.values.toList(), // just names - dropdownDecoratorProps: DropDownDecoratorProps( - dropdownSearchDecoration: InputDecoration( - border: InputBorder.none, - // contentPadding: EdgeInsets.symmetric(horizontal: 1), - contentPadding: - EdgeInsets.symmetric(horizontal: 10, vertical: 5), - ), - ), - - dropdownBuilder: (context, selectedItem) { - if (selectedItem == null || selectedItem.isEmpty) { + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select Purpose", // fallback text + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.grey, + ), + ); + } return Text( - "Select Purpose", // fallback text + selectedItem ?? '', style: GoogleFonts.poppins( - fontSize: 12, color: Colors.grey), + fontSize: 12, + color: Colors.black, + ), ); - } - return Text( - selectedItem ?? '', - style: GoogleFonts.poppins( - fontSize: 12, - color: Colors.black, - ), - ); - }, - // dropdownBuilder: (context, selectedItem) => Align( - // alignment: Alignment.centerLeft, - // child: Text( - // selectedItem ?? "Select", - // style: TextStyle(fontSize: 12), - // ), - // ), - onChanged: (String? newValue) { - setState(() { - selectedCostCenterId = costCenterMap.entries - .firstWhere((entry) => entry.value == newValue) - .key; - }); - }, - ), + }, + // dropdownBuilder: (context, selectedItem) => Align( + // alignment: Alignment.centerLeft, + // child: Text( + // selectedItem ?? "Select", + // style: TextStyle(fontSize: 12), + // ), + // ), + onChanged: (String? newValue) { + setState(() { + selectedCostCenterId = + costCenterMap.entries + .firstWhere( + (entry) => entry.value == newValue, + ) + .key; + }); + }, + ), ), // child: SizedBox( @@ -2036,114 +2186,125 @@ class CreateNewPlansState extends State { ), ], ), - SizedBox( - width: 25, - height: 5, - ), + SizedBox(width: 25, height: 5), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text("Purpose of Trip *", // Your label + Text( + "Purpose of Trip *", // Your label - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74))), + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), + ), SizedBox(height: 5), CustomTextFieldWrapper( - width: isDesktop - ? MediaQuery.of(context).size.width * 0.2 - : MediaQuery.of(context).size.width * 0.85, + width: + isDesktop + ? MediaQuery.of(context).size.width * 0.2 + : MediaQuery.of(context).size.width * 0.85, isFocused: false, // Dropdown doesn't use focus isDesktop: widget.isDesktop, child: SizedBox( height: 35, // Set appropriate height - child: apiData == null - ? Center( - child: - CircularProgressIndicator()) // Show loading inside dropdown - : DropdownSearch>( - selectedItem: purposeList.firstWhere( - (item) => - item['dropdown_key'].toString() == selectedPurpose, - orElse: () => {}, // ✅ Safe fallback - ), - items: purposeList, - itemAsString: (Map item) => - item['dropdown_value'], - popupProps: PopupProps.menu( - showSearchBox: true, - fit: FlexFit.loose, - constraints: BoxConstraints(maxHeight: 250), - searchFieldProps: TextFieldProps( - decoration: InputDecoration( - hintText: "Search Purpose...", - hintStyle: GoogleFonts.poppins( - fontSize: 13, color: Colors.grey), - contentPadding: - EdgeInsets.symmetric(horizontal: 10), + child: + apiData == null + ? Center( + child: CircularProgressIndicator(), + ) // Show loading inside dropdown + : DropdownSearch>( + selectedItem: purposeList.firstWhere( + (item) => + item['dropdown_key'].toString() == + selectedPurpose, + orElse: () => {}, // ✅ Safe fallback + ), + items: purposeList, + itemAsString: + (Map item) => + item['dropdown_value'], + popupProps: PopupProps.menu( + showSearchBox: true, + fit: FlexFit.loose, + constraints: BoxConstraints(maxHeight: 250), + searchFieldProps: TextFieldProps( + decoration: InputDecoration( + hintText: "Search Purpose...", + hintStyle: GoogleFonts.poppins( + fontSize: 13, + color: Colors.grey, + ), + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + ), + ), + style: GoogleFonts.poppins(fontSize: 13), ), - style: GoogleFonts.poppins( - fontSize: 13, + menuProps: MenuProps(backgroundColor: Colors.white), + itemBuilder: + (context, item, isSelected) => Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8.0, + vertical: 6.0, + ), + child: Text( + item['dropdown_value'], + style: GoogleFonts.poppins( + fontSize: 13, + ), // 👈 Set your desired text size here + ), + ), + ), + dropdownDecoratorProps: DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + border: InputBorder.none, ), ), - menuProps: MenuProps( - backgroundColor: Colors.white, - ), - itemBuilder: (context, item, isSelected) => Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8.0, vertical: 6.0), - child: Text( - item['dropdown_value'], - style: GoogleFonts.poppins( - fontSize: 13, - ), // 👈 Set your desired text size here - ), - ), - ), - dropdownDecoratorProps: DropDownDecoratorProps( - dropdownSearchDecoration: InputDecoration( - contentPadding: - EdgeInsets.symmetric(horizontal: 10, vertical: 5), - border: InputBorder.none, - ), - ), - onChanged: widget.isViewMode - ? null - : (Map? newValue) { - setState(() { - selectedPurpose = - newValue?['dropdown_key'].toString(); - }); - print("selectedPurpose - $selectedPurpose"); - }, + onChanged: + widget.isViewMode + ? null + : (Map? newValue) { + setState(() { + selectedPurpose = + newValue?['dropdown_key'].toString(); + }); + print("selectedPurpose - $selectedPurpose"); + }, - dropdownBuilder: (context, selectedItem) { - if (selectedItem == null || selectedItem.isEmpty) { + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select Purpose", // fallback text + style: GoogleFonts.poppins( + fontSize: 13, + color: Colors.grey, + ), + ); + } return Text( - "Select Purpose", // fallback text + selectedItem['dropdown_value'] ?? '', style: GoogleFonts.poppins( - fontSize: 13, color: Colors.grey), + fontSize: + 12, // 👈 Small font size for selected item + color: Colors.black, + ), ); - } - return Text( - selectedItem['dropdown_value'] ?? '', - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Small font size for selected item - color: Colors.black, - ), - ); - }, - // dropdownBuilder: (context, selectedItem) => Align( - // alignment: Alignment.centerLeft, - // child: Text( - // selectedItem?['dropdown_value'] ?? '', - // style: TextStyle(fontSize: 12), - // ), - // ), - ), + }, + // dropdownBuilder: (context, selectedItem) => Align( + // alignment: Alignment.centerLeft, + // child: Text( + // selectedItem?['dropdown_value'] ?? '', + // style: TextStyle(fontSize: 12), + // ), + // ), + ), ), ), @@ -2181,115 +2342,128 @@ class CreateNewPlansState extends State { // ), ], ), - SizedBox( - width: 25, - height: 5, - ), + SizedBox(width: 25, height: 5), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Functional Department", // Your label style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74)), + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), ), SizedBox(height: 5), CustomTextFieldWrapper( isFocused: false, // Dropdown doesn't use focus isDesktop: widget.isDesktop, - width: isDesktop - ? MediaQuery.of(context).size.width * 0.2 - : MediaQuery.of(context).size.width * 0.85, + width: + isDesktop + ? MediaQuery.of(context).size.width * 0.2 + : MediaQuery.of(context).size.width * 0.85, // width: MediaQuery.of(context).size.width * 0.2, child: SizedBox( height: 35, // Set appropriate height - child: apiData == null - ? Center( - child: - CircularProgressIndicator()) // Show loading inside dropdown - : DropdownSearch>( - selectedItem: funcDeptList.firstWhere( - (item) => - item['dropdown_key'].toString() == selectedFuncDept, - orElse: () => {}, // ✅ Safe fallback - ), - items: funcDeptList, - itemAsString: (Map item) => - item['dropdown_value'], - popupProps: PopupProps.menu( - showSearchBox: true, - fit: FlexFit.loose, - constraints: BoxConstraints(maxHeight: 250), - searchFieldProps: TextFieldProps( + child: + apiData == null + ? Center( + child: CircularProgressIndicator(), + ) // Show loading inside dropdown + : DropdownSearch>( + selectedItem: funcDeptList.firstWhere( + (item) => + item['dropdown_key'].toString() == + selectedFuncDept, + orElse: () => {}, // ✅ Safe fallback + ), + items: funcDeptList, + itemAsString: + (Map item) => + item['dropdown_value'], + popupProps: PopupProps.menu( + showSearchBox: true, + fit: FlexFit.loose, + constraints: BoxConstraints(maxHeight: 250), + searchFieldProps: TextFieldProps( decoration: InputDecoration( hintText: "Search department...", hintStyle: GoogleFonts.poppins( - fontSize: 13, color: Colors.grey), - contentPadding: - EdgeInsets.symmetric(horizontal: 10), + fontSize: 13, + color: Colors.grey, + ), + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + ), ), style: GoogleFonts.poppins( fontSize: 13, // 👈 Small font size for selected item - )), - menuProps: MenuProps( - backgroundColor: Colors.white, + ), + ), + menuProps: MenuProps(backgroundColor: Colors.white), + itemBuilder: + (context, item, isSelected) => Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8.0, + vertical: 6.0, + ), + child: Text( + item['dropdown_value'], + style: GoogleFonts.poppins( + fontSize: + 13, // 👈 Small font size for selected item + ), // 👈 Set your desired text size here + ), + ), ), - itemBuilder: (context, item, isSelected) => Padding( - padding: const EdgeInsets.symmetric( - horizontal: 8.0, vertical: 6.0), - child: Text( - item['dropdown_value'], + dropdownDecoratorProps: DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + border: InputBorder.none, + ), + ), + onChanged: + widget.isViewMode + ? null + : (Map? newValue) { + setState(() { + selectedFuncDept = + newValue?['dropdown_key'].toString(); + }); + print("selectedFuncDept - $selectedFuncDept"); + }, + + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return const Text( + "Select Purpose", // fallback text + style: TextStyle( + fontSize: 12, + color: Colors.grey, + ), + ); + } + return Text( + selectedItem['dropdown_value'] ?? '', style: GoogleFonts.poppins( fontSize: - 13, // 👈 Small font size for selected item - ), // 👈 Set your desired text size here - ), - ), - ), - dropdownDecoratorProps: DropDownDecoratorProps( - dropdownSearchDecoration: InputDecoration( - contentPadding: - EdgeInsets.symmetric(horizontal: 10, vertical: 5), - border: InputBorder.none, - ), - ), - onChanged: widget.isViewMode - ? null - : (Map? newValue) { - setState(() { - selectedFuncDept = - newValue?['dropdown_key'].toString(); - }); - print("selectedFuncDept - $selectedFuncDept"); - }, - - dropdownBuilder: (context, selectedItem) { - if (selectedItem == null || selectedItem.isEmpty) { - return const Text( - "Select Purpose", // fallback text - style: TextStyle(fontSize: 12, color: Colors.grey), + 12, // 👈 Small font size for selected item + color: Colors.black, + ), ); - } - return Text( - selectedItem['dropdown_value'] ?? '', - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Small font size for selected item - color: Colors.black, - ), - ); - }, - // dropdownBuilder: (context, selectedItem) => Align( - // alignment: Alignment.centerLeft, - // child: Text( - // selectedItem?['dropdown_value'] ?? '', - // style: TextStyle(fontSize: 12), - // ), - // ), - ), + }, + // dropdownBuilder: (context, selectedItem) => Align( + // alignment: Alignment.centerLeft, + // child: Text( + // selectedItem?['dropdown_value'] ?? '', + // style: TextStyle(fontSize: 12), + // ), + // ), + ), ), ), ], @@ -2313,30 +2487,32 @@ class CreateNewPlansState extends State { height: 35, width: double.infinity, child: DropdownSearch( - selectedItem: options - .firstWhere((opt) => opt['value'] == _selectedOption)['title'], + selectedItem: + options.firstWhere( + (opt) => opt['value'] == _selectedOption, + )['title'], enabled: !widget.isViewMode, items: options.map((opt) => opt['title']!).toList(), popupProps: PopupProps.menu( showSearchBox: false, - menuProps: const MenuProps( - backgroundColor: Colors.white, - ), + menuProps: const MenuProps(backgroundColor: Colors.white), constraints: BoxConstraints(maxHeight: 100), - itemBuilder: (context, item, isSelected) => Padding( - padding: - const EdgeInsets.symmetric(horizontal: 8.0, vertical: 6.0), - child: Text( - item, - style: GoogleFonts.poppins(fontSize: 13), - ), - ), + itemBuilder: + (context, item, isSelected) => Padding( + padding: const EdgeInsets.symmetric( + horizontal: 8.0, + vertical: 6.0, + ), + child: Text(item, style: GoogleFonts.poppins(fontSize: 13)), + ), ), dropdownDecoratorProps: DropDownDecoratorProps( dropdownSearchDecoration: InputDecoration( border: InputBorder.none, - contentPadding: - const EdgeInsets.symmetric(horizontal: 10, vertical: 5), + contentPadding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), ), ), dropdownBuilder: (context, selectedItem) { @@ -2350,8 +2526,9 @@ class CreateNewPlansState extends State { }, onChanged: (String? newTitle) { if (newTitle == null) return; - final selected = - options.firstWhere((opt) => opt["title"] == newTitle); + final selected = options.firstWhere( + (opt) => opt["title"] == newTitle, + ); setState(() { _selectedOption = selected["value"]!; if (_selectedOption == "Option 2" || @@ -2364,7 +2541,7 @@ class CreateNewPlansState extends State { }, ), ), - ) + ), ]; } @@ -2384,24 +2561,26 @@ class CreateNewPlansState extends State { color: Color(0xFFF5F5F5), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), layoutColor: widget.layoutColor, - width: option["value"] == "Option 2" - ? 185 - : 125, // Adjust width conditionally + width: + option["value"] == "Option 2" + ? 185 + : 125, // Adjust width conditionally borderRadius: BorderRadius.circular(10), isFocused: _selectedOption == option["value"], isDesktop: isDesktop, child: GestureDetector( - onTap: widget.isViewMode - ? null - : () { - setState(() { - _selectedOption = option["value"]!; - if (option["value"] == 'Option 2' || - option["value"] == 'Option 3') { - _showInputDialog(option["title"]!); - } - }); - }, + onTap: + widget.isViewMode + ? null + : () { + setState(() { + _selectedOption = option["value"]!; + if (option["value"] == 'Option 2' || + option["value"] == 'Option 3') { + _showInputDialog(option["title"]!); + } + }); + }, child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -2410,12 +2589,14 @@ class CreateNewPlansState extends State { option["title"]!, style: TextStyle( fontSize: 13, - color: _selectedOption == option["value"] - ? Colors.white - : Colors.black, - fontWeight: _selectedOption == option["value"] - ? FontWeight.w500 - : null, + color: + _selectedOption == option["value"] + ? Colors.white + : Colors.black, + fontWeight: + _selectedOption == option["value"] + ? FontWeight.w500 + : null, ), ), Container( @@ -2428,15 +2609,17 @@ class CreateNewPlansState extends State { // : Colors.transparent, borderRadius: BorderRadius.circular(4), // Rounded rectangle border: Border.all( - color: _selectedOption == option["value"] - ? Colors.white - : Colors.black, + color: + _selectedOption == option["value"] + ? Colors.white + : Colors.black, width: _selectedOption == option["value"] ? 2 : 1, ), ), - child: _selectedOption == option["value"] - ? Icon(Icons.rectangle, size: 8, color: Colors.white) - : null, // Add checkmark if selected + child: + _selectedOption == option["value"] + ? Icon(Icons.rectangle, size: 8, color: Colors.white) + : null, // Add checkmark if selected ), ], ), @@ -2450,16 +2633,18 @@ class CreateNewPlansState extends State { return [ if (showDomestic == true) GestureDetector( - onTap: widget.isViewMode - ? null - : () { - setState(() { - _selectedTripType = "1"; - fetchTrainFlightClass(1); + onTap: + widget.isViewMode + ? null + : () { + setState(() { + _selectedTripType = "1"; + fetchTrainFlightClass(1); - dynamicItineraryKey.currentState?.updateSelectedServices(); - }); - }, + dynamicItineraryKey.currentState + ?.updateSelectedServices(); + }); + }, child: CustomTextFieldWrapper( color: Color(0xFFF4F4FB), layoutColor: widget.layoutColor, @@ -2475,12 +2660,12 @@ class CreateNewPlansState extends State { Text( "Domestic", style: TextStyle( - color: _selectedTripType == "1" - ? Colors.white - : Colors.black, - fontWeight: - _selectedTripType == "1" ? FontWeight.w500 : null, - fontSize: 13), + color: + _selectedTripType == "1" ? Colors.white : Colors.black, + fontWeight: + _selectedTripType == "1" ? FontWeight.w500 : null, + fontSize: 13, + ), ), Container( width: 15, @@ -2493,15 +2678,17 @@ class CreateNewPlansState extends State { // : Colors.transparent, borderRadius: BorderRadius.circular(4), // Rounded rectangle border: Border.all( - color: _selectedTripType == "1" - ? Colors.white - : Colors.black, + color: + _selectedTripType == "1" + ? Colors.white + : Colors.black, width: _selectedTripType == "1" ? 2 : 1, ), ), - child: _selectedTripType == "1" - ? Icon(Icons.rectangle, size: 8, color: Colors.white) - : null, // Add checkmark if selected + child: + _selectedTripType == "1" + ? Icon(Icons.rectangle, size: 8, color: Colors.white) + : null, // Add checkmark if selected ), ], ), @@ -2510,15 +2697,17 @@ class CreateNewPlansState extends State { SizedBox(width: 20), if (showInternational) GestureDetector( - onTap: widget.isViewMode - ? null - : () { - setState(() { - _selectedTripType = "2"; - fetchTrainFlightClass(2); - dynamicItineraryKey.currentState?.updateSelectedServices(); - }); - }, + onTap: + widget.isViewMode + ? null + : () { + setState(() { + _selectedTripType = "2"; + fetchTrainFlightClass(2); + dynamicItineraryKey.currentState + ?.updateSelectedServices(); + }); + }, child: CustomTextFieldWrapper( color: Color(0xFFF4F4FB), layoutColor: widget.layoutColor, @@ -2552,15 +2741,17 @@ class CreateNewPlansState extends State { // : Colors.transparent, borderRadius: BorderRadius.circular(4), // Rounded rectangle border: Border.all( - color: _selectedTripType == "2" - ? Colors.white - : Colors.black, + color: + _selectedTripType == "2" + ? Colors.white + : Colors.black, width: _selectedTripType == "2" ? 2 : 1, ), ), - child: _selectedTripType == "2" - ? Icon(Icons.rectangle, size: 8, color: Colors.white) - : null, // Add checkmark if selected + child: + _selectedTripType == "2" + ? Icon(Icons.rectangle, size: 8, color: Colors.white) + : null, // Add checkmark if selected ), ], ), @@ -2586,48 +2777,49 @@ class CreateNewPlansState extends State { } Widget _buildNonDescriptionColumn() { - return Column(children: [ - Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Trip Name", // Your label + return Column( + children: [ + Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Trip Name", // Your label style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74)) - ), - SizedBox(height: 5), - CustomTextFieldWrapper( - isFocused: _isTripTitleFocused, - isDesktop: widget.isDesktop, - child: SizedBox( - height: 35, - child: TextField( - focusNode: _tripTitleFocusNode, - controller: _tripTitleController, - style: TextStyle(fontSize: 12), - enabled: !widget.isViewMode, - decoration: InputDecoration( - labelText: "Trip Name", - labelStyle: TextStyle(fontSize: 12, color: Colors.grey), - floatingLabelBehavior: FloatingLabelBehavior.never, - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric(vertical: 16), + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), + ), + SizedBox(height: 5), + CustomTextFieldWrapper( + isFocused: _isTripTitleFocused, + isDesktop: widget.isDesktop, + child: SizedBox( + height: 35, + child: TextField( + focusNode: _tripTitleFocusNode, + controller: _tripTitleController, + style: TextStyle(fontSize: 12), + enabled: !widget.isViewMode, + decoration: InputDecoration( + labelText: "Trip Name", + labelStyle: TextStyle(fontSize: 12, color: Colors.grey), + floatingLabelBehavior: FloatingLabelBehavior.never, + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric(vertical: 16), + ), ), ), ), - ), - ], - ), - ], - ), - SizedBox( - height: 8, - ), - ]); + ], + ), + ], + ), + SizedBox(height: 8), + ], + ); } Widget _buildDescriptionColumn(isDesktop) { @@ -2641,9 +2833,10 @@ class CreateNewPlansState extends State { Text( "Description", // Your label style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74)), + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), ), SizedBox(height: 5), @@ -2690,7 +2883,9 @@ class CreateNewPlansState extends State { decoration: InputDecoration( labelText: "Description", labelStyle: GoogleFonts.poppins( - fontSize: 12, color: Colors.grey), + fontSize: 12, + color: Colors.grey, + ), // labelStyle: TextStyle(fontSize: 12, color: Colors.grey), floatingLabelBehavior: FloatingLabelBehavior.never, border: InputBorder.none, @@ -2710,36 +2905,38 @@ class CreateNewPlansState extends State { List _buildSubmit1(isDesktop) { return [ ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.white, - foregroundColor: Colors.blueAccent, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8), - side: BorderSide(color: Colors.blueAccent, width: 2), - ), - padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), + style: ElevatedButton.styleFrom( + backgroundColor: Colors.white, + foregroundColor: Colors.blueAccent, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8), + side: BorderSide(color: Colors.blueAccent, width: 2), ), - onPressed: () { - widget.isApprover - ? context.go('/approvallist') - : context.go('/listPlan'); - }, - child: Text("Cancel")), - SizedBox( - width: 20, + padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), + ), + onPressed: () { + widget.isApprover + ? context.go('/approvallist') + : context.go('/listPlan'); + }, + child: Text("Cancel"), ), + SizedBox(width: 20), MouseRegion( - cursor: widget.isViewMode - ? SystemMouseCursors.forbidden - : SystemMouseCursors.click, + cursor: + widget.isViewMode + ? SystemMouseCursors.forbidden + : SystemMouseCursors.click, child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: widget.isViewMode - ? Colors.blueAccent - : Colors.blueAccent, // Keep original color - foregroundColor: widget.isViewMode - ? Colors.white - : Colors.white, // Keep original color + backgroundColor: + widget.isViewMode + ? Colors.blueAccent + : Colors.blueAccent, // Keep original color + foregroundColor: + widget.isViewMode + ? Colors.white + : Colors.white, // Keep original color disabledBackgroundColor: Colors.blueAccent, // Ensure color remains when disabled disabledForegroundColor: Colors.white, @@ -2749,12 +2946,13 @@ class CreateNewPlansState extends State { ), padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), ), - onPressed: widget.isViewMode - ? null - : handleSubmit, // Disable when in view mode + onPressed: + widget.isViewMode + ? null + : handleSubmit, // Disable when in view mode child: Text("Submit"), ), - ) + ), ]; } @@ -2775,17 +2973,15 @@ class CreateNewPlansState extends State { decoration: InputDecoration( labelText: "Trip Name *", labelStyle: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74)), + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), floatingLabelBehavior: FloatingLabelBehavior.never, border: InputBorder.none, contentPadding: EdgeInsets.symmetric(vertical: 16), errorText: validationErrors["trip_title"], // <--- add this line - errorStyle: TextStyle( - fontSize: 10, - color: Colors.red, - ), + errorStyle: GoogleFonts.poppins(fontSize: 12, color: Colors.red), ), ), ); @@ -2828,9 +3024,10 @@ class CreateNewPlansState extends State { } List _buildApproverControls(bool isDesktop) { - final statusText = isApproverApproved - ? "Approved" - : isApproverRejected + final statusText = + isApproverApproved + ? "Approved" + : isApproverRejected ? "Rejected" : (statusValue ?? ""); @@ -2882,7 +3079,9 @@ class CreateNewPlansState extends State { // }, onTap: () async { final result = await showApprovalDialog( - context, widget.layoutColor ?? Colors.grey); + context, + widget.layoutColor ?? Colors.grey, + ); if (result == 'approved') { // User approved @@ -3041,7 +3240,11 @@ class CreateNewPlansState extends State { children: [ Padding( padding: const EdgeInsets.only( - top: 6.0, bottom: 6.0, left: 15, right: 15), + top: 6.0, + bottom: 6.0, + left: 15, + right: 15, + ), child: Text( statusText, style: GoogleFonts.poppins( @@ -3051,8 +3254,8 @@ class CreateNewPlansState extends State { isApproverApproved ? "Approved" : isApproverRejected - ? "Rejected" - : (statusValue ?? ""), + ? "Rejected" + : (statusValue ?? ""), ), ), // style: TextStyle( @@ -3081,9 +3284,10 @@ class CreateNewPlansState extends State { borderRadius: BorderRadius.circular(8), child: SizedBox( child: Container( - width: isDesktop - ? MediaQuery.of(context).size.width * 0.25 - : MediaQuery.of(context).size.width, + width: + isDesktop + ? MediaQuery.of(context).size.width * 0.25 + : MediaQuery.of(context).size.width, padding: const EdgeInsets.all(12), decoration: BoxDecoration( color: Colors.white, @@ -3096,24 +3300,26 @@ class CreateNewPlansState extends State { children: [ if (!hasApprovals) Center( - child: Text( - "--- No Approvals ---", - style: TextStyle( - fontFamily: "Archivo", - fontSize: 11, - fontWeight: FontWeight.w500, - color: Colors.black87, + child: Text( + "--- No Approvals ---", + style: TextStyle( + fontFamily: "Archivo", + fontSize: 11, + fontWeight: FontWeight.w500, + color: Colors.black87, + ), ), - )), + ), for (int i = 0; i < planStatusList.length; i++) ...[ - if (planStatusList[i].entries.any((entry) => - entry.key.contains('status') && - entry.value != null && - entry.value.toString().isNotEmpty)) ...[ + if (planStatusList[i].entries.any( + (entry) => + entry.key.contains('status') && + entry.value != null && + entry.value.toString().isNotEmpty, + )) ...[ _buildApprovalItem( "Approver ${i + 1}", - planStatusList[i] - .entries + planStatusList[i].entries .firstWhere( (entry) => entry.key.contains('status'), orElse: () => MapEntry('', ''), @@ -3206,9 +3412,15 @@ class CreateNewPlansState extends State { borderRadius: BorderRadius.circular(8), side: BorderSide(color: Color(0xFF114D8B), width: 2), ), - padding: isDesktop - ? EdgeInsets.only(top: 6.0, bottom: 6.0, left: 15, right: 15) - : EdgeInsets.symmetric(horizontal: 15, vertical: 10), + padding: + isDesktop + ? EdgeInsets.only( + top: 6.0, + bottom: 6.0, + left: 15, + right: 15, + ) + : EdgeInsets.symmetric(horizontal: 15, vertical: 10), ), onPressed: () { getPdfDownload(); @@ -3228,11 +3440,7 @@ class CreateNewPlansState extends State { ), if (isDesktop) SizedBox(width: 8), // spacing between icon and text - Icon( - Icons.download_rounded, - size: 15, - color: Colors.white, - ), + Icon(Icons.download_rounded, size: 15, color: Colors.white), ], ), ), @@ -3267,25 +3475,26 @@ class CreateNewPlansState extends State { void _showInputDialog(String title) { showDialog( - context: context, - builder: (BuildContext context) { - return UserSelectionDialog( - title: title, - onSubmit: (input, userId, isTraveller) { - setState(() { - otherUserName = input; - selectedplanUserId = userId; - selectedIstravelUser = isTraveller; - }); - print("USer entered : $otherUserName $userId $isTraveller"); - getSelectedPlanFor(); - }, - onClose: () { - print("Choosede Clsoes"); - fetchUserDetails(); - }, - layoutColorForUser: widget.layoutColor!, - ); - }); + context: context, + builder: (BuildContext context) { + return UserSelectionDialog( + title: title, + onSubmit: (input, userId, isTraveller) { + setState(() { + otherUserName = input; + selectedplanUserId = userId; + selectedIstravelUser = isTraveller; + }); + print("USer entered : $otherUserName $userId $isTraveller"); + getSelectedPlanFor(); + }, + onClose: () { + print("Choosede Clsoes"); + fetchUserDetails(); + }, + layoutColorForUser: widget.layoutColor!, + ); + }, + ); } } diff --git a/lib/routes/custom_appBar.dart b/lib/routes/custom_appBar.dart index c8d85bf..8539d59 100644 --- a/lib/routes/custom_appBar.dart +++ b/lib/routes/custom_appBar.dart @@ -273,6 +273,7 @@ class _CustomAppBarState extends State { location.contains('/listTravelAgentPlan')) { selectedTab = TabSelection.myTrips; } else if (location.contains('/ApprovalList') || + location.contains('/approvallist') || location.contains('/approver/plans')) { selectedTab = TabSelection.myApprovals; } else {