merge
This commit is contained in:
parent
20a24c7d46
commit
a8712dcb68
@ -387,7 +387,7 @@ class _AccomodationScreenState extends State<AccomodationScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(28.0),
|
padding: const EdgeInsets.only(top: 30.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -13,12 +13,13 @@ class BusScreen extends StatefulWidget {
|
|||||||
final Map<String, dynamic>? selectedItem;
|
final Map<String, dynamic>? selectedItem;
|
||||||
final String? loginUser;
|
final String? loginUser;
|
||||||
|
|
||||||
BusScreen(
|
BusScreen({
|
||||||
{required this.onClose,
|
required this.onClose,
|
||||||
this.apiData,
|
this.apiData,
|
||||||
required this.onSaveBus,
|
required this.onSaveBus,
|
||||||
required this.selectedItem,
|
required this.selectedItem,
|
||||||
required this.loginUser});
|
required this.loginUser,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_BusScreenState createState() => _BusScreenState();
|
_BusScreenState createState() => _BusScreenState();
|
||||||
@ -195,51 +196,54 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ResponsiveBuilder(builder: (context, sizingInfo) {
|
return ResponsiveBuilder(
|
||||||
bool isMobile = sizingInfo.isMobile;
|
builder: (context, sizingInfo) {
|
||||||
bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
bool isMobile = sizingInfo.isMobile;
|
||||||
|
bool isDesktop =
|
||||||
|
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
// color: Colors.white,
|
// color: Colors.white,
|
||||||
child: Form(
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
// Align(
|
// Align(
|
||||||
// alignment: Alignment.centerRight,
|
// alignment: Alignment.centerRight,
|
||||||
// child: InkWell(
|
// child: InkWell(
|
||||||
// onTap: () {
|
// onTap: () {
|
||||||
// widget.onClose(false);
|
// widget.onClose(false);
|
||||||
// },
|
// },
|
||||||
// child: Icon(
|
// child: Icon(
|
||||||
// Icons.close,
|
// Icons.close,
|
||||||
// size: 18,
|
// size: 18,
|
||||||
// color: Color(0xFF575A74),
|
// color: Color(0xFF575A74),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// ),
|
// ),
|
||||||
// Text("Bus Booking List",
|
// Text("Bus Booking List",
|
||||||
// style: TextStyle(
|
// style: TextStyle(
|
||||||
// fontSize: 18,
|
// fontSize: 18,
|
||||||
// fontWeight: FontWeight.bold,
|
// fontWeight: FontWeight.bold,
|
||||||
// color: Color(0xFF575A74))),
|
// color: Color(0xFF575A74))),
|
||||||
// SizedBox(
|
// SizedBox(
|
||||||
// height: 6,
|
// height: 6,
|
||||||
// ),
|
// ),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(28.0),
|
padding: const EdgeInsets.only(top: 30.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildAccomadtionForm(bool isDesktop) {
|
List<Widget> _buildAccomadtionForm(bool isDesktop) {
|
||||||
@ -252,7 +256,7 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
|
|
||||||
List<List<Widget>> rowBuilders = [
|
List<List<Widget>> rowBuilders = [
|
||||||
// _builClassType(isDesktop),
|
// _builClassType(isDesktop),
|
||||||
_buildSecondRow(isDesktop)
|
_buildSecondRow(isDesktop),
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -275,41 +279,42 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
Text(
|
Text(
|
||||||
"Trip Type",
|
"Trip Type",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
isDesktop
|
isDesktop
|
||||||
? Row(children: _buildTripType(isDesktop))
|
? Row(children: _buildTripType(isDesktop))
|
||||||
: Column(children: _buildTripType(isDesktop))
|
: Column(children: _buildTripType(isDesktop)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (isDesktop)
|
if (isDesktop) Spacer() else SizedBox(height: 8),
|
||||||
Spacer()
|
|
||||||
else
|
|
||||||
SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildTripType(bool isDesktop) {
|
List<Widget> _buildTripType(bool isDesktop) {
|
||||||
List<dynamic> purposeList = widget.apiData?['flight_trip_type'] ?? [];
|
List<dynamic> purposeList = widget.apiData?['flight_trip_type'] ?? [];
|
||||||
|
|
||||||
List<DropdownMenuItem<String>> dropdownItems = purposeList
|
List<DropdownMenuItem<String>> dropdownItems =
|
||||||
.map((item) => DropdownMenuItem<String>(
|
purposeList
|
||||||
value: item['dropdown_key'],
|
.map(
|
||||||
child: Text(item['dropdown_value']),
|
(item) => DropdownMenuItem<String>(
|
||||||
))
|
value: item['dropdown_key'],
|
||||||
.toList();
|
child: Text(item['dropdown_value']),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
if (dropdownItems.isEmpty) {
|
if (dropdownItems.isEmpty) {
|
||||||
dropdownItems.add(
|
dropdownItems.add(
|
||||||
DropdownMenuItem<String>(
|
DropdownMenuItem<String>(
|
||||||
value: null,
|
value: null,
|
||||||
child: Text("No options available",
|
child: Text(
|
||||||
style: TextStyle(color: Colors.grey)),
|
"No options available",
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -331,18 +336,21 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
|
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
contentPadding:
|
contentPadding: EdgeInsets.symmetric(
|
||||||
EdgeInsets.symmetric(horizontal: 10), // Proper padding
|
horizontal: 10,
|
||||||
|
), // Proper padding
|
||||||
),
|
),
|
||||||
onChanged: purposeList.isNotEmpty
|
onChanged:
|
||||||
? (newValue) {
|
purposeList.isNotEmpty
|
||||||
setState(() {
|
? (newValue) {
|
||||||
selectedPurpose = newValue;
|
setState(() {
|
||||||
});
|
selectedPurpose = newValue;
|
||||||
print(
|
});
|
||||||
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}");
|
print(
|
||||||
}
|
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}",
|
||||||
: null,
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
|
||||||
items: dropdownItems,
|
items: dropdownItems,
|
||||||
),
|
),
|
||||||
@ -361,10 +369,11 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
|
|
||||||
DateTime? pickedDate = await showDatePicker(
|
DateTime? pickedDate = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate: _selectedCheckOutDate != null &&
|
initialDate:
|
||||||
_selectedCheckOutDate!.isAfter(today)
|
_selectedCheckOutDate != null &&
|
||||||
? _selectedCheckOutDate!
|
_selectedCheckOutDate!.isAfter(today)
|
||||||
: today,
|
? _selectedCheckOutDate!
|
||||||
|
: today,
|
||||||
firstDate: today,
|
firstDate: today,
|
||||||
lastDate: DateTime(2100),
|
lastDate: DateTime(2100),
|
||||||
);
|
);
|
||||||
@ -399,11 +408,10 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
pickedTime.minute,
|
pickedTime.minute,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
final isToday =
|
final isToday =
|
||||||
selectedDate.year == now.year &&
|
selectedDate.year == now.year &&
|
||||||
selectedDate.month == now.month &&
|
selectedDate.month == now.month &&
|
||||||
selectedDate.day == now.day;
|
selectedDate.day == now.day;
|
||||||
|
|
||||||
bool isPastTime = selectedDateTime.isBefore(now);
|
bool isPastTime = selectedDateTime.isBefore(now);
|
||||||
|
|
||||||
@ -411,19 +419,26 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
errorMessages["time"] = "You can't select a past time.";
|
errorMessages["time"] = "You can't select a past time.";
|
||||||
_selectedCheckOutTime = null; // ✅ Reset time variable
|
_selectedCheckOutTime = null; // ✅ Reset time variable
|
||||||
_timeController.text = ""; // ✅ Clear text field
|
_timeController.text = ""; // ✅ Clear text field
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}else{ setState(() {
|
} else {
|
||||||
_selectedCheckOutTime = pickedTime;
|
setState(() {
|
||||||
// Formatting time to HH:mm (24-hour format)
|
_selectedCheckOutTime = pickedTime;
|
||||||
final now = DateTime.now();
|
// Formatting time to HH:mm (24-hour format)
|
||||||
final formattedTime = DateFormat('HH:mm').format(
|
final now = DateTime.now();
|
||||||
DateTime(now.year, now.month, now.day, pickedTime.hour,
|
final formattedTime = DateFormat('HH:mm').format(
|
||||||
pickedTime.minute),
|
DateTime(
|
||||||
);
|
now.year,
|
||||||
_timeController.text = formattedTime;
|
now.month,
|
||||||
}); }
|
now.day,
|
||||||
|
pickedTime.hour,
|
||||||
|
pickedTime.minute,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
_timeController.text = formattedTime;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,9 +449,10 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
Text(
|
Text(
|
||||||
"From *",
|
"From *",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldItnerarySubWrapper(
|
CustomTextFieldItnerarySubWrapper(
|
||||||
@ -460,28 +476,21 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
),
|
),
|
||||||
if (errorMessages["from"] != null) ...[
|
if (errorMessages["from"] != null) ...[
|
||||||
SizedBox(height: 5), // Space before error message
|
SizedBox(height: 5), // Space before error message
|
||||||
Text(
|
Text("Required", style: TextStyle(color: Colors.red, fontSize: 12)),
|
||||||
"Required",
|
|
||||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (isDesktop)
|
if (isDesktop) Spacer() else SizedBox(height: 8),
|
||||||
Spacer()
|
|
||||||
else
|
|
||||||
SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"To *",
|
"To *",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldItnerarySubWrapper(
|
CustomTextFieldItnerarySubWrapper(
|
||||||
@ -505,28 +514,21 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
),
|
),
|
||||||
if (errorMessages["to"] != null) ...[
|
if (errorMessages["to"] != null) ...[
|
||||||
SizedBox(height: 5), // Space before error message
|
SizedBox(height: 5), // Space before error message
|
||||||
Text(
|
Text("Required", style: TextStyle(color: Colors.red, fontSize: 12)),
|
||||||
"Required",
|
|
||||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (isDesktop)
|
if (isDesktop) Spacer() else SizedBox(height: 8),
|
||||||
Spacer()
|
|
||||||
else
|
|
||||||
SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Date *",
|
"Date *",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldItnerarySubWrapper(
|
CustomTextFieldItnerarySubWrapper(
|
||||||
@ -547,8 +549,11 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||||
suffixIcon: Icon(Icons.calendar_today,
|
suffixIcon: Icon(
|
||||||
size: 16, color: Colors.grey),
|
Icons.calendar_today,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -557,28 +562,21 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
),
|
),
|
||||||
if (errorMessages["date"] != null) ...[
|
if (errorMessages["date"] != null) ...[
|
||||||
SizedBox(height: 5), // Space before error message
|
SizedBox(height: 5), // Space before error message
|
||||||
Text(
|
Text("Required", style: TextStyle(color: Colors.red, fontSize: 12)),
|
||||||
"Required",
|
|
||||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (isDesktop)
|
if (isDesktop) Spacer() else SizedBox(height: 8),
|
||||||
Spacer()
|
|
||||||
else
|
|
||||||
SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Time *",
|
"Time *",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldItnerarySubWrapper(
|
CustomTextFieldItnerarySubWrapper(
|
||||||
@ -599,8 +597,11 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||||
suffixIcon:
|
suffixIcon: Icon(
|
||||||
Icon(Icons.access_time, size: 16, color: Colors.grey),
|
Icons.access_time,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -627,9 +628,10 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
Text(
|
Text(
|
||||||
"Comments",
|
"Comments",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldWrapper(
|
CustomTextFieldWrapper(
|
||||||
@ -675,9 +677,7 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.grey[400], // Light grey color
|
backgroundColor: Colors.grey[400], // Light grey color
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -686,7 +686,6 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10), // Space between buttons
|
SizedBox(width: 10), // Space between buttons
|
||||||
|
|
||||||
// Save Changes Button
|
// Save Changes Button
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -694,9 +693,7 @@ class _BusScreenState extends State<BusScreen> {
|
|||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Color(0xFF114D8B), // Primary color for save
|
backgroundColor: Color(0xFF114D8B), // Primary color for save
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@ -1203,7 +1203,8 @@ class _ForexScreenState extends State<ForexScreen> {
|
|||||||
// height: 8,
|
// height: 8,
|
||||||
// ),
|
// ),
|
||||||
if (isDesktop)
|
if (isDesktop)
|
||||||
SizedBox(width: MediaQuery.of(context).size.width * 0.048)
|
Spacer()
|
||||||
|
// SizedBox(width: MediaQuery.of(context).size.width * 0.048)
|
||||||
else
|
else
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
Column(
|
Column(
|
||||||
|
|||||||
@ -14,13 +14,14 @@ class MiscellaneousScreen extends StatefulWidget {
|
|||||||
final int? selectedIndex;
|
final int? selectedIndex;
|
||||||
final String? loginUser;
|
final String? loginUser;
|
||||||
|
|
||||||
MiscellaneousScreen(
|
MiscellaneousScreen({
|
||||||
{required this.onClose,
|
required this.onClose,
|
||||||
required this.apiData,
|
required this.apiData,
|
||||||
required this.onSaveMiscellaneous,
|
required this.onSaveMiscellaneous,
|
||||||
this.selectedItem,
|
this.selectedItem,
|
||||||
this.selectedIndex,
|
this.selectedIndex,
|
||||||
required this.loginUser});
|
required this.loginUser,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MiscellaneousScreenState createState() => _MiscellaneousScreenState();
|
_MiscellaneousScreenState createState() => _MiscellaneousScreenState();
|
||||||
@ -87,8 +88,9 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
_commentsController =
|
_commentsController = TextEditingController(
|
||||||
TextEditingController(text: widget.selectedItem?["comments"] ?? "");
|
text: widget.selectedItem?["comments"] ?? "",
|
||||||
|
);
|
||||||
|
|
||||||
// Set the selected value if available
|
// Set the selected value if available
|
||||||
if (widget.selectedItem != null &&
|
if (widget.selectedItem != null &&
|
||||||
@ -143,29 +145,32 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ResponsiveBuilder(builder: (context, sizingInfo) {
|
return ResponsiveBuilder(
|
||||||
bool isMobile = sizingInfo.isMobile;
|
builder: (context, sizingInfo) {
|
||||||
bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
bool isMobile = sizingInfo.isMobile;
|
||||||
|
bool isDesktop =
|
||||||
|
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
child: Form(
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(28.0),
|
padding: const EdgeInsets.only(top: 30.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildAccomadtionForm(bool isDesktop) {
|
List<Widget> _buildAccomadtionForm(bool isDesktop) {
|
||||||
@ -193,14 +198,15 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
Text(
|
Text(
|
||||||
"Special Type *",
|
"Special Type *",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
isDesktop
|
isDesktop
|
||||||
? Row(children: _buildTripType(isDesktop))
|
? Row(children: _buildTripType(isDesktop))
|
||||||
: Column(children: _buildTripType(isDesktop))
|
: Column(children: _buildTripType(isDesktop)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
@ -211,19 +217,24 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
widget.apiData?['miscellaneous_special_request'] ?? [];
|
widget.apiData?['miscellaneous_special_request'] ?? [];
|
||||||
// selectedInsuranceType = purposeList.isNotEmpty ? purposeList.first['dropdown_value'] : null;
|
// selectedInsuranceType = purposeList.isNotEmpty ? purposeList.first['dropdown_value'] : null;
|
||||||
|
|
||||||
List<DropdownMenuItem<String>> dropdownItems = purposeList
|
List<DropdownMenuItem<String>> dropdownItems =
|
||||||
.map((item) => DropdownMenuItem<String>(
|
purposeList
|
||||||
value: item['dropdown_key'],
|
.map(
|
||||||
child: Text(item['dropdown_value']),
|
(item) => DropdownMenuItem<String>(
|
||||||
))
|
value: item['dropdown_key'],
|
||||||
.toList();
|
child: Text(item['dropdown_value']),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
if (dropdownItems.isEmpty) {
|
if (dropdownItems.isEmpty) {
|
||||||
dropdownItems.add(
|
dropdownItems.add(
|
||||||
DropdownMenuItem<String>(
|
DropdownMenuItem<String>(
|
||||||
value: null,
|
value: null,
|
||||||
child: Text("No options available",
|
child: Text(
|
||||||
style: TextStyle(color: Colors.grey)),
|
"No options available",
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -236,9 +247,10 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
CustomTextFieldWrapper(
|
CustomTextFieldWrapper(
|
||||||
isFocused: _isHotelNameFocused,
|
isFocused: _isHotelNameFocused,
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
width: isDesktop
|
width:
|
||||||
? MediaQuery.of(context).size.width * 0.34
|
isDesktop
|
||||||
: MediaQuery.of(context).size.width * 0.66,
|
? MediaQuery.of(context).size.width * 0.34
|
||||||
|
: MediaQuery.of(context).size.width * 0.66,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
child: DropdownButtonFormField<String>(
|
child: DropdownButtonFormField<String>(
|
||||||
@ -247,28 +259,27 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
style: TextStyle(fontSize: 12),
|
style: TextStyle(fontSize: 12),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
contentPadding:
|
contentPadding: EdgeInsets.symmetric(
|
||||||
EdgeInsets.symmetric(horizontal: 10), // Proper padding
|
horizontal: 10,
|
||||||
|
), // Proper padding
|
||||||
),
|
),
|
||||||
onChanged: purposeList.isNotEmpty
|
onChanged:
|
||||||
? (newValue) {
|
purposeList.isNotEmpty
|
||||||
setState(() {
|
? (newValue) {
|
||||||
selectedSpecialType = newValue;
|
setState(() {
|
||||||
});
|
selectedSpecialType = newValue;
|
||||||
|
});
|
||||||
|
|
||||||
print(selectedSpecialType);
|
print(selectedSpecialType);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
items: dropdownItems,
|
items: dropdownItems,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (errorMessages["special_request"] != null) ...[
|
if (errorMessages["special_request"] != null) ...[
|
||||||
SizedBox(height: 5), // Space before error message
|
SizedBox(height: 5), // Space before error message
|
||||||
Text(
|
Text("Required", style: TextStyle(color: Colors.red, fontSize: 12)),
|
||||||
"Required",
|
|
||||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -281,17 +292,19 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
Text(
|
Text(
|
||||||
"Comments *",
|
"Comments *",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldWrapper(
|
CustomTextFieldWrapper(
|
||||||
isFocused: _commentsFocus, // Dropdown doesn't use focus
|
isFocused: _commentsFocus, // Dropdown doesn't use focus
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
width: isDesktop
|
width:
|
||||||
? MediaQuery.of(context).size.width * 0.34
|
isDesktop
|
||||||
: MediaQuery.of(context).size.width * 0.66,
|
? MediaQuery.of(context).size.width * 0.34
|
||||||
|
: MediaQuery.of(context).size.width * 0.66,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
@ -310,17 +323,12 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
),
|
),
|
||||||
if (errorMessages["comments"] != null) ...[
|
if (errorMessages["comments"] != null) ...[
|
||||||
SizedBox(height: 5), // Space before error message
|
SizedBox(height: 5), // Space before error message
|
||||||
Text(
|
Text("Required", style: TextStyle(color: Colors.red, fontSize: 12)),
|
||||||
"Required",
|
|
||||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (isDesktop) Spacer(),
|
if (isDesktop) Spacer(),
|
||||||
SizedBox(
|
SizedBox(height: 5),
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: _handleAction(isDesktop),
|
children: _handleAction(isDesktop),
|
||||||
@ -338,9 +346,7 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.grey[400], // Light grey color
|
backgroundColor: Colors.grey[400], // Light grey color
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -349,7 +355,6 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10), // Space between buttons
|
SizedBox(width: 10), // Space between buttons
|
||||||
|
|
||||||
// Save Changes Button
|
// Save Changes Button
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -357,9 +362,7 @@ class _MiscellaneousScreenState extends State<MiscellaneousScreen> {
|
|||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Color(0xFF114D8B), // Primary color for save
|
backgroundColor: Color(0xFF114D8B), // Primary color for save
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@ -99,7 +99,7 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
|
|
||||||
_addFocusListener(
|
_addFocusListener(
|
||||||
_destinationFocusNode,
|
_destinationFocusNode,
|
||||||
(focus) => _destinationFocus = focus,
|
(focus) => _destinationFocus = focus,
|
||||||
);
|
);
|
||||||
_addFocusListener(_locationFocusNode, (focus) => _locationFocus = focus);
|
_addFocusListener(_locationFocusNode, (focus) => _locationFocus = focus);
|
||||||
_addFocusListener(_dateFocusNode, (focus) => _dateFocus = focus);
|
_addFocusListener(_dateFocusNode, (focus) => _dateFocus = focus);
|
||||||
@ -107,7 +107,7 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
_addFocusListener(_taxiReqFocusNode, (focus) => _taxiReqFocused = focus);
|
_addFocusListener(_taxiReqFocusNode, (focus) => _taxiReqFocused = focus);
|
||||||
_addFocusListener(
|
_addFocusListener(
|
||||||
_numPassengerFocusNode,
|
_numPassengerFocusNode,
|
||||||
(focus) => _numPassengerFocus = focus,
|
(focus) => _numPassengerFocus = focus,
|
||||||
);
|
);
|
||||||
_addFocusListener(_commentsFocusNode, (focus) => _commentsFocus = focus);
|
_addFocusListener(_commentsFocusNode, (focus) => _commentsFocus = focus);
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(28.0),
|
padding: const EdgeInsets.only(top: 30.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
||||||
),
|
),
|
||||||
@ -262,14 +262,14 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
List<dynamic> purposeList = widget.apiData?['taxt_car_type'] ?? [];
|
List<dynamic> purposeList = widget.apiData?['taxt_car_type'] ?? [];
|
||||||
|
|
||||||
List<DropdownMenuItem<String>> dropdownItems =
|
List<DropdownMenuItem<String>> dropdownItems =
|
||||||
purposeList
|
purposeList
|
||||||
.map(
|
.map(
|
||||||
(item) => DropdownMenuItem<String>(
|
(item) => DropdownMenuItem<String>(
|
||||||
value: item['dropdown_key'],
|
value: item['dropdown_key'],
|
||||||
child: Text(item['dropdown_value']),
|
child: Text(item['dropdown_value']),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (dropdownItems.isEmpty) {
|
if (dropdownItems.isEmpty) {
|
||||||
dropdownItems.add(
|
dropdownItems.add(
|
||||||
@ -285,7 +285,7 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
|
|
||||||
// Default selected value
|
// Default selected value
|
||||||
selectedCarType ??=
|
selectedCarType ??=
|
||||||
dropdownItems.isNotEmpty ? dropdownItems.first.value : null;
|
dropdownItems.isNotEmpty ? dropdownItems.first.value : null;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Column(
|
Column(
|
||||||
@ -378,16 +378,16 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
), // Proper padding
|
), // Proper padding
|
||||||
),
|
),
|
||||||
onChanged:
|
onChanged:
|
||||||
purposeList.isNotEmpty
|
purposeList.isNotEmpty
|
||||||
? (newValue) {
|
? (newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedCarType = newValue;
|
selectedCarType = newValue;
|
||||||
});
|
});
|
||||||
print(
|
print(
|
||||||
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}",
|
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
|
|
||||||
items: dropdownItems,
|
items: dropdownItems,
|
||||||
),
|
),
|
||||||
@ -403,14 +403,14 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
List<dynamic> purposeList = widget.apiData?['taxi_car_required_for'] ?? [];
|
List<dynamic> purposeList = widget.apiData?['taxi_car_required_for'] ?? [];
|
||||||
|
|
||||||
List<DropdownMenuItem<String>> dropdownItems =
|
List<DropdownMenuItem<String>> dropdownItems =
|
||||||
purposeList
|
purposeList
|
||||||
.map(
|
.map(
|
||||||
(item) => DropdownMenuItem<String>(
|
(item) => DropdownMenuItem<String>(
|
||||||
value: item['dropdown_key'],
|
value: item['dropdown_key'],
|
||||||
child: Text(item['dropdown_value']),
|
child: Text(item['dropdown_value']),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (dropdownItems.isEmpty) {
|
if (dropdownItems.isEmpty) {
|
||||||
dropdownItems.add(
|
dropdownItems.add(
|
||||||
@ -426,16 +426,16 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
|
|
||||||
// Default selected value
|
// Default selected value
|
||||||
selectedReqTaxi ??=
|
selectedReqTaxi ??=
|
||||||
dropdownItems.isNotEmpty ? dropdownItems.first.value : null;
|
dropdownItems.isNotEmpty ? dropdownItems.first.value : null;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
CustomTextFieldWrapper(
|
CustomTextFieldWrapper(
|
||||||
isFocused: _taxiReqFocused,
|
isFocused: _taxiReqFocused,
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
width:
|
width:
|
||||||
isDesktop
|
isDesktop
|
||||||
? MediaQuery.of(context).size.width * 0.34
|
? MediaQuery.of(context).size.width * 0.34
|
||||||
: MediaQuery.of(context).size.width * 0.66,
|
: MediaQuery.of(context).size.width * 0.66,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
child: DropdownButtonFormField<String>(
|
child: DropdownButtonFormField<String>(
|
||||||
@ -449,16 +449,16 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
), // Proper padding
|
), // Proper padding
|
||||||
),
|
),
|
||||||
onChanged:
|
onChanged:
|
||||||
purposeList.isNotEmpty
|
purposeList.isNotEmpty
|
||||||
? (newValue) {
|
? (newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedReqTaxi = newValue;
|
selectedReqTaxi = newValue;
|
||||||
});
|
});
|
||||||
print(
|
print(
|
||||||
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}",
|
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
|
|
||||||
items: dropdownItems,
|
items: dropdownItems,
|
||||||
),
|
),
|
||||||
@ -478,10 +478,10 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
DateTime? pickedDate = await showDatePicker(
|
DateTime? pickedDate = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialDate:
|
initialDate:
|
||||||
_selectedCheckOutDate != null &&
|
_selectedCheckOutDate != null &&
|
||||||
_selectedCheckOutDate!.isAfter(today)
|
_selectedCheckOutDate!.isAfter(today)
|
||||||
? _selectedCheckOutDate!
|
? _selectedCheckOutDate!
|
||||||
: today,
|
: today,
|
||||||
firstDate: today,
|
firstDate: today,
|
||||||
lastDate: DateTime(2100),
|
lastDate: DateTime(2100),
|
||||||
);
|
);
|
||||||
@ -516,11 +516,10 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
pickedTime.minute,
|
pickedTime.minute,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
final isToday =
|
final isToday =
|
||||||
selectedDate.year == now.year &&
|
selectedDate.year == now.year &&
|
||||||
selectedDate.month == now.month &&
|
selectedDate.month == now.month &&
|
||||||
selectedDate.day == now.day;
|
selectedDate.day == now.day;
|
||||||
|
|
||||||
bool isPastTime = selectedDateTime.isBefore(now);
|
bool isPastTime = selectedDateTime.isBefore(now);
|
||||||
|
|
||||||
@ -528,20 +527,27 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
errorMessages["time"] = "You can't select a past time.";
|
errorMessages["time"] = "You can't select a past time.";
|
||||||
_selectedCheckOutTime = null; // ✅ Reset time variable
|
_selectedCheckOutTime = null; // ✅ Reset time variable
|
||||||
_timeController.text = ""; // ✅ Clear text field
|
_timeController.text = ""; // ✅ Clear text field
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}else{ setState(() {
|
} else {
|
||||||
_selectedCheckOutTime = pickedTime;
|
setState(() {
|
||||||
// Formatting time to HH:mm (24-hour format)
|
_selectedCheckOutTime = pickedTime;
|
||||||
final now = DateTime.now();
|
// Formatting time to HH:mm (24-hour format)
|
||||||
final formattedTime = DateFormat('HH:mm').format(
|
final now = DateTime.now();
|
||||||
DateTime(now.year, now.month, now.day, pickedTime.hour,
|
final formattedTime = DateFormat('HH:mm').format(
|
||||||
pickedTime.minute),
|
DateTime(
|
||||||
);
|
now.year,
|
||||||
errorMessages["time"] = "";
|
now.month,
|
||||||
_timeController.text = formattedTime;
|
now.day,
|
||||||
}); }
|
pickedTime.hour,
|
||||||
|
pickedTime.minute,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
errorMessages["time"] = "";
|
||||||
|
_timeController.text = formattedTime;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -713,7 +719,10 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => _selectCheckOutTime(context),
|
onTap: () {
|
||||||
|
_timeController.text = "";
|
||||||
|
_selectCheckOutTime(context);
|
||||||
|
},
|
||||||
child: AbsorbPointer(
|
child: AbsorbPointer(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
focusNode: _timeFocusNode,
|
focusNode: _timeFocusNode,
|
||||||
@ -739,7 +748,10 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
if (errorMessages["time"] != null) ...[
|
if (errorMessages["time"] != 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("Required", style: TextStyle(color: Colors.red, fontSize: 12)),
|
||||||
Text(errorMessages["time"]!, style: TextStyle(color: Colors.red, fontSize: 12)),
|
Text(
|
||||||
|
errorMessages["time"]!,
|
||||||
|
style: TextStyle(color: Colors.red, fontSize: 12),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -764,9 +776,9 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
isFocused: _commentsFocus, // Dropdown doesn't use focus
|
isFocused: _commentsFocus, // Dropdown doesn't use focus
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
width:
|
width:
|
||||||
isDesktop
|
isDesktop
|
||||||
? MediaQuery.of(context).size.width * 0.34
|
? MediaQuery.of(context).size.width * 0.34
|
||||||
: MediaQuery.of(context).size.width * 0.66,
|
: MediaQuery.of(context).size.width * 0.66,
|
||||||
|
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
@ -834,4 +846,4 @@ class _TaxiScreenState extends State<TaxiScreen> {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -324,7 +324,7 @@ class _TrainScreenState extends State<TrainScreen> {
|
|||||||
// height: 6,
|
// height: 6,
|
||||||
// ),
|
// ),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(28.0),
|
padding: const EdgeInsets.only(top: 30.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -18,14 +18,15 @@ class VisaScreen extends StatefulWidget {
|
|||||||
final Map<String, dynamic>? selectedItem;
|
final Map<String, dynamic>? selectedItem;
|
||||||
final String? loginUser;
|
final String? loginUser;
|
||||||
|
|
||||||
VisaScreen(
|
VisaScreen({
|
||||||
{required this.onClose,
|
required this.onClose,
|
||||||
required this.onSaveVisa,
|
required this.onSaveVisa,
|
||||||
this.apiData,
|
this.apiData,
|
||||||
required this.selectedItem,
|
required this.selectedItem,
|
||||||
required this.apiCountryData,
|
required this.apiCountryData,
|
||||||
required this.loginUser,
|
required this.loginUser,
|
||||||
required this.flightData});
|
required this.flightData,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_VisaScreenState createState() => _VisaScreenState();
|
_VisaScreenState createState() => _VisaScreenState();
|
||||||
@ -99,14 +100,18 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
|
|
||||||
_addFocusListener(_tripTypeFocusNode, (focus) => _tripTypeFocused = focus);
|
_addFocusListener(_tripTypeFocusNode, (focus) => _tripTypeFocused = focus);
|
||||||
_addFocusListener(
|
_addFocusListener(
|
||||||
_hotelNameFocusNode, (focus) => _isHotelNameFocused = focus);
|
_hotelNameFocusNode,
|
||||||
|
(focus) => _isHotelNameFocused = focus,
|
||||||
|
);
|
||||||
_addFocusListener(_dateFocusNode, (focus) => _dateFocus = focus);
|
_addFocusListener(_dateFocusNode, (focus) => _dateFocus = focus);
|
||||||
_addFocusListener(_commentsFocusNode, (focus) => _commentsFocus = focus);
|
_addFocusListener(_commentsFocusNode, (focus) => _commentsFocus = focus);
|
||||||
|
|
||||||
_visaCommentsController =
|
_visaCommentsController = TextEditingController(
|
||||||
TextEditingController(text: widget.selectedItem?["comments"] ?? "");
|
text: widget.selectedItem?["comments"] ?? "",
|
||||||
_dateController =
|
);
|
||||||
TextEditingController(text: widget.selectedItem?["start_date"] ?? "");
|
_dateController = TextEditingController(
|
||||||
|
text: widget.selectedItem?["start_date"] ?? "",
|
||||||
|
);
|
||||||
|
|
||||||
// Set the selected value if available
|
// Set the selected value if available
|
||||||
if (widget.selectedItem != null &&
|
if (widget.selectedItem != null &&
|
||||||
@ -130,8 +135,9 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
// ✅ Only set controller after value is updated
|
// ✅ Only set controller after value is updated
|
||||||
// final parsedDate =
|
// final parsedDate =
|
||||||
// DateTime.tryParse(flightFirstTripDateNotifier.value ?? '');
|
// DateTime.tryParse(flightFirstTripDateNotifier.value ?? '');
|
||||||
final parsedDate = DateFormat("dd-MM-yyyy")
|
final parsedDate = DateFormat(
|
||||||
.parse(flightFirstTripDateNotifier.value ?? '');
|
"dd-MM-yyyy",
|
||||||
|
).parse(flightFirstTripDateNotifier.value ?? '');
|
||||||
if (parsedDate != null) {
|
if (parsedDate != null) {
|
||||||
_dateController.text = DateFormat('dd-MM-yyyy').format(parsedDate);
|
_dateController.text = DateFormat('dd-MM-yyyy').format(parsedDate);
|
||||||
}
|
}
|
||||||
@ -181,17 +187,16 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String?> getFlightTripDateRange(
|
Map<String, String?> getFlightTripDateRange(
|
||||||
List<Map<String, dynamic>> flightData) {
|
List<Map<String, dynamic>> flightData,
|
||||||
final allTrips = flightData
|
) {
|
||||||
.expand((flight) => flight['trips'] ?? [])
|
final allTrips =
|
||||||
.whereType<Map<String, dynamic>>()
|
flightData
|
||||||
.toList();
|
.expand((flight) => flight['trips'] ?? [])
|
||||||
|
.whereType<Map<String, dynamic>>()
|
||||||
|
.toList();
|
||||||
|
|
||||||
if (allTrips.isEmpty) {
|
if (allTrips.isEmpty) {
|
||||||
return {
|
return {'firstTripDate': null, 'lastTripDate': null};
|
||||||
'firstTripDate': null,
|
|
||||||
'lastTripDate': null,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allTrips.sort((a, b) {
|
allTrips.sort((a, b) {
|
||||||
@ -229,7 +234,7 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
List<String> requiredFields = [
|
List<String> requiredFields = [
|
||||||
"type_of_visa",
|
"type_of_visa",
|
||||||
"country_code",
|
"country_code",
|
||||||
"start_date"
|
"start_date",
|
||||||
];
|
];
|
||||||
|
|
||||||
// Check validation for each field
|
// Check validation for each field
|
||||||
@ -260,29 +265,32 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ResponsiveBuilder(builder: (context, sizingInfo) {
|
return ResponsiveBuilder(
|
||||||
bool isMobile = sizingInfo.isMobile;
|
builder: (context, sizingInfo) {
|
||||||
bool isDesktop = sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
bool isMobile = sizingInfo.isMobile;
|
||||||
|
bool isDesktop =
|
||||||
|
sizingInfo.deviceScreenType == DeviceScreenType.desktop;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
child: Form(
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(28.0),
|
padding: const EdgeInsets.only(top: 30.0),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
child: Column(children: _buildAccomadtionForm(isDesktop)),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
});
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildAccomadtionForm(bool isDesktop) {
|
List<Widget> _buildAccomadtionForm(bool isDesktop) {
|
||||||
@ -308,14 +316,7 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildFirstRow(isDesktop) {
|
List<Widget> _buildFirstRow(isDesktop) {
|
||||||
return [
|
return [if (isDesktop) Spacer() else SizedBox(height: 8)];
|
||||||
if (isDesktop)
|
|
||||||
Spacer()
|
|
||||||
else
|
|
||||||
SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _buildTripType(bool isDesktop) {
|
List<Widget> _buildTripType(bool isDesktop) {
|
||||||
@ -354,7 +355,7 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
// Map country codes to country names
|
// Map country codes to country names
|
||||||
countryMap = {
|
countryMap = {
|
||||||
for (var item in countryList)
|
for (var item in countryList)
|
||||||
item['country_code'] as String: item['country_name'] as String
|
item['country_code'] as String: item['country_name'] as String,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extract only country codes for processing
|
// Extract only country codes for processing
|
||||||
@ -417,19 +418,24 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
|
|
||||||
List<dynamic> purposeList = widget.apiData?['visa_type_of_visa'] ?? [];
|
List<dynamic> purposeList = widget.apiData?['visa_type_of_visa'] ?? [];
|
||||||
|
|
||||||
List<DropdownMenuItem<String>> dropdownItems = purposeList
|
List<DropdownMenuItem<String>> dropdownItems =
|
||||||
.map((item) => DropdownMenuItem<String>(
|
purposeList
|
||||||
value: item['dropdown_key'],
|
.map(
|
||||||
child: Text(item['dropdown_value']),
|
(item) => DropdownMenuItem<String>(
|
||||||
))
|
value: item['dropdown_key'],
|
||||||
.toList();
|
child: Text(item['dropdown_value']),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
if (dropdownItems.isEmpty) {
|
if (dropdownItems.isEmpty) {
|
||||||
dropdownItems.add(
|
dropdownItems.add(
|
||||||
DropdownMenuItem<String>(
|
DropdownMenuItem<String>(
|
||||||
value: null,
|
value: null,
|
||||||
child: Text("No options available",
|
child: Text(
|
||||||
style: TextStyle(color: Colors.grey)),
|
"No options available",
|
||||||
|
style: TextStyle(color: Colors.grey),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -438,25 +444,26 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
selectedPurpose ??=
|
selectedPurpose ??=
|
||||||
dropdownItems.isNotEmpty ? dropdownItems.first.value : null;
|
dropdownItems.isNotEmpty ? dropdownItems.first.value : null;
|
||||||
return [
|
return [
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Country *",
|
"Country *",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldWrapper(
|
CustomTextFieldWrapper(
|
||||||
isFocused: _isHotelNameFocused,
|
isFocused: _isHotelNameFocused,
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
// width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null,
|
// width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null,
|
||||||
width: isDesktop
|
width:
|
||||||
? MediaQuery.of(context).size.width * 0.34
|
isDesktop
|
||||||
: MediaQuery.of(context).size.width * 0.66,
|
? MediaQuery.of(context).size.width * 0.34
|
||||||
|
: MediaQuery.of(context).size.width * 0.66,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
child: DropdownSearch<String>(
|
child: DropdownSearch<String>(
|
||||||
@ -474,25 +481,25 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
dropdownDecoratorProps: DropDownDecoratorProps(
|
dropdownDecoratorProps: DropDownDecoratorProps(
|
||||||
dropdownSearchDecoration: InputDecoration(
|
dropdownSearchDecoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
contentPadding: EdgeInsets.symmetric(
|
contentPadding: EdgeInsets.symmetric(horizontal: 1),
|
||||||
horizontal: 1,
|
),
|
||||||
|
),
|
||||||
|
dropdownBuilder:
|
||||||
|
(context, selectedItem) => Align(
|
||||||
|
// Center-align selected item
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Text(
|
||||||
|
selectedItem ?? "Select ",
|
||||||
|
style: TextStyle(fontSize: 12),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
dropdownBuilder: (context, selectedItem) => Align(
|
|
||||||
// Center-align selected item
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: Text(
|
|
||||||
selectedItem ?? "Select ",
|
|
||||||
style: TextStyle(fontSize: 12),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onChanged: (String? newValue) {
|
onChanged: (String? newValue) {
|
||||||
setState(() {
|
setState(() {
|
||||||
// Find the country_code based on selected country_name
|
// Find the country_code based on selected country_name
|
||||||
selectedCountry = countryMap.entries
|
selectedCountry =
|
||||||
.firstWhere((entry) => entry.value == newValue)
|
countryMap.entries
|
||||||
.key;
|
.firstWhere((entry) => entry.value == newValue)
|
||||||
|
.key;
|
||||||
|
|
||||||
if (selectedCountry!.isNotEmpty) {
|
if (selectedCountry!.isNotEmpty) {
|
||||||
errorMessages.remove("country_code");
|
errorMessages.remove("country_code");
|
||||||
@ -504,29 +511,22 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
),
|
),
|
||||||
if (errorMessages["country_code"] != null) ...[
|
if (errorMessages["country_code"] != null) ...[
|
||||||
SizedBox(height: 5), // Space before error message
|
SizedBox(height: 5), // Space before error message
|
||||||
Text(
|
Text("Required", style: TextStyle(color: Colors.red, fontSize: 12)),
|
||||||
"Required",
|
|
||||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
||||||
if (isDesktop)
|
if (isDesktop) Spacer() else SizedBox(height: 8),
|
||||||
Spacer()
|
|
||||||
else
|
|
||||||
SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Type of Visa",
|
"Type of Visa",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldWrapper(
|
CustomTextFieldWrapper(
|
||||||
@ -544,18 +544,21 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
style: TextStyle(fontSize: 12),
|
style: TextStyle(fontSize: 12),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
contentPadding:
|
contentPadding: EdgeInsets.symmetric(
|
||||||
EdgeInsets.symmetric(horizontal: 10), // Proper padding
|
horizontal: 10,
|
||||||
|
), // Proper padding
|
||||||
),
|
),
|
||||||
onChanged: purposeList.isNotEmpty
|
onChanged:
|
||||||
? (newValue) {
|
purposeList.isNotEmpty
|
||||||
setState(() {
|
? (newValue) {
|
||||||
selectedPurpose = newValue;
|
setState(() {
|
||||||
});
|
selectedPurpose = newValue;
|
||||||
print(
|
});
|
||||||
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}");
|
print(
|
||||||
}
|
"Updating form data: Flight -> trip_type -> ${newValue ?? ""}",
|
||||||
: null,
|
);
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
|
||||||
items: dropdownItems,
|
items: dropdownItems,
|
||||||
),
|
),
|
||||||
@ -563,28 +566,21 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
),
|
),
|
||||||
if (errorMessages["type_of_visa"] != null) ...[
|
if (errorMessages["type_of_visa"] != null) ...[
|
||||||
SizedBox(height: 5), // Space before error message
|
SizedBox(height: 5), // Space before error message
|
||||||
Text(
|
Text("Required", style: TextStyle(color: Colors.red, fontSize: 12)),
|
||||||
"Required",
|
|
||||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (isDesktop)
|
if (isDesktop) Spacer() else SizedBox(height: 8),
|
||||||
Spacer()
|
|
||||||
else
|
|
||||||
SizedBox(
|
|
||||||
height: 8,
|
|
||||||
),
|
|
||||||
Column(
|
Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Start Date *",
|
"Start Date *",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldWrapper(
|
CustomTextFieldWrapper(
|
||||||
@ -613,8 +609,11 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
floatingLabelBehavior: FloatingLabelBehavior.never,
|
floatingLabelBehavior: FloatingLabelBehavior.never,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
contentPadding: EdgeInsets.symmetric(vertical: 16),
|
||||||
suffixIcon: Icon(Icons.calendar_today,
|
suffixIcon: Icon(
|
||||||
size: 16, color: Colors.grey),
|
Icons.calendar_today,
|
||||||
|
size: 16,
|
||||||
|
color: Colors.grey,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -623,10 +622,7 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
),
|
),
|
||||||
if (errorMessages["start_date"] != null) ...[
|
if (errorMessages["start_date"] != null) ...[
|
||||||
SizedBox(height: 5), // Space before error message
|
SizedBox(height: 5), // Space before error message
|
||||||
Text(
|
Text("Required", style: TextStyle(color: Colors.red, fontSize: 12)),
|
||||||
"Required",
|
|
||||||
style: TextStyle(color: Colors.red, fontSize: 12),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -641,17 +637,19 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
Text(
|
Text(
|
||||||
"Comments",
|
"Comments",
|
||||||
style: GoogleFonts.poppins(
|
style: GoogleFonts.poppins(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Color(0xFF575A74)),
|
color: Color(0xFF575A74),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 5),
|
SizedBox(height: 5),
|
||||||
CustomTextFieldWrapper(
|
CustomTextFieldWrapper(
|
||||||
isFocused: _commentsFocus, // Dropdown doesn't use focus
|
isFocused: _commentsFocus, // Dropdown doesn't use focus
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
width: isDesktop
|
width:
|
||||||
? MediaQuery.of(context).size.width * 0.34
|
isDesktop
|
||||||
: MediaQuery.of(context).size.width * 0.66,
|
? MediaQuery.of(context).size.width * 0.34
|
||||||
|
: MediaQuery.of(context).size.width * 0.66,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
child: TextField(
|
child: TextField(
|
||||||
@ -671,9 +669,7 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (isDesktop) Spacer(),
|
if (isDesktop) Spacer(),
|
||||||
SizedBox(
|
SizedBox(height: 5),
|
||||||
height: 5,
|
|
||||||
),
|
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@ -694,9 +690,7 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Colors.grey[400], // Light grey color
|
backgroundColor: Colors.grey[400], // Light grey color
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
@ -705,7 +699,6 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(width: 10), // Space between buttons
|
SizedBox(width: 10), // Space between buttons
|
||||||
|
|
||||||
// Save Changes Button
|
// Save Changes Button
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@ -713,9 +706,7 @@ class _VisaScreenState extends State<VisaScreen> {
|
|||||||
},
|
},
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: Color(0xFF114D8B), // Primary color for save
|
backgroundColor: Color(0xFF114D8B), // Primary color for save
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
padding: EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
|||||||
@ -903,10 +903,15 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
apiCostData = plansJson;
|
apiCostData = plansJson;
|
||||||
|
|
||||||
|
print("apiCostData...1");
|
||||||
costCenterMap = {
|
costCenterMap = {
|
||||||
for (var item in apiCostData!)
|
for (var item in apiCostData!)
|
||||||
|
// item['department_id'].toString(): item['name'].toString(),
|
||||||
item['cost_center_id'].toString(): item['name'].toString(),
|
item['cost_center_id'].toString(): item['name'].toString(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
print("apiCostData...122");
|
||||||
costCenterIds = costCenterMap.keys.toList();
|
costCenterIds = costCenterMap.keys.toList();
|
||||||
|
|
||||||
// Optionally auto-select the first item if not already selected
|
// Optionally auto-select the first item if not already selected
|
||||||
@ -1030,8 +1035,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
// Handle Submit
|
// Handle Submit
|
||||||
|
|
||||||
bool validateForm() {
|
bool validateForm() {
|
||||||
|
print("validateForm");
|
||||||
validationErrors.clear(); // Clear previous errors
|
validationErrors.clear(); // Clear previous errors
|
||||||
|
print("validateForm.....1");
|
||||||
// Ensure either "user_id" or "traveller_id" is provided
|
// Ensure either "user_id" or "traveller_id" is provided
|
||||||
if ((planUsrId == null || planUsrId!.isEmpty) &&
|
if ((planUsrId == null || planUsrId!.isEmpty) &&
|
||||||
(planTravlrId == null || planTravlrId!.isEmpty)) {
|
(planTravlrId == null || planTravlrId!.isEmpty)) {
|
||||||
@ -1040,7 +1046,7 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
validationErrors["traveller_id"] =
|
validationErrors["traveller_id"] =
|
||||||
"Either User ID or Traveller ID is required";
|
"Either User ID or Traveller ID is required";
|
||||||
}
|
}
|
||||||
|
print("validateForm.....2");
|
||||||
final requiredFields = {
|
final requiredFields = {
|
||||||
if (TripPlanAction != "Plan Creation Not Allowed") //
|
if (TripPlanAction != "Plan Creation Not Allowed") //
|
||||||
"trip_type": _selectedTripType,
|
"trip_type": _selectedTripType,
|
||||||
@ -1049,14 +1055,14 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
"functional_department": selectedFuncDept,
|
"functional_department": selectedFuncDept,
|
||||||
"purpose_of_travel": selectedPurpose,
|
"purpose_of_travel": selectedPurpose,
|
||||||
};
|
};
|
||||||
|
print("validateForm.....3");
|
||||||
for (var entry in requiredFields.entries) {
|
for (var entry in requiredFields.entries) {
|
||||||
if (entry.value == null || entry.value!.isEmpty) {
|
if (entry.value == null || entry.value!.isEmpty) {
|
||||||
validationErrors[entry.key] = "Required";
|
validationErrors[entry.key] = "Required";
|
||||||
// "${entry.key.replaceAll('_', ' ').toUpperCase()} Required";
|
// "${entry.key.replaceAll('_', ' ').toUpperCase()} Required";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
print("validateForm.....1");
|
||||||
// Validate at least one service is selected
|
// Validate at least one service is selected
|
||||||
final serviceLists = [
|
final serviceLists = [
|
||||||
flightList,
|
flightList,
|
||||||
@ -1179,7 +1185,9 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
|
|
||||||
void handleSubmit() {
|
void handleSubmit() {
|
||||||
setState(() async {
|
setState(() async {
|
||||||
|
print("Hansle Submit....11");
|
||||||
if (validateForm() && temporaryMessage == null) {
|
if (validateForm() && temporaryMessage == null) {
|
||||||
|
print("Hansle Submit....11222");
|
||||||
// if (selectedPlanId != null && selectedPlanId!.isNotEmpty) {
|
// if (selectedPlanId != null && selectedPlanId!.isNotEmpty) {
|
||||||
// planData['plan_id'] = selectedPlanId; // Add plan_id for update
|
// planData['plan_id'] = selectedPlanId; // Add plan_id for update
|
||||||
// }
|
// }
|
||||||
@ -1251,6 +1259,26 @@ class CreateNewPlansState extends State<CreateNewPlan> {
|
|||||||
} else {
|
} else {
|
||||||
print("Failed to submit plan. Status: ${response.statusCode}");
|
print("Failed to submit plan. Status: ${response.statusCode}");
|
||||||
print("Error: ${response.body}");
|
print("Error: ${response.body}");
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text("Trip Creation Failed"),
|
||||||
|
content: Text(
|
||||||
|
"There was a problem submitting your plan. Please try again.",
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
child: Text("OK"),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print(" Error submitting plan: $e");
|
print(" Error submitting plan: $e");
|
||||||
|
|||||||
@ -101,6 +101,12 @@ class DynamicItineraryState extends State<DynamicItinerary> {
|
|||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
|
|
||||||
if (widget.tripType != _tripType) {
|
if (widget.tripType != _tripType) {
|
||||||
|
// setState(() {
|
||||||
|
// selectedOption = "";
|
||||||
|
// isSelected = false;
|
||||||
|
// selectedIndex = null;
|
||||||
|
// selectedItem = null;
|
||||||
|
// });
|
||||||
updateTripType(widget.tripType);
|
updateTripType(widget.tripType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user