forked from eatvio/eatvio_app
All the user details fields are added to the edit form. Json request is correctly formed based on a current form controllers values. Data is sent to API
This commit is contained in:
@@ -236,6 +236,7 @@ class _HyperState extends State<HyperSwitch> {
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
switchValue = value;
|
||||
widget.state!.hyperFormController = value ? "1" : "0";
|
||||
});
|
||||
},
|
||||
inactiveThumbColor: appTheme.blueA400,
|
||||
@@ -283,6 +284,7 @@ class _HypoState extends State<HypoSwitch> {
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
switchValue = value;
|
||||
widget.state!.hypoFormController = value ? "1" : "0";
|
||||
});
|
||||
},
|
||||
inactiveThumbColor: appTheme.blueA400,
|
||||
@@ -439,7 +441,7 @@ class _ExpandableListState extends State<ExpandableList> {
|
||||
decoration: InputDecoration(labelText: 'country'.tr),
|
||||
),
|
||||
DropdownButtonFormField<String>(
|
||||
hint: Text(state.cityFormController!.text),
|
||||
hint: Text(state.selectedCity ?? "Не выбрано"),
|
||||
value: state.selectedCity,
|
||||
onChanged: (newValue) {
|
||||
// Обработчик изменения выбранного города
|
||||
@@ -525,10 +527,13 @@ class _ExpandableListState extends State<ExpandableList> {
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
HypoSwitch('do_you_have_hypertension_tendency'.tr, state),
|
||||
HyperSwitch('do_you_have_hypertension_tendency'.tr, state),
|
||||
],
|
||||
),
|
||||
NextStepButton(
|
||||
onPressed: () {
|
||||
sendProfileData(state);
|
||||
},
|
||||
buttonStyle: CustomButtonStyles.outlinePrimaryTL15,
|
||||
text: "save".tr.toUpperCase(),
|
||||
margin: EdgeInsets.only(top: 20.h, bottom: 20.h)),
|
||||
@@ -551,19 +556,29 @@ class _ExpandableListState extends State<ExpandableList> {
|
||||
try {
|
||||
// Создаем JSON объект с данными профиля
|
||||
Map<String, dynamic> profileData = {
|
||||
'weight': state?.weightController?.text,
|
||||
'chestCircumference': state?.chestCircumferenceController?.text,
|
||||
'waistCircumference': state?.waistCircumferenceController?.text,
|
||||
'hipCircumference': state?.hipCircumferenceController?.text,
|
||||
'firstName': state?.firstNameFormController?.text,
|
||||
'lastName': state?.lastNameFormController?.text,
|
||||
'first_name': state?.firstNameFormController?.text,
|
||||
'last_name': state?.lastNameFormController?.text,
|
||||
'chest_circumference': state?.chestCircumferenceFormController?.text,
|
||||
'waist_circumference': state?.waistCircumferenceFormController?.text,
|
||||
'hip_circumference': state?.hipCircumferenceFormController?.text,
|
||||
'birthdate': state?.dateFormController?.text,
|
||||
'height': state?.heightFormController?.text,
|
||||
'weight': state?.weightFormController?.text,
|
||||
'blood_pressure_up': state?.upPressureFormController?.text,
|
||||
'blood_pressure_down': state?.downPressureFormController?.text,
|
||||
'about_alergy': state?.allergiesFormController?.text,
|
||||
'about_taking_pils': state?.pillsFormController?.text,
|
||||
'about_sport_hobbies': state?.sportsFormController?.text,
|
||||
'favorite_foods': state?.favoriteFormController?.text,
|
||||
'unfavorite_foods': state?.unfavoriteFormController?.text,
|
||||
'additional_info': state?.additionalFormController?.text,
|
||||
'country': state?.selectedCountry,
|
||||
'city': state?.selectedCity,
|
||||
'hypoFormController': state?.hypoFormController,
|
||||
'hyperFormController': state?.hyperFormController,
|
||||
// добавьте остальные поля здесь
|
||||
'has_hypo': state?.hypoFormController,
|
||||
'has_hyper': state?.hyperFormController,
|
||||
};
|
||||
|
||||
print(profileData);
|
||||
// Отправляем JSON на сервер
|
||||
String apiUrl = dotenv.env['SERVER_ROOT']! + 'profile/edit';
|
||||
http.Response response = await http.post(
|
||||
|
||||
Reference in New Issue
Block a user