From 5e4a09345653cf6c914957d463d211ac8059c9c6 Mon Sep 17 00:00:00 2001 From: venbaittech Date: Fri, 25 Apr 2025 13:04:25 +0530 Subject: [PATCH] plan iternary ui changes --- lib/Screens/approvals/approval_list.dart | 49 ++++++++++- lib/Screens/itnerary_list/flight_list.dart | 11 ++- .../itnerary_list/miscellaneous_list.dart | 2 +- lib/Screens/itnerary_list/visa_list.dart | 4 +- lib/Screens/organization/orgSetup.dart | 8 +- lib/Screens/plans/create_plans.dart | 82 ++++++++++++------- .../plans/dynamic_itinerary_stepper.dart | 23 +++--- lib/Screens/plans/list_plans.dart | 49 ++++++++++- lib/routes/custom_drawer.dart | 4 +- 9 files changed, 177 insertions(+), 55 deletions(-) diff --git a/lib/Screens/approvals/approval_list.dart b/lib/Screens/approvals/approval_list.dart index d6d6221..128765d 100644 --- a/lib/Screens/approvals/approval_list.dart +++ b/lib/Screens/approvals/approval_list.dart @@ -157,6 +157,42 @@ class _ApprovalListState extends State { } } + Future postPlanData(planData, planId) async { + final String apiUrldata = '$apiUrl/api/plans/createOrEditPlan'; + + final token = await getToken(); // Fetch token + + if (token == null) { + throw Exception('Token not found. Please log in.'); + } + + planData['is_active'] = "0"; + + print("POSTPlanTesting------- $planData"); // Add plan_id for update + + try { + final response = await http.post( + Uri.parse(apiUrldata), + headers: { + 'Authorization': 'Bearer $token', + 'Content-Type': 'application/json', + }, + body: jsonEncode(planData), // Convert map to JSON + ); + + if (response.statusCode == 200) { + print("Plan Deleted successfully!"); + print("Response: ${response.body}"); + initializeData(); + } else { + print("Failed to submit plan. Status: ${response.statusCode}"); + print("Error: ${response.body}"); + } + } catch (e) { + print(" Error submitting plan: $e"); + } + } + // Future> getViewPlan(String planId) async { // final String apiUrldata = '$apiUrl/api/plans/find/$planId'; // print("API URL: $apiUrldata"); @@ -200,6 +236,17 @@ class _ApprovalListState extends State { // } // } + void deletePlan(String planId) async { + try { + Map planData = await getViewPlan(planId); + print("ViewAAA - $planData"); + + postPlanData(planData, planId); + } catch (e) { + print("Error fetching plan: $e"); + } + } + Future> getViewPlan(String planId) async { final String apiUrldata = '$apiUrl/api/plans/find/$planId'; print("API URL: $apiUrldata"); @@ -583,7 +630,7 @@ class _ApprovalListState extends State { width: 5, ), GestureDetector( - onTap: () => (), + onTap: () => deletePlan(plan.planId), child: Image.asset( 'assets/images/IconsImg/delete.png', width: 20, diff --git a/lib/Screens/itnerary_list/flight_list.dart b/lib/Screens/itnerary_list/flight_list.dart index 7fac9c3..39638a6 100644 --- a/lib/Screens/itnerary_list/flight_list.dart +++ b/lib/Screens/itnerary_list/flight_list.dart @@ -148,11 +148,18 @@ class FlightListWidget extends StatelessWidget { borderRadius: BorderRadius.circular(12), // color: Colors.orange.shade50, color: Colors.white, + boxShadow: [ BoxShadow( color: Colors.black12, - blurRadius: 3, - offset: Offset(0, 1), + blurRadius: 2, + offset: Offset(0, 2), // down + ), + // Top shadow + BoxShadow( + color: Colors.black12, + blurRadius: 0.5, + offset: Offset(0, -1), // up ), ], border: Border( diff --git a/lib/Screens/itnerary_list/miscellaneous_list.dart b/lib/Screens/itnerary_list/miscellaneous_list.dart index 951f068..8382d39 100644 --- a/lib/Screens/itnerary_list/miscellaneous_list.dart +++ b/lib/Screens/itnerary_list/miscellaneous_list.dart @@ -33,7 +33,7 @@ class MiscellaneousListWidget extends StatelessWidget { children: [ Text( "Miscellaneous List", - style: TextStyle(fontSize: 14, fontWeight: FontWeight.bold), + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), MouseRegion( cursor: isViewMode diff --git a/lib/Screens/itnerary_list/visa_list.dart b/lib/Screens/itnerary_list/visa_list.dart index 0916118..a5087ac 100644 --- a/lib/Screens/itnerary_list/visa_list.dart +++ b/lib/Screens/itnerary_list/visa_list.dart @@ -36,8 +36,8 @@ class VisaListWidget extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - "Visa Booking List", - style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + "Visa List", + style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold), ), MouseRegion( cursor: isViewMode diff --git a/lib/Screens/organization/orgSetup.dart b/lib/Screens/organization/orgSetup.dart index ae7e142..5647c47 100644 --- a/lib/Screens/organization/orgSetup.dart +++ b/lib/Screens/organization/orgSetup.dart @@ -498,12 +498,12 @@ class _OrgSetUpState extends State { ), ) : selectedOrg?['logo'] != null - ? ClipOval( + ? ClipRect( child: Image.network( selectedOrg!['logo'], - width: 50, - height: 50, - fit: BoxFit.cover, + width: 100, + height: 30, + fit: BoxFit.contain, errorBuilder: (context, error, stackTrace) { return const CircleAvatar( diff --git a/lib/Screens/plans/create_plans.dart b/lib/Screens/plans/create_plans.dart index b320e20..10ed5ec 100644 --- a/lib/Screens/plans/create_plans.dart +++ b/lib/Screens/plans/create_plans.dart @@ -924,6 +924,15 @@ class CreateNewPlansState extends State { } Widget build(BuildContext context) { + bool hasApprovals = planStatusList.any( + (item) => item.entries.any( + (entry) => + entry.key.contains('status') && + entry.value != null && + entry.value.toString().isNotEmpty, + ), + ); + return ResponsiveBuilder(builder: (context, sizingInfo) { bool isMobile = sizingInfo.isMobile; bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; @@ -983,6 +992,17 @@ class CreateNewPlansState extends State { 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') && @@ -1563,35 +1583,35 @@ class CreateNewPlansState extends State { borderRadius: BorderRadius.circular(25), isFocused: _selectedOption == option["value"], isDesktop: isDesktop, - child: Row( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - option["title"]!, - style: TextStyle( - fontSize: 13, - color: _selectedOption == option["value"] - ? Colors.white - : Colors.black, - fontWeight: _selectedOption == option["value"] - ? FontWeight.w500 - : null, + child: GestureDetector( + 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, + children: [ + Text( + option["title"]!, + style: TextStyle( + fontSize: 13, + color: _selectedOption == option["value"] + ? Colors.white + : Colors.black, + fontWeight: _selectedOption == option["value"] + ? FontWeight.w500 + : null, + ), ), - ), - GestureDetector( - onTap: widget.isViewMode - ? null - : () { - setState(() { - _selectedOption = option["value"]!; - if (option["value"] == 'Option 2' || - option["value"] == 'Option 3') { - _showInputDialog(option["title"]!); - } - }); - }, - child: Container( + Container( width: 15, height: 15, decoration: BoxDecoration( @@ -1611,8 +1631,8 @@ class CreateNewPlansState extends State { ? Icon(Icons.rectangle, size: 8, color: Colors.white) : null, // Add checkmark if selected ), - ) - ], + ], + ), ), ), ); @@ -2238,7 +2258,7 @@ class CreateNewPlansState extends State { }); }, child: Icon( - Icons.approval, + Icons.approval_outlined, size: 18, color: isStatusExpanded ? Colors.green : Colors.grey, ), diff --git a/lib/Screens/plans/dynamic_itinerary_stepper.dart b/lib/Screens/plans/dynamic_itinerary_stepper.dart index 767801f..f34b2b6 100644 --- a/lib/Screens/plans/dynamic_itinerary_stepper.dart +++ b/lib/Screens/plans/dynamic_itinerary_stepper.dart @@ -812,16 +812,17 @@ class _DynamicItineraryState extends State { SizedBox(width: 2), // if (selectedListOption == title && widget.isViewMode == false) if (hasData) - Container( - height: 10, - width: 10, - // decoration: BoxDecoration( - // shape: BoxShape.circle, - // border: Border.all(color: Colors.green, width: 1.5), - // ), - child: Icon(Icons.circle, size: 8, color: Colors.green - // color: Colors.grey, - )), + Icon(Icons.circle, size: 8, color: Colors.green + // color: Colors.grey, + ) + // Container( + // height: 10, + // width: 10, + // // decoration: BoxDecoration( + // // shape: BoxShape.circle, + // // border: Border.all(color: Colors.green, width: 1.5), + // // ), + // child:), ]), ); } @@ -833,7 +834,7 @@ class _DynamicItineraryState extends State { case 'train': return Icons.train_outlined; case 'bus': - return Icons.directions_bus_filled_outlined; + return Icons.directions_bus_rounded; case 'taxi': return Icons.local_taxi_outlined; case 'accomodation': diff --git a/lib/Screens/plans/list_plans.dart b/lib/Screens/plans/list_plans.dart index a9784d3..d5411ca 100644 --- a/lib/Screens/plans/list_plans.dart +++ b/lib/Screens/plans/list_plans.dart @@ -139,6 +139,42 @@ class _ListPlansState extends State { } } + Future postPlanData(planData, planId) async { + final String apiUrldata = '$apiUrl/api/plans/createOrEditPlan'; + + final token = await getToken(); // Fetch token + + if (token == null) { + throw Exception('Token not found. Please log in.'); + } + + planData['is_active'] = "0"; + + print("POSTPlanTesting------- $planData"); // Add plan_id for update + + try { + final response = await http.post( + Uri.parse(apiUrldata), + headers: { + 'Authorization': 'Bearer $token', + 'Content-Type': 'application/json', + }, + body: jsonEncode(planData), // Convert map to JSON + ); + + if (response.statusCode == 200) { + print("Plan Deleted successfully!"); + print("Response: ${response.body}"); + initializeData(); + } else { + print("Failed to submit plan. Status: ${response.statusCode}"); + print("Error: ${response.body}"); + } + } catch (e) { + print(" Error submitting plan: $e"); + } + } + Future> getViewPlan(String planId) async { final String apiUrldata = '$apiUrl/api/plans/find/$planId'; print("API URL: $apiUrldata"); @@ -177,6 +213,17 @@ class _ListPlansState extends State { } } + void deletePlan(String planId) async { + try { + Map planData = await getViewPlan(planId); + print("ViewAAA - $planData"); + + postPlanData(planData, planId); + } catch (e) { + print("Error fetching plan: $e"); + } + } + Widget build(BuildContext context) { return ResponsiveBuilder(builder: (context, sizingInfo) { bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop; @@ -582,7 +629,7 @@ class _ListPlansState extends State { width: 5, ), GestureDetector( - onTap: () => (), + onTap: () => deletePlan(plan.planId), child: Image.asset( 'assets/images/IconsImg/delete.png', width: 20, diff --git a/lib/routes/custom_drawer.dart b/lib/routes/custom_drawer.dart index ec593ae..e37ae47 100644 --- a/lib/routes/custom_drawer.dart +++ b/lib/routes/custom_drawer.dart @@ -142,9 +142,9 @@ class _CustomDrawerState extends State { ? ClipRect( child: Image.network( selectedOrg!['logo'], - width: 150, + width: 100, height: 50, - fit: BoxFit.fitWidth, + fit: BoxFit.contain, errorBuilder: (context, error, stackTrace) { return const CircleAvatar( radius: 20,