WT 1.1.24+2 Weight calculation
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/sport.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:aitrainer_app/repository/mautic_repository.dart';
|
||||
import 'package:aitrainer_app/util/app_language.dart';
|
||||
import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
@@ -138,6 +139,10 @@ class CustomerChangeBloc extends Bloc<CustomerChangeEvent, CustomerChangeState>
|
||||
customerRepository.customer!.sportId = selectedSport!.sportId;
|
||||
}
|
||||
|
||||
if (customerRepository.customer!.lang == null) {
|
||||
customerRepository.customer!.lang = AppLanguage().appLocal.languageCode;
|
||||
}
|
||||
|
||||
await customerRepository.saveCustomer();
|
||||
MauticRepository mauticRepository = MauticRepository(customerRepository: customerRepository);
|
||||
await mauticRepository.sendMauticDataChange();
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:aitrainer_app/repository/mautic_repository.dart';
|
||||
import 'package:aitrainer_app/repository/split_test_respository.dart';
|
||||
import 'package:aitrainer_app/repository/training_plan_repository.dart';
|
||||
import 'package:aitrainer_app/repository/user_repository.dart';
|
||||
import 'package:aitrainer_app/util/app_language.dart';
|
||||
import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:aitrainer_app/util/enums.dart';
|
||||
import 'package:aitrainer_app/util/track.dart';
|
||||
@@ -170,6 +171,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
|
||||
customerRepository!.customer!.dataPolicyAllowed = 1;
|
||||
customerRepository!.customer!.emailSubscription = 1;
|
||||
customerRepository!.customer!.syncedDate = DateTime.now();
|
||||
customerRepository!.customer!.lang = AppLanguage().appLocal.languageCode;
|
||||
customerRepository!.setCustomerProperty("Weight", tempCustomer.getProperty("Weight"));
|
||||
customerRepository!.setCustomerProperty("Height", tempCustomer.getProperty("Height"));
|
||||
await customerRepository!.saveCustomer();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user