date validation
This commit is contained in:
parent
ffa40af980
commit
7527838cf5
@ -248,6 +248,30 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
// Additional validation starts
|
||||
final start_Date = data["start_date"];
|
||||
final end_Date = data["end_date"];
|
||||
|
||||
if (start_Date != null &&
|
||||
end_Date != null &&
|
||||
start_Date.toString().isNotEmpty &&
|
||||
end_Date.toString().isNotEmpty) {
|
||||
try {
|
||||
final format = DateFormat("dd-MM-yyyy");
|
||||
|
||||
final checkStartDate = format.parse("$start_Date");
|
||||
final checkEndDate = format.parse("$end_Date");
|
||||
|
||||
if (checkEndDate.isBefore(checkStartDate)) {
|
||||
errorMessages["end_date"] =
|
||||
"End date cannot be earlier than start date";;
|
||||
}
|
||||
} catch (e) {
|
||||
errorMessages["end_date"] = "Invalid date format";
|
||||
}
|
||||
return errorMessages.isEmpty;
|
||||
}
|
||||
// Additional validation ends
|
||||
return errorMessages.values.every((msg) => msg.trim().isEmpty);
|
||||
|
||||
// if (hasErrors) {
|
||||
@ -290,7 +314,7 @@ class _ForexScreenState extends State<ForexScreen> {
|
||||
|
||||
Map<String, dynamic> data = forexData;
|
||||
|
||||
if (!isValidForexData(data) && errorMessages.isNotEmpty) {
|
||||
if (!isValidForexData(data)) { // && errorMessages.isNotEmpty) {
|
||||
print("Validation Failed: Required fields are missing.");
|
||||
setState(() {});
|
||||
return; // Stop execution if validation fails
|
||||
|
||||
@ -654,6 +654,7 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
|
||||
void handleSubmit() async {
|
||||
print("USR Detail Submit");
|
||||
|
||||
// printFormData();
|
||||
|
||||
bool isValid = travellerDetailsKey.currentState?.boolValidation() ?? false;
|
||||
@ -668,10 +669,44 @@ class _CreateUserFormDetialsState extends State<CreateUserFormDetials> {
|
||||
travelDetailsData = travellerDetailsKey.currentState?.travel_Detials;
|
||||
|
||||
|
||||
// Additional validation starts - travelDetailsData passport
|
||||
String start_Date = travelDetailsData?['date_of_issue'];
|
||||
String end_Date = travelDetailsData?['date_of_expiry'];
|
||||
|
||||
print("travelDetailsData - $travelDetailsData");
|
||||
if (start_Date != null && end_Date != null && start_Date.toString().isNotEmpty && end_Date.toString().isNotEmpty) {
|
||||
try {
|
||||
final format = DateFormat("dd-MM-yyyy");
|
||||
final checkStartDate = format.parse("$start_Date");
|
||||
final checkEndDate = format.parse("$end_Date");
|
||||
|
||||
print("travelDetailsData - $travelDetailsData");
|
||||
if (checkEndDate.isBefore(checkStartDate)) {
|
||||
// return "End date cannot be earlier than start date";;
|
||||
return ;
|
||||
}
|
||||
} catch (e) { // return "End date cannot be earlier than start date";
|
||||
return ;
|
||||
// errorMessages["end_date"] = "Invalid date format";
|
||||
}
|
||||
}
|
||||
|
||||
// String valid_from = travelDetailsData?['valid_from'];
|
||||
// String valid_upto = travelDetailsData?['valid_upto'];
|
||||
//
|
||||
// if (valid_from != null && valid_upto != null && valid_from.toString().isNotEmpty && valid_upto.toString().isNotEmpty) {
|
||||
// try {
|
||||
// final format = DateFormat("dd-MM-yyyy");
|
||||
// final checkValidFrom = format.parse("$valid_from");
|
||||
// final checkValidUpto = format.parse("$valid_upto");
|
||||
//
|
||||
// if (checkValidUpto.isBefore(checkValidFrom)) {
|
||||
// // return "End date cannot be earlier than start date";
|
||||
// return ;
|
||||
// }
|
||||
// } catch (e) { // return "End date cannot be earlier than start date";
|
||||
// return ;
|
||||
// // errorMessages["end_date"] = "Invalid date format";
|
||||
// }
|
||||
// }
|
||||
// errorMessagesTravel = travellerDetailsKey.currentState!.errorMessages;
|
||||
|
||||
print("TRAVEL DETAILS FROM CHILD");
|
||||
|
||||
@ -1047,7 +1047,8 @@ class PersonalDetailsState extends State<PersonalDetails> {
|
||||
? _selectedDateOfBirth!
|
||||
: today,
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime(2100),
|
||||
// lastDate: DateTime(2100),
|
||||
lastDate: today,
|
||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
);
|
||||
|
||||
|
||||
@ -1351,8 +1351,10 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
);
|
||||
}
|
||||
|
||||
DateTime? _selectedDateOfIssue;
|
||||
DateTime? _selectedDateOfExpiry;
|
||||
|
||||
Widget buildDateOfIssue() {
|
||||
DateTime? _selectedDateOfIssue;
|
||||
|
||||
Future<void> _selectCheckDateOfIssue(BuildContext context) async {
|
||||
DateTime now = DateTime.now();
|
||||
@ -1360,11 +1362,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
|
||||
DateTime? pickedDate = await showDatePicker(
|
||||
context: context,
|
||||
initialDate:
|
||||
_selectedDateOfIssue != null && _selectedDateOfIssue!.isAfter(today)
|
||||
? _selectedDateOfIssue!
|
||||
: today,
|
||||
// firstDate: today,
|
||||
initialDate: _selectedDateOfIssue != null && _selectedDateOfIssue!.isAfter(today)
|
||||
? _selectedDateOfIssue!
|
||||
: today,
|
||||
firstDate: DateTime(1900),
|
||||
lastDate: DateTime(2100),
|
||||
initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
@ -1373,9 +1373,15 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
if (pickedDate != null && pickedDate != _selectedDateOfIssue) {
|
||||
setState(() {
|
||||
_selectedDateOfIssue = pickedDate;
|
||||
controllers["dateOfIssue"]?.text = DateFormat(
|
||||
'dd-MM-yyyy',
|
||||
).format(pickedDate);
|
||||
controllers["dateOfIssue"]?.text = DateFormat('dd-MM-yyyy').format(pickedDate);
|
||||
|
||||
// Revalidate expiry
|
||||
if (_selectedDateOfExpiry != null &&
|
||||
_selectedDateOfExpiry!.isBefore(_selectedDateOfIssue!)) {
|
||||
errorMessages["date_of_expiry"] = "Expiry date cannot be earlier than Issue date";
|
||||
} else {
|
||||
errorMessages.remove("date_of_expiry");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1394,25 +1400,25 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
SizedBox(height: 5),
|
||||
CustomTextFieldUserTravellerWrapper(
|
||||
width:
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.13
|
||||
: null,
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.13
|
||||
: null,
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
child: GestureDetector(
|
||||
onTap:
|
||||
widget.isViewMode
|
||||
? null
|
||||
: () async {
|
||||
await _selectCheckDateOfIssue(context);
|
||||
if (controllers["dateOfIssue"]!.text.isNotEmpty) {
|
||||
setState(() {
|
||||
// errorMessages.remove("start_date");
|
||||
});
|
||||
}
|
||||
},
|
||||
widget.isViewMode
|
||||
? null
|
||||
: () async {
|
||||
await _selectCheckDateOfIssue(context);
|
||||
if (controllers["dateOfIssue"]!.text.isNotEmpty) {
|
||||
setState(() {
|
||||
// errorMessages.remove("start_date");
|
||||
});
|
||||
}
|
||||
},
|
||||
child: AbsorbPointer(
|
||||
child: TextField(
|
||||
controller: controllers["dateOfIssue"],
|
||||
@ -1442,19 +1448,18 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
}
|
||||
|
||||
Widget buildDateOfExpiry() {
|
||||
DateTime? _selectedDateOfExpiry;
|
||||
|
||||
Future<void> _selectCheckDateOfExpiry(BuildContext context) async {
|
||||
|
||||
DateTime now = DateTime.now();
|
||||
DateTime today = DateTime(now.year, now.month, now.day);
|
||||
// DateTime today = DateTime(now.year now.day, now.month,);
|
||||
|
||||
// DateTime firstDate = today;
|
||||
DateTime? validFromDate;
|
||||
|
||||
try {
|
||||
String? fromDateText = controllers["dateOfIssue"]?.text.trim();
|
||||
print("dateOfIssue From Text: $fromDateText");
|
||||
if (fromDateText!.isNotEmpty) {
|
||||
if (fromDateText != null && fromDateText.isNotEmpty) {
|
||||
validFromDate = DateFormat('dd-MM-yyyy').parseStrict(fromDateText);
|
||||
print("dateOfIssue Valid From: $validFromDate");
|
||||
}
|
||||
@ -1492,10 +1497,17 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
);
|
||||
|
||||
if (pickedDate != null) {
|
||||
_selectedDateOfExpiry = pickedDate;
|
||||
controllers["dateOfExpiry"]?.text = DateFormat(
|
||||
"dd-MM-yyyy",
|
||||
).format(pickedDate);
|
||||
setState(() {
|
||||
_selectedDateOfExpiry = pickedDate;
|
||||
controllers["dateOfExpiry"]?.text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
||||
|
||||
if (_selectedDateOfIssue != null &&
|
||||
_selectedDateOfExpiry!.isBefore(_selectedDateOfIssue!)) {
|
||||
errorMessages["date_of_expiry"] = "Expiry date cannot be earlier than Issue date";
|
||||
} else {
|
||||
errorMessages.remove("date_of_expiry");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// if (pickedDate != null && pickedDate != _selectedDateOfExpiry) {
|
||||
@ -1527,23 +1539,23 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
width:
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.13
|
||||
: null,
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.13
|
||||
: null,
|
||||
child: SizedBox(
|
||||
height: 40,
|
||||
child: GestureDetector(
|
||||
onTap:
|
||||
widget.isViewMode
|
||||
? null
|
||||
: () async {
|
||||
await _selectCheckDateOfExpiry(context);
|
||||
if (controllers["dateOfExpiry"]!.text.isNotEmpty) {
|
||||
setState(() {
|
||||
// errorMessages.remove("start_date");
|
||||
});
|
||||
}
|
||||
},
|
||||
widget.isViewMode
|
||||
? null
|
||||
: () async {
|
||||
await _selectCheckDateOfExpiry(context);
|
||||
if (controllers["dateOfExpiry"]!.text.isNotEmpty) {
|
||||
setState(() {
|
||||
// errorMessages.remove("start_date");
|
||||
});
|
||||
}
|
||||
},
|
||||
child: AbsorbPointer(
|
||||
child: TextField(
|
||||
controller: controllers["dateOfExpiry"],
|
||||
@ -1568,9 +1580,236 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (errorMessages["date_of_expiry"] != null) ...[
|
||||
SizedBox(height: 5), // Space before error message
|
||||
Text(
|
||||
errorMessages["date_of_expiry"]!,
|
||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
// Widget buildDateOfIssue() {
|
||||
// DateTime? _selectedDateOfIssue;
|
||||
//
|
||||
// Future<void> _selectCheckDateOfIssue(BuildContext context) async {
|
||||
// DateTime now = DateTime.now();
|
||||
// DateTime today = DateTime(now.year, now.month, now.day);
|
||||
//
|
||||
// DateTime? pickedDate = await showDatePicker(
|
||||
// context: context,
|
||||
// initialDate:
|
||||
// _selectedDateOfIssue != null && _selectedDateOfIssue!.isAfter(today)
|
||||
// ? _selectedDateOfIssue!
|
||||
// : today,
|
||||
// // firstDate: today,
|
||||
// firstDate: DateTime(1900),
|
||||
// lastDate: DateTime(2100),
|
||||
// initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
// );
|
||||
//
|
||||
// if (pickedDate != null && pickedDate != _selectedDateOfIssue) {
|
||||
// setState(() {
|
||||
// _selectedDateOfIssue = pickedDate;
|
||||
// controllers["dateOfIssue"]?.text = DateFormat(
|
||||
// 'dd-MM-yyyy',
|
||||
// ).format(pickedDate);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Date of Issue",
|
||||
// style: GoogleFonts.poppins(
|
||||
// fontSize: 12,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: Color(0xFF575A74),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: 5),
|
||||
// CustomTextFieldUserTravellerWrapper(
|
||||
// width:
|
||||
// widget.isDesktop
|
||||
// ? MediaQuery.of(context).size.width * 0.13
|
||||
// : null,
|
||||
// isFocused: false,
|
||||
// isDesktop: widget.isDesktop,
|
||||
// child: SizedBox(
|
||||
// height: 40,
|
||||
// child: GestureDetector(
|
||||
// onTap:
|
||||
// widget.isViewMode
|
||||
// ? null
|
||||
// : () async {
|
||||
// await _selectCheckDateOfIssue(context);
|
||||
// if (controllers["dateOfIssue"]!.text.isNotEmpty) {
|
||||
// setState(() {
|
||||
// // errorMessages.remove("start_date");
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// child: AbsorbPointer(
|
||||
// child: TextField(
|
||||
// controller: controllers["dateOfIssue"],
|
||||
// style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
|
||||
// decoration: InputDecoration(
|
||||
// labelText: "Select Date",
|
||||
// labelStyle: GoogleFonts.poppins(
|
||||
// fontSize: 12,
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
// floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||
// border: InputBorder.none,
|
||||
// contentPadding: const EdgeInsets.symmetric(vertical: 16),
|
||||
// suffixIcon: const Icon(
|
||||
// Icons.calendar_today,
|
||||
// size: 16,
|
||||
// color: Color(0xFF8B8FB2),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// Widget buildDateOfExpiry() {
|
||||
// DateTime? _selectedDateOfExpiry;
|
||||
//
|
||||
// Future<void> _selectCheckDateOfExpiry(BuildContext context) async {
|
||||
// DateTime now = DateTime.now();
|
||||
// DateTime today = DateTime(now.year, now.month, now.day);
|
||||
// // DateTime today = DateTime(now.year now.day, now.month,);
|
||||
//
|
||||
// DateTime? validFromDate;
|
||||
//
|
||||
// try {
|
||||
// String? fromDateText = controllers["dateOfIssue"]?.text.trim();
|
||||
// print("dateOfIssue From Text: $fromDateText");
|
||||
// if (fromDateText!.isNotEmpty) {
|
||||
// validFromDate = DateFormat('dd-MM-yyyy').parseStrict(fromDateText);
|
||||
// print("dateOfIssue Valid From: $validFromDate");
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print("Error parsing valid from date: $e");
|
||||
// }
|
||||
//
|
||||
// // Use max(today, validFromDate) as firstDate
|
||||
// // DateTime firstDate = today;
|
||||
// DateTime firstDate = validFromDate ?? today;
|
||||
//
|
||||
// // Parse dateOfIssue safely
|
||||
// // DateTime firstDate;
|
||||
// // try {
|
||||
// // firstDate = DateFormat(
|
||||
// // "yyyy-MM-dd",
|
||||
// // ).parse(controllers["dateOfIssue"]!.text);
|
||||
// // } catch (e) {
|
||||
// // firstDate = today; // fallback if parsing fails
|
||||
// // }
|
||||
//
|
||||
// DateTime? pickedDate = await showDatePicker(
|
||||
// context: context,
|
||||
//
|
||||
// // initialDate:
|
||||
// // _selectedDateOfExpiry != null &&
|
||||
// // _selectedDateOfExpiry!.isAfter(firstDate)
|
||||
// // ? _selectedDateOfExpiry!
|
||||
// // : today,
|
||||
// initialDate: firstDate,
|
||||
// firstDate: firstDate,
|
||||
// // firstDate: DateTime(1900),
|
||||
// lastDate: DateTime(2100),
|
||||
// initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
// );
|
||||
//
|
||||
// if (pickedDate != null) {
|
||||
// _selectedDateOfExpiry = pickedDate;
|
||||
// controllers["dateOfExpiry"]?.text = DateFormat(
|
||||
// "dd-MM-yyyy",
|
||||
// ).format(pickedDate);
|
||||
// }
|
||||
//
|
||||
// // if (pickedDate != null && pickedDate != _selectedDateOfExpiry) {
|
||||
// // setState(() {
|
||||
// // _selectedDateOfExpiry = pickedDate;
|
||||
// // controllers["dateOfExpiry"]?.text = DateFormat(
|
||||
// // 'dd-MM-yyyy',
|
||||
// // ).format(pickedDate);
|
||||
// //
|
||||
// // // controllers["dateOfExpiry"]?.text =
|
||||
// // // DateFormat('dd-MM-yyyy').format(pickedDate);
|
||||
// // });
|
||||
// // }
|
||||
// }
|
||||
//
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Date of Expiry",
|
||||
// style: GoogleFonts.poppins(
|
||||
// fontSize: 12,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: Color(0xFF575A74),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: 5),
|
||||
// CustomTextFieldUserTravellerWrapper(
|
||||
// isFocused: false,
|
||||
// isDesktop: widget.isDesktop,
|
||||
// width:
|
||||
// widget.isDesktop
|
||||
// ? MediaQuery.of(context).size.width * 0.13
|
||||
// : null,
|
||||
// child: SizedBox(
|
||||
// height: 40,
|
||||
// child: GestureDetector(
|
||||
// onTap:
|
||||
// widget.isViewMode
|
||||
// ? null
|
||||
// : () async {
|
||||
// await _selectCheckDateOfExpiry(context);
|
||||
// if (controllers["dateOfExpiry"]!.text.isNotEmpty) {
|
||||
// setState(() {
|
||||
// // errorMessages.remove("start_date");
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// child: AbsorbPointer(
|
||||
// child: TextField(
|
||||
// controller: controllers["dateOfExpiry"],
|
||||
// style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
|
||||
// decoration: InputDecoration(
|
||||
// labelText: "Select Date",
|
||||
// labelStyle: GoogleFonts.poppins(
|
||||
// fontSize: 12,
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
// floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||
// border: InputBorder.none,
|
||||
// contentPadding: const EdgeInsets.symmetric(vertical: 16),
|
||||
// suffixIcon: const Icon(
|
||||
// Icons.calendar_today,
|
||||
// size: 16,
|
||||
// color: Color(0xFF8B8FB2),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget buildPassportDocument() {
|
||||
void pickPDFWeb() {
|
||||
@ -3767,8 +4006,11 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
);
|
||||
}
|
||||
|
||||
DateTime? _selectedCheckOutDate;
|
||||
DateTime? _selectedCheckInDate;
|
||||
|
||||
Widget buildVisaValidFrom(Map<String, dynamic> entry) {
|
||||
DateTime? _selectedCheckOutDate;
|
||||
|
||||
TimeOfDay? _selectedCheckOutTime;
|
||||
|
||||
Future<void> _selectValidFromDate(BuildContext context) async {
|
||||
@ -3795,12 +4037,16 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
|
||||
if (pickedDate != null && pickedDate != _selectedCheckOutDate) {
|
||||
setState(() {
|
||||
_selectedCheckOutDate = pickedDate;
|
||||
// _dateController.text = DateFormat('yyyy-MM-dd').format(pickedDate);
|
||||
_selectedCheckInDate = pickedDate;
|
||||
entry["controller_valid_from"]?.text = DateFormat('dd-MM-yyyy').format(pickedDate);
|
||||
|
||||
entry["controller_valid_from"].text = DateFormat(
|
||||
'dd-MM-yyyy',
|
||||
).format(pickedDate);
|
||||
// Revalidate expiry
|
||||
if (_selectedCheckOutDate != null &&
|
||||
_selectedCheckOutDate!.isBefore(_selectedCheckInDate!)) {
|
||||
errorMessages["valid_upto"] = "end date cannot be earlier than from date";
|
||||
} else {
|
||||
errorMessages.remove("valid_upto");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -3819,9 +4065,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
SizedBox(height: 5),
|
||||
CustomTextFieldUserTravellerWrapper(
|
||||
width:
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.15
|
||||
: null,
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.15
|
||||
: null,
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
child: SizedBox(
|
||||
@ -3858,7 +4104,7 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
}
|
||||
|
||||
Widget buildVisaValidUpTo(Map<String, dynamic> entry) {
|
||||
DateTime? _selectedCheckOutDate;
|
||||
|
||||
TimeOfDay? _selectedCheckOutTime;
|
||||
|
||||
Future<void> _selectValidUpToDate(BuildContext context) async {
|
||||
@ -3909,11 +4155,14 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
if (pickedDate != null && pickedDate != _selectedCheckOutDate) {
|
||||
setState(() {
|
||||
_selectedCheckOutDate = pickedDate;
|
||||
// _dateController.text = DateFormat('yyyy-MM-dd').format(pickedDate);
|
||||
entry["controller_valid_upto"].text = DateFormat("dd-MM-yyyy").format(pickedDate);
|
||||
|
||||
entry["controller_valid_upto"].text = DateFormat(
|
||||
'dd-MM-yyyy',
|
||||
).format(pickedDate);
|
||||
if (_selectedCheckInDate != null &&
|
||||
_selectedCheckOutDate!.isBefore(_selectedCheckInDate!)) {
|
||||
errorMessages["valid_upto"] = "end date cannot be earlier than from date";
|
||||
} else {
|
||||
errorMessages.remove("valid_upto");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -3932,9 +4181,9 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
SizedBox(height: 5),
|
||||
CustomTextFieldUserTravellerWrapper(
|
||||
width:
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.15
|
||||
: null,
|
||||
widget.isDesktop
|
||||
? MediaQuery.of(context).size.width * 0.15
|
||||
: null,
|
||||
isFocused: false,
|
||||
isDesktop: widget.isDesktop,
|
||||
child: SizedBox(
|
||||
@ -3970,6 +4219,209 @@ class TravellerDetailsState extends State<TravellerDetails> {
|
||||
);
|
||||
}
|
||||
|
||||
// Widget buildVisaValidFrom(Map<String, dynamic> entry) {
|
||||
// DateTime? _selectedCheckOutDate;
|
||||
// TimeOfDay? _selectedCheckOutTime;
|
||||
//
|
||||
// Future<void> _selectValidFromDate(BuildContext context) async {
|
||||
// DateTime now = DateTime.now();
|
||||
// DateTime today = DateTime(now.year, now.month, now.day);
|
||||
//
|
||||
// // Parse date from notifier if available, else use today
|
||||
// DateTime initialDate = today;
|
||||
//
|
||||
// // Use previously selected date if valid
|
||||
// if (_selectedCheckOutDate != null &&
|
||||
// _selectedCheckOutDate!.isAfter(today)) {
|
||||
// initialDate = _selectedCheckOutDate!;
|
||||
// }
|
||||
//
|
||||
// final pickedDate = await showDatePicker(
|
||||
// context: context,
|
||||
// // initialDate: initialDate,
|
||||
// // firstDate: initialDate,
|
||||
// firstDate: DateTime(1900),
|
||||
// lastDate: DateTime(2100),
|
||||
// initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
// );
|
||||
//
|
||||
// if (pickedDate != null && pickedDate != _selectedCheckOutDate) {
|
||||
// setState(() {
|
||||
// _selectedCheckOutDate = pickedDate;
|
||||
// // _dateController.text = DateFormat('yyyy-MM-dd').format(pickedDate);
|
||||
//
|
||||
// entry["controller_valid_from"].text = DateFormat(
|
||||
// 'dd-MM-yyyy',
|
||||
// ).format(pickedDate);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Valid From",
|
||||
// style: GoogleFonts.poppins(
|
||||
// fontSize: 12,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: Color(0xFF575A74),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: 5),
|
||||
// CustomTextFieldUserTravellerWrapper(
|
||||
// width:
|
||||
// widget.isDesktop
|
||||
// ? MediaQuery.of(context).size.width * 0.15
|
||||
// : null,
|
||||
// isFocused: false,
|
||||
// isDesktop: widget.isDesktop,
|
||||
// child: SizedBox(
|
||||
// height: 40,
|
||||
// child: GestureDetector(
|
||||
// onTap: () async {
|
||||
// await _selectValidFromDate(context);
|
||||
// },
|
||||
// child: AbsorbPointer(
|
||||
// child: TextField(
|
||||
// // focusNode: _dateFocusNode,
|
||||
// controller: entry["controller_valid_from"],
|
||||
//
|
||||
// style: const TextStyle(fontSize: 12),
|
||||
// decoration: const InputDecoration(
|
||||
// labelText: "Select Date",
|
||||
// labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
|
||||
// floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||
// border: InputBorder.none,
|
||||
// contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||
// suffixIcon: Icon(
|
||||
// Icons.calendar_today,
|
||||
// size: 16,
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// Widget buildVisaValidUpTo(Map<String, dynamic> entry) {
|
||||
// DateTime? _selectedCheckOutDate;
|
||||
// TimeOfDay? _selectedCheckOutTime;
|
||||
//
|
||||
// Future<void> _selectValidUpToDate(BuildContext context) async {
|
||||
// DateTime now = DateTime.now();
|
||||
// DateTime today = DateTime(now.year, now.month, now.day);
|
||||
// print("buildVisaValidUpTo ");
|
||||
// print("buildVisaValidUpTo - ${entry["controller_valid_from"].text}");
|
||||
//
|
||||
// // Parse date from notifier if available, else use today
|
||||
// DateTime initialDate = today;
|
||||
//
|
||||
// // Use previously selected date if valid
|
||||
// // if (_selectedCheckOutDate != null &&
|
||||
// // _selectedCheckOutDate!.isAfter(today)) {
|
||||
// // initialDate = _selectedCheckOutDate!;
|
||||
// // }
|
||||
//
|
||||
// DateTime? validFromDate;
|
||||
//
|
||||
// try {
|
||||
// String fromDateText = entry["controller_valid_from"].text.trim();
|
||||
// print("Valid From Text: $fromDateText");
|
||||
// if (fromDateText.isNotEmpty) {
|
||||
// validFromDate = DateFormat('dd-MM-yyyy').parseStrict(fromDateText);
|
||||
// print("Parsed Valid From: $validFromDate");
|
||||
// }
|
||||
// } catch (e) {
|
||||
// print("Error parsing valid from date: $e");
|
||||
// }
|
||||
//
|
||||
// // Use max(today, validFromDate) as firstDate
|
||||
// // DateTime firstDate = today;
|
||||
// DateTime firstDate = validFromDate ?? today;
|
||||
// if (validFromDate != null && validFromDate.isAfter(today)) {
|
||||
// firstDate = validFromDate;
|
||||
// }
|
||||
// final pickedDate = await showDatePicker(
|
||||
// context: context,
|
||||
// // initialDate: initialDate,
|
||||
// // firstDate: initialDate,
|
||||
// // firstDate: DateTime(1900),
|
||||
// initialDate: firstDate,
|
||||
// firstDate: firstDate,
|
||||
// lastDate: DateTime(2100),
|
||||
// initialEntryMode: DatePickerEntryMode.calendarOnly,
|
||||
// );
|
||||
//
|
||||
// if (pickedDate != null && pickedDate != _selectedCheckOutDate) {
|
||||
// setState(() {
|
||||
// _selectedCheckOutDate = pickedDate;
|
||||
// // _dateController.text = DateFormat('yyyy-MM-dd').format(pickedDate);
|
||||
//
|
||||
// entry["controller_valid_upto"].text = DateFormat(
|
||||
// 'dd-MM-yyyy',
|
||||
// ).format(pickedDate);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Text(
|
||||
// "Valid To",
|
||||
// style: GoogleFonts.poppins(
|
||||
// fontSize: 12,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: Color(0xFF575A74),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: 5),
|
||||
// CustomTextFieldUserTravellerWrapper(
|
||||
// width:
|
||||
// widget.isDesktop
|
||||
// ? MediaQuery.of(context).size.width * 0.15
|
||||
// : null,
|
||||
// isFocused: false,
|
||||
// isDesktop: widget.isDesktop,
|
||||
// child: SizedBox(
|
||||
// height: 40,
|
||||
// child: GestureDetector(
|
||||
// onTap: () async {
|
||||
// await _selectValidUpToDate(context);
|
||||
// },
|
||||
// child: AbsorbPointer(
|
||||
// child: TextField(
|
||||
// // focusNode: _dateFocusNode,
|
||||
// // controller: _dateController,
|
||||
// controller: entry["controller_valid_upto"],
|
||||
// style: const TextStyle(fontSize: 12),
|
||||
// decoration: const InputDecoration(
|
||||
// labelText: "Select Date",
|
||||
// labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
|
||||
// floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||
// border: InputBorder.none,
|
||||
// contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||
// suffixIcon: Icon(
|
||||
// Icons.calendar_today,
|
||||
// size: 16,
|
||||
// color: Colors.grey,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget IconForVisa() {
|
||||
return Container(
|
||||
height: 60, // must define height
|
||||
|
||||
Loading…
Reference in New Issue
Block a user