v1.1 dart fix
This commit is contained in:
@@ -6,7 +6,7 @@ class ExerciseDeviceRepository {
|
||||
List<ExerciseDevice> _devices = [];
|
||||
|
||||
List<ExerciseDevice> getDevices() {
|
||||
return this._devices;
|
||||
return _devices;
|
||||
}
|
||||
|
||||
void setDevices(List<ExerciseDevice> list) {
|
||||
@@ -14,15 +14,15 @@ class ExerciseDeviceRepository {
|
||||
}
|
||||
|
||||
Future<List<ExerciseDevice>> getDBDevices() async {
|
||||
this._devices = await ExerciseDeviceApi().getDevices();
|
||||
return this._devices;
|
||||
_devices = await ExerciseDeviceApi().getDevices();
|
||||
return _devices;
|
||||
}
|
||||
|
||||
bool isGym(int deviceId) {
|
||||
bool isGym = false;
|
||||
_devices.forEach((element) {
|
||||
for (var element in _devices) {
|
||||
isGym = isGymElement(element.name);
|
||||
});
|
||||
}
|
||||
return isGym;
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ class ExerciseDeviceRepository {
|
||||
if (_devices.isEmpty) {
|
||||
_devices = Cache().getDevices()!;
|
||||
}
|
||||
_devices.forEach((element) {
|
||||
for (var element in _devices) {
|
||||
if (isGymElement(element.name)) {
|
||||
gymDevices.add(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
return gymDevices;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,21 +20,21 @@ class TrainingPlanRepository with Common, Logging {
|
||||
final List<ExerciseTree>? exerciseTree = Cache().getExerciseTree();
|
||||
int? parentId;
|
||||
if (exerciseTree != null) {
|
||||
exerciseTree.forEach((element) {
|
||||
for (var element in exerciseTree) {
|
||||
if (element.internalName == parent) {
|
||||
parentId = element.treeId;
|
||||
parentTree = element;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
final List<TrainingPlan>? plans = Cache().getTrainingPlans();
|
||||
if (plans != null && parentId != null) {
|
||||
plans.forEach((element) {
|
||||
for (var element in plans) {
|
||||
if (element.treeId == parentId) {
|
||||
resultList.add(element);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
@@ -48,12 +48,12 @@ class TrainingPlanRepository with Common, Logging {
|
||||
log(" **** Activate Plan: $trainingPlanId");
|
||||
// 1. deactivate
|
||||
if (Cache().getCustomerTrainingPlans() != null) {
|
||||
Cache().getCustomerTrainingPlans()!.forEach((plan) {
|
||||
for (var plan in Cache().getCustomerTrainingPlans()!) {
|
||||
plan.active = false;
|
||||
if (plan.customerTrainingPlanId != null) {
|
||||
//TrainingPlanApi().updateCustomerTrainingPlan(plan, plan.customerTrainingPlanId!);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
CustomerTrainingPlan plan = CustomerTrainingPlan();
|
||||
@@ -72,14 +72,14 @@ class TrainingPlanRepository with Common, Logging {
|
||||
// 3 calculate weights
|
||||
int index = 0;
|
||||
int exerciseTypeIdOrig = 0;
|
||||
trainingPlan.details!.forEach((elem) {
|
||||
for (var elem in trainingPlan.details!) {
|
||||
List<CustomerTrainingPlanDetails> list = createDetail(plan, elem, exerciseTypeIdOrig, index);
|
||||
exerciseTypeIdOrig = elem.exerciseTypeId;
|
||||
list.forEach((element) {
|
||||
for (var element in list) {
|
||||
plan.details.add(element);
|
||||
index++;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Cache().myTrainingPlan = plan;
|
||||
|
||||
@@ -251,21 +251,21 @@ class TrainingPlanRepository with Common, Logging {
|
||||
// reverse
|
||||
return a.dateAdd!.compareTo(b.dateAdd!);
|
||||
});
|
||||
exercises.forEach((exercise) {
|
||||
for (var exercise in exercises) {
|
||||
if (exercise.exerciseTypeId == exerciseTypeId && exercise.dateAdd!.compareTo(dt) >= 0) {
|
||||
detail.weight = weight;
|
||||
lastExercise1RM = exercise;
|
||||
//print("last exercise: $exercise");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (lastExercise1RM == null || lastExercise1RM!.unitQuantity == null) {
|
||||
if (lastExercise1RM == null || lastExercise1RM.unitQuantity == null) {
|
||||
detail.weight = weight;
|
||||
detail.isTest = true;
|
||||
return detail;
|
||||
}
|
||||
|
||||
double oneRepMax = calculateMax1RMSameDay(lastExercise1RM!);
|
||||
double oneRepMax = calculateMax1RMSameDay(lastExercise1RM);
|
||||
// Common.calculate1RM(lastExercise1RM!.unitQuantity!, lastExercise1RM!.quantity!);
|
||||
//print("Exercise $exerciseTypeId - 1RM : $oneRepMax");
|
||||
weight = oneRepMax * Common.get1RMPercent(detail.repeats!);
|
||||
@@ -286,7 +286,7 @@ class TrainingPlanRepository with Common, Logging {
|
||||
List<Exercise> exercises = Cache().getExercises()!;
|
||||
double max1RM = 0.0;
|
||||
|
||||
exercises.forEach((exercise) {
|
||||
for (var exercise in exercises) {
|
||||
if (actual.exerciseTypeId == exercise.exerciseTypeId &&
|
||||
actual.dateAdd!.year == exercise.dateAdd!.year &&
|
||||
actual.dateAdd!.month == exercise.dateAdd!.month &&
|
||||
@@ -296,7 +296,7 @@ class TrainingPlanRepository with Common, Logging {
|
||||
max1RM = oneRepMax;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return max1RM;
|
||||
}
|
||||
@@ -307,11 +307,11 @@ class TrainingPlanRepository with Common, Logging {
|
||||
return 0;
|
||||
}
|
||||
int originalRepeats = 0;
|
||||
plan.details!.forEach((element) {
|
||||
for (var element in plan.details!) {
|
||||
if (element.trainingPlanDetailId == detail.trainingPlanDetailsId) {
|
||||
originalRepeats = element.repeats ?? 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
return originalRepeats;
|
||||
}
|
||||
|
||||
@@ -321,11 +321,11 @@ class TrainingPlanRepository with Common, Logging {
|
||||
return 0;
|
||||
}
|
||||
double originalWeight = 0;
|
||||
plan.details!.forEach((element) {
|
||||
for (var element in plan.details!) {
|
||||
if (element.trainingPlanDetailId == detail.trainingPlanDetailsId) {
|
||||
originalWeight = element.weight ?? 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
return originalWeight;
|
||||
}
|
||||
|
||||
@@ -371,11 +371,11 @@ class TrainingPlanRepository with Common, Logging {
|
||||
|
||||
// 1.b get the original detail's repeat
|
||||
int originalRepeats = detail.repeats!;
|
||||
plan.details!.forEach((element) {
|
||||
for (var element in plan.details!) {
|
||||
if (element.trainingPlanDetailId == detail.trainingPlanDetailsId) {
|
||||
originalRepeats = element.repeats ?? 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 2 get recalculated repeats
|
||||
recalculatedDetail.weight = Common.calculateWeigthByChangedQuantity(detail.weight!, detail.repeats!.toDouble(), originalRepeats.toDouble());
|
||||
|
||||
Reference in New Issue
Block a user