From cf23f4f936c07a21cbdaf80af5a7e6c41e811ddf Mon Sep 17 00:00:00 2001 From: venbaittech Date: Tue, 22 Jul 2025 14:46:43 +0530 Subject: [PATCH] BUG_FIX --- lib/Screens/allTrips/list_all_plans.dart | 25 +- .../itnerary_list/miscellaneous_list.dart | 111 +- lib/Screens/organization/themeColor.dart | 49 +- lib/Screens/plans/create_plans.dart | 17 +- .../plans/dynamic_itinerary_stepper.dart | 241 ++- lib/Screens/policy/policy.dart | 747 ++++---- lib/Screens/policy/policyCriteria.dart | 1655 +++++++++-------- lib/app.dart | 257 +-- lib/config/apiUrl.dart | 3 +- pubspec.lock | 8 + pubspec.yaml | 1 + web/index.html | 2 +- 12 files changed, 1580 insertions(+), 1536 deletions(-) diff --git a/lib/Screens/allTrips/list_all_plans.dart b/lib/Screens/allTrips/list_all_plans.dart index 3c8378b..7e25490 100644 --- a/lib/Screens/allTrips/list_all_plans.dart +++ b/lib/Screens/allTrips/list_all_plans.dart @@ -811,11 +811,13 @@ class _ListAllPlansState extends State { ), columns: [ DataColumn( - label: Text( - 'S.NO', - style: GoogleFonts.poppins( - fontSize: 13, - fontWeight: FontWeight.w600, + label: Expanded( + child: Text( + 'S.NO', + style: GoogleFonts.poppins( + fontSize: 13, + fontWeight: FontWeight.w600, + ), ), ), ), @@ -928,8 +930,11 @@ class _ListAllPlansState extends State { fontSize: 13, fontFamily: "Inter", ), - softWrap: true, - overflow: TextOverflow.ellipsis, + softWrap: true, // Allows wrapping + overflow: + TextOverflow + .visible, // Ensures full display + maxLines: null, ), ), DataCell( @@ -1251,6 +1256,12 @@ class _ListAllPlansState extends State { fontWeight: FontWeight.w500, ), + softWrap: + true, // Allows wrapping + overflow: + TextOverflow + .visible, // Ensures full display + maxLines: null, ), ], ), diff --git a/lib/Screens/itnerary_list/miscellaneous_list.dart b/lib/Screens/itnerary_list/miscellaneous_list.dart index e9a2279..8de06f9 100644 --- a/lib/Screens/itnerary_list/miscellaneous_list.dart +++ b/lib/Screens/itnerary_list/miscellaneous_list.dart @@ -26,13 +26,15 @@ class MiscellaneousListWidget extends StatelessWidget { return Padding( padding: const EdgeInsets.all(16.0), child: Container( - margin: const EdgeInsets.only(top: 16.0), + // color: Color(0xFFE8F0FC), + margin: const EdgeInsets.only(top: 28.0), + padding: const EdgeInsets.all(10.0), child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ // Header with title and button Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.end, children: [ MouseRegion( cursor: @@ -56,10 +58,23 @@ class MiscellaneousListWidget extends StatelessWidget { // style: TextStyle(fontSize: 13), // ), // SizedBox(width: 8), // spacing between icon and text - Icon( - Icons.add_circle_sharp, - size: 30, - color: Color(0xFF114D8B), + Container( + decoration: BoxDecoration( + shape: BoxShape.circle, + border: Border.all( + color: Color(0xFF114D8B), // Outline color + width: 2, // Outline thickness + ), + ), + height: 30, + width: 30, + child: Center( + child: Icon( + Icons.add, + size: 20, + color: Colors.black, + ), + ), ), ], ), @@ -159,7 +174,8 @@ class MiscellaneousListWidget extends StatelessWidget { getRequestValue(item["special_request"]?.toString()), style: GoogleFonts.poppins( fontSize: 14, - fontWeight: FontWeight.w800, + color: Color(0xFF114D8B), + fontWeight: FontWeight.w500, ), ), Spacer(), @@ -189,54 +205,67 @@ class MiscellaneousListWidget extends StatelessWidget { ), ], ), - Divider(color: Colors.blueGrey.shade50), - SizedBox(height: 4), + // Divider(color: Colors.blueGrey.shade50), + SizedBox(height: 10), isDesktop ? Row( children: [ - Expanded( - flex: 2, - child: Text( - "Special Request", - style: GoogleFonts.poppins(fontSize: 11), - ), - ), + // Expanded( + // flex: 2, + // child: Text( + // "Special Request", + // style: GoogleFonts.poppins(fontSize: 11), + // ), + // ), Expanded( flex: 3, child: Text( - " Comments", - style: GoogleFonts.poppins(fontSize: 11), + "Comments", + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + fontWeight: FontWeight.w600, + ), ), ), ], ) : SizedBox.shrink(), + SizedBox(height: 4), isDesktop - ? Row( - children: [ - Expanded( - flex: 2, - child: Text( - getRequestValue( - item["special_request"]?.toString(), + ? Container( + // color: Color(0xFFE8F0FC), + color: Colors.white, + child: Expanded( + child: Row( + children: [ + // Expanded( + // flex: 2, + // child: Text( + // getRequestValue( + // item["special_request"]?.toString(), + // ), + // style: GoogleFonts.poppins( + // fontSize: 12, + // fontWeight: FontWeight.w600, + // ), + // ), + // ), + Container( + // width: MediaQuery.of(context).size.width * 0.6, + // padding: EdgeInsets.all(16), + // color: Color(0xFFE8F0FC), + child: Expanded( + // flex: 1, + child: Text( + item["comments"], + style: GoogleFonts.poppins(fontSize: 11), + ), + ), ), - 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: [ diff --git a/lib/Screens/organization/themeColor.dart b/lib/Screens/organization/themeColor.dart index f2090a3..524ce0f 100644 --- a/lib/Screens/organization/themeColor.dart +++ b/lib/Screens/organization/themeColor.dart @@ -32,12 +32,10 @@ class _ColorThemePickerWidgetState extends State { Color(0xFF027E87), // Blue Shade Color(0xFF12B24B), // Green Color(0xFFe30f01), // Emerald Green - // Color(0xFFef3030), // Emerald Green Color(0xFFf26157), // Emerald Green - // Color(0xFF2ECC71), // Emerald Green Color(0xFFFF9800), // Orange - Color(0xFFE67E22), // Orange 2 - Color(0xFFBF4C0D), // Orange dark orange 3 + Color(0xFF3F51B5), // Orange 2 + Color(0xFF00695C), // Orange dark orange 3 Color(0xFFD9067A), // rose Color(0xFFc94b92), // rose light Color(0xFF9C27B0), // Purple @@ -45,31 +43,32 @@ class _ColorThemePickerWidgetState extends State { ]; final List layoutSecondaryColors = [ - Color(0xFF00B0FF), // Lighter Blue - Color(0xFF00ACC1), // Teal Blue - Color(0xFF43A047), // Dark Green - Color(0xFF27AE60), // Medium Emerald - Color(0xFFFFC107), // Amber (complementary to orange) - Color(0xFFFFA726), // Light orange - Color(0xFFE64A19), // Deep Orange - Color(0xFFFF4081), // Bright Pink (complementary to rose) + Color(0xFF82B1FF), // Lighter BlueAccent + Color(0xFF4DD0E1), // Lighter Teal + Color(0xFF43A047), // Light Green + Color(0xFFEF5350), // Lighter Red + Color(0xFFFF8A65), // Coral Peach + Color(0xFFFFB74D), // Amber Orange + Color(0xFF7986CB), // Indigo Soft + Color(0xFF4DB6AC), // Soft Teal + Color(0xFFF06292), // Light Rose Color(0xFFF48FB1), // Light Pink - Color(0xFFBA68C8), // Light Purple - Color(0xFFAB47BC), // Orchid Purple + Color(0xFFBA68C8), // Soft Purple + Color(0xFFDDA0DD), // Plum ]; final List layoutTertiaryColors = [ - Color(0xFF82B1FF), // Very Light Blue - Color(0xFF4DD0E1), // Lighter Teal - Color(0xFF81C784), // Light Green - Color(0xFFAAF0D1), // Pastel Mint - Color(0xFFFFE0B2), // Pale Orange - Color(0xFFFFCCBC), // Light Orange Peach - Color(0xFFFFAB91), // Light Coral - Color(0xFFF8BBD0), // Pastel Rose - Color(0xFFF8BBD0), // Pastel Pink - Color(0xFFE1BEE7), // Lavender - Color(0xFFD1C4E9), // Light Purple Grey + Color(0xFFE3F2FD), // Very Light Blue + Color(0xFFE0F7FA), // Very Light Teal + Color(0xFFC8E6C9), // Mint Green + Color(0xFFFFCDD2), // Light Coral/Red + Color(0xFFFFE0B2), // Peach + Color(0xFFFFF3E0), // Lightest Orange + Color(0xFFFFEBEE), // Very Light Rose + Color(0xFFFCE4EC), // Pastel Pink + Color(0xFFF3E5F5), // Light Lavender + Color(0xFFEDE7F6), // Soft Purple Grey + Color(0xFFF8F9FA), // Near-white Neutral ]; // Body colors diff --git a/lib/Screens/plans/create_plans.dart b/lib/Screens/plans/create_plans.dart index c58e3fe..360f918 100644 --- a/lib/Screens/plans/create_plans.dart +++ b/lib/Screens/plans/create_plans.dart @@ -659,6 +659,8 @@ class CreateNewPlansState extends State { } else if (userId.isNotEmpty && userId != "0") { print("TestplanUsrId : $userId"); print("TestplanUsrIdSelf : $selfId"); + planUsrId = userId; + print("TestplanUsrId2 : $planUsrId"); _selectedOption = (selfId != userId) ? "Option 2" : "Option 1"; otherUserName = userName; } @@ -3766,7 +3768,9 @@ class CreateNewPlansState extends State { reverse: false, // show right-end on overflow physics: BouncingScrollPhysics(), child: ConstrainedBox( - constraints: BoxConstraints(minWidth: isDesktop ? MediaQuery.of(context).size.width * 0.5 : 180), + constraints: BoxConstraints( + minWidth: isDesktop ? MediaQuery.of(context).size.width * 0.5 : 180, + ), child: IntrinsicWidth( child: TextField( controller: _tripTitleController, @@ -3786,9 +3790,15 @@ class CreateNewPlansState extends State { ), floatingLabelBehavior: FloatingLabelBehavior.never, border: InputBorder.none, - contentPadding: EdgeInsets.symmetric(horizontal: 1, vertical: 16), + contentPadding: EdgeInsets.symmetric( + horizontal: 1, + vertical: 16, + ), errorText: validationErrors["trip_title"], - errorStyle: GoogleFonts.poppins(fontSize: 12, color: Colors.red), + errorStyle: GoogleFonts.poppins( + fontSize: 12, + color: Colors.red, + ), ), keyboardType: TextInputType.text, scrollPhysics: BouncingScrollPhysics(), @@ -3799,7 +3809,6 @@ class CreateNewPlansState extends State { ); } - Widget _buildApprovalItem(String title, String name) { return Row( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/Screens/plans/dynamic_itinerary_stepper.dart b/lib/Screens/plans/dynamic_itinerary_stepper.dart index af38ab1..13c5159 100644 --- a/lib/Screens/plans/dynamic_itinerary_stepper.dart +++ b/lib/Screens/plans/dynamic_itinerary_stepper.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:dotted_border/dotted_border.dart'; import 'package:easy_stepper/easy_stepper.dart'; import 'package:flutter/material.dart'; import 'package:frontend/Screens/itnerary_list/accomodation_list.dart'; @@ -7,6 +8,7 @@ import 'package:frontend/Screens/itnerary_list/bus_list.dart'; import 'package:frontend/Screens/itnerary_list/flight_list.dart'; import 'package:frontend/Screens/itnerary_list/taxi_list.dart'; import 'package:frontend/Screens/itnerary_list/train_list.dart'; +import 'package:frontend/utils/auth_utils.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:responsive_builder/responsive_builder.dart'; @@ -64,6 +66,14 @@ class DynamicItinerary extends StatefulWidget { class DynamicItineraryState extends State { final ApiService apiService = ApiService(); + late ScrollController _scrollController; + bool _canScrollLeft = false; + bool _canScrollRight = true; + + Color? layoutColor; + Color? secondColor; + Color? thridColor; + String? _tripType; String selectedOption = ""; String selectedListOption = ""; @@ -98,6 +108,13 @@ class DynamicItineraryState extends State { handleSelectedPlan(); updateSelectedServices(); _tripType = widget.tripType; + loadInitialData(); + _scrollController = ScrollController(); + _scrollController.addListener(_updateScrollButtonState); + // Delay check after layout is built + WidgetsBinding.instance.addPostFrameCallback((_) { + _updateScrollButtonState(); // Initial scroll check + }); } @override @@ -116,6 +133,54 @@ class DynamicItineraryState extends State { } } + @override + void dispose() { + _scrollController.removeListener(_updateScrollButtonState); + _scrollController.dispose(); + super.dispose(); + } + + void _updateScrollButtonState() { + if (!_scrollController.hasClients) return; + + final max = _scrollController.position.maxScrollExtent; + final offset = _scrollController.offset; + + setState(() { + _canScrollLeft = offset > 0; + _canScrollRight = offset < max; + }); + } + + void loadInitialData() async { + String? layoutString = await getLayoutColor(); + String? secondString = await getSecondaryColor(); + String? thridString = await getTernaryColor(); + + // String? bodyStringColor = await getBodyColor(); + + setState(() { + layoutColor = + layoutString != null + ? Color(int.parse(layoutString)) + : Colors.redAccent; + + secondColor = + layoutString != null + ? Color(int.parse(secondString!)) + : Colors.orange; + + thridColor = + layoutString != null + ? Color(int.parse(thridString!)) + : Colors.orangeAccent; + // bodyColor = + // bodyStringColor != null + // ? Color(int.parse(bodyStringColor)) + // : Colors.white; + }); + } + void updateTripType(String? newTripType) { if (_tripType != newTripType) { setState(() { @@ -823,10 +888,11 @@ class DynamicItineraryState extends State { left: MediaQuery.of(context).size.width * 0.05, right: MediaQuery.of(context).size.width * 0.05, child: Container( - padding: EdgeInsets.symmetric(vertical: 10, horizontal: 12), + padding: EdgeInsets.symmetric(vertical: 2, horizontal: 2), decoration: BoxDecoration( color: Colors.white, // Card background - borderRadius: BorderRadius.circular(8), + // color: thridColor, // Card background + borderRadius: BorderRadius.circular(40), // color: Color(0xFFE6E7F5) // border: Border.all(color: Colors.black12, width: 1.3), @@ -840,16 +906,54 @@ class DynamicItineraryState extends State { ), ], ), - child: + child: Row( + children: [ isMobile - ? SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row(children: _buildOptions()), + ? IconButton( + icon: Icon( + Icons.arrow_back_ios, + color: Colors.black54, + // color: _canScrollLeft ? Colors.black : Colors.grey, + ), + onPressed: + _canScrollLeft + ? () { + _scrollBy(-100); + } + : null, ) - : Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: _buildOptions(), - ), + : SizedBox.shrink(), + Expanded( + child: + isMobile + ? SingleChildScrollView( + controller: _scrollController, + scrollDirection: Axis.horizontal, + child: Row(children: _buildOptions()), + ) + : Row( + mainAxisAlignment: + MainAxisAlignment.spaceEvenly, + children: _buildOptions(), + ), + ), + isMobile + ? IconButton( + icon: Icon( + Icons.arrow_forward_ios, + color: Colors.black54, + // color: _canScrollRight ? Colors.black : Colors.grey, + ), + onPressed: + _canScrollRight + ? () { + _scrollBy(100); + } + : null, + ) + : SizedBox.shrink(), + ], + ), ), ), ], @@ -858,6 +962,21 @@ class DynamicItineraryState extends State { ); } + void _scrollBy(double offset) { + if (!_scrollController.hasClients) return; + + final targetOffset = (_scrollController.offset + offset).clamp( + _scrollController.position.minScrollExtent, + _scrollController.position.maxScrollExtent, + ); + + _scrollController.animateTo( + targetOffset, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + } + bool hasValidItineraryEntries() { if (ServicesChoosed == null || ServicesChoosed!.isEmpty) return false; @@ -986,39 +1105,66 @@ class DynamicItineraryState extends State { }, child: Container( decoration: BoxDecoration( - border: Border( - bottom: BorderSide( - color: isOptionSelected ? Color(0xFF114D8B) : Colors.transparent, - width: 2, - ), - ), + // border: Border( + // bottom: BorderSide( + // color: isOptionSelected ? Color(0xFF114D8B) : Colors.transparent, + // width: 2, + // ), + // ), ), - padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 10), + padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 3), child: Column( children: [ - iconUrl.isNotEmpty - ? Image.network( - iconUrl, - width: 18, - height: 18, - errorBuilder: (context, error, stackTrace) { - return Icon( - fallbackIcon, - size: 25, - color: - isOptionSelected - ? Color(0xFF114D8B) - : Color(0xFF475569), - ); - }, - ) - : Icon( - fallbackIcon, - size: 25, - color: - isOptionSelected ? Color(0xFF114D8B) : Color(0xFF475569), + DottedBorder( + options: RoundedRectDottedBorderOptions( + dashPattern: [1, 3], + strokeWidth: 1.5, + radius: Radius.circular(46), + color: isOptionSelected ? secondColor! : Colors.transparent, + padding: EdgeInsets.all(3.5), + ), + child: Container( + decoration: BoxDecoration( + color: isOptionSelected ? secondColor : Colors.white, + + borderRadius: BorderRadius.circular(20.0), ), - SizedBox(height: 2), + + padding: const EdgeInsets.all(3.0), + child: + iconUrl.isNotEmpty + ? Image.network( + iconUrl, + width: 15, + height: 15, + errorBuilder: (context, error, stackTrace) { + return Icon( + fallbackIcon, + size: 20, + color: + isOptionSelected + ? Colors.white + : Colors.black87, + // color: + // isOptionSelected + // ? Color(0xFF114D8B) + // : Color(0xFF475569), + ); + }, + ) + : Icon( + fallbackIcon, + size: 20, + color: + isOptionSelected ? Colors.white : Colors.black87, + // color: + // isOptionSelected + // ? Color(0xFF114D8B) + // : Color(0xFF475569), + ), + ), + ), + SizedBox(height: 1), Row( children: [ Text( @@ -1027,15 +1173,16 @@ class DynamicItineraryState extends State { // style: GoogleFonts.poppins( fontSize: 12, // fontWeight: FontWeight.w600, // color: Color(0xFF575A74)) - style: TextStyle( - fontSize: 14, - color: - isOptionSelected - ? Color(0xFF114D8B) - : Color(0xFF475569), - fontFamily: "Inter", + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + // color: + // isOptionSelected + // ? Color(0xFF114D8B) + // : Color(0xFF475569), + // fontFamily: "Inter", fontWeight: - isOptionSelected ? FontWeight.bold : FontWeight.w500, + isOptionSelected ? FontWeight.w700 : FontWeight.w400, ), ), SizedBox(width: 4), diff --git a/lib/Screens/policy/policy.dart b/lib/Screens/policy/policy.dart index 61a990f..b8df39d 100644 --- a/lib/Screens/policy/policy.dart +++ b/lib/Screens/policy/policy.dart @@ -40,7 +40,7 @@ class Policy extends StatefulWidget { class _PolicyState extends State { final GlobalKey policyCriteriaKey = - GlobalKey(); + GlobalKey(); final ApiService apiService = ApiService(); @@ -84,23 +84,22 @@ class _PolicyState extends State { Map get policyData { List> policyDetails = - policy_details!.where((service) { - // Only check these specific fields for emptiness - final fieldsToCheck = [ - 'cost', - 'class', - 'a1_action', - 'a2_action', - 'a3_action', - ]; - - // If any of the important fields has a value, keep it - return fieldsToCheck.any((field) { - final value = service[field]; - return value != null && value.toString().trim().isNotEmpty; - }); - }).toList(); + policy_details!.where((service) { + // Only check these specific fields for emptiness + final fieldsToCheck = [ + 'cost', + 'class', + 'a1_action', + 'a2_action', + 'a3_action', + ]; + // If any of the important fields has a value, keep it + return fieldsToCheck.any((field) { + final value = service[field]; + return value != null && value.toString().trim().isNotEmpty; + }); + }).toList(); Map data = { "name": _policyController.text, @@ -153,6 +152,7 @@ class _PolicyState extends State { // } // }); } + void _addFocusListener(FocusNode node, Function(bool) updateState) { node.addListener(() { setState(() { @@ -160,6 +160,7 @@ class _PolicyState extends State { }); }); } + void _checkAuthAndLoadData() async { final String? token = await getToken(); // Your async function to get token @@ -198,14 +199,14 @@ class _PolicyState extends State { setState(() { layoutColor = - layoutString != null - ? Color(int.parse(layoutString)) - : Colors.redAccent; + layoutString != null + ? Color(int.parse(layoutString)) + : Colors.redAccent; bodyColor = - bodyStringColor != null - ? Color(int.parse(bodyStringColor)) - : Colors.white; + bodyStringColor != null + ? Color(int.parse(bodyStringColor)) + : Colors.white; }); } @@ -237,9 +238,9 @@ class _PolicyState extends State { try { List decoded = json.decode(rawServices); List> formatted = - decoded - .map((e) => {"service_id": e['service_id'].toString()}) - .toList(); + decoded + .map((e) => {"service_id": e['service_id'].toString()}) + .toList(); setState(() { selectedOrgServiceIds = formatted; @@ -264,7 +265,7 @@ class _PolicyState extends State { await loadOrgSelectedAlServices(); final selectedIds = - selectedOrgServiceIds.map((e) => e['service_id']).toSet(); + selectedOrgServiceIds.map((e) => e['service_id']).toSet(); if (widget.policy != null) { final details = List>.from( @@ -277,12 +278,12 @@ class _PolicyState extends State { // pr int("UUFiltered Selected Services - $details"); final filtered = - selectedAllServices! - .where( - (service) => - selectedIds.contains(service['service_id'].toString()), - ) - .toList(); + selectedAllServices! + .where( + (service) => + selectedIds.contains(service['service_id'].toString()), + ) + .toList(); setState(() { ServicesChoosed = filtered; @@ -307,11 +308,11 @@ class _PolicyState extends State { List>.from(decoded) .map( (service) => { - 'service_id': service['service_id'].toString(), - 'name': service['name'].toString(), - 'order': service['order'].toString(), - }, - ) + 'service_id': service['service_id'].toString(), + 'name': service['name'].toString(), + 'order': service['order'].toString(), + }, + ) .toList(); }); @@ -321,12 +322,12 @@ class _PolicyState extends State { print("Filtered Selected Services Added to Policy: $ServicesChoosed"); } else { final filtered = - selectedAllServices! - .where( - (service) => - selectedIds.contains(service['service_id'].toString()), - ) - .toList(); + selectedAllServices! + .where( + (service) => + selectedIds.contains(service['service_id'].toString()), + ) + .toList(); print("ServicesChoosedYY: $ServicesChoosed"); setState(() { @@ -341,12 +342,12 @@ class _PolicyState extends State { ServicesChoosed! .map( (service) => { - 'service_id': service['service_id'].toString(), - 'name': - service['name'].toString(), // ✅ no space before 'name' - 'order': service['order'].toString(), - }, - ) + 'service_id': service['service_id'].toString(), + 'name': + service['name'].toString(), // ✅ no space before 'name' + 'order': service['order'].toString(), + }, + ) .toList(); }); @@ -461,7 +462,6 @@ class _PolicyState extends State { }); } - bool isValidData(Map data) { errorMessages.clear(); // Reset previous errors @@ -480,7 +480,7 @@ class _PolicyState extends State { if (domestic != "1" && international != "1") { errorMessages["trip_type"] = - "Required"; // "Please select Domestic or International."; + "Required"; // "Please select Domestic or International."; } // Validate at least one policy_detail with valid content @@ -502,7 +502,7 @@ class _PolicyState extends State { if (!hasAtLeastOneDetail) { errorMessages["policy_details"] = - "Required"; // "At least one valid policy detail is required."; + "Required"; // "At least one valid policy detail is required."; } return errorMessages.isEmpty; @@ -571,16 +571,16 @@ class _PolicyState extends State { 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(8), + 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(8), child: Column( children: [ Expanded( @@ -666,15 +666,15 @@ class _PolicyState extends State { color: Colors.white, padding: const EdgeInsets.all(8.0), child: - isDesktop - ? Row( - mainAxisAlignment: MainAxisAlignment.end, - children: _buildSubmit(isDesktop), - ) - : Row( - mainAxisAlignment: MainAxisAlignment.center, - children: _buildSubmit(isDesktop), - ), + isDesktop + ? Row( + mainAxisAlignment: MainAxisAlignment.end, + children: _buildSubmit(isDesktop), + ) + : Row( + mainAxisAlignment: MainAxisAlignment.center, + children: _buildSubmit(isDesktop), + ), ), ], ), @@ -687,9 +687,9 @@ class _PolicyState extends State { // ? EdgeInsets.all(10.0) // : EdgeInsets.only(left: 20.0, bottom: 20.0, top: 10.0, right: 20.0), height: - isDesktop - ? MediaQuery.of(context).size.height * 0.98 - : MediaQuery.of(context).size.height, + isDesktop + ? MediaQuery.of(context).size.height * 0.98 + : MediaQuery.of(context).size.height, // decoration: BoxDecoration( // border: isDesktop // ? Border.all( @@ -738,23 +738,23 @@ class _PolicyState extends State { Container( padding: isDesktop ? const EdgeInsets.only(left: 35) : null, child: - isDesktop - ? Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded(child: _buildPolicyNameField(isDesktop)), - Spacer(), - Expanded(child: _buildPolicyTypeField(isDesktop)), - ], - ) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _buildPolicyNameField(isDesktop), - SizedBox(height: 20), - _buildPolicyTypeField(isDesktop), - ], - ), + isDesktop + ? Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: _buildPolicyNameField(isDesktop)), + Spacer(), + Expanded(child: _buildPolicyTypeField(isDesktop)), + ], + ) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _buildPolicyNameField(isDesktop), + SizedBox(height: 20), + _buildPolicyTypeField(isDesktop), + ], + ), ), SizedBox(height: 10), Divider(thickness: 0.1, color: Colors.grey), @@ -767,66 +767,66 @@ class _PolicyState extends State { ], isDesktop ? Padding( - padding: const EdgeInsets.only(left: 30.0, right: 98.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Approval Criteria", - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74), - ), + padding: const EdgeInsets.only(left: 30.0, right: 98.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Approval Criteria", + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), + ), + Text( + "Service Priority", + style: GoogleFonts.poppins( + fontSize: 12, + fontWeight: FontWeight.w600, + color: Color(0xFF575A74), + ), + ), + ], ), - Text( - "Service Priority", - style: GoogleFonts.poppins( - fontSize: 12, - fontWeight: FontWeight.w600, - color: Color(0xFF575A74), - ), - ), - ], - ), - ) + ) : SizedBox.shrink(), isDesktop ? Container( - // color: Colors.yellow.shade50, - height: MediaQuery.of(context).size.height * 0.54, - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( + // color: Colors.yellow.shade50, + height: MediaQuery.of(context).size.height * 0.54, + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - _buildPolicyOrdering(isDesktop), - _buildPolicyCategory(isDesktop), + Column( + children: [ + _buildPolicyOrdering(isDesktop), + _buildPolicyCategory(isDesktop), + ], + ), + Column(children: [_buildPolicyCategoryList(isDesktop)]), ], ), - Column(children: [_buildPolicyCategoryList(isDesktop)]), - ], - ), - ), - ) + ), + ) : Expanded( - child: Container( - child: SingleChildScrollView( - scrollDirection: Axis.vertical, - child: Column( - children: [ - _buildPolicyCategoryList(isDesktop), - _buildPolicyOrdering(isDesktop), - _buildPolicyCategory(isDesktop), - ], + child: Container( + child: SingleChildScrollView( + scrollDirection: Axis.vertical, + child: Column( + children: [ + _buildPolicyCategoryList(isDesktop), + _buildPolicyOrdering(isDesktop), + _buildPolicyCategory(isDesktop), + ], + ), + ), ), ), - ), - ), // isDesktop // ? Expanded( // child: Row( @@ -940,28 +940,28 @@ class _PolicyState extends State { border: Border.all(color: Colors.blueGrey.shade100, width: 0.35), ), child: - isDesktop - ? Padding( - padding: const EdgeInsets.all(10.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.start, - children: [_buildPolicySubCategoryList(isDesktop)], - ), - ) - : Column( - children: [ - Container( - // color: Colors.amber, - child: _buildPolicySubCategoryList(isDesktop), - // child: Text("FAta"), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.start, - // children: [_buildPolicySubCategoryList(isDesktop)], - // ), - ), - ], - ), + isDesktop + ? Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [_buildPolicySubCategoryList(isDesktop)], + ), + ) + : Column( + children: [ + Container( + // color: Colors.amber, + child: _buildPolicySubCategoryList(isDesktop), + // child: Text("FAta"), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.start, + // children: [_buildPolicySubCategoryList(isDesktop)], + // ), + ), + ], + ), ); } @@ -1118,21 +1118,21 @@ class _PolicyState extends State { width: isDesktop ? MediaQuery.of(context).size.width * 0.62 : null, // width: isDesktop ? MediaQuery.of(context).size.width * 0.75 : null, child: - isDesktop - ? Container( - // color: Colors.amber, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [_buildPolicyServiceOrdering(isDesktop)], - ), - ) - : Container( - // color: Colors.amber, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [_buildPolicyServiceOrdering(isDesktop)], - ), - ), + isDesktop + ? Container( + // color: Colors.amber, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [_buildPolicyServiceOrdering(isDesktop)], + ), + ) + : Container( + // color: Colors.amber, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [_buildPolicyServiceOrdering(isDesktop)], + ), + ), ); } @@ -1143,14 +1143,16 @@ class _PolicyState extends State { // Sort services by 'order' ServicesChoosed!.sort( - (a, b) => (a['order'] ?? 0).compareTo(b['order'] ?? 0), + (a, b) => (a['order'] ?? 0).compareTo(b['order'] ?? 0), ); List services = - ServicesChoosed!.map((service) => service['name'].toString()).toList(); + ServicesChoosed!.map((service) => service['name'].toString()).toList(); List serviceDBvalue = - ServicesChoosed!.map((service) => service['service_id'].toString()).toList(); + ServicesChoosed! + .map((service) => service['service_id'].toString()) + .toList(); print("1093"); print(services); @@ -1162,109 +1164,110 @@ class _PolicyState extends State { child: Flex( direction: Axis.horizontal, children: - services.asMap().entries.map((entry) { - int index = entry.key + 1; - String service = entry.value; - String serviceId = index.toString(); - bool isSelected = - selectedServiceIndex.value == index.toString(); + services.asMap().entries.map((entry) { + int index = entry.key + 1; + String service = entry.value; + String serviceId = index.toString(); + bool isSelected = + selectedServiceIndex.value == index.toString(); - return SizedBox( - // width: isDesktop ? 40 : null, - height: - isDesktop - ? max( - (MediaQuery.of(context).size.height * 0.075), - 10, - ) - : 45, + return SizedBox( + // width: isDesktop ? 40 : null, + height: + isDesktop + ? max( + (MediaQuery.of(context).size.height * 0.075), + 10, + ) + : 45, - // max((MediaQuery.of(context).size.height * 0.09), 10) - child: GestureDetector( - onTap: () { - print("Selected Services - $service - $index"); - setState(() { - selectedServiceIndex.value = index.toString(); - selectedServiceDBValue = serviceDBvalue[entry.key]; - selectedService = service; + // max((MediaQuery.of(context).size.height * 0.09), 10) + child: GestureDetector( + onTap: () { + print("Selected Services - $service - $index"); + setState(() { + selectedServiceIndex.value = index.toString(); + selectedServiceDBValue = serviceDBvalue[entry.key]; + selectedService = service; - print( - " selectedServiceIndex.value - ${selectedServiceIndex.value}", - ); + print( + " selectedServiceIndex.value - ${selectedServiceIndex.value}", + ); - print( - " selectedServiceDBValue.value - ${selectedServiceDBValue}", - ); + print( + " selectedServiceDBValue.value - ${selectedServiceDBValue}", + ); - // policyCriteriaKey.currentState?.fieldForPolicy(); - // policyCriteriaKey.currentState - // ?.addOrUpdatePolicy(selectedServiceIndex.value); - print("policyselectedService - $selectedService"); - if (selectedService == "Flight" || - selectedService == "Train" || selectedService == "Accomodation") { - showClass = true; - showCost = false; - int serviceCode = selectedService == "Flight" ? 1 : 2; - print("policyselectedService1 - $selectedService"); - policyCriteriaKey.currentState - ?.fetchTrainFlightClass(); - } - // else if (selectedService == "Accommodation") { - // showClass = true; - // showCost = false; - // } - else { - showClass = false; - showCost = false; - } - }); - }, - child: Container( - margin: const EdgeInsets.all(5), - padding: - isDesktop - ? const EdgeInsets.all(8) - : const EdgeInsets.symmetric( - horizontal: 8, - vertical: 3, - ), - alignment: Alignment.center, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - service, - style: GoogleFonts.poppins( - color: - isSelected - ? const Color(0xFF114D8B) - : Colors.black87, - fontSize: 13, - fontWeight: - isSelected - ? FontWeight.bold - : FontWeight.w500, - decoration: - TextDecoration - .none, // remove built-in underline - ), + // policyCriteriaKey.currentState?.fieldForPolicy(); + // policyCriteriaKey.currentState + // ?.addOrUpdatePolicy(selectedServiceIndex.value); + print("policyselectedService - $selectedService"); + if (selectedService == "Flight" || + selectedService == "Train" || + selectedService == "Accomodation") { + showClass = true; + showCost = false; + int serviceCode = selectedService == "Flight" ? 1 : 2; + print("policyselectedService1 - $selectedService"); + policyCriteriaKey.currentState + ?.fetchTrainFlightClass(); + } + // else if (selectedService == "Accommodation") { + // showClass = true; + // showCost = false; + // } + else { + showClass = false; + showCost = false; + } + }); + }, + child: Container( + margin: const EdgeInsets.all(5), + padding: + isDesktop + ? const EdgeInsets.all(8) + : const EdgeInsets.symmetric( + horizontal: 8, + vertical: 3, + ), + alignment: Alignment.center, + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + service, + style: GoogleFonts.poppins( + color: + isSelected + ? const Color(0xFF114D8B) + : Colors.black87, + fontSize: 13, + fontWeight: + isSelected + ? FontWeight.bold + : FontWeight.w500, + decoration: + TextDecoration + .none, // remove built-in underline + ), + ), + if (isSelected) + const SizedBox( + height: 1, + ), // spacing between text and underline + if (isSelected) + Container( + height: 2, + width: 30, // or based on text width + color: const Color(0xFF114D8B), + ), + ], ), - if (isSelected) - const SizedBox( - height: 1, - ), // spacing between text and underline - if (isSelected) - Container( - height: 2, - width: 30, // or based on text width - color: const Color(0xFF114D8B), - ), - ], + ), ), - ), - ), - ); - }).toList(), + ); + }).toList(), ), ), ); @@ -1288,7 +1291,7 @@ class _PolicyState extends State { } List services = - ServicesChoosed!.map((service) => service['name'].toString()).toList(); + ServicesChoosed!.map((service) => service['name'].toString()).toList(); return Expanded( child: SingleChildScrollView( @@ -1296,88 +1299,88 @@ class _PolicyState extends State { child: Flex( direction: isDesktop ? Axis.vertical : Axis.horizontal, children: - services.asMap().entries.map((entry) { - int index = entry.key + 1; - String service = entry.value; - bool isSelected = - selectedServiceIndex.value == index.toString(); + services.asMap().entries.map((entry) { + int index = entry.key + 1; + String service = entry.value; + bool isSelected = + selectedServiceIndex.value == index.toString(); - return SizedBox( - width: isDesktop ? 180 : null, - height: - isDesktop - ? max( - (MediaQuery.of(context).size.height * 0.075), - 10, - ) - : 45, + return SizedBox( + width: isDesktop ? 180 : null, + height: + isDesktop + ? max( + (MediaQuery.of(context).size.height * 0.075), + 10, + ) + : 45, - // max((MediaQuery.of(context).size.height * 0.09), 10) - child: GestureDetector( - onTap: () { - print("Selected Services - $service - $index"); - setState(() { - // selectedServiceIndex.value = index.toString(); - // selectedService = service; - // - // if (selectedService == "Flight" || - // selectedService == "Train") { - // showClass = true; - // showCost = true; - // int serviceCode = selectedService == "Flight" ? 1 : 2; - // policyCriteriaKey.currentState?.fetchTrainFlightClass(); - // } else if (selectedService == "Accommodation") { - // showClass = true; - // showCost = false; - // } else { - // showClass = false; - // showCost = false; - // } - }); - }, - child: Container( - margin: EdgeInsets.all(5), - padding: - isDesktop - ? EdgeInsets.all(8) - : EdgeInsets.only( - top: 3, - bottom: 3, - left: 8, - right: 8, - ), - decoration: BoxDecoration( - // color: Colors.blue, - color: isSelected ? Color(0xFF114D8B) : Colors.white, - // : Color(0xFFEBEBF7), - borderRadius: BorderRadius.circular(8), - border: Border.all( - color: Colors.white, // Light grey border - width: 1, - ), - boxShadow: [ - BoxShadow( - color: Colors.grey.withAlpha(90), // Shadow color - blurRadius: 1, // Blur radius - spreadRadius: 1, // Spread radius - offset: Offset(0, 1), // Shadow position + // max((MediaQuery.of(context).size.height * 0.09), 10) + child: GestureDetector( + onTap: () { + print("Selected Services - $service - $index"); + setState(() { + // selectedServiceIndex.value = index.toString(); + // selectedService = service; + // + // if (selectedService == "Flight" || + // selectedService == "Train") { + // showClass = true; + // showCost = true; + // int serviceCode = selectedService == "Flight" ? 1 : 2; + // policyCriteriaKey.currentState?.fetchTrainFlightClass(); + // } else if (selectedService == "Accommodation") { + // showClass = true; + // showCost = false; + // } else { + // showClass = false; + // showCost = false; + // } + }); + }, + child: Container( + margin: EdgeInsets.all(5), + padding: + isDesktop + ? EdgeInsets.all(8) + : EdgeInsets.only( + top: 3, + bottom: 3, + left: 8, + right: 8, + ), + decoration: BoxDecoration( + // color: Colors.blue, + color: isSelected ? Color(0xFF114D8B) : Colors.white, + // : Color(0xFFEBEBF7), + borderRadius: BorderRadius.circular(8), + border: Border.all( + color: Colors.white, // Light grey border + width: 1, + ), + boxShadow: [ + BoxShadow( + color: Colors.grey.withAlpha(90), // Shadow color + blurRadius: 1, // Blur radius + spreadRadius: 1, // Spread radius + offset: Offset(0, 1), // Shadow position + ), + ], + ), + alignment: Alignment.center, + child: Text( + service, + style: GoogleFonts.poppins( + color: isSelected ? Colors.white : Colors.black87, + fontSize: 13, + fontWeight: + isSelected ? FontWeight.bold : FontWeight.w100, + ), ), - ], - ), - alignment: Alignment.center, - child: Text( - service, - style: GoogleFonts.poppins( - color: isSelected ? Colors.white : Colors.black87, - fontSize: 13, - fontWeight: - isSelected ? FontWeight.bold : FontWeight.w100, ), ), - ), - ), - ); - }).toList(), + ); + }).toList(), ), ), ); @@ -1455,14 +1458,14 @@ class _PolicyState extends State { borderRadius: BorderRadius.circular(4), // Rounded rectangle border: Border.all( color: - _selectedTripType == "1" ? Colors.green : Colors.black, + _selectedTripType == "1" ? Colors.green : Colors.black, width: _selectedTripType == "1" ? 2 : 1, ), ), child: - _selectedTripType == "1" - ? Icon(Icons.rectangle, size: 8, color: Colors.green) - : null, // Add checkmark if selected + _selectedTripType == "1" + ? Icon(Icons.rectangle, size: 8, color: Colors.green) + : null, // Add checkmark if selected ), ), ], @@ -1511,14 +1514,14 @@ class _PolicyState extends State { borderRadius: BorderRadius.circular(4), // Rounded rectangle border: Border.all( color: - _selectedTripType == "2" ? Colors.green : Colors.black, + _selectedTripType == "2" ? Colors.green : Colors.black, width: _selectedTripType == "2" ? 2 : 1, ), ), child: - _selectedTripType == "2" - ? Icon(Icons.rectangle, size: 8, color: Colors.green) - : null, // Add checkmark if selected + _selectedTripType == "2" + ? Icon(Icons.rectangle, size: 8, color: Colors.green) + : null, // Add checkmark if selected ), ), ], @@ -1563,17 +1566,17 @@ class _PolicyState extends State { SizedBox(width: 20), MouseRegion( cursor: - isViewMode - ? SystemMouseCursors.forbidden - : SystemMouseCursors.click, + isViewMode + ? SystemMouseCursors.forbidden + : SystemMouseCursors.click, child: ElevatedButton( style: ElevatedButton.styleFrom( backgroundColor: - isViewMode ? layoutColor : layoutColor, // Keep original color + isViewMode ? layoutColor : layoutColor, // Keep original color foregroundColor: - isViewMode ? Colors.white : Colors.white, // Keep original color + isViewMode ? Colors.white : Colors.white, // Keep original color disabledBackgroundColor: - layoutColor, // Ensure color remains when disabled + layoutColor, // Ensure color remains when disabled disabledForegroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), @@ -1582,8 +1585,8 @@ class _PolicyState extends State { padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12), ), onPressed: - // isViewMode ? null : handleSubmit, // Disable when in view mode - isViewMode || isDisable ? null : handleSubmit, + // isViewMode ? null : handleSubmit, // Disable when in view mode + isViewMode || isDisable ? null : handleSubmit, child: Text("Submit", style: GoogleFonts.poppins(fontSize: 10)), ), ), @@ -1655,4 +1658,4 @@ class _PolicyState extends State { ), ]; } -} \ No newline at end of file +} diff --git a/lib/Screens/policy/policyCriteria.dart b/lib/Screens/policy/policyCriteria.dart index 92531c6..0193d1f 100644 --- a/lib/Screens/policy/policyCriteria.dart +++ b/lib/Screens/policy/policyCriteria.dart @@ -141,7 +141,7 @@ class PolicyCriteriaState extends State { // Step 2: Collect existing service_ids from policyData final existingServiceIds = - policyData?.map((e) => e['service_id'].toString()).toSet(); + policyData?.map((e) => e['service_id'].toString()).toSet(); // Step 3: Loop through all service definitions for (var service in services) { @@ -184,7 +184,7 @@ class PolicyCriteriaState extends State { "a3_exceptional_action": ThirdExceptionalApproverAction[id], "a4_exceptional_action": FourthExceptionalApproverAction[id], "exceptional_parallel_process_from": - SelectedParallelExceptionalProcess[id], + SelectedParallelExceptionalProcess[id], "a1_amendment_action": FirstAmendApproverAction[id], "a2_amendment_action": SecondAmendApproverAction[id], "a3_amendment_action": ThirdAmendApproverAction[id], @@ -266,7 +266,7 @@ class PolicyCriteriaState extends State { print("addOrUpdatePolicyserviceId - $serviceId"); // 1. First, find existing item if any final existingIndex = policyData!.indexWhere( - (item) => item["service_id"] == serviceId, + (item) => item["service_id"] == serviceId, ); print(FirstApproverAction); @@ -284,13 +284,13 @@ class PolicyCriteriaState extends State { "a3_exceptional_action": ThirdExceptionalApproverAction[serviceId], "a4_exceptional_action": FourthExceptionalApproverAction[serviceId], "exceptional_parallel_process_from": - SelectedParallelExceptionalProcess[serviceId], + SelectedParallelExceptionalProcess[serviceId], "a1_amendment_action": FirstAmendApproverAction[serviceId], "a2_amendment_action": SecondAmendApproverAction[serviceId], "a3_amendment_action": ThirdAmendApproverAction[serviceId], "a4_amendment_action": FourthAmendApproverAction[serviceId], "amendment_parallel_process_from": - SelectedParallelAmendProcess[serviceId], + SelectedParallelAmendProcess[serviceId], "created_by": widget.userId, }; @@ -319,17 +319,19 @@ class PolicyCriteriaState extends State { bool allActionsNull = a1 == null && a2 == null && a3 == null; bool someActionsMissing = [a1, a2, a3].where((a) => a != null).length > 0 && - [a1, a2, a3].where((a) => a == null).length > 0; + [a1, a2, a3].where((a) => a == null).length > 0; - bool allExceptionalActionsNull = ae1 == null && ae2 == null && ae3 == null && ae4 == null; + bool allExceptionalActionsNull = + ae1 == null && ae2 == null && ae3 == null && ae4 == null; bool someExceptionalActionsMissing = [ae1, ae2, ae3, ae4].where((a) => a != null).length > 0 && - [ae1, ae2, ae3, ae4].where((a) => a == null).length > 0; + [ae1, ae2, ae3, ae4].where((a) => a == null).length > 0; - bool allAmendActionsNull = aa1 == null && aa2 == null && aa3 == null && aa4 == null; + bool allAmendActionsNull = + aa1 == null && aa2 == null && aa3 == null && aa4 == null; bool someAmendActionsMissing = [aa1, aa2, aa3, aa4].where((a) => a != null).length > 0 && - [aa1, aa2, aa3, aa4].where((a) => a == null).length > 0; + [aa1, aa2, aa3, aa4].where((a) => a == null).length > 0; if (someActionsMissing) { validationErrors[serviceId] = "All 3 approver actions must be selected."; @@ -337,12 +339,12 @@ class PolicyCriteriaState extends State { } if (someExceptionalActionsMissing) { validationErrors[serviceId] = - "All 4 exceptional approver actions must be selected."; + "All 4 exceptional approver actions must be selected."; return; } if (someAmendActionsMissing) { validationErrors[serviceId] = - "All 4 amendment approver actions must be selected."; + "All 4 amendment approver actions must be selected."; return; } @@ -458,6 +460,7 @@ class PolicyCriteriaState extends State { void fieldForPolicy() { print("fieldForPolicy - ${widget.selectedTabNotifier.value}"); + print("POlicyCheck - $policyData"); // Save current input to policyData before switching if (ServiceId != null) { print("Calling addOrUpdatePolicy"); @@ -470,7 +473,7 @@ class PolicyCriteriaState extends State { ServiceId = widget.selectedServiceDBValue; print("ServiceId"); print(ServiceId); - // Initialize controllers and variables if not present + // Initialize controllers and variables if not present (Controller Creation) costController.putIfAbsent(ServiceId!, () => TextEditingController()); classAction.putIfAbsent((widget.selectedServiceDBValue), () => "1"); // classController.putIfAbsent(ServiceId!, () => TextEditingController()); @@ -527,9 +530,9 @@ class PolicyCriteriaState extends State { widget.isDesktop ? SizedBox(height: 1) : SizedBox(height: 1), Padding( padding: - widget.isDesktop - ? const EdgeInsets.only(left: 0.0) - : const EdgeInsets.only(left: 0), + widget.isDesktop + ? const EdgeInsets.only(left: 0.0) + : const EdgeInsets.only(left: 0), child: Row( children: [ Container( @@ -541,27 +544,27 @@ class PolicyCriteriaState extends State { right: 5, ), child: - widget.isDesktop - ? Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - if (widget.isClass) - buildClassWidget(widget.isDesktop), - SizedBox(width: 45), - if (widget.isCost!) - buildCostWidget(widget.isDesktop), - ], - ) - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (widget.isClass!) - buildClassWidget(widget.isDesktop), - SizedBox(height: 10), - if (widget.isCost!) - buildCostWidget(widget.isDesktop), - ], - ), + widget.isDesktop + ? Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + if (widget.isClass) + buildClassWidget(widget.isDesktop), + SizedBox(width: 45), + if (widget.isCost!) + buildCostWidget(widget.isDesktop), + ], + ) + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (widget.isClass!) + buildClassWidget(widget.isDesktop), + SizedBox(height: 10), + if (widget.isCost!) + buildCostWidget(widget.isDesktop), + ], + ), ), ], ), @@ -599,13 +602,13 @@ class PolicyCriteriaState extends State { Container( // color: Colors.yellow, width: - widget.isDesktop - ? MediaQuery.of(context).size.width * 0.18 - : 600, + widget.isDesktop + ? MediaQuery.of(context).size.width * 0.18 + : 600, height: - widget.isDesktop - ? MediaQuery.of(context).size.height * 0.56 - : null, + widget.isDesktop + ? MediaQuery.of(context).size.height * 0.56 + : null, child: Column( children: [ Container( @@ -624,9 +627,9 @@ class PolicyCriteriaState extends State { ), child: Row( mainAxisAlignment: - widget.isDesktop - ? MainAxisAlignment.spaceAround - : MainAxisAlignment.spaceBetween, + widget.isDesktop + ? MainAxisAlignment.spaceAround + : MainAxisAlignment.spaceBetween, children: [ Expanded( flex: 3, @@ -674,11 +677,11 @@ class PolicyCriteriaState extends State { border: Border( right: BorderSide( color: - Colors - .blueGrey - .shade50, // Change this to your desired color + Colors + .blueGrey + .shade50, // Change this to your desired color width: - 1.0, // Change this to your desired width + 1.0, // Change this to your desired width ), ), ), @@ -702,9 +705,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -712,38 +715,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - FirstApproverAction[ServiceId], + FirstApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: GoogleFonts.poppins( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -751,29 +754,29 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: ( - context, - selectedItem, + context, + selectedItem, ) => Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -796,7 +799,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelProcess[ServiceId!] = - "1"; + "1"; }); print( @@ -810,10 +813,10 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - (SelectedParallelProcess[ServiceId] == - "1") - ? Colors.green - : Colors.grey, + (SelectedParallelProcess[ServiceId] == + "1") + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -821,10 +824,10 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - (SelectedParallelProcess[ServiceId] == - "1") - ? Colors.green - : Colors.grey, + (SelectedParallelProcess[ServiceId] == + "1") + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -847,9 +850,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -857,38 +860,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - SecondApproverAction[ServiceId], + SecondApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: TextStyle( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: TextStyle( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -896,29 +899,29 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: ( - context, - selectedItem, + context, + selectedItem, ) => Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -941,7 +944,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelProcess[ServiceId!] = - "2"; + "2"; }); print( @@ -955,12 +958,12 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - ((SelectedParallelProcess[ServiceId] == - "1") || - (SelectedParallelProcess[ServiceId] == - "2")) - ? Colors.green - : Colors.grey, + ((SelectedParallelProcess[ServiceId] == + "1") || + (SelectedParallelProcess[ServiceId] == + "2")) + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -968,12 +971,12 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - ((SelectedParallelProcess[ServiceId] == - "1") || - (SelectedParallelProcess[ServiceId] == - "2")) - ? Colors.green - : Colors.grey, + ((SelectedParallelProcess[ServiceId] == + "1") || + (SelectedParallelProcess[ServiceId] == + "2")) + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -995,9 +998,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -1005,38 +1008,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - ThirdApproverAction[ServiceId], + ThirdApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: GoogleFonts.poppins( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -1044,28 +1047,28 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: (context, selectedItem) => - // Center-align selected item - Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + // Center-align selected item + Text( + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -1088,7 +1091,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelProcess[ServiceId!] = - "3"; + "3"; }); print( "SelectedParallelProcess - $SelectedParallelProcess[ServiceId]", @@ -1101,14 +1104,14 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - ((SelectedParallelProcess[ServiceId] == - "1") || - (SelectedParallelProcess[ServiceId] == - "2") || - (SelectedParallelProcess[ServiceId] == - "3")) - ? Colors.green - : Colors.grey, + ((SelectedParallelProcess[ServiceId] == + "1") || + (SelectedParallelProcess[ServiceId] == + "2") || + (SelectedParallelProcess[ServiceId] == + "3")) + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -1116,14 +1119,14 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - ((SelectedParallelProcess[ServiceId] == - "1") || - (SelectedParallelProcess[ServiceId] == - "2") || - (SelectedParallelProcess[ServiceId] == - "3")) - ? Colors.green - : Colors.grey, + ((SelectedParallelProcess[ServiceId] == + "1") || + (SelectedParallelProcess[ServiceId] == + "2") || + (SelectedParallelProcess[ServiceId] == + "3")) + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -1146,13 +1149,13 @@ class PolicyCriteriaState extends State { children: [ Container( width: - widget.isDesktop - ? MediaQuery.of(context).size.width * 0.18 - : 600, + widget.isDesktop + ? MediaQuery.of(context).size.width * 0.18 + : 600, height: - widget.isDesktop - ? MediaQuery.of(context).size.height * 0.56 - : null, + widget.isDesktop + ? MediaQuery.of(context).size.height * 0.56 + : null, child: Column( children: [ Container( @@ -1171,9 +1174,9 @@ class PolicyCriteriaState extends State { ), child: Row( mainAxisAlignment: - widget.isDesktop - ? MainAxisAlignment.spaceAround - : MainAxisAlignment.spaceBetween, + widget.isDesktop + ? MainAxisAlignment.spaceAround + : MainAxisAlignment.spaceBetween, children: [ Expanded( flex: 3, @@ -1221,11 +1224,11 @@ class PolicyCriteriaState extends State { border: Border( right: BorderSide( color: - Colors - .blueGrey - .shade50, // Change this to your desired color + Colors + .blueGrey + .shade50, // Change this to your desired color width: - 1.0, // Change this to your desired width + 1.0, // Change this to your desired width ), ), ), @@ -1235,7 +1238,10 @@ class PolicyCriteriaState extends State { children: [ Container( // padding: const EdgeInsets.all(10), - padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0), + padding: const EdgeInsets.symmetric( + horizontal: 4.0, + vertical: 4.0, + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -1249,9 +1255,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -1259,38 +1265,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - FirstExceptionalApproverAction[ServiceId], + FirstExceptionalApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: GoogleFonts.poppins( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -1298,29 +1304,29 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: ( - context, - selectedItem, + context, + selectedItem, ) => Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -1343,7 +1349,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelExceptionalProcess[ServiceId!] = - "1"; + "1"; }); print( @@ -1357,10 +1363,10 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - (SelectedParallelExceptionalProcess[ServiceId] == - "1") - ? Colors.green - : Colors.grey, + (SelectedParallelExceptionalProcess[ServiceId] == + "1") + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -1368,10 +1374,10 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - (SelectedParallelExceptionalProcess[ServiceId] == - "1") - ? Colors.green - : Colors.grey, + (SelectedParallelExceptionalProcess[ServiceId] == + "1") + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -1381,7 +1387,10 @@ class PolicyCriteriaState extends State { ), Container( // padding: const EdgeInsets.all(10), - padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0), + padding: const EdgeInsets.symmetric( + horizontal: 4.0, + vertical: 4.0, + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -1395,9 +1404,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -1405,38 +1414,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - SecondExceptionalApproverAction[ServiceId], + SecondExceptionalApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: TextStyle( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: TextStyle( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -1444,29 +1453,29 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: ( - context, - selectedItem, + context, + selectedItem, ) => Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -1489,7 +1498,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelExceptionalProcess[ServiceId!] = - "2"; + "2"; }); print( @@ -1503,12 +1512,12 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - ((SelectedParallelExceptionalProcess[ServiceId] == - "1") || - (SelectedParallelExceptionalProcess[ServiceId] == - "2")) - ? Colors.green - : Colors.grey, + ((SelectedParallelExceptionalProcess[ServiceId] == + "1") || + (SelectedParallelExceptionalProcess[ServiceId] == + "2")) + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -1516,12 +1525,12 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - ((SelectedParallelExceptionalProcess[ServiceId] == - "1") || - (SelectedParallelExceptionalProcess[ServiceId] == - "2")) - ? Colors.green - : Colors.grey, + ((SelectedParallelExceptionalProcess[ServiceId] == + "1") || + (SelectedParallelExceptionalProcess[ServiceId] == + "2")) + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -1531,7 +1540,10 @@ class PolicyCriteriaState extends State { ), Container( // padding: const EdgeInsets.all(10), - padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0), + padding: const EdgeInsets.symmetric( + horizontal: 4.0, + vertical: 4.0, + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -1544,9 +1556,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -1554,38 +1566,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - ThirdExceptionalApproverAction[ServiceId], + ThirdExceptionalApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: GoogleFonts.poppins( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -1593,28 +1605,28 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: (context, selectedItem) => - // Center-align selected item - Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + // Center-align selected item + Text( + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -1637,7 +1649,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelExceptionalProcess[ServiceId!] = - "3"; + "3"; }); print( "SelectedParallelExceptionalProcess - $SelectedParallelExceptionalProcess[ServiceId]", @@ -1650,14 +1662,14 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - ((SelectedParallelExceptionalProcess[ServiceId] == - "1") || - (SelectedParallelExceptionalProcess[ServiceId] == - "2") || - (SelectedParallelExceptionalProcess[ServiceId] == - "3")) - ? Colors.green - : Colors.grey, + ((SelectedParallelExceptionalProcess[ServiceId] == + "1") || + (SelectedParallelExceptionalProcess[ServiceId] == + "2") || + (SelectedParallelExceptionalProcess[ServiceId] == + "3")) + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -1665,14 +1677,14 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - ((SelectedParallelExceptionalProcess[ServiceId] == - "1") || - (SelectedParallelExceptionalProcess[ServiceId] == - "2") || - (SelectedParallelExceptionalProcess[ServiceId] == - "3")) - ? Colors.green - : Colors.grey, + ((SelectedParallelExceptionalProcess[ServiceId] == + "1") || + (SelectedParallelExceptionalProcess[ServiceId] == + "2") || + (SelectedParallelExceptionalProcess[ServiceId] == + "3")) + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -1682,7 +1694,10 @@ class PolicyCriteriaState extends State { ), Container( // padding: const EdgeInsets.all(10), - padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0), + padding: const EdgeInsets.symmetric( + horizontal: 4.0, + vertical: 4.0, + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -1695,9 +1710,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -1705,38 +1720,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - FourthExceptionalApproverAction[ServiceId], + FourthExceptionalApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: GoogleFonts.poppins( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -1744,28 +1759,28 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: (context, selectedItem) => - // Center-align selected item - Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + // Center-align selected item + Text( + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -1788,7 +1803,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelExceptionalProcess[ServiceId!] = - "4"; + "4"; }); print( "SelectedParallelExceptionalProcess - $SelectedParallelExceptionalProcess[ServiceId]", @@ -1801,16 +1816,16 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - ((SelectedParallelExceptionalProcess[ServiceId] == - "1") || - (SelectedParallelExceptionalProcess[ServiceId] == - "2") || - (SelectedParallelExceptionalProcess[ServiceId] == - "3") || - (SelectedParallelExceptionalProcess[ServiceId] == - "4")) - ? Colors.green - : Colors.grey, + ((SelectedParallelExceptionalProcess[ServiceId] == + "1") || + (SelectedParallelExceptionalProcess[ServiceId] == + "2") || + (SelectedParallelExceptionalProcess[ServiceId] == + "3") || + (SelectedParallelExceptionalProcess[ServiceId] == + "4")) + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -1818,16 +1833,16 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - ((SelectedParallelExceptionalProcess[ServiceId] == - "1") || - (SelectedParallelExceptionalProcess[ServiceId] == - "2") || - (SelectedParallelExceptionalProcess[ServiceId] == - "3") || - (SelectedParallelExceptionalProcess[ServiceId] == - "4")) - ? Colors.green - : Colors.grey, + ((SelectedParallelExceptionalProcess[ServiceId] == + "1") || + (SelectedParallelExceptionalProcess[ServiceId] == + "2") || + (SelectedParallelExceptionalProcess[ServiceId] == + "3") || + (SelectedParallelExceptionalProcess[ServiceId] == + "4")) + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -1850,13 +1865,13 @@ class PolicyCriteriaState extends State { Container( //color: Colors.grey.shade100, width: - widget.isDesktop - ? MediaQuery.of(context).size.width * 0.18 - : 600, + widget.isDesktop + ? MediaQuery.of(context).size.width * 0.18 + : 600, height: - widget.isDesktop - ? MediaQuery.of(context).size.height * 0.56 - : null, + widget.isDesktop + ? MediaQuery.of(context).size.height * 0.56 + : null, child: Column( children: [ Container( @@ -1875,9 +1890,9 @@ class PolicyCriteriaState extends State { ), child: Row( mainAxisAlignment: - widget.isDesktop - ? MainAxisAlignment.spaceAround - : MainAxisAlignment.spaceBetween, + widget.isDesktop + ? MainAxisAlignment.spaceAround + : MainAxisAlignment.spaceBetween, children: [ Expanded( flex: 3, @@ -1927,7 +1942,10 @@ class PolicyCriteriaState extends State { children: [ Container( // padding: const EdgeInsets.all(10), - padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0), + padding: const EdgeInsets.symmetric( + horizontal: 4.0, + vertical: 4.0, + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -1941,9 +1959,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -1951,38 +1969,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - FirstAmendApproverAction[ServiceId], + FirstAmendApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: GoogleFonts.poppins( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -1990,29 +2008,29 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: ( - context, - selectedItem, + context, + selectedItem, ) => Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -2035,7 +2053,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelAmendProcess[ServiceId!] = - "1"; + "1"; }); print( @@ -2049,10 +2067,10 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - (SelectedParallelAmendProcess[ServiceId] == - "1") - ? Colors.green - : Colors.grey, + (SelectedParallelAmendProcess[ServiceId] == + "1") + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -2060,10 +2078,10 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - (SelectedParallelAmendProcess[ServiceId] == - "1") - ? Colors.green - : Colors.grey, + (SelectedParallelAmendProcess[ServiceId] == + "1") + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -2073,7 +2091,10 @@ class PolicyCriteriaState extends State { ), Container( // padding: const EdgeInsets.all(10), - padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0), + padding: const EdgeInsets.symmetric( + horizontal: 4.0, + vertical: 4.0, + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -2087,9 +2108,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -2097,38 +2118,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - SecondAmendApproverAction[ServiceId], + SecondAmendApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: TextStyle( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: TextStyle( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -2136,29 +2157,29 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: ( - context, - selectedItem, + context, + selectedItem, ) => Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -2181,7 +2202,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelAmendProcess[ServiceId!] = - "2"; + "2"; }); print( @@ -2195,12 +2216,12 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - ((SelectedParallelAmendProcess[ServiceId] == - "1") || - (SelectedParallelAmendProcess[ServiceId] == - "2")) - ? Colors.green - : Colors.grey, + ((SelectedParallelAmendProcess[ServiceId] == + "1") || + (SelectedParallelAmendProcess[ServiceId] == + "2")) + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -2208,12 +2229,12 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - ((SelectedParallelAmendProcess[ServiceId] == - "1") || - (SelectedParallelAmendProcess[ServiceId] == - "2")) - ? Colors.green - : Colors.grey, + ((SelectedParallelAmendProcess[ServiceId] == + "1") || + (SelectedParallelAmendProcess[ServiceId] == + "2")) + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -2223,7 +2244,10 @@ class PolicyCriteriaState extends State { ), Container( // padding: const EdgeInsets.all(10), - padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0), + padding: const EdgeInsets.symmetric( + horizontal: 4.0, + vertical: 4.0, + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -2236,9 +2260,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -2246,38 +2270,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - ThirdAmendApproverAction[ServiceId], + ThirdAmendApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: GoogleFonts.poppins( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -2285,28 +2309,28 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: (context, selectedItem) => - // Center-align selected item - Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + // Center-align selected item + Text( + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -2329,7 +2353,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelAmendProcess[ServiceId!] = - "3"; + "3"; }); print( "SelectedParallelAmendProcess - $SelectedParallelAmendProcess[ServiceId]", @@ -2342,14 +2366,14 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - ((SelectedParallelAmendProcess[ServiceId] == - "1") || - (SelectedParallelAmendProcess[ServiceId] == - "2") || - (SelectedParallelAmendProcess[ServiceId] == - "3")) - ? Colors.green - : Colors.grey, + ((SelectedParallelAmendProcess[ServiceId] == + "1") || + (SelectedParallelAmendProcess[ServiceId] == + "2") || + (SelectedParallelAmendProcess[ServiceId] == + "3")) + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -2357,14 +2381,14 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - ((SelectedParallelAmendProcess[ServiceId] == - "1") || - (SelectedParallelAmendProcess[ServiceId] == - "2") || - (SelectedParallelAmendProcess[ServiceId] == - "3")) - ? Colors.green - : Colors.grey, + ((SelectedParallelAmendProcess[ServiceId] == + "1") || + (SelectedParallelAmendProcess[ServiceId] == + "2") || + (SelectedParallelAmendProcess[ServiceId] == + "3")) + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -2374,7 +2398,10 @@ class PolicyCriteriaState extends State { ), Container( // padding: const EdgeInsets.all(10), - padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0), + padding: const EdgeInsets.symmetric( + horizontal: 4.0, + vertical: 4.0, + ), child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ @@ -2387,9 +2414,9 @@ class PolicyCriteriaState extends State { Spacer(), CustomTextFieldUserWrapper( width: - MediaQuery.of( - context, - ).size.width * + MediaQuery.of( + context, + ).size.width * 0.12, isFocused: false, isDesktop: widget.isDesktop, @@ -2397,38 +2424,38 @@ class PolicyCriteriaState extends State { height: 35, child: DropdownSearch( selectedItem: - FourthAmendApproverAction[ServiceId], + FourthAmendApproverAction[ServiceId], // enabled: !isViewMode, popupProps: PopupProps.menu( // showSearchBox: true, fit: - FlexFit - .loose, // Allows flexible height + FlexFit + .loose, // Allows flexible height constraints: BoxConstraints( maxHeight: 250, ), itemBuilder: ( - context, - item, - isSelected, + context, + item, + isSelected, ) => Padding( - padding: - const EdgeInsets.symmetric( - horizontal: 16.0, - vertical: 8.0, - ), - child: Text( - item, - style: GoogleFonts.poppins( - fontSize: - 12, // 👈 Smaller text size here - color: - Colors - .black, // You can customize this + padding: + const EdgeInsets.symmetric( + horizontal: 16.0, + vertical: 8.0, + ), + child: Text( + item, + style: GoogleFonts.poppins( + fontSize: + 12, // 👈 Smaller text size here + color: + Colors + .black, // You can customize this + ), + ), ), - ), - ), ), items: [ "Approval", @@ -2436,28 +2463,28 @@ class PolicyCriteriaState extends State { "None", ], dropdownDecoratorProps: - DropDownDecoratorProps( - dropdownSearchDecoration: - InputDecoration( - border: - InputBorder.none, - contentPadding: - EdgeInsets.symmetric( - horizontal: 1, - vertical: 5, + DropDownDecoratorProps( + dropdownSearchDecoration: + InputDecoration( + border: + InputBorder.none, + contentPadding: + EdgeInsets.symmetric( + horizontal: 1, + vertical: 5, + ), + ), ), - ), - ), dropdownBuilder: (context, selectedItem) => - // Center-align selected item - Text( - selectedItem ?? "Select", - style: GoogleFonts.poppins( - fontSize: 12, - color: Color(0xFF114D8B), - ), - ), + // Center-align selected item + Text( + selectedItem ?? "Select", + style: GoogleFonts.poppins( + fontSize: 12, + color: Color(0xFF114D8B), + ), + ), onChanged: (String? newValue) { setState(() { @@ -2480,7 +2507,7 @@ class PolicyCriteriaState extends State { onTap: () { setState(() { SelectedParallelAmendProcess[ServiceId!] = - "4"; + "4"; }); print( "SelectedParallelAmendProcess - $SelectedParallelAmendProcess[ServiceId]", @@ -2493,16 +2520,16 @@ class PolicyCriteriaState extends State { shape: BoxShape.circle, border: Border.all( color: - ((SelectedParallelAmendProcess[ServiceId] == - "1") || - (SelectedParallelAmendProcess[ServiceId] == - "2") || - (SelectedParallelAmendProcess[ServiceId] == - "3") || - (SelectedParallelAmendProcess[ServiceId] == - "4")) - ? Colors.green - : Colors.grey, + ((SelectedParallelAmendProcess[ServiceId] == + "1") || + (SelectedParallelAmendProcess[ServiceId] == + "2") || + (SelectedParallelAmendProcess[ServiceId] == + "3") || + (SelectedParallelAmendProcess[ServiceId] == + "4")) + ? Colors.green + : Colors.grey, width: 2, ), ), @@ -2510,16 +2537,16 @@ class PolicyCriteriaState extends State { Icons.check_circle, size: 20, color: - ((SelectedParallelAmendProcess[ServiceId] == - "1") || - (SelectedParallelAmendProcess[ServiceId] == - "2") || - (SelectedParallelAmendProcess[ServiceId] == - "3") || - (SelectedParallelAmendProcess[ServiceId] == - "4")) - ? Colors.green - : Colors.grey, + ((SelectedParallelAmendProcess[ServiceId] == + "1") || + (SelectedParallelAmendProcess[ServiceId] == + "2") || + (SelectedParallelAmendProcess[ServiceId] == + "3") || + (SelectedParallelAmendProcess[ServiceId] == + "4")) + ? Colors.green + : Colors.grey, // color: Colors.grey, ), ), @@ -2590,15 +2617,14 @@ class PolicyCriteriaState extends State { }); List> dropdownItems = - purposeList - .map( - (item) => DropdownMenuItem( - value: item['dropdown_key'], - child: Text(item['dropdown_value']), - ), - ) - .toList(); - + purposeList + .map( + (item) => DropdownMenuItem( + value: item['dropdown_key'], + child: Text(item['dropdown_value']), + ), + ) + .toList(); if (dropdownItems.isEmpty) { dropdownItems.add( @@ -2631,7 +2657,8 @@ class PolicyCriteriaState extends State { // Important to wrap inside setState if async WidgetsBinding.instance.addPostFrameCallback((_) { setState(() { - classAction[(widget.selectedServiceDBValue)] = dropdownItems.first.value!; + classAction[(widget.selectedServiceDBValue)] = + dropdownItems.first.value!; }); }); } @@ -2691,96 +2718,104 @@ class PolicyCriteriaState extends State { height: 40, width: double.infinity, child: - (widget.selectedServiceDBValue) != null && (isLoading || dropdownItems.isEmpty) - ? const Center(child: CircularProgressIndicator()) - : DropdownSearch>( - key: - classAction[(widget.selectedServiceDBValue)] == null - ? UniqueKey() - : ValueKey(classAction[(widget.selectedServiceDBValue)]), - items: purposeList.cast>(), + (widget.selectedServiceDBValue) != null && + (isLoading || dropdownItems.isEmpty) + ? const Center(child: CircularProgressIndicator()) + : DropdownSearch>( + key: + classAction[(widget.selectedServiceDBValue)] == + null + ? UniqueKey() + : ValueKey( + classAction[(widget + .selectedServiceDBValue)], + ), + items: purposeList.cast>(), - // selectedItem: purposeList.firstWhere( - // (item) => item['dropdown_key'] == selectedClass, - // orElse: () => {}, - // ), - selectedItem: - classAction[(widget.selectedServiceDBValue)] != null - ? purposeList.firstWhere( - (item) => - item['dropdown_key'] == - classAction[(widget.selectedServiceDBValue)], - orElse: () => {}, - ) - : null, - itemAsString: (item) => item['dropdown_value'] ?? '', - popupProps: PopupProps.menu( - showSearchBox: false, - fit: FlexFit.loose, - menuProps: const MenuProps( - backgroundColor: Colors.white, - ), - itemBuilder: (context, item, isSelected) { - final bool isNotAllowed = - item['is_allowed'] == 'No'; - return Padding( - padding: const EdgeInsets.symmetric( - horizontal: 10, - vertical: 5, - ), - child: Text( - item['dropdown_value'] ?? '', - style: GoogleFonts.poppins( - fontSize: 12, - color: - isNotAllowed - ? Colors.redAccent - : Colors.black, + // selectedItem: purposeList.firstWhere( + // (item) => item['dropdown_key'] == selectedClass, + // orElse: () => {}, + // ), + selectedItem: + classAction[(widget.selectedServiceDBValue)] != + null + ? purposeList.firstWhere( + (item) => + item['dropdown_key'] == + classAction[(widget + .selectedServiceDBValue)], + orElse: () => {}, + ) + : null, + itemAsString: (item) => item['dropdown_value'] ?? '', + popupProps: PopupProps.menu( + showSearchBox: false, + fit: FlexFit.loose, + menuProps: const MenuProps( + backgroundColor: Colors.white, + ), + itemBuilder: (context, item, isSelected) { + final bool isNotAllowed = + item['is_allowed'] == 'No'; + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + child: Text( + item['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: + isNotAllowed + ? Colors.redAccent + : Colors.black, + ), + ), + ); + }, ), + dropdownDecoratorProps: const DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), + ), + ), + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select ", + style: GoogleFonts.poppins( + color: Colors.grey, + fontSize: 13, + ), + ); + } + return Text( + selectedItem['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ); + }, + onChanged: + purposeList.isNotEmpty + ? (Map? newValue) async { + setState(() { + classAction[(widget + .selectedServiceDBValue)] = + newValue?['dropdown_key']; + print( + "Selected Purpose: ${classAction[(widget.selectedServiceDBValue)]}", + ); + }); + } + : null, ), - ); - }, - ), - dropdownDecoratorProps: const DropDownDecoratorProps( - dropdownSearchDecoration: InputDecoration( - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric( - horizontal: 10, - vertical: 10, - ), - ), - ), - dropdownBuilder: (context, selectedItem) { - if (selectedItem == null || selectedItem.isEmpty) { - return Text( - "Select ", - style: GoogleFonts.poppins( - color: Colors.grey, - fontSize: 13, - ), - ); - } - return Text( - selectedItem['dropdown_value'] ?? '', - style: GoogleFonts.poppins( - fontSize: 12, - color: Colors.black, - ), - ); - }, - onChanged: - purposeList.isNotEmpty - ? (Map? newValue) async { - setState(() { - classAction[(widget.selectedServiceDBValue)] = - newValue?['dropdown_key']; - print( - "Selected Purpose: ${classAction[(widget.selectedServiceDBValue)]}", - ); - }); - } - : null, - ), ), ), ], @@ -2834,4 +2869,4 @@ class PolicyCriteriaState extends State { ], ); } -} \ No newline at end of file +} diff --git a/lib/app.dart b/lib/app.dart index 4808724..493d383 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -31,14 +31,34 @@ class _MyAppState extends State { @override void initState() { super.initState(); - SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here - for testing uncomment this + SemanticsBinding.instance + .ensureSemantics(); // Safe here -only for testing uncomment, Otherwise Email Template wont allow to type if (kIsWeb) { final uri = Uri.parse(html.window.location.href); print("URI - $uri"); + final fragment = uri.fragment; // e.g., 'authredirection?code=xyz123' - if (uri.path == '/tstat/authredirection' && - uri.queryParameters['code'] != null) { - _authCode = uri.queryParameters['code']; + print("Full URI: $uri"); + print("Fragment: $fragment"); + + // Parse just the fragment safely + final fragmentParts = fragment.split('?'); + print("fragmentParts: $fragmentParts"); + final fragmentPath = fragmentParts.first; + print("fragmentPath: $fragmentPath"); + final query = fragmentParts.length > 1 ? fragmentParts[1] : ''; + + print("query: $query"); + + final queryParams = Uri.splitQueryString(query); + print("query: $query"); + + final authCode = queryParams['code']; + + if (fragmentPath == '/authredirection' && authCode != null) { + // _authCode = uri.queryParameters['code']; + + _authCode = queryParams['code']; // _isAuthRedirect = true; html.window.console.log("Auth code detected: $_authCode"); // print(">>> _isAuthRedirect: $_isAuthRedirect"); @@ -54,9 +74,14 @@ class _MyAppState extends State { } Future handleTokenUsingMS(String? authCode) async { + print("handleTokenUsingMS- $authCode"); if (authCode == null) return; + // final url = + // 'http://localhost:40617/tstat/auth/verifyMSAuthUser?code=$authCode'; final url = '$apiUrl/auth/verifyMSAuthUser?code=$authCode'; + + print("url- $url"); try { final response = await http.get( Uri.parse(url), @@ -103,57 +128,6 @@ class _MyAppState extends State { } } - // Future handleTokenUsingMS(authCode) async { - // if (authCode == null) return; - // - // final url = '$apiUrl/auth/verifyMSAuthUser?code=$authCode'; - // try { - // final response = await http.get( - // Uri.parse(url), - // headers: {'Content-Type': 'application/json'}, - // ); - // - // if (response.statusCode == 200) { - // final MS_Token = json.decode(response.body)['token']; - // print("MS_Token - $MS_Token"); - // - // if (MS_Token != '') { - // print('Microsoft - Token Available'); - // await storeUserDetails(MS_Token); - // - // print("userRole - $userRole"); - // - // if (userRole == "Travel Agent") { - // router.go('/listTravelAgentPlan'); - // } else if (userRole == "Org Admin" || userRole == "Travel Admin") { - // router.go('/listAllPlan'); - // } else { - // router.go('/listPlan'); - // } - // } else { - // print('Microsoft - Token Not Available'); - // throw Exception('Token not Founded'); - // } - // } else { - // // final errorMessage = json.decode(response.body)['message']; - // // print(errorMessage); - // // throw Exception(errorMessage); - // - // try { - // final errorMessage = json.decode(response.body)['message']; - // print(errorMessage); - // throw Exception(errorMessage); - // } catch (_) { - // print("Non-JSON error from server: ${response.body}"); - // throw Exception("Authentication failed: ${response.body}"); - // } - // } - // } catch (e) { - // router.go('/'); - // print("Error: $e"); - // } - // } - Future storeUserDetails(String token) async { try { final parts = token.split('.'); @@ -209,176 +183,3 @@ class _MyAppState extends State { ); } } - -// -// import 'package:flutter/foundation.dart'; -// import 'package:flutter/material.dart'; -// import 'package:flutter/rendering.dart'; -// import 'package:flutter_quill/flutter_quill.dart'; -// import 'package:flutter_localizations/flutter_localizations.dart'; -// -// import 'package:frontend/routes/custom_router.dart'; -// import 'dart:html' as html; -// import 'package:frontend/config/apiUrl.dart'; // 1 newly added -// import 'package:go_router/go_router.dart'; -// import 'package:http/http.dart' as http; // 2 newly added -// import 'dart:convert'; // 3 newly added -// -// import 'package:shared_preferences/shared_preferences.dart'; -// -// import 'Screens/myTemplates/templateTest.dart'; -// -// class MyApp extends StatefulWidget { -// const MyApp({super.key}); -// -// @override -// State createState() => _MyAppState(); -// } -// -// class _MyAppState extends State { -// String? _authCode; -// String? userRole; -// bool _isAuthRedirect = false; -// @override -// void initState() { -// super.initState(); -// SemanticsBinding.instance.ensureSemantics(); // ✅ Safe here -// if (kIsWeb) { -// final uri = Uri.parse(html.window.location.href); -// if (uri.path == '/authredirection' && -// uri.queryParameters['code'] != null) { -// _authCode = uri.queryParameters['code']; -// // _isAuthRedirect = true; -// html.window.console.log("Auth code detected: $_authCode"); -// // print(">>> _isAuthRedirect: $_isAuthRedirect"); -// print(">>> Auth code found at startup: $_authCode"); -// -// WidgetsBinding.instance.addPostFrameCallback((_) { -// handleTokenUsingMS(_authCode); -// }); -// } else { -// html.window.console.log("No auth code found or wrong path."); -// } -// } -// } -// -// Future handleTokenUsingMS(authCode) async { -// if (authCode == null) return; -// -// final url = '$apiUrl/auth/verifyMSAuthUser?code=$authCode'; -// try { -// final response = await http.get( -// Uri.parse(url), -// headers: {'Content-Type': 'application/json'}, -// ); -// -// if (response.statusCode == 200) { -// final MS_Token = json.decode(response.body)['token']; -// print("MS_Token - $MS_Token"); -// -// if (MS_Token != '') { -// print('Microsoft - Token Available'); -// await storeUserDetails(MS_Token); -// -// print("userRole - $userRole"); -// -// if (userRole == "Travel Agent") { -// router.go('/listTravelAgentPlan'); -// } else if (userRole == "Org Admin" || userRole == "Travel Admin") { -// router.go('/listAllPlan'); -// } else { -// router.go('/listPlan'); -// } -// } else { -// print('Microsoft - Token Not Available'); -// throw Exception('Token not Founded'); -// } -// } else { -// final errorMessage = json.decode(response.body)['message']; -// print(errorMessage); -// throw Exception(errorMessage); -// } -// } catch (e) { -// print("Error: $e"); -// } -// } -// -// Future storeUserDetails(String token) async { -// try { -// final parts = token.split('.'); -// if (parts.length != 3) throw Exception('Invalid token format'); -// -// final payload = json.decode( -// utf8.decode(base64Url.decode(base64Url.normalize(parts[1]))), -// ); -// -// final userData = payload['data']; -// -// final prefs = await SharedPreferences.getInstance(); -// await prefs.setString('auth_token', token); -// await prefs.setString( -// 'user_data', -// jsonEncode(userData), -// ); // Store full user data -// -// if (userData != null) { -// final pref = await SharedPreferences.getInstance(); -// await pref.setString('auth_token', token); -// await pref.setString('user_data', jsonEncode(userData)); -// -// userRole = userData['role']; -// -// print("userData - $userData"); -// print("userData11 - ${userData['role']}"); -// print("userData12 - $userRole"); -// } -// } catch (e) { -// print('Error decoding token: $e'); -// } -// } -// -// @override -// Widget build(BuildContext context) { -// // if (_isAuthRedirect) { -// // print("Rendering MicrosoftPage with code: $_authCode"); -// // return MaterialApp( -// // home: MicrosoftPage(code: _authCode), -// // debugShowCheckedModeBanner: false, -// // ); -// // } -// // return MaterialApp( -// // title: 'Quill Web Test', -// // localizationsDelegates: const [ -// // GlobalMaterialLocalizations.delegate, -// // GlobalCupertinoLocalizations.delegate, -// // GlobalWidgetsLocalizations.delegate, -// // FlutterQuillLocalizations.delegate, -// // ], -// // supportedLocales: const [Locale('en')], -// // home: const MyHomePage(title: 'Flutter Demo Home Page'), -// // ); -// return MaterialApp.router( -// title: 'TRIP MANAGEMENT', -// routerConfig: router, -// debugShowCheckedModeBanner: false, -// localizationsDelegates: const [ -// GlobalMaterialLocalizations.delegate, -// GlobalCupertinoLocalizations.delegate, -// GlobalWidgetsLocalizations.delegate, -// FlutterQuillLocalizations.delegate, -// ], -// supportedLocales: const [ -// Locale('en'), -// Locale('es'), // Add more as needed -// ], -// localeResolutionCallback: (locale, supportedLocales) { -// for (var supportedLocale in supportedLocales) { -// if (supportedLocale.languageCode == locale?.languageCode) { -// return supportedLocale; -// } -// } -// return supportedLocales.first; -// }, -// ); -// } -// } diff --git a/lib/config/apiUrl.dart b/lib/config/apiUrl.dart index 522e833..a6f413b 100644 --- a/lib/config/apiUrl.dart +++ b/lib/config/apiUrl.dart @@ -1,4 +1,5 @@ //api url // const String apiUrl = 'http://localhost/tstat_be'; // const String apiUrl = 'https://uat.tripapprovaltool.com/tstat_be'; -const String apiUrl = 'http://apitest.tripapprovaltool.com/tstat_be'; // look at this +const String apiUrl = + 'http://apitest.tripapprovaltool.com/tstat_be'; // look at this diff --git a/pubspec.lock b/pubspec.lock index c8bb6f4..dd87d19 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -145,6 +145,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.1" + dotted_border: + dependency: "direct main" + description: + name: dotted_border + sha256: "99b091ec6891ba0c5331fdc2b502993c7c108f898995739a73c6845d71dad70c" + url: "https://pub.dev" + source: hosted + version: "3.1.0" dropdown_search: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 6b40858..fe6d555 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -63,6 +63,7 @@ dependencies: html2md: ^1.3.2 flutter_quill_delta_from_html: ^1.5.2 flutter_launcher_icons: ^0.14.4 + dotted_border: ^3.1.0 diff --git a/web/index.html b/web/index.html index cd8955d..eea2d20 100644 --- a/web/index.html +++ b/web/index.html @@ -31,7 +31,7 @@ - frontend + Trip Approval Tool