forked from eatvio/eatvio_app
Country and city of living selectors added for profile edit. HintText is loaded dynamically
This commit is contained in:
@@ -112,6 +112,7 @@ final Map<String, String> ru = {
|
||||
"loading": "Загрузка...",
|
||||
"weight_chart": "График веса",
|
||||
"circumferences_chart": "График обхватов",
|
||||
"city_of_living": "Город проживания",
|
||||
"bodymass_chart": "График ИМТ",
|
||||
"chest": "Грудь",
|
||||
"waist": "Талия",
|
||||
|
||||
@@ -29,6 +29,8 @@ class MyProfileLoadedState extends MyProfileState {
|
||||
this.chartPoints,
|
||||
this.plans,
|
||||
this.token,
|
||||
this.selectedCountry,
|
||||
this.selectedCity,
|
||||
this.chestCircumferenceFormController,
|
||||
this.waistCircumferenceFormController,
|
||||
this.hipCircumferenceFormController,
|
||||
@@ -73,6 +75,8 @@ class MyProfileLoadedState extends MyProfileState {
|
||||
TextEditingController? pillsFormController;
|
||||
TextEditingController? sportsFormController;
|
||||
String? token;
|
||||
String? selectedCountry;
|
||||
String? selectedCity;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -101,6 +105,8 @@ class MyProfileLoadedState extends MyProfileState {
|
||||
allergiesFormController,
|
||||
pillsFormController,
|
||||
sportsFormController,
|
||||
selectedCountry,
|
||||
selectedCity,
|
||||
];
|
||||
MyProfileLoadedState copyWith({
|
||||
MyProfileModel? myProfileModelObj,
|
||||
@@ -127,6 +133,8 @@ class MyProfileLoadedState extends MyProfileState {
|
||||
TextEditingController? pillsFormController,
|
||||
TextEditingController? sportsFormController,
|
||||
String? token,
|
||||
String? selectedCountry,
|
||||
String? selectedCity,
|
||||
TextEditingController? downPressureFormController,
|
||||
TextEditingController? upPressureFormController,
|
||||
}) {
|
||||
@@ -169,6 +177,8 @@ class MyProfileLoadedState extends MyProfileState {
|
||||
pillsFormController: pillsFormController ?? this.pillsFormController,
|
||||
sportsFormController: sportsFormController ?? this.sportsFormController,
|
||||
token: token ?? this.token,
|
||||
selectedCountry: selectedCountry ?? this.selectedCountry,
|
||||
selectedCity: selectedCity ?? this.selectedCity,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,6 +306,41 @@ class _ExpandableListState extends State<ExpandableList> {
|
||||
}
|
||||
|
||||
Widget _buildForm(BuildContext context, MyProfileLoadedState state) {
|
||||
List<String> cities = [
|
||||
'Москва',
|
||||
'Санкт-Петербург',
|
||||
'Новосибирск',
|
||||
'Екатеринбург',
|
||||
'Нижний Новгород',
|
||||
'Казань',
|
||||
'Челябинск',
|
||||
'Омск',
|
||||
'Самара',
|
||||
'Ростов-на-Дону',
|
||||
'Уфа',
|
||||
'Красноярск',
|
||||
'Воронеж',
|
||||
'Пермь',
|
||||
'Волгоград',
|
||||
'Краснодар',
|
||||
'Саратов',
|
||||
'Тюмень',
|
||||
'Тольятти',
|
||||
'Ижевск',
|
||||
'Барнаул',
|
||||
'Ульяновск',
|
||||
'Иркутск',
|
||||
'Хабаровск',
|
||||
'Ярославль',
|
||||
'Владивосток',
|
||||
'Махачкала',
|
||||
'Томск',
|
||||
'Оренбург',
|
||||
'Кемерово'
|
||||
];
|
||||
List<String> countries = [
|
||||
'Россия',
|
||||
];
|
||||
return Column(children: [
|
||||
TextField(
|
||||
controller: state.firstNameFormController,
|
||||
@@ -328,18 +363,40 @@ class _ExpandableListState extends State<ExpandableList> {
|
||||
if (selectedDate != null) {
|
||||
setState(() {
|
||||
state.dateFormController!.text =
|
||||
DateFormat('yyyy-MM-dd').format(selectedDate);
|
||||
DateFormat('dd-MM-yyyy').format(selectedDate);
|
||||
});
|
||||
}
|
||||
});
|
||||
}),
|
||||
TextField(
|
||||
controller: state.countryFormController,
|
||||
DropdownButtonFormField<String>(
|
||||
value: state.selectedCountry,
|
||||
hint: Text(state.countryFormController!.text),
|
||||
onChanged: (newValue) {
|
||||
// Обработчик изменения выбранной страны
|
||||
setSelectedCountry(state, newValue);
|
||||
},
|
||||
items: countries.map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
decoration: InputDecoration(labelText: 'country'.tr),
|
||||
),
|
||||
TextField(
|
||||
controller: state.cityFormController,
|
||||
decoration: InputDecoration(labelText: 'place_of_living'.tr),
|
||||
DropdownButtonFormField<String>(
|
||||
hint: Text(state.cityFormController!.text),
|
||||
value: state.selectedCity,
|
||||
onChanged: (newValue) {
|
||||
// Обработчик изменения выбранного города
|
||||
setSelectedCity(state, newValue);
|
||||
},
|
||||
items: cities.map<DropdownMenuItem<String>>((String value) {
|
||||
return DropdownMenuItem<String>(
|
||||
value: value,
|
||||
child: Text(value),
|
||||
);
|
||||
}).toList(),
|
||||
decoration: InputDecoration(labelText: 'city_of_living'.tr),
|
||||
),
|
||||
TextField(
|
||||
controller: state.weightFormController,
|
||||
@@ -407,4 +464,16 @@ class _ExpandableListState extends State<ExpandableList> {
|
||||
margin: EdgeInsets.only(top: 20.h, bottom: 20.h)),
|
||||
]);
|
||||
}
|
||||
|
||||
void setSelectedCity(MyProfileLoadedState? state, String? newValue) {
|
||||
setState(() {
|
||||
state!.selectedCity = newValue;
|
||||
});
|
||||
}
|
||||
|
||||
void setSelectedCountry(MyProfileLoadedState? state, String? newValue) {
|
||||
setState(() {
|
||||
state!.selectedCountry = newValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user