Merge - branch main

This commit is contained in:
venba-Inspriron-3558 2025-06-09 12:17:00 +05:30
commit 80f4f62fb1
3 changed files with 230 additions and 105 deletions

View File

@ -55,6 +55,8 @@ class FlightScreenState extends State<FlightScreen> {
Map<String, String?> selectedValues = {}; Map<String, String?> selectedValues = {};
int rowCount = 1;
String? selectedTripType; String? selectedTripType;
Map<int, String?> selectedClasses = {}; // Store class selection for each trip Map<int, String?> selectedClasses = {}; // Store class selection for each trip
Map<int, String?> selectedFrom = {}; // Store class selection for each trip Map<int, String?> selectedFrom = {}; // Store class selection for each trip
@ -251,9 +253,14 @@ class FlightScreenState extends State<FlightScreen> {
Map<String, String> tempCountryMap = {}; Map<String, String> tempCountryMap = {};
for (var country in result) { for (var country in result) {
String city = country['City'] ?? ''; // String city = country['City'] ?? '';
String airport = country['Airport'] ?? ''; // String airport = country['Airport'] ?? '';
String displayName = '${country['City']} - ${country['Airport']}'; // String displayName = '${country['City']} - ${country['Airport']}';
final code = country['Code'] ?? '';
final city = country['City'] ?? '';
final airport = country['Airport'] ?? '';
final displayName = '$city ($code)\n$airport';
tempCountryMap[country['Code']] = displayName; tempCountryMap[country['Code']] = displayName;
} }
@ -563,7 +570,7 @@ class FlightScreenState extends State<FlightScreen> {
bool validateFields() { bool validateFields() {
errorMessages.clear(); // Reset errors errorMessages.clear(); // Reset errors
int rowCount = 1; // Default row count for One-way rowCount = 1; // Default row count for One-way
if (selectedTripType == "Roundtrip") { if (selectedTripType == "Roundtrip") {
rowCount = 2; // Fixed for Roundtrip rowCount = 2; // Fixed for Roundtrip
} else if (selectedTripType == "Multitrip") { } else if (selectedTripType == "Multitrip") {
@ -579,9 +586,31 @@ class FlightScreenState extends State<FlightScreen> {
if (selectedFrom[i] == null) { if (selectedFrom[i] == null) {
errorMessages["from_place_$i"] = "Required"; errorMessages["from_place_$i"] = "Required";
} }
// if (selectedTo[i] == null) {
// errorMessages["to_place_$i"] = "Required";
// }else if (
// selectedFrom[i] == selectedTo[i]) {
// errorMessages["to_place_$i"] = "Change Destination";
// }
if (selectedTo[i] == null) { if (selectedTo[i] == null) {
errorMessages["to_place_$i"] = "Required"; errorMessages["to_place_$i"] = "Required";
print("Error: to_place_$i -> Required (selectedTo[$i] is null)");
} else if (selectedFrom[i] == selectedTo[i]) {
if(selectedTripType == "Roundtrip"){
errorMessages["to_place_1"] = "Change Destination";
}
else{
errorMessages["to_place_$i"] = "Change Destination";
}
print("Error: to_place_$i -> Change Destination (selectedFrom[$i] == selectedTo[$i])");
} }
// if (textControllers["_to${i}Controller"]?.text.trim().isEmpty ?? true) { // if (textControllers["_to${i}Controller"]?.text.trim().isEmpty ?? true) {
// errorMessages["to_place_$i"] = "Required"; // errorMessages["to_place_$i"] = "Required";
// } // }
@ -591,8 +620,13 @@ class FlightScreenState extends State<FlightScreen> {
if (textControllers["_time${i}Controller"]?.text.trim().isEmpty ?? true) { if (textControllers["_time${i}Controller"]?.text.trim().isEmpty ?? true) {
errorMessages["time_$i"] = "Required"; errorMessages["time_$i"] = "Required";
} }
} }
setState(() {}); // Update UI to show error messages setState(() {}); // Update UI to show error messages
return errorMessages return errorMessages
@ -882,6 +916,15 @@ class FlightScreenState extends State<FlightScreen> {
multiTripRowCount = 1; multiTripRowCount = 1;
} }
errorMessages.clear(); errorMessages.clear();
for (int i = 1; i <= rowCount; i++) {
textControllers["_date${i}Controller"]?.clear();
textControllers["_time${i}Controller"]?.clear();
// Also clear the actual selected data (not just the text in controllers)
selectedFrom[i] = null; // Assuming null means no selection
selectedTo[i] = null;
}
}); });
print( print(
"Updating form data: Flight -> trip_type -> $selectedTripType", "Updating form data: Flight -> trip_type -> $selectedTripType",
@ -1254,6 +1297,7 @@ class FlightScreenState extends State<FlightScreen> {
isCountryLoading isCountryLoading
? Center(child: CircularProgressIndicator()) ? Center(child: CircularProgressIndicator())
: DropdownSearch<String>( : DropdownSearch<String>(
enabled: !(selectedTripType == "Roundtrip" && index == 2),
selectedItem: selectedItem:
selectedFrom[index] != null selectedFrom[index] != null
? countryMap[selectedFrom[index]] ? countryMap[selectedFrom[index]]
@ -1273,19 +1317,61 @@ class FlightScreenState extends State<FlightScreen> {
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
), ),
menuProps: MenuProps(backgroundColor: Colors.white), menuProps: MenuProps(backgroundColor: Colors.white),
itemBuilder: itemBuilder: (context, item, isSelected) {
(context, item, isSelected) => Padding( final parts = item.split('\n');
padding: const EdgeInsets.symmetric( final cityAndCode = parts[0];
horizontal: 8.0, final airport = parts.length > 1 ? parts[1] : '';
vertical: 6.0,
), // Extract city and code from "City (CODE)"
child: Text( final cityMatch = RegExp(r'^(.*)\s+\(([^)]+)\)$').firstMatch(cityAndCode);
item, final city = cityMatch?.group(1) ?? '';
style: TextStyle( final code = cityMatch?.group(2) ?? '';
fontSize: 13,
), // 👈 Set your desired text size here return Padding(
), padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 6.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
city,
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
),
Text(
code,
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
),
],
),
const SizedBox(height: 1),
Text(
airport,
style: const TextStyle(
fontSize: 11,
color: Colors.grey,
overflow: TextOverflow.ellipsis,
),
),
],
), ),
);
},
// itemBuilder:
// (context, item, isSelected) => Padding(
// padding: const EdgeInsets.symmetric(
// horizontal: 8.0,
// vertical: 6.0,
// ),
// child: Text(
// item,
// style: TextStyle(
// fontSize: 13,
// ), // 👈 Set your desired text size here
// ),
// ),
), ),
items: countryMap.values.toList(), items: countryMap.values.toList(),
dropdownDecoratorProps: DropDownDecoratorProps( dropdownDecoratorProps: DropDownDecoratorProps(
@ -1294,14 +1380,33 @@ class FlightScreenState extends State<FlightScreen> {
contentPadding: EdgeInsets.symmetric(horizontal: 1), contentPadding: EdgeInsets.symmetric(horizontal: 1),
), ),
), ),
dropdownBuilder: dropdownBuilder: (context, selectedItem) {
(context, selectedItem) => Align( if (selectedItem == null) {
return Align(
alignment: Alignment.centerLeft,child: const Text("Select", style: TextStyle(fontSize: 12)));
}
final parts = selectedItem.split('\n');
final cityAndCode = parts[0];
final airport = parts.length > 1 ? parts[1] : '';
return Align(
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: Text( child: Text(
selectedItem ?? "Select", cityAndCode ?? "Select",
style: TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
), ),
), );
},
// dropdownBuilder:
// (context, selectedItem) => Align(
// alignment: Alignment.centerLeft,
// child: Text(
// selectedItem ?? "Select",
// style: TextStyle(fontSize: 12),
// ),
// ),
onChanged: (String? newValue) { onChanged: (String? newValue) {
setState(() { setState(() {
// selectedFrom[index] = countryMap.entries // selectedFrom[index] = countryMap.entries
@ -1315,7 +1420,13 @@ class FlightScreenState extends State<FlightScreen> {
) )
.key; .key;
print(selectedFrom[index]); if(selectedTripType == "Roundtrip"){
print('rounfTo${selectedFrom[index]}');
// textControllers["_to${index+1}Controller"]?.text = selectedFrom[index]!;
selectedTo[2]= selectedFrom[index]!;
}
}); });
}, },
), ),
@ -1366,6 +1477,7 @@ class FlightScreenState extends State<FlightScreen> {
isCountryLoading isCountryLoading
? Center(child: CircularProgressIndicator()) ? Center(child: CircularProgressIndicator())
: DropdownSearch<String>( : DropdownSearch<String>(
enabled: !(selectedTripType == "Roundtrip" && index == 2),
selectedItem: selectedItem:
selectedTo[index] != null selectedTo[index] != null
? countryMap[selectedTo[index]] ? countryMap[selectedTo[index]]
@ -1385,19 +1497,61 @@ class FlightScreenState extends State<FlightScreen> {
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
), ),
menuProps: MenuProps(backgroundColor: Colors.white), menuProps: MenuProps(backgroundColor: Colors.white),
itemBuilder: itemBuilder: (context, item, isSelected) {
(context, item, isSelected) => Padding( final parts = item.split('\n');
padding: const EdgeInsets.symmetric( final cityAndCode = parts[0];
horizontal: 8.0, final airport = parts.length > 1 ? parts[1] : '';
vertical: 6.0,
),
child: Text( // Extract city and code from "City (CODE)"
item, final cityMatch = RegExp(r'^(.*)\s+\(([^)]+)\)$').firstMatch(cityAndCode);
style: TextStyle( final city = cityMatch?.group(1) ?? '';
fontSize: 13, final code = cityMatch?.group(2) ?? '';
), // 👈 Set your desired text size here
), return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 6.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
city,
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
),
Text(
code,
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
),
],
),
const SizedBox(height: 1),
Text(
airport,
style: const TextStyle(
fontSize: 11,
color: Colors.grey,
overflow: TextOverflow.ellipsis,
),
),
],
), ),
);
},
// itemBuilder:
// (context, item, isSelected) => Padding(
// padding: const EdgeInsets.symmetric(
// horizontal: 8.0,
// vertical: 6.0,
// ),
// child: Text(
// item,
// style: TextStyle(
// fontSize: 13,
// ), // 👈 Set your desired text size here
// ),
// ),
), ),
items: countryMap.values.toList(), items: countryMap.values.toList(),
dropdownDecoratorProps: DropDownDecoratorProps( dropdownDecoratorProps: DropDownDecoratorProps(
@ -1406,16 +1560,36 @@ class FlightScreenState extends State<FlightScreen> {
contentPadding: EdgeInsets.symmetric(horizontal: 1), contentPadding: EdgeInsets.symmetric(horizontal: 1),
), ),
), ),
dropdownBuilder: // dropdownBuilder:
(context, selectedItem) => Align( // (context, selectedItem) => Align(
alignment: Alignment.centerLeft, // alignment: Alignment.centerLeft,
child: Text( // child: Text(
selectedItem ?? "Select Country", // selectedItem ?? "Select Country",
style: TextStyle(fontSize: 12), // style: TextStyle(fontSize: 12),
), // ),
), // ),
onChanged: (String? newValue) {
dropdownBuilder: (context, selectedItem) {
if (selectedItem == null) {
return Align(
alignment: Alignment.centerLeft,child: const Text("Select", style: TextStyle(fontSize: 12)));
}
final parts = selectedItem.split('\n');
final cityAndCode = parts[0];
final airport = parts.length > 1 ? parts[1] : '';
return Align(
alignment: Alignment.centerLeft,
child: Text(
cityAndCode ?? "Select",
style: const TextStyle(fontSize: 12),
),
);
},
onChanged: (String? newValue) {
setState(() { setState(() {
errorMessages.remove("to_place_$index");
selectedTo[index] = selectedTo[index] =
countryMap.entries countryMap.entries
.firstWhere( .firstWhere(
@ -1424,6 +1598,13 @@ class FlightScreenState extends State<FlightScreen> {
.key; .key;
print(selectedTo[index]); print(selectedTo[index]);
if(selectedTripType == "Roundtrip"){
print('rounfTo${selectedTo[index]}');
// textControllers["_to${index+1}Controller"]?.text = selectedFrom[index]!;
selectedFrom[2]= selectedTo[index]!;
}
}); });
}, },
), ),
@ -1431,7 +1612,7 @@ class FlightScreenState extends State<FlightScreen> {
), ),
if (errorMessages["to_place_$index"] != null) ...[ if (errorMessages["to_place_$index"] != null) ...[
SizedBox(height: 5), // Space before error message SizedBox(height: 5), // Space before error message
Text("Required", style: TextStyle(color: Colors.red, fontSize: 12)), Text( errorMessages["to_place_$index"]! , style: TextStyle(color: Colors.red, fontSize: 12)),
], ],
], ],
), ),

View File

@ -438,63 +438,7 @@ class _VisaScreenState extends State<VisaScreen> {
selectedPurpose ??= selectedPurpose ??=
dropdownItems.isNotEmpty ? dropdownItems.first.value : null; dropdownItems.isNotEmpty ? dropdownItems.first.value : null;
return [ return [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Type of Visa *",
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w500,
color: Color(0xFF575A74)),
),
SizedBox(height: 5),
CustomTextFieldWrapper(
isFocused: _tripTypeFocused,
isDesktop: isDesktop,
width: isDesktop
? MediaQuery.of(context).size.width * 0.34
: MediaQuery.of(context).size.width * 0.66,
child: SizedBox(
height: 40,
child: DropdownButtonFormField<String>(
focusNode: _tripTypeFocusNode, // Assign the correct focus node
value: selectedPurpose,
style: TextStyle(fontSize: 12),
decoration: InputDecoration(
border: InputBorder.none,
contentPadding:
EdgeInsets.symmetric(horizontal: 10), // Proper padding
),
onChanged: purposeList.isNotEmpty
? (newValue) {
setState(() {
selectedPurpose = newValue;
});
print(
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}");
}
: null,
items: dropdownItems,
),
),
),
if (errorMessages["type_of_visa"] != null) ...[
SizedBox(height: 5), // Space before error message
Text(
"Required",
style: TextStyle(color: Colors.red, fontSize: 12),
),
],
],
),
if (isDesktop)
Spacer()
else
SizedBox(
height: 8,
),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [

View File

@ -580,7 +580,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
// travelDetailsData = [travellerDetailsKey.currentState?.travel_Detials]; // travelDetailsData = [travellerDetailsKey.currentState?.travel_Detials];
travelDetailsData = travellerDetailsKey.currentState?.travel_Detials; travelDetailsData = travellerDetailsKey.currentState?.travel_Detials;
errorMessagesTravel = travellerDetailsKey.currentState!.errorMessages; // errorMessagesTravel = travellerDetailsKey.currentState!.errorMessages;
print("TRAVEL DETAILS FROM CHILD: $travelDetailsData"); print("TRAVEL DETAILS FROM CHILD: $travelDetailsData");
@ -672,7 +672,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
print("travelDetailsData - $travelDetailsData"); print("travelDetailsData - $travelDetailsData");
print("travelDetailsData - $travelDetailsData"); print("travelDetailsData - $travelDetailsData");
errorMessagesTravel = travellerDetailsKey.currentState!.errorMessages; // errorMessagesTravel = travellerDetailsKey.currentState!.errorMessages;
print("TRAVEL DETAILS FROM CHILD"); print("TRAVEL DETAILS FROM CHILD");
// print("TRAVEL DETAILS FROM CHILD: $travelDetailsData"); // print("TRAVEL DETAILS FROM CHILD: $travelDetailsData");
@ -697,7 +697,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
print("USERDETAILS : $userDetials"); print("USERDETAILS : $userDetials");
orgId = await getOrgId(); orgId = await getOrgId();
// createUserData(userDetials); createUserData(userDetials);
} }
} }