WT 1.1.20(4) Training plan improvements

This commit is contained in:
bossanyit
2021-07-05 22:10:32 +02:00
parent 211307e63e
commit 48a0c3f7de
52 changed files with 2086 additions and 1229 deletions
+20 -11
View File
@@ -36,11 +36,11 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
double bmiAngle = 0;
double bmiTop = 0;
double bmiLeft = 0;
late double weight;
late double height;
double? weight;
double? height;
double bmrEnergy = 0;
late int birthYear;
late String fitnessLevel;
int? birthYear;
String? fitnessLevel;
bool changedWeight = false;
bool changedSizes = false;
@@ -155,6 +155,12 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
Cache().initBadges();
Track().track(TrackingEvent.exercise_new, eventValue: exerciseRepository.exerciseType!.name);
yield ExerciseNewSaved();
} else if (event is ExerciseNewSubmitNoRegistration) {
yield ExerciseNewLoading();
exerciseRepository.addExerciseNoRegistration();
menuBloc.add(MenuTreeDown(parent: 0));
Track().track(TrackingEvent.exercise_new_no_registration, eventValue: exerciseRepository.exerciseType!.name);
yield ExerciseNewSaved();
} else if (event is ExerciseNewBMIAnimate) {
yield ExerciseNewLoading();
yield ExerciseNewReady();
@@ -168,18 +174,18 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
}
double getBMI() {
if (height == 0 || weight == 0) {
if (weight == null || height == null || height == 0 || weight == 0) {
this.bmi = 0;
return 0;
}
this.bmi = weight / (height * height / 10000);
this.bmi = weight! / (height! * height! / 10000);
this.getGoalBMI();
return this.bmi;
}
double getBMR() {
var date = DateTime.now();
if (height == 0 || weight == 0) {
if (weight == null || height == null || height == 0 || weight == 0) {
this.bmi = 0;
return 0;
}
@@ -188,10 +194,10 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
if (customerRepository.customer!.sex == "m") {
//66.47 + ( 13.75 × tömeg kg-ban ) + ( 5.003 × magasság cm-ben ) ( 6.755 × életkor évben kifejezve )
bmr = 66.47 + (13.75 * weight) + (5.003 * height) - (6.755 * (year - customerRepository.customer!.birthYear!));
bmr = 66.47 + (13.75 * weight!) + (5.003 * height!) - (6.755 * (year - customerRepository.customer!.birthYear!));
} else {
//BMR = 655.1 + ( 9.563 × ömeg kg-ban ) + ( 1.85 × magasság cm-ben) ( 4.676 × életkor évben kifejezve )
bmr = 655.1 + (9.563 * weight) + (1.85 * height) - (4.676 * (year - customerRepository.customer!.birthYear!));
bmr = 655.1 + (9.563 * weight!) + (1.85 * height!) - (4.676 * (year - customerRepository.customer!.birthYear!));
}
bmrEnergy = bmr;
@@ -208,6 +214,9 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
}
double getGoalBMI() {
if (weight == null || height == null) {
return 0;
}
if (this.bmi == 0) {
getBMI();
}
@@ -226,8 +235,8 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
}
goalBMI = 24;
this.goalWeight = goalBMI * (height * height / 10000);
this.goalMilestoneWeight = goalMilestoneBMI * (height * height / 10000);
this.goalWeight = goalBMI * (height! * height! / 10000);
this.goalMilestoneWeight = goalMilestoneBMI * (height! * height! / 10000);
//print("Angle: " + bmiAngle.toStringAsFixed(1));
@@ -83,6 +83,10 @@ class ExerciseNewSubmit extends ExerciseNewEvent {
const ExerciseNewSubmit();
}
class ExerciseNewSubmitNoRegistration extends ExerciseNewEvent {
const ExerciseNewSubmitNoRegistration();
}
class ExerciseNewAddError extends ExerciseNewEvent {
final String message;
const ExerciseNewAddError({required this.message});