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(
focusNode: _checkOutFocusNode,
controller: _checkOutController,
style: const TextStyle(fontSize: 12),
style: const TextStyle(fontSize: 12, color: Colors.black),
decoration: const InputDecoration(
labelText: "Select Date",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey),

View File

@ -327,7 +327,8 @@ class _BusScreenState extends State<BusScreen> {
child: DropdownButtonFormField<String>(
focusNode: _tripTypeFocusNode, // Assign the correct focus node
value: selectedPurpose,
style: TextStyle(fontSize: 12),
// style: TextStyle(fontSize: 12),
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
decoration: InputDecoration(
border: InputBorder.none,
contentPadding:
@ -561,7 +562,7 @@ class _BusScreenState extends State<BusScreen> {
child: TextField(
focusNode: _timeFocusNode,
controller: _timeController,
style: const TextStyle(fontSize: 12),
style: const TextStyle(fontSize: 12, color: Colors.black),
decoration: const InputDecoration(
labelText: "Select Time",
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:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
@ -39,16 +40,18 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
final FocusNode _fromFocusNode = FocusNode();
final FocusNode _dateFocusNode = FocusNode();
final FocusNode _commentsFocusNode = FocusNode();
final FocusNode _nomineeFocusNode = FocusNode();
late TextEditingController _tripTypeController = TextEditingController();
late TextEditingController _startdateController = TextEditingController();
late TextEditingController _endDateController = TextEditingController();
late TextEditingController _insuranceCommentsController =
TextEditingController();
late TextEditingController _insuranceCommentsController = TextEditingController();
late TextEditingController _nomineeController = TextEditingController();
bool _isHotelNameFocused = false;
bool _dateFocus = false;
bool _commentsFocus = false;
bool _nomineeFocus = false;
String? selectedTripType;
String? selectedInsuranceType;
@ -61,6 +64,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
"start_date": _startdateController.text,
"end_date": _endDateController.text,
"comments": _insuranceCommentsController.text,
"nominee_name" : _nomineeController.text,
"created_by": widget.loginUser,
"updated_by": widget.loginUser,
};
@ -98,12 +102,20 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
});
});
_nomineeFocusNode.addListener(() {
setState(() {
_nomineeFocus = _nomineeFocusNode.hasFocus;
});
});
_insuranceCommentsController =
TextEditingController(text: widget.selectedItem?["comments"] ?? "");
_startdateController =
TextEditingController(text: widget.selectedItem?["start_date"] ?? "");
_endDateController =
TextEditingController(text: widget.selectedItem?['end_date'] ?? "");
_nomineeController =
TextEditingController(text: widget.selectedItem?['nominee_name'] ?? "");
// Set the selected value if available
if (widget.selectedItem != null &&
@ -249,6 +261,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
_tripTypeController.dispose();
_startdateController.dispose();
_insuranceCommentsController.dispose();
_nomineeController.dispose();
super.dispose();
}
@ -311,7 +324,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Insurance Type",
"Insurance Type", // not in use
style: GoogleFonts.poppins(
fontSize: 12,
fontWeight: FontWeight.w500,
@ -370,7 +383,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
child: DropdownButtonFormField<String>(
focusNode: _tripTypeFocusNode, // Assign the correct focus node
value: selectedInsuranceType,
style: TextStyle(fontSize: 12),
style: GoogleFonts.poppins(fontSize: 12, color: Colors.black),
decoration: InputDecoration(
border: InputBorder.none,
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<dynamic> purposeList =
widget.apiData?['insurance_type_of_insurance'] ?? [];
@ -524,47 +624,103 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
}
}
return [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Insurance Type *",
style: GoogleFonts.poppins(
fontSize: 12,
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.w500,
fontWeight: FontWeight.w600,
color: Color(0xFF575A74)),
),
SizedBox(height: 5),
CustomTextFieldWrapper(
isFocused: _isHotelNameFocused,
isFocused: _nomineeFocus,
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(
height: 40,
child: DropdownButtonFormField<String>(
focusNode: _tripTypeFocusNode, // Assign the correct focus node
value: selectedInsuranceType,
child: TextField(
focusNode: _nomineeFocusNode,
controller: _nomineeController,
style: TextStyle(fontSize: 12),
decoration: InputDecoration(
labelText: "Nominee",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
floatingLabelBehavior: FloatingLabelBehavior.never,
border: InputBorder.none,
contentPadding:
EdgeInsets.symmetric(horizontal: 10), // Proper padding
contentPadding: EdgeInsets.symmetric(vertical: 16),
// 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,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",
labelText: "Select ",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
floatingLabelBehavior: FloatingLabelBehavior.never,
border: InputBorder.none,
@ -682,7 +838,7 @@ class _InsuranceScreenState extends State<InsuranceScreen> {
controller: _endDateController,
style: const TextStyle(fontSize: 12),
decoration: const InputDecoration(
labelText: "Select Date",
labelText: "Select ",
labelStyle: TextStyle(fontSize: 12, color: Colors.grey),
floatingLabelBehavior: FloatingLabelBehavior.never,
border: InputBorder.none,

View File

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

View File

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