feat(profile): Activity level select added to settings profile edit

This commit is contained in:
2024-04-04 14:49:10 +03:00
parent c5c7033ada
commit 9862892636
3 changed files with 81 additions and 1 deletions

View File

@@ -91,6 +91,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
hyperFormController: currentState.hyperFormController,
selectedCity: currentState.selectedCity,
selectedCountry: currentState.selectedCountry,
selectedActivity: currentState.selectedActivity,
));
} else {
var plans = []
@@ -168,7 +169,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
};
}
}
print(data['userDetails']);
/*print(chartPoints);
print(circumferences);*/
/*print(weights);
@@ -229,6 +230,8 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
TextEditingController(text: data['userDetails']['birthdate']),
selectedCity: data['userDetails']['city'],
selectedCountry: data['userDetails']['country'],
selectedActivity: determineActivityLevel(
double.parse(data['userDetails']['activity_coefficient'])),
));
}
} else {
@@ -245,4 +248,18 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
emit(MyProfileErrorState('Ошибка при получении данных профиля: $e'));
}
}
String determineActivityLevel(double activityFactor) {
if (activityFactor <= 1.2) {
return "сидячий";
} else if (activityFactor <= 1.375) {
return "низкий (1-3 тренировки в неделю по 20 мин)";
} else if (activityFactor <= 1.55) {
return "умеренный (3-4 тренировки в неделю по 30-60 мин)";
} else if (activityFactor <= 1.7) {
return "высокий (5-7 тренировок по 30-60 мин)";
} else {
return "экстремальный (несколько интенсивных тренировок в день)";
}
} // колхоз, но свитчкейсы в дарте странно ведут себя при сравнении double
}

View File

@@ -32,6 +32,7 @@ class MyProfileLoadedState extends MyProfileState {
this.token,
this.selectedCountry,
this.selectedCity,
this.selectedActivity,
this.chestCircumferenceFormController,
this.waistCircumferenceFormController,
this.hipCircumferenceFormController,
@@ -87,6 +88,7 @@ class MyProfileLoadedState extends MyProfileState {
String? token;
String? selectedCountry;
String? selectedCity;
String? selectedActivity;
String? hypoFormController;
String? hyperFormController;
@override
@@ -122,6 +124,7 @@ class MyProfileLoadedState extends MyProfileState {
additionalFormController,
selectedCountry,
selectedCity,
selectedActivity,
hypoFormController,
hyperFormController,
];
@@ -158,6 +161,7 @@ class MyProfileLoadedState extends MyProfileState {
String? token,
String? selectedCountry,
String? selectedCity,
String? selectedActivity,
String? hypoFormController,
String? hyperFormController,
}) {
@@ -209,6 +213,7 @@ class MyProfileLoadedState extends MyProfileState {
token: token ?? this.token,
selectedCountry: selectedCountry ?? this.selectedCountry,
selectedCity: selectedCity ?? this.selectedCity,
selectedActivity: selectedActivity ?? this.selectedActivity,
hypoFormController: hypoFormController ?? this.hypoFormController,
hyperFormController: hyperFormController ?? this.hyperFormController,
);