WT 1.1.24+2 Weight calculation

This commit is contained in:
bossanyit
2021-11-02 17:18:49 +01:00
parent fd6a5a3145
commit e8fc6cd7ec
25 changed files with 222 additions and 236 deletions
+11 -15
View File
@@ -43,6 +43,8 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
bool celebrating = false;
int activeDayIndex = 0;
double base1RM = 0;
CustomerTrainingPlan? getMyPlan() => this._myPlan;
setMyPlan(CustomerTrainingPlan? myPlan) => this._myPlan = myPlan;
@@ -106,21 +108,13 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
} else if (event is TrainingPlanWeightChangeRecalculate) {
yield TrainingPlanExerciseLoading();
/* double weightFromPlan = trainingPlanRepository.getOriginalWeight(this.getMyPlan()!.trainingPlanId!, event.detail);
print("Plan Wieght: $weightFromPlan");
if (weightFromPlan != -1 || (weightFromPlan == -1 && event.detail.set! > 1)) {
bool isTest = weightFromPlan != -1 || weightFromPlan != -2;
if (!isTest || (isTest && event.detail.set! > 1)) {
//&& event.detail.exercises.length > 0
print("Base1RM ${event.detail.base1RM}");
if (event.detail.base1RM > 0) {
event.detail.repeats =
Common.reCalculateRepeatsByChangedWeight(event.detail.weight!, event.detail.repeats!.toDouble(), event.weight);
if (event.detail.repeats! < 3) {
event.detail.repeats = 4;
}
Common.calculateQuantityByChangedWeight(event.detail.base1RM, event.weight, event.detail.repeats!.toDouble());
ExerciseSaveStream().repeats = event.detail.repeats!;
ExerciseSaveStream().getStreamController().add(true);
} */
}
event.detail.weight = event.weight;
yield TrainingPlanExerciseReady();
yield TrainingPlanReady();
@@ -171,18 +165,22 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
nextDetail.customerTrainingPlanDetailsId != event.detail.customerTrainingPlanDetailsId) {
print("recalculating -2 ${event.detail.customerTrainingPlanDetailsId}");
trainingPlanRepository.recalculateDetail(_myPlan!.trainingPlanId!, event.detail, nextDetail);
nextDetail.base1RM = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
} else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId && weightFromPlan == -1 && nextDetail.set! > 1) {
print("recalculating -1 ${event.detail.customerTrainingPlanDetailsId}");
nextDetail = trainingPlanRepository.recalculateDetailFixRepeats(_myPlan!.trainingPlanId!, nextDetail);
nextDetail.base1RM = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
} else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId && nextDetail.weight == -1 && nextDetail.set! == 1) {
print("recalculating -1, set 1 ${event.detail.customerTrainingPlanDetailsId}");
nextDetail = trainingPlanRepository.recalculateDetailFixRepeatsSet1(_myPlan!.trainingPlanId!, nextDetail, event.detail);
nextDetail.base1RM = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
} else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId &&
weightFromPlan == -2 &&
nextDetail.set! == 1 &&
nextDetail.exercises.length == 0) {
print("recalculating -1/ no exercise, set 1 ${event.detail.customerTrainingPlanDetailsId}");
nextDetail = trainingPlanRepository.recalculateDetailFixRepeatsSet1(_myPlan!.trainingPlanId!, nextDetail, event.detail);
nextDetail.base1RM = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
}
}
}
@@ -427,9 +425,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
String getSummary(TrainingPlanDetail detail) {
String summary = "";
String set = "1";
set = detail.set.toString() + "/ ";
List<TrainingPlanDetail> details = getAllTrainingPlanDetailsSameExercise(detail);
int index = 0;
@@ -622,7 +618,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
}
int index = indexInStart > indexInProgress ? indexInStart : indexInProgress;
offset = (index) * 300;
print("Offset: $offset day: $day ($indexInStart, $indexInProgress)");
//print("Offset: $offset day: $day ($indexInStart, $indexInProgress)");
return offset;
}