This commit is contained in:
Surendiran 2025-06-07 18:17:20 +05:30
commit b157fc40a7
5 changed files with 192 additions and 35 deletions

View File

@ -817,7 +817,7 @@ class _AccomodationScreenState extends State<AccomodationScreen> {
child: TextField( child: TextField(
focusNode: _checkOutFocusNode, focusNode: _checkOutFocusNode,
controller: _checkOutController, controller: _checkOutController,
style: const TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12, color: Colors.black),
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: "Select Date", labelText: "Select Date",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey), labelStyle: TextStyle(fontSize: 12, color: Colors.grey),

View File

@ -327,7 +327,8 @@ class _BusScreenState extends State<BusScreen> {
child: DropdownButtonFormField<String>( child: DropdownButtonFormField<String>(
focusNode: _tripTypeFocusNode, // Assign the correct focus node focusNode: _tripTypeFocusNode, // Assign the correct focus node
value: selectedPurpose, value: selectedPurpose,
style: TextStyle(fontSize: 12), // style: TextStyle(fontSize: 12),
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
contentPadding: contentPadding:
@ -561,7 +562,7 @@ class _BusScreenState extends State<BusScreen> {
child: TextField( child: TextField(
focusNode: _timeFocusNode, focusNode: _timeFocusNode,
controller: _timeController, controller: _timeController,
style: const TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12, color: Colors.black),
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: "Select Time", labelText: "Select Time",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey), labelStyle: TextStyle(fontSize: 12, color: Colors.grey),

View File

@ -1,3 +1,4 @@
import 'package:dropdown_search/dropdown_search.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
@ -39,16 +40,18 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
final FocusNode _fromFocusNode = FocusNode(); final FocusNode _fromFocusNode = FocusNode();
final FocusNode _dateFocusNode = FocusNode(); final FocusNode _dateFocusNode = FocusNode();
final FocusNode _commentsFocusNode = FocusNode(); final FocusNode _commentsFocusNode = FocusNode();
final FocusNode _nomineeFocusNode = FocusNode();
late TextEditingController _tripTypeController = TextEditingController(); late TextEditingController _tripTypeController = TextEditingController();
late TextEditingController _startdateController = TextEditingController(); late TextEditingController _startdateController = TextEditingController();
late TextEditingController _endDateController = TextEditingController(); late TextEditingController _endDateController = TextEditingController();
late TextEditingController _insuranceCommentsController = late TextEditingController _insuranceCommentsController = TextEditingController();
TextEditingController(); late TextEditingController _nomineeController = TextEditingController();
bool _isHotelNameFocused = false; bool _isHotelNameFocused = false;
bool _dateFocus = false; bool _dateFocus = false;
bool _commentsFocus = false; bool _commentsFocus = false;
bool _nomineeFocus = false;
String? selectedTripType; String? selectedTripType;
String? selectedInsuranceType; String? selectedInsuranceType;
@ -61,6 +64,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
"start_date": _startdateController.text, "start_date": _startdateController.text,
"end_date": _endDateController.text, "end_date": _endDateController.text,
"comments": _insuranceCommentsController.text, "comments": _insuranceCommentsController.text,
"nominee_name" : _nomineeController.text,
"created_by": widget.loginUser, "created_by": widget.loginUser,
"updated_by": widget.loginUser, "updated_by": widget.loginUser,
}; };
@ -98,12 +102,20 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
}); });
}); });
_nomineeFocusNode.addListener(() {
setState(() {
_nomineeFocus = _nomineeFocusNode.hasFocus;
});
});
_insuranceCommentsController = _insuranceCommentsController =
TextEditingController(text: widget.selectedItem?["comments"] ?? ""); TextEditingController(text: widget.selectedItem?["comments"] ?? "");
_startdateController = _startdateController =
TextEditingController(text: widget.selectedItem?["start_date"] ?? ""); TextEditingController(text: widget.selectedItem?["start_date"] ?? "");
_endDateController = _endDateController =
TextEditingController(text: widget.selectedItem?['end_date'] ?? ""); TextEditingController(text: widget.selectedItem?['end_date'] ?? "");
_nomineeController =
TextEditingController(text: widget.selectedItem?['nominee_name'] ?? "");
// Set the selected value if available // Set the selected value if available
if (widget.selectedItem != null && if (widget.selectedItem != null &&
@ -249,6 +261,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
_tripTypeController.dispose(); _tripTypeController.dispose();
_startdateController.dispose(); _startdateController.dispose();
_insuranceCommentsController.dispose(); _insuranceCommentsController.dispose();
_nomineeController.dispose();
super.dispose(); super.dispose();
} }
@ -311,7 +324,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Insurance Type", "Insurance Type", // not in use
style: GoogleFonts.poppins( style: GoogleFonts.poppins(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@ -370,7 +383,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
child: DropdownButtonFormField<String>( child: DropdownButtonFormField<String>(
focusNode: _tripTypeFocusNode, // Assign the correct focus node focusNode: _tripTypeFocusNode, // Assign the correct focus node
value: selectedInsuranceType, value: selectedInsuranceType,
style: TextStyle(fontSize: 12), style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
contentPadding: contentPadding:
@ -396,6 +409,93 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
]; ];
} }
List<Widget> _buildInsuranceTypeDropdown(bool isDesktop) {
// List<dynamic> purposeList = widget.apiData?['insurance_type_of_insurance'] ?? [];
List<Map<String, dynamic>> purposeList = (widget.apiData?['insurance_type_of_insurance'] as List<dynamic>?)
?.map((e) => Map<String, dynamic>.from(e as Map))
.toList() ?? [];
// Find selected item object based on key
Map<String, dynamic>? selectedItem = purposeList.firstWhere(
(item) => item['dropdown_key'] == selectedInsuranceType,
orElse: () => {},
);
return [
CustomTextFieldWrapper(
isFocused: false,
isDesktop: isDesktop,
child: SizedBox(
height: 35,
width: double.infinity,
child: DropdownSearch<Map<String, dynamic>>(
popupProps: PopupProps.menu(
showSearchBox: false,
fit: FlexFit.loose,
constraints: BoxConstraints(maxHeight: 10),
menuProps: const MenuProps(backgroundColor: Colors.white),
itemBuilder: (context, item, isSelected) {
return Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 8,
),
child: Text(
item['dropdown_value'] ?? '',
style: GoogleFonts.poppins(
fontSize: 12, // 👈 Smaller font size
color: Colors.black,
),
),
);
},
),
dropdownDecoratorProps: const DropDownDecoratorProps(
dropdownSearchDecoration: InputDecoration(
border: InputBorder.none, // No underline
contentPadding: EdgeInsets.symmetric(
horizontal: 10,
vertical: 5,
),
),
),
dropdownBuilder: (context, selectedItem) {
if (selectedItem == null || selectedItem.isEmpty) {
return Text(
"Select Insurance Type",
style: GoogleFonts.poppins(color: Colors.grey, fontSize: 13),
);
}
return Text(
selectedItem['dropdown_value'] ?? '',
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
);
},
selectedItem: selectedItem!.isNotEmpty ? selectedItem : null,
itemAsString: (item) => item['dropdown_value'] ?? '',
onChanged: purposeList.isNotEmpty
? (Map<String, dynamic>? newItem) {
if (newItem != null) {
setState(() {
selectedInsuranceType = newItem['dropdown_key'];
errorMessages.remove("type_of_insurance");
});
print("Selected Insurance Type: $selectedInsuranceType");
}
}
: null,
items: purposeList,
),
),
),
];
}
List<Widget> _buildSecondRow(bool isDesktop) { List<Widget> _buildSecondRow(bool isDesktop) {
List<dynamic> purposeList = List<dynamic> purposeList =
widget.apiData?['insurance_type_of_insurance'] ?? []; widget.apiData?['insurance_type_of_insurance'] ?? [];
@ -524,6 +624,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
} }
} }
return [ return [
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
@ -533,38 +634,93 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
style: GoogleFonts.poppins( style: GoogleFonts.poppins(
fontSize: 12, fontSize: 12,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
color: const Color(0xFF575A74),
),
),
const SizedBox(height: 5),
// Dropdown Wrapper
CustomTextFieldWrapper(
isFocused: _isHotelNameFocused,
isDesktop: isDesktop,
width: isDesktop ? MediaQuery.of(context).size.width * 0.17 : null,
child: SizedBox(
height: 35,
width: double.infinity,
child: DropdownButtonFormField<String>(
focusNode: _tripTypeFocusNode,
value: selectedInsuranceType,
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
decoration: const InputDecoration(
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
),
hint: Text(
"Select ",
style: GoogleFonts.poppins(color: Colors.grey, fontSize: 13),
),
items: purposeList.map<DropdownMenuItem<String>>((item) {
return DropdownMenuItem<String>(
value: item['dropdown_key'],
child: Text(
item['dropdown_value'] ?? '',
style: GoogleFonts.poppins(fontSize: 12),
),
);
}).toList(),
onChanged: purposeList.isNotEmpty
? (String? newValue) {
setState(() {
selectedInsuranceType = newValue;
if ((selectedInsuranceType ?? '').isNotEmpty) {
errorMessages.remove("type_of_insurance");
}
});
print("Selected Insurance Type: $selectedInsuranceType");
}
: null,
),
),
),
],
),
if (isDesktop)
Spacer()
else
SizedBox(
height: 8,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Nominee",
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Color(0xFF575A74)), color: Color(0xFF575A74)),
), ),
SizedBox(height: 5), SizedBox(height: 5),
CustomTextFieldWrapper( CustomTextFieldWrapper(
isFocused: _isHotelNameFocused, isFocused: _nomineeFocus,
isDesktop: isDesktop, isDesktop: isDesktop,
width: isDesktop ? MediaQuery.of(context).size.width * 0.34 : null, width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null,
// width: isDesktop ? MediaQuery.of(context).size.width * 0.34 : null,
child: SizedBox( child: SizedBox(
height: 40, height: 40,
child: DropdownButtonFormField<String>( child: TextField(
focusNode: _tripTypeFocusNode, // Assign the correct focus node focusNode: _nomineeFocusNode,
value: selectedInsuranceType, controller: _nomineeController,
style: TextStyle(fontSize: 12), style: TextStyle(fontSize: 12),
decoration: InputDecoration( decoration: InputDecoration(
labelText: "Nominee",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
floatingLabelBehavior: FloatingLabelBehavior.never,
border: InputBorder.none, border: InputBorder.none,
contentPadding: contentPadding: EdgeInsets.symmetric(vertical: 16),
EdgeInsets.symmetric(horizontal: 10), // Proper padding // contentPadding: EdgeInsets.symmetric(horizontal: 1,vertical: 1),
), ),
onChanged: purposeList.isNotEmpty
? (newValue) {
setState(() {
selectedInsuranceType = newValue;
if (selectedInsuranceType!.isNotEmpty) {
errorMessages.remove("type_of_insurance");
}
});
print(selectedInsuranceType);
}
: null,
items: dropdownItems,
), ),
), ),
), ),
@ -609,7 +765,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
controller: _startdateController, controller: _startdateController,
style: const TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: "Select Date", labelText: "Select ",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey), labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
floatingLabelBehavior: FloatingLabelBehavior.never, floatingLabelBehavior: FloatingLabelBehavior.never,
border: InputBorder.none, border: InputBorder.none,
@ -682,7 +838,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
controller: _endDateController, controller: _endDateController,
style: const TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: "Select Date", labelText: "Select ",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey), labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
floatingLabelBehavior: FloatingLabelBehavior.never, floatingLabelBehavior: FloatingLabelBehavior.never,
border: InputBorder.none, border: InputBorder.none,

View File

@ -968,7 +968,7 @@ class _ListPlansState extends State<ListPlans> {
height: 15, height: 15,
), ),
tooltip: tooltip:
'Edit Trip/Plans Details', 'Edit Trip Details',
onPressed: () { onPressed: () {
Navigator.pop( Navigator.pop(
context, context,
@ -1222,7 +1222,7 @@ class _ListPlansState extends State<ListPlans> {
height: 15, height: 15,
), ),
tooltip: tooltip:
'Edit Trip/plan Details', 'Edit Trip Details',
onPressed: () { onPressed: () {
Navigator.pop( Navigator.pop(
context, context,

View File

@ -42,7 +42,7 @@ class UserActionsMenu extends StatelessWidget {
children: [ children: [
GestureDetector( GestureDetector(
child: Tooltip( child: Tooltip(
message: 'View User Details', message: 'View Details',
child: Icon(Icons.remove_red_eye, child: Icon(Icons.remove_red_eye,
color: Color(0xFF475569), size: 18) color: Color(0xFF475569), size: 18)
), ),
@ -61,7 +61,7 @@ class UserActionsMenu extends StatelessWidget {
SizedBox(width: 8), SizedBox(width: 8),
GestureDetector( GestureDetector(
child: Tooltip( child: Tooltip(
message: 'Edit User Details', message: 'Edit Details',
child: Image.asset( child: Image.asset(
'assets/images/IconsImg/edit.png', 'assets/images/IconsImg/edit.png',
width: 20, width: 20,