WT 1.26
This commit is contained in:
@@ -27,7 +27,7 @@ import 'package:flutter/material.dart';
|
||||
part 'training_plan_event.dart';
|
||||
part 'training_plan_state.dart';
|
||||
|
||||
class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> with Common {
|
||||
final TrainingPlanRepository trainingPlanRepository;
|
||||
final MenuBloc menuBloc;
|
||||
TrainingPlanBloc({required this.trainingPlanRepository, required this.menuBloc}) : super(TrainingPlanInitial()) {
|
||||
@@ -198,7 +198,6 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
|
||||
int baseCustomerTrainingPlanDetailsId = 0;
|
||||
if (eventDetail.exerciseType!.unitQuantity != null && eventDetail.weight! > 0) {
|
||||
double calculatedWeight = 0;
|
||||
for (var nextDetail in _myPlan!.details) {
|
||||
if (nextDetail.exerciseTypeId == eventDetail.exerciseTypeId) {
|
||||
if (id == 0 && nextDetail.customerTrainingPlanDetailsId == eventDetail.customerTrainingPlanDetailsId) {
|
||||
@@ -214,7 +213,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
if (nextDetail.weight == -2 && nextDetail.customerTrainingPlanDetailsId != eventDetail.customerTrainingPlanDetailsId) {
|
||||
print("Nr 1. - recalculating -2 ${eventDetail.customerTrainingPlanDetailsId}");
|
||||
trainingPlanRepository.recalculateDetail(_myPlan!.trainingPlanId!, eventDetail, nextDetail);
|
||||
nextDetail.baseOneRepMax = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
|
||||
nextDetail.baseOneRepMax = calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
|
||||
} /* else if (weightFromPlan == -1 && nextDetail.set! > 1 && nextDetail.exercises.length == 1) {
|
||||
print("Nr 2. recalculating -1 ${event.detail.customerTrainingPlanDetailsId}");
|
||||
nextDetail = trainingPlanRepository.recalculateDetailFixRepeats(_myPlan!.trainingPlanId!, nextDetail);
|
||||
@@ -223,22 +222,21 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
else if (nextDetail.weight == -1 && nextDetail.set! == 1) {
|
||||
print("Nr 3. recalculating -1, set 1 ${eventDetail.customerTrainingPlanDetailsId}");
|
||||
nextDetail = trainingPlanRepository.recalculateDetailFixRepeatsSet1(_myPlan!.trainingPlanId!, nextDetail, eventDetail);
|
||||
nextDetail.baseOneRepMax = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
|
||||
nextDetail.baseOneRepMax = calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
|
||||
} else if (eventDetail.set! == 1 &&
|
||||
(weightFromPlan == -2 || weightFromPlan == -1) &&
|
||||
nextDetail.customerTrainingPlanDetailsId! == id + 1 &&
|
||||
recalculate) {
|
||||
print("Nr 4. recalculating after the first exercise ${eventDetail.customerTrainingPlanDetailsId}");
|
||||
nextDetail = trainingPlanRepository.recalculateDetailFixRepeatsSet1(_myPlan!.trainingPlanId!, nextDetail, eventDetail);
|
||||
nextDetail.baseOneRepMax = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
|
||||
calculatedWeight = nextDetail.weight!;
|
||||
nextDetail.baseOneRepMax = calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
|
||||
} else if (eventDetail.set! == 1 &&
|
||||
(weightFromPlan == -2 || weightFromPlan == -1) &&
|
||||
nextDetail.customerTrainingPlanDetailsId! > id + 1 &&
|
||||
recalculate) {
|
||||
print("Nr 5. recalculating after the second exercise ${eventDetail.customerTrainingPlanDetailsId}");
|
||||
nextDetail = trainingPlanRepository.recalculateDetailFixRepeatsSet1(_myPlan!.trainingPlanId!, nextDetail, eventDetail);
|
||||
nextDetail.baseOneRepMax = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
|
||||
nextDetail.baseOneRepMax = calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
|
||||
} else if (id != 0) {
|
||||
// calculate weight and repeat based on the first baseOneRepMax
|
||||
if (baseCustomerTrainingPlanDetailsId != 0) {
|
||||
@@ -918,8 +916,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
if (_myDetail == null || _myDetail!.exerciseType == null) {
|
||||
return exerciseName;
|
||||
}
|
||||
exerciseName =
|
||||
AppLanguage().appLocal == Locale("en") ? getMyDetail()!.exerciseType!.name : getMyDetail()!.exerciseType!.nameTranslation;
|
||||
exerciseName = AppLanguage().appLocal == Locale("en") ? getMyDetail()!.exerciseType!.name : getMyDetail()!.exerciseType!.nameTranslation;
|
||||
return exerciseName;
|
||||
}
|
||||
|
||||
@@ -1007,8 +1004,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
||||
if (listDetail.exercises.length >= listDetail.set!) {
|
||||
listDetail.state = ExercisePlanDetailState.finished;
|
||||
}
|
||||
allFinished =
|
||||
allFinished && (listDetail.exercises.length >= listDetail.set! || listDetail.state.equalsTo(ExercisePlanDetailState.skipped));
|
||||
allFinished = allFinished && (listDetail.exercises.length >= listDetail.set! || listDetail.state.equalsTo(ExercisePlanDetailState.skipped));
|
||||
}
|
||||
//print("All finished: $allFinished for ${detail.exerciseTypeId}");
|
||||
return allFinished;
|
||||
|
||||
Reference in New Issue
Block a user