diff --git a/lib/Screens/itnerary/forex.dart b/lib/Screens/itnerary/forex.dart index 1994b19..efc0c04 100644 --- a/lib/Screens/itnerary/forex.dart +++ b/lib/Screens/itnerary/forex.dart @@ -1145,6 +1145,51 @@ class _ForexScreenState extends State { ), ), SizedBox(height: 5), + // CustomTextFieldForexWrapper( + // isFocused: focusStates["_countries"] ?? false, + // isDesktop: isDesktop, + // child: SizedBox( + // height: 40, + // child: DropdownSearch( + // selectedItem: countryMap[selectedCountry], + // popupProps: PopupProps.menu( + // showSearchBox: true, // Enables search functionality + // searchFieldProps: TextFieldProps( + // decoration: InputDecoration( + // hintText: "Search ...", + // contentPadding: EdgeInsets.symmetric(horizontal: 10), + // ), + // ), + // ), + // items: countryMap.values.toList(), + // dropdownDecoratorProps: DropDownDecoratorProps( + // dropdownSearchDecoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: EdgeInsets.symmetric(horizontal: 1), + // ), + // ), + // dropdownBuilder: + // (context, selectedItem) => Align( + // // Center-align selected item + // alignment: Alignment.centerLeft, + // child: Text( + // selectedItem ?? "Select ", + // style: TextStyle(fontSize: 12), + // ), + // ), + // onChanged: (String? newValue) { + // setState(() { + // // Find the country_code based on selected country_name + // selectedCountry = + // countryMap.entries + // .firstWhere((entry) => entry.value == newValue) + // .key; + // _onCountryChanged(selectedCountry); + // }); + // }, + // ), + // ), + // ), CustomTextFieldForexWrapper( isFocused: focusStates["_countries"] ?? false, isDesktop: isDesktop, @@ -1153,7 +1198,22 @@ class _ForexScreenState extends State { child: DropdownSearch( selectedItem: countryMap[selectedCountry], popupProps: PopupProps.menu( - showSearchBox: true, // Enables search functionality + showSearchBox: true, + fit: FlexFit.loose, + constraints: BoxConstraints(maxHeight: 250), + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: + (context, item, isSelected) => Container( + color: Colors.white, + padding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), + child: Text( + item, + style: GoogleFonts.poppins(fontSize: 11.5), + ), + ), searchFieldProps: TextFieldProps( decoration: InputDecoration( hintText: "Search ...", @@ -1170,13 +1230,15 @@ class _ForexScreenState extends State { ), dropdownBuilder: (context, selectedItem) => Align( - // Center-align selected item - alignment: Alignment.centerLeft, - child: Text( - selectedItem ?? "Select ", - style: TextStyle(fontSize: 12), - ), + alignment: Alignment.centerLeft, + child: Text( + selectedItem ?? "Select ", + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, ), + ), + ), onChanged: (String? newValue) { setState(() { // Find the country_code based on selected country_name diff --git a/lib/Screens/itnerary/insurance.dart b/lib/Screens/itnerary/insurance.dart index 6486cbc..9c6ac2b 100644 --- a/lib/Screens/itnerary/insurance.dart +++ b/lib/Screens/itnerary/insurance.dart @@ -695,56 +695,128 @@ class _InsuranceScreenState extends State { ), const SizedBox(height: 5), + // ▼ Dropdown Wrapper ▼ + // CustomTextFieldWrapper( + // isFocused: _isHotelNameFocused, + // isDesktop: isDesktop, + // width: isDesktop ? MediaQuery.of(context).size.width * 0.31 : null, + // child: SizedBox( + // height: 35, + // width: double.infinity, + // child: DropdownButtonFormField( + // 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>((item) { + // return DropdownMenuItem( + // 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, + // ), + // ), + // ), // ▼ Dropdown Wrapper ▼ CustomTextFieldWrapper( isFocused: _isHotelNameFocused, isDesktop: isDesktop, width: isDesktop ? MediaQuery.of(context).size.width * 0.31 : null, child: SizedBox( - height: 35, + height: 40, width: double.infinity, - child: DropdownButtonFormField( - 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, + child: DropdownSearch>( + items: purposeList.cast>(), + selectedItem: purposeList.firstWhere( + (item) => item['dropdown_key'] == selectedInsuranceType, + orElse: () => {}, + ), + itemAsString: (item) => item['dropdown_value'] ?? '', + popupProps: PopupProps.menu( + showSearchBox: false, + fit: FlexFit.loose, + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: (context, item, isSelected) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + child: Text( + item['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ), + ); + }, + ), + dropdownDecoratorProps: const DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric(horizontal: 10,vertical: 10,), ), ), - hint: Text( - "Select ", - style: GoogleFonts.poppins(color: Colors.grey, fontSize: 13), - ), - items: - purposeList.map>((item) { - return DropdownMenuItem( - value: item['dropdown_key'], - child: Text( - item['dropdown_value'] ?? '', - style: GoogleFonts.poppins(fontSize: 12), - ), - ); - }).toList(), + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select ", + style: GoogleFonts.poppins( + color: Colors.grey, + fontSize: 13, + ), + ); + } + return Text( + selectedItem['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ); + }, onChanged: - purposeList.isNotEmpty - ? (String? newValue) { - setState(() { - selectedInsuranceType = newValue; - if ((selectedInsuranceType ?? '').isNotEmpty) { - errorMessages.remove("type_of_insurance"); - } - }); - print( - "Selected Insurance Type: $selectedInsuranceType", - ); - } - : null, + purposeList.isNotEmpty + ? (Map? newValue) { + setState(() { + selectedInsuranceType= newValue?['dropdown_key']; + print("selected Insurance Type: ${selectedInsuranceType}"); + }); + } + : null, ), ), ), + ], ), diff --git a/lib/Screens/itnerary/miscellaneous.dart b/lib/Screens/itnerary/miscellaneous.dart index 3088666..409bd3d 100644 --- a/lib/Screens/itnerary/miscellaneous.dart +++ b/lib/Screens/itnerary/miscellaneous.dart @@ -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'; @@ -244,36 +245,114 @@ class _MiscellaneousScreenState extends State { dropdownItems.isNotEmpty ? dropdownItems.first.value : "No options"; return [ - CustomTextFieldWrapper( + // CustomTextFieldWrapper( + // isFocused: _isHotelNameFocused, + // isDesktop: isDesktop, + // width: + // isDesktop + // ? MediaQuery.of(context).size.width * 0.34 + // : MediaQuery.of(context).size.width * 0.66, + // child: SizedBox( + // height: 40, + // child: DropdownButtonFormField( + // focusNode: _tripTypeFocusNode, // Assign the correct focus node + // value: selectedSpecialType, + // style: TextStyle(fontSize: 12), + // decoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: EdgeInsets.symmetric( + // horizontal: 10, + // ), // Proper padding + // ), + // onChanged: + // purposeList.isNotEmpty + // ? (newValue) { + // setState(() { + // selectedSpecialType = newValue; + // }); + // + // print(selectedSpecialType); + // } + // : null, + // items: dropdownItems, + // ), + // ), + // ), + CustomTextFieldItnerarySubWrapper( isFocused: _isHotelNameFocused, isDesktop: isDesktop, - width: - isDesktop - ? MediaQuery.of(context).size.width * 0.34 - : MediaQuery.of(context).size.width * 0.66, + width: isDesktop + ? MediaQuery.of(context).size.width * 0.34 + : MediaQuery.of(context).size.width * 0.66, child: SizedBox( height: 40, - child: DropdownButtonFormField( - focusNode: _tripTypeFocusNode, // Assign the correct focus node - value: selectedSpecialType, - style: TextStyle(fontSize: 12), - decoration: InputDecoration( - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric( - horizontal: 10, - ), // Proper padding + width: double.infinity, + child: DropdownSearch>( + // focusNode: _taxiReqFocusNode, + items: purposeList.cast>(), + selectedItem: purposeList.firstWhere( + (item) => item['dropdown_key'] == selectedSpecialType, + orElse: () => {}, ), + itemAsString: (item) => item['dropdown_value'] ?? '', + popupProps: PopupProps.menu( + showSearchBox: false, + fit: FlexFit.loose, + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: (context, item, isSelected) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + child: Text( + item['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ), + ); + }, + ), + dropdownDecoratorProps: const DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), + ), + ), + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select ", + style: GoogleFonts.poppins( + color: Colors.grey, + fontSize: 13, + ), + ); + } + return Text( + selectedItem['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ); + }, onChanged: - purposeList.isNotEmpty - ? (newValue) { - setState(() { - selectedSpecialType = newValue; - }); - - print(selectedSpecialType); - } - : null, - items: dropdownItems, + purposeList.isNotEmpty + ? (newValue) { + setState(() { + selectedSpecialType = newValue as String?; + }); + print( + "Updating form data: -> ${newValue ?? ""}", + ); + } + : null, ), ), ), diff --git a/lib/Screens/itnerary/taxi.dart b/lib/Screens/itnerary/taxi.dart index 116c2f9..2b55e21 100644 --- a/lib/Screens/itnerary/taxi.dart +++ b/lib/Screens/itnerary/taxi.dart @@ -1,3 +1,4 @@ +import 'package:dropdown_search/dropdown_search.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; @@ -362,34 +363,109 @@ class _TaxiScreenState extends State { ), ), SizedBox(height: 5), + // CustomTextFieldItnerarySubWrapper( + // isFocused: _toFocus, + // isDesktop: isDesktop, + // child: SizedBox( + // height: 40, + // child: DropdownButtonFormField( + // focusNode: _toFocusNode, // Assign the correct focus node + // value: selectedCarType, + // style: TextStyle(fontSize: 12), + // decoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: EdgeInsets.symmetric( + // horizontal: 10, + // ), // Proper padding + // ), + // onChanged: + // purposeList.isNotEmpty + // ? (newValue) { + // setState(() { + // selectedCarType = newValue; + // }); + // print( + // "Updating form data: Flight -> trip_type -> ${newValue ?? ""}", + // ); + // } + // : null, + // + // items: dropdownItems, + // ), + // ), + // ), CustomTextFieldItnerarySubWrapper( isFocused: _toFocus, isDesktop: isDesktop, child: SizedBox( height: 40, - child: DropdownButtonFormField( - focusNode: _toFocusNode, // Assign the correct focus node - value: selectedCarType, - style: TextStyle(fontSize: 12), - decoration: InputDecoration( - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric( - horizontal: 10, - ), // Proper padding + width: double.infinity, + child: DropdownSearch>( + // focusNode: _taxiReqFocusNode, + items: purposeList.cast>(), + selectedItem: purposeList.firstWhere( + (item) => item['dropdown_key'] == selectedCarType, + orElse: () => {}, ), + itemAsString: (item) => item['dropdown_value'] ?? '', + popupProps: PopupProps.menu( + showSearchBox: false, + fit: FlexFit.loose, + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: (context, item, isSelected) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + child: Text( + item['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ), + ); + }, + ), + dropdownDecoratorProps: const DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), + ), + ), + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select ", + style: GoogleFonts.poppins( + color: Colors.grey, + fontSize: 13, + ), + ); + } + return Text( + selectedItem['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ); + }, onChanged: - purposeList.isNotEmpty - ? (newValue) { - setState(() { - selectedCarType = newValue; - }); - print( - "Updating form data: Flight -> trip_type -> ${newValue ?? ""}", - ); - } - : null, - - items: dropdownItems, + purposeList.isNotEmpty + ? (newValue) { + setState(() { + selectedCarType = newValue as String?; + }); + print( + "Updating form data: -> ${newValue ?? ""}", + ); + } + : null, ), ), ), @@ -429,38 +505,117 @@ class _TaxiScreenState extends State { dropdownItems.isNotEmpty ? dropdownItems.first.value : null; return [ - CustomTextFieldWrapper( + // CustomTextFieldWrapper( + // isFocused: _taxiReqFocused, + // isDesktop: isDesktop, + // width: + // isDesktop + // ? MediaQuery.of(context).size.width * 0.34 + // : MediaQuery.of(context).size.width * 0.66, + // child: SizedBox( + // height: 40, + // child: DropdownButtonFormField( + // focusNode: _taxiReqFocusNode, // Assign the correct focus node + // value: selectedReqTaxi, + // style: TextStyle(fontSize: 12), + // decoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: EdgeInsets.symmetric( + // horizontal: 10, + // ), // Proper padding + // ), + // onChanged: + // purposeList.isNotEmpty + // ? (newValue) { + // setState(() { + // selectedReqTaxi = newValue; + // }); + // print( + // "Updating form data: Flight -> trip_type -> ${newValue ?? ""}", + // ); + // } + // : null, + // + // items: dropdownItems, + // ), + // ), + // ), + CustomTextFieldItnerarySubWrapper( isFocused: _taxiReqFocused, isDesktop: isDesktop, width: - isDesktop - ? MediaQuery.of(context).size.width * 0.34 - : MediaQuery.of(context).size.width * 0.66, + isDesktop + ? MediaQuery.of(context).size.width * 0.34 + : MediaQuery.of(context).size.width * 0.66, child: SizedBox( height: 40, - child: DropdownButtonFormField( - focusNode: _taxiReqFocusNode, // Assign the correct focus node - value: selectedReqTaxi, - style: TextStyle(fontSize: 12), - decoration: InputDecoration( - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric( - horizontal: 10, - ), // Proper padding + width: double.infinity, + child: DropdownSearch>( + // focusNode: _taxiReqFocusNode, + items: purposeList.cast>(), + selectedItem: purposeList.firstWhere( + (item) => item['dropdown_key'] == selectedReqTaxi, + orElse: () => {}, ), + itemAsString: (item) => item['dropdown_value'] ?? '', + popupProps: PopupProps.menu( + showSearchBox: false, + fit: FlexFit.loose, + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: (context, item, isSelected) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + child: Text( + item['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ), + ); + }, + ), + dropdownDecoratorProps: const DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 10, + ), + ), + ), + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select ", + style: GoogleFonts.poppins( + color: Colors.grey, + fontSize: 13, + ), + ); + } + return Text( + selectedItem['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ); + }, onChanged: - purposeList.isNotEmpty - ? (newValue) { - setState(() { - selectedReqTaxi = newValue; - }); - print( - "Updating form data: Flight -> trip_type -> ${newValue ?? ""}", - ); - } - : null, - - items: dropdownItems, + purposeList.isNotEmpty + ? (newValue) { + setState(() { + selectedReqTaxi = newValue as String?; + }); + print( + "Updating form data: -> ${newValue ?? ""}", + ); + } + : null, ), ), ), @@ -765,7 +920,7 @@ class _TaxiScreenState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Comments *", + "Comments", style: GoogleFonts.poppins( fontSize: 12, fontWeight: FontWeight.w500, diff --git a/lib/Screens/itnerary/train.dart b/lib/Screens/itnerary/train.dart index 8dfc0aa..a48e864 100644 --- a/lib/Screens/itnerary/train.dart +++ b/lib/Screens/itnerary/train.dart @@ -592,34 +592,104 @@ class _TrainScreenState extends State { ), ), SizedBox(height: 5), - CustomTextFieldItnerarySubWrapper( + // CustomTextFieldItnerarySubWrapper( + // isFocused: _isHotelNameFocused, + // isDesktop: isDesktop, + // // width: isDesktop + // // ? MediaQuery.of(context).size.width * 0.34 + // // : MediaQuery.of(context).size.width * 0.66, + // child: SizedBox( + // height: 40, + // child: DropdownButtonFormField( + // focusNode: _hotelNameFocusNode, // Assign the correct focus node + // // controller: _hotelNameController, + // value: selectedClass, + // style: TextStyle(fontSize: 12), + // decoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: EdgeInsets.symmetric( + // horizontal: 10, + // ), // Proper padding + // ), + // onChanged: + // purposeList.isNotEmpty + // ? (newValue) { + // setState(() { + // selectedClass = newValue; + // }); + // } + // : null, + // items: dropdownItems, + // ), + // ), + // ), + CustomTextFieldWrapper( isFocused: _isHotelNameFocused, isDesktop: isDesktop, - // width: isDesktop - // ? MediaQuery.of(context).size.width * 0.34 - // : MediaQuery.of(context).size.width * 0.66, + width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null, child: SizedBox( height: 40, - child: DropdownButtonFormField( - focusNode: _hotelNameFocusNode, // Assign the correct focus node - // controller: _hotelNameController, - value: selectedClass, - style: TextStyle(fontSize: 12), - decoration: InputDecoration( - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric( - horizontal: 10, - ), // Proper padding + width: double.infinity, + child: DropdownSearch>( + items: purposeList.cast>(), + selectedItem: purposeList.firstWhere( + (item) => item['dropdown_key'] == selectedClass, + orElse: () => {}, ), + itemAsString: (item) => item['dropdown_value'] ?? '', + popupProps: PopupProps.menu( + showSearchBox: false, + fit: FlexFit.loose, + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: (context, item, isSelected) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + child: Text( + item['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ), + ); + }, + ), + dropdownDecoratorProps: const DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric(horizontal: 10,vertical: 10,), + ), + ), + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select ", + style: GoogleFonts.poppins( + color: Colors.grey, + fontSize: 13, + ), + ); + } + return Text( + selectedItem['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ); + }, onChanged: - purposeList.isNotEmpty - ? (newValue) { - setState(() { - selectedClass = newValue; - }); - } - : null, - items: dropdownItems, + purposeList.isNotEmpty + ? (Map? newValue) { + setState(() { + selectedClass= newValue?['dropdown_key']; + print("Selected Purpose: ${selectedClass}"); + }); + } + : null, ), ), ), @@ -642,96 +712,158 @@ class _TrainScreenState extends State { ), ), SizedBox(height: 5), + // CustomTextFieldItnerarySubWrapper( + // isFocused: _fromFocus, + // isDesktop: isDesktop, + // child: SizedBox( + // height: 40, + // child: + // isCountryLoading + // ? Center(child: CircularProgressIndicator()) + // : DropdownSearch( + // // selectedItem: selectedFrom != null + // // ? countryMap[selectedFrom] + // // : null, + // selectedItem: + // selectedFrom != null + // ? countryMap[selectedFrom] // get the display value from code + // : null, + // popupProps: PopupProps.menu( + // menuProps: MenuProps(backgroundColor: Colors.white), + // constraints: BoxConstraints(maxHeight: 230), + // showSearchBox: true, + // searchFieldProps: TextFieldProps( + // decoration: InputDecoration( + // hintText: "Search ...", + // contentPadding: EdgeInsets.symmetric( + // horizontal: 10, + // ), + // ), + // ), + // ), + // + // items: countryMap.values.toList(), + // + // dropdownDecoratorProps: DropDownDecoratorProps( + // dropdownSearchDecoration: InputDecoration( + // contentPadding: EdgeInsets.symmetric( + // horizontal: 10, + // vertical: 5, + // ), + // border: InputBorder.none, + // ), + // ), + // dropdownBuilder: + // (context, selectedItem) => Align( + // alignment: Alignment.centerLeft, + // child: Text( + // selectedItem ?? "Select", + // style: TextStyle(fontSize: 12), + // ), + // ), + // + // // onChanged: (String? newValue) { + // // setState(() { + // // // selectedFrom[index] = countryMap.entries + // // // .firstWhere((entry) => entry.value == newValue) + // // // .key; + // // + // // selectedFrom = countryMap.entries + // // .firstWhere((entry) => entry.value == newValue) + // // .key; + // // + // // print(selectedFrom); + // // }); + // // }, + // onChanged: (String? newValue) { + // setState(() { + // selectedFrom = + // countryMap.entries + // .firstWhere( + // (entry) => entry.value == newValue, + // ) + // .key; + // }); + // }, + // ), + // ), + // // child: SizedBox( + // // height: 40, + // // child: TextField( + // // focusNode: _fromFocusNode, + // // controller: _fromController, + // // style: const TextStyle(fontSize: 12), + // // decoration: const InputDecoration( + // // labelText: "From", + // // labelStyle: TextStyle(fontSize: 12, color: Colors.grey), + // // floatingLabelBehavior: FloatingLabelBehavior.never, + // // border: InputBorder.none, + // // contentPadding: EdgeInsets.symmetric(vertical: 16), + // // ), + // // ), + // // ), + // ), CustomTextFieldItnerarySubWrapper( - isFocused: _fromFocus, + isFocused: _fromFocus ?? false, isDesktop: isDesktop, child: SizedBox( height: 40, - child: - isCountryLoading - ? Center(child: CircularProgressIndicator()) - : DropdownSearch( - // selectedItem: selectedFrom != null - // ? countryMap[selectedFrom] - // : null, - selectedItem: - selectedFrom != null - ? countryMap[selectedFrom] // get the display value from code - : null, - popupProps: PopupProps.menu( - menuProps: MenuProps(backgroundColor: Colors.white), - constraints: BoxConstraints(maxHeight: 230), - showSearchBox: true, - searchFieldProps: TextFieldProps( - decoration: InputDecoration( - hintText: "Search ...", - contentPadding: EdgeInsets.symmetric( - horizontal: 10, - ), - ), - ), - ), - - items: countryMap.values.toList(), - - dropdownDecoratorProps: DropDownDecoratorProps( - dropdownSearchDecoration: InputDecoration( - contentPadding: EdgeInsets.symmetric( - horizontal: 10, - vertical: 5, - ), - border: InputBorder.none, - ), - ), - dropdownBuilder: - (context, selectedItem) => Align( - alignment: Alignment.centerLeft, - child: Text( - selectedItem ?? "Select", - style: TextStyle(fontSize: 12), - ), - ), - - // onChanged: (String? newValue) { - // setState(() { - // // selectedFrom[index] = countryMap.entries - // // .firstWhere((entry) => entry.value == newValue) - // // .key; - // - // selectedFrom = countryMap.entries - // .firstWhere((entry) => entry.value == newValue) - // .key; - // - // print(selectedFrom); - // }); - // }, - onChanged: (String? newValue) { - setState(() { - selectedFrom = - countryMap.entries - .firstWhere( - (entry) => entry.value == newValue, - ) - .key; - }); - }, - ), + child: DropdownSearch( + selectedItem: countryMap[selectedFrom], + popupProps: PopupProps.menu( + showSearchBox: true, + fit: FlexFit.loose, + constraints: BoxConstraints(maxHeight: 250), + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: + (context, item, isSelected) => Container( + color: Colors.white, + padding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), + child: Text( + item, + style: GoogleFonts.poppins(fontSize: 11.5), + ), + ), + searchFieldProps: TextFieldProps( + decoration: InputDecoration( + hintText: "Search ...", + contentPadding: EdgeInsets.symmetric(horizontal: 10), + ), + ), + ), + items: countryMap.values.toList(), + dropdownDecoratorProps: DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric(horizontal: 1), + ), + ), + dropdownBuilder: + (context, selectedItem) => Align( + alignment: Alignment.centerLeft, + child: Text( + selectedItem ?? "Select ", + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ), + ), + onChanged: (String? newValue) { + setState(() { + selectedFrom = + countryMap.entries + .firstWhere( + (entry) => entry.value == newValue, + ) + .key; + }); + }, + ), ), - // child: SizedBox( - // height: 40, - // child: TextField( - // focusNode: _fromFocusNode, - // controller: _fromController, - // style: const TextStyle(fontSize: 12), - // decoration: const InputDecoration( - // labelText: "From", - // labelStyle: TextStyle(fontSize: 12, color: Colors.grey), - // floatingLabelBehavior: FloatingLabelBehavior.never, - // border: InputBorder.none, - // contentPadding: EdgeInsets.symmetric(vertical: 16), - // ), - // ), - // ), ), if (errorMessages["from_station"] != null) ...[ SizedBox(height: 5), // Space before error message @@ -752,58 +884,120 @@ class _TrainScreenState extends State { ), ), SizedBox(height: 5), + // CustomTextFieldItnerarySubWrapper( + // isFocused: _toFocus, + // isDesktop: isDesktop, + // child: SizedBox( + // height: 40, + // child: + // isCountryLoading + // ? Center(child: CircularProgressIndicator()) + // : DropdownSearch( + // selectedItem: + // selectedTo != null + // ? countryMap[selectedTo] // get the display value from code + // : null, + // popupProps: PopupProps.menu( + // menuProps: MenuProps(backgroundColor: Colors.white), + // constraints: BoxConstraints(maxHeight: 230), + // showSearchBox: true, + // searchFieldProps: TextFieldProps( + // decoration: InputDecoration( + // hintText: "Search ...", + // contentPadding: EdgeInsets.symmetric( + // horizontal: 10, + // ), + // ), + // ), + // ), + // items: countryMap.values.toList(), + // dropdownDecoratorProps: DropDownDecoratorProps( + // dropdownSearchDecoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: EdgeInsets.symmetric(horizontal: 1), + // ), + // ), + // dropdownBuilder: + // (context, selectedItem) => Align( + // alignment: Alignment.centerLeft, + // child: Text( + // selectedItem ?? "Select", + // style: TextStyle(fontSize: 12), + // ), + // ), + // onChanged: (String? newValue) { + // setState(() { + // selectedTo = + // countryMap.entries + // .firstWhere( + // (entry) => entry.value == newValue, + // ) + // .key; + // }); + // }, + // ), + // ), + // ), CustomTextFieldItnerarySubWrapper( - isFocused: _toFocus, + isFocused: _toFocus ?? false, isDesktop: isDesktop, child: SizedBox( height: 40, - child: - isCountryLoading - ? Center(child: CircularProgressIndicator()) - : DropdownSearch( - selectedItem: - selectedTo != null - ? countryMap[selectedTo] // get the display value from code - : null, - popupProps: PopupProps.menu( - menuProps: MenuProps(backgroundColor: Colors.white), - constraints: BoxConstraints(maxHeight: 230), - showSearchBox: true, - searchFieldProps: TextFieldProps( - decoration: InputDecoration( - hintText: "Search ...", - contentPadding: EdgeInsets.symmetric( - horizontal: 10, - ), - ), - ), - ), - items: countryMap.values.toList(), - dropdownDecoratorProps: DropDownDecoratorProps( - dropdownSearchDecoration: InputDecoration( - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric(horizontal: 1), - ), - ), - dropdownBuilder: - (context, selectedItem) => Align( - alignment: Alignment.centerLeft, - child: Text( - selectedItem ?? "Select", - style: TextStyle(fontSize: 12), - ), - ), - onChanged: (String? newValue) { - setState(() { - selectedTo = - countryMap.entries - .firstWhere( - (entry) => entry.value == newValue, - ) - .key; - }); - }, - ), + child: DropdownSearch( + selectedItem: countryMap[selectedTo], + popupProps: PopupProps.menu( + showSearchBox: true, + fit: FlexFit.loose, + constraints: BoxConstraints(maxHeight: 250), + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: + (context, item, isSelected) => Container( + color: Colors.white, + padding: EdgeInsets.symmetric( + horizontal: 10, + vertical: 6, + ), + child: Text( + item, + style: GoogleFonts.poppins(fontSize: 11.5), + ), + ), + searchFieldProps: TextFieldProps( + decoration: InputDecoration( + hintText: "Search ...", + contentPadding: EdgeInsets.symmetric(horizontal: 10), + ), + ), + ), + items: countryMap.values.toList(), + dropdownDecoratorProps: DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric(horizontal: 1), + ), + ), + dropdownBuilder: + (context, selectedItem) => Align( + alignment: Alignment.centerLeft, + child: Text( + selectedItem ?? "Select ", + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ), + ), + onChanged: (String? newValue) { + setState(() { + selectedTo = + countryMap.entries + .firstWhere( + (entry) => entry.value == newValue, + ) + .key; + }); + }, + ), ), ), if (errorMessages["to_station"] != null) ...[ diff --git a/lib/Screens/itnerary/visa.dart b/lib/Screens/itnerary/visa.dart index b560007..5b025e3 100644 --- a/lib/Screens/itnerary/visa.dart +++ b/lib/Screens/itnerary/visa.dart @@ -457,26 +457,86 @@ class _VisaScreenState extends State { ), ), SizedBox(height: 5), - CustomTextFieldWrapper( + // CustomTextFieldWrapper( + // isFocused: _isHotelNameFocused, + // isDesktop: isDesktop, + // // width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null, + // width: + // isDesktop + // ? MediaQuery.of(context).size.width * 0.34 + // : MediaQuery.of(context).size.width * 0.66, + // child: SizedBox( + // height: 40, + // child: DropdownSearch( + // selectedItem: countryMap[selectedCountry], + // popupProps: PopupProps.menu( + // showSearchBox: true, // Enables search functionality + // searchFieldProps: TextFieldProps( + // decoration: InputDecoration( + // hintText: "Search ...", + // contentPadding: EdgeInsets.symmetric(horizontal: 10), + // ), + // ), + // ), + // items: countryMap.values.toList(), + // dropdownDecoratorProps: DropDownDecoratorProps( + // dropdownSearchDecoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: EdgeInsets.symmetric(horizontal: 1), + // ), + // ), + // dropdownBuilder: + // (context, selectedItem) => Align( + // // Center-align selected item + // alignment: Alignment.centerLeft, + // child: Text( + // selectedItem ?? "Select ", + // style: TextStyle(fontSize: 12), + // ), + // ), + // onChanged: (String? newValue) { + // setState(() { + // // Find the country_code based on selected country_name + // selectedCountry = + // countryMap.entries + // .firstWhere((entry) => entry.value == newValue) + // .key; + // + // if (selectedCountry!.isNotEmpty) { + // errorMessages.remove("country_code"); + // } + // }); + // }, + // ), + // ), + // ), + CustomTextFieldItnerarySubWrapper( isFocused: _isHotelNameFocused, isDesktop: isDesktop, - // width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null, - width: - isDesktop - ? MediaQuery.of(context).size.width * 0.34 - : MediaQuery.of(context).size.width * 0.66, + width: isDesktop + ? MediaQuery.of(context).size.width * 0.34 + : MediaQuery.of(context).size.width * 0.66, child: SizedBox( height: 40, child: DropdownSearch( selectedItem: countryMap[selectedCountry], popupProps: PopupProps.menu( - showSearchBox: true, // Enables search functionality + showSearchBox: true, searchFieldProps: TextFieldProps( decoration: InputDecoration( hintText: "Search ...", contentPadding: EdgeInsets.symmetric(horizontal: 10), ), ), + itemBuilder: (context, item, isSelected) { + return Container( + padding: EdgeInsets.symmetric(horizontal: 10, vertical: 4), + child: Text( + item, + style: TextStyle(fontSize: 12,color: Colors.black,), + ), + ); + }, ), items: countryMap.values.toList(), dropdownDecoratorProps: DropDownDecoratorProps( @@ -485,26 +545,19 @@ class _VisaScreenState extends State { contentPadding: EdgeInsets.symmetric(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( + alignment: Alignment.centerLeft, + child: Text( + selectedItem ?? "Select", + style: TextStyle(fontSize: 12), + ), + ), onChanged: (String? newValue) { setState(() { - // Find the country_code based on selected country_name - selectedCountry = - countryMap.entries - .firstWhere((entry) => entry.value == newValue) - .key; + selectedCountry = countryMap.entries + .firstWhere((entry) => entry.value == newValue) + .key; - if (selectedCountry!.isNotEmpty) { - errorMessages.remove("country_code"); - } }); }, ), @@ -530,38 +583,116 @@ class _VisaScreenState extends State { ), ), SizedBox(height: 5), + // CustomTextFieldWrapper( + // isFocused: _tripTypeFocused, + // isDesktop: isDesktop, + // width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null, + // // width: isDesktop + // // ? MediaQuery.of(context).size.width * 0.34 + // // : MediaQuery.of(context).size.width * 0.66, + // child: SizedBox( + // height: 40, + // child: DropdownButtonFormField( + // focusNode: _tripTypeFocusNode, // Assign the correct focus node + // value: selectedPurpose, + // style: TextStyle(fontSize: 12), + // decoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: EdgeInsets.symmetric( + // horizontal: 10, + // ), // Proper padding + // ), + // onChanged: + // purposeList.isNotEmpty + // ? (newValue) { + // setState(() { + // selectedPurpose = newValue; + // }); + // print( + // "Updating form data: Flight -> trip_type -> ${newValue ?? ""}", + // ); + // } + // : null, + // + // items: dropdownItems, + // ), + // ), + // ), CustomTextFieldWrapper( isFocused: _tripTypeFocused, isDesktop: isDesktop, width: isDesktop ? MediaQuery.of(context).size.width * 0.15 : null, - // width: isDesktop - // ? MediaQuery.of(context).size.width * 0.34 - // : MediaQuery.of(context).size.width * 0.66, child: SizedBox( height: 40, - child: DropdownButtonFormField( - focusNode: _tripTypeFocusNode, // Assign the correct focus node - value: selectedPurpose, - style: TextStyle(fontSize: 12), - decoration: InputDecoration( - border: InputBorder.none, - contentPadding: EdgeInsets.symmetric( - horizontal: 10, - ), // Proper padding + width: double.infinity, + child: DropdownSearch>( + items: purposeList.cast>(), + selectedItem: purposeList.firstWhere( + (item) => item['dropdown_key'] == selectedPurpose, + orElse: () => {}, ), + itemAsString: (item) => item['dropdown_value'] ?? '', + popupProps: PopupProps.menu( + showSearchBox: false, + fit: FlexFit.loose, + menuProps: const MenuProps(backgroundColor: Colors.white), + itemBuilder: (context, item, isSelected) { + return Padding( + padding: const EdgeInsets.symmetric( + horizontal: 10, + vertical: 5, + ), + child: Text( + item['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ), + ); + }, + ), + dropdownDecoratorProps: const DropDownDecoratorProps( + dropdownSearchDecoration: InputDecoration( + border: InputBorder.none, + contentPadding: EdgeInsets.symmetric(horizontal: 10,vertical: 10,), + ), + ), + dropdownBuilder: (context, selectedItem) { + if (selectedItem == null || selectedItem.isEmpty) { + return Text( + "Select ", + style: GoogleFonts.poppins( + color: Colors.grey, + fontSize: 13, + ), + ); + } + return Text( + selectedItem['dropdown_value'] ?? '', + style: GoogleFonts.poppins( + fontSize: 12, + color: Colors.black, + ), + ); + }, + // focusNode: _tripTypeFocusNode, // Assign the correct focus node + // value: selectedPurpose, + // style: TextStyle(fontSize: 12), + // decoration: InputDecoration( + // border: InputBorder.none, + // contentPadding: + // EdgeInsets.symmetric(horizontal: 10), // Proper padding + // ), onChanged: - purposeList.isNotEmpty - ? (newValue) { - setState(() { - selectedPurpose = newValue; - }); - print( - "Updating form data: Flight -> trip_type -> ${newValue ?? ""}", - ); - } - : null, - - items: dropdownItems, + purposeList.isNotEmpty + ? (Map? newValue) { + setState(() { + selectedPurpose= newValue?['dropdown_key']; + print("Selected Purpose: ${selectedPurpose}"); + }); + } + : null, ), ), ), diff --git a/lib/Screens/userManagement/create_user/traveller_details.dart b/lib/Screens/userManagement/create_user/traveller_details.dart index afee1b8..83b0ba5 100644 --- a/lib/Screens/userManagement/create_user/traveller_details.dart +++ b/lib/Screens/userManagement/create_user/traveller_details.dart @@ -1494,7 +1494,7 @@ class TravellerDetailsState extends State { if (pickedDate != null) { _selectedDateOfExpiry = pickedDate; controllers["dateOfExpiry"]?.text = DateFormat( - "yyyy-MM-dd", + "dd-MM-yyyy", ).format(pickedDate); }