WT 1.1.11+3 Evaluation, null-safe fixes

This commit is contained in:
bossanyit
2021-04-12 00:51:09 +02:00
parent 01148c6e39
commit 10c8a0a2d8
73 changed files with 3256 additions and 676 deletions
+75 -55
View File
@@ -21,8 +21,8 @@ class GenderItem {
}
class CustomerRepository with Logging {
late Customer customer;
late Customer? _trainee;
Customer? customer;
Customer? _trainee;
List<Customer>? _trainees;
List<CustomerProperty>? _allProperties;
final PropertyRepository propertyRepository = PropertyRepository();
@@ -68,51 +68,61 @@ class CustomerRepository with Logging {
}
String? get name {
return this.customer.name != null ? this.customer.name : "";
return this.customer != null && this.customer!.name != null ? this.customer!.name : "";
}
String? get firstName {
return this.customer.firstname != null ? this.customer.firstname : "";
return this.customer != null && this.customer!.firstname != null ? this.customer!.firstname : "";
}
String get sex {
return this.customer.sex == "m" ? "Man" : "Woman";
if (this.customer == null) throw Exception("Initialize the customer object");
return this.customer!.sex == "m" ? "Man" : "Woman";
}
int? get birthYear {
return this.customer.birthYear;
if (this.customer == null) throw Exception("Initialize the customer object");
return this.customer!.birthYear;
}
String? get goal {
return this.customer.goal;
if (this.customer == null) throw Exception("Initialize the customer object");
return this.customer!.goal;
}
String? get fitnessLevel {
return this.customer.fitnessLevel;
if (this.customer == null) throw Exception("Initialize the customer object");
return this.customer!.fitnessLevel;
}
String? get bodyType {
return this.customer.bodyType;
if (this.customer == null) throw Exception("Initialize the customer object");
return this.customer!.bodyType;
}
setName(String name) {
this.customer.name = name;
if (this.customer == null) return;
this.customer!.name = name;
}
setFirstName(String firstName) {
this.customer.firstname = firstName;
if (this.customer == null) return;
this.customer!.firstname = firstName;
}
setPassword(String password) {
this.customer.password = password;
if (this.customer == null) return;
this.customer!.password = password;
}
setEmail(String email) {
this.customer.email = email;
if (this.customer == null) return;
this.customer!.email = email;
}
setSex(String sex) {
this.customer.sex = sex;
if (this.customer == null) return;
this.customer!.sex = sex;
}
setWeight(int weight) {
@@ -126,19 +136,20 @@ class CustomerRepository with Logging {
}
setCustomerProperty(String propertyName, double value, {id = 0}) {
if (this.customer.properties[propertyName] == null) {
this.customer.properties[propertyName] = CustomerProperty(
if (this.customer == null) throw Exception("Initialize the customer object");
if (this.customer!.properties[propertyName] == null) {
this.customer!.properties[propertyName] = CustomerProperty(
propertyId: propertyRepository.getPropertyByName("Height")!.propertyId,
customerId: this.customer.customerId!,
customerId: this.customer!.customerId!,
propertyValue: value,
dateAdd: DateTime.now());
} else {
this.customer.properties[propertyName]!.propertyValue = value;
this.customer!.properties[propertyName]!.propertyValue = value;
}
this.customer.properties[propertyName]!.dateAdd = DateTime.now();
this.customer.properties[propertyName]!.newData = true;
this.customer!.properties[propertyName]!.dateAdd = DateTime.now();
this.customer!.properties[propertyName]!.newData = true;
if (id > 0) {
this.customer.properties[propertyName]!.customerPropertyId = id;
this.customer!.properties[propertyName]!.customerPropertyId = id;
}
}
@@ -151,31 +162,36 @@ class CustomerRepository with Logging {
}
double getCustomerPropertyValue(String propertyName) {
if (this.customer.properties[propertyName] == null) {
if (this.customer == null || this.customer!.properties[propertyName] == null) {
return 0.0;
} else {
return this.customer.properties[propertyName]!.propertyValue;
return this.customer!.properties[propertyName]!.propertyValue;
}
}
CustomerProperty? getCustomerProperty(String propertyName) {
return this.customer.properties[propertyName];
if (this.customer == null) throw Exception("Initialize the customer object");
return this.customer!.properties[propertyName];
}
setBirthYear(int birthYear) {
this.customer.birthYear = birthYear;
if (this.customer == null) throw Exception("Initialize the customer object");
this.customer!.birthYear = birthYear;
}
setFitnessLevel(String level) {
this.customer.fitnessLevel = level;
if (this.customer == null) throw Exception("Initialize the customer object");
this.customer!.fitnessLevel = level;
}
setGoal(String goal) {
this.customer.goal = goal;
if (this.customer == null) throw Exception("Initialize the customer object");
this.customer!.goal = goal;
}
setBodyType(String bodyType) {
this.customer.bodyType = bodyType;
if (this.customer == null) throw Exception("Initialize the customer object");
this.customer!.bodyType = bodyType;
}
createNew() {
@@ -183,7 +199,8 @@ class CustomerRepository with Logging {
}
Customer getCustomer() {
return this.customer;
if (this.customer == null) throw Exception("Initialize the customer object");
return this.customer!;
}
void setCustomer(Customer customer) {
@@ -191,12 +208,14 @@ class CustomerRepository with Logging {
}
Future<void> addCustomer() async {
final Customer modelCustomer = customer;
if (this.customer == null) throw Exception("Initialize the customer object");
final Customer modelCustomer = customer!;
await CustomerApi().addCustomer(modelCustomer);
}
Future<void> saveCustomer() async {
final Customer modelCustomer = customer;
if (this.customer == null) throw Exception("Initialize the customer object");
final Customer modelCustomer = customer!;
await CustomerApi().saveCustomer(modelCustomer);
await this.saveProperties(modelCustomer.properties);
}
@@ -317,6 +336,7 @@ class CustomerRepository with Logging {
}
void addSizes(String sex) {
if (this.customer == null) throw Exception("Initialize the customer object");
List<Property>? properties = Cache().getProperties();
if (properties == null) {
return;
@@ -328,62 +348,62 @@ class CustomerRepository with Logging {
if (element.propertyName == "Shoulder") {
element.top = (122 * distortionHeight).toInt();
element.left = (130 * distortionWidth).toInt();
element.value = this.customer.getProperty("Shoulder");
element.value = this.customer!.getProperty("Shoulder");
manSizes.add(element);
} else if (element.propertyName == "Neck") {
element.top = (68 * distortionHeight).toInt();
element.left = (130 * distortionWidth).toInt();
element.value = this.customer.getProperty("Neck");
element.value = this.customer!.getProperty("Neck");
manSizes.add(element);
} else if (element.propertyName == "Biceps") {
element.top = (178 * distortionHeight).toInt();
element.left = (208 * distortionWidth).toInt();
element.value = this.customer.getProperty("Biceps");
element.value = this.customer!.getProperty("Biceps");
manSizes.add(element);
} else if (element.propertyName == "Chest") {
element.top = (154 * distortionHeight).toInt();
element.left = (130 * distortionWidth).toInt();
element.value = this.customer.getProperty("Chest");
element.value = this.customer!.getProperty("Chest");
manSizes.add(element);
} else if (element.propertyName == "Belly") {
element.top = (244 * distortionHeight).toInt();
element.left = (130 * distortionWidth).toInt();
element.value = this.customer.getProperty("Belly");
element.value = this.customer!.getProperty("Belly");
manSizes.add(element);
} else if (element.propertyName == "Hip") {
element.top = (308 * distortionHeight).toInt();
element.left = (130 * distortionWidth).toInt();
element.value = this.customer.getProperty("Hip");
element.value = this.customer!.getProperty("Hip");
manSizes.add(element);
} else if (element.propertyName == "Thigh Top") {
element.top = (332 * distortionHeight).toInt();
element.left = (165 * distortionWidth).toInt();
element.value = this.customer.getProperty("Thigh Top");
element.value = this.customer!.getProperty("Thigh Top");
manSizes.add(element);
} else if (element.propertyName == "Thigh Middle") {
element.top = (382 * distortionHeight).toInt();
element.left = (100 * distortionWidth).toInt();
element.value = this.customer.getProperty("Thigh Middle");
element.value = this.customer!.getProperty("Thigh Middle");
manSizes.add(element);
} else if (element.propertyName == "Knee") {
element.top = (464 * distortionHeight).toInt();
element.left = (97 * distortionWidth).toInt();
element.value = this.customer.getProperty("Knee");
element.value = this.customer!.getProperty("Knee");
manSizes.add(element);
} else if (element.propertyName == "Calf") {
element.top = (520 * distortionHeight).toInt();
element.left = (97 * distortionWidth).toInt();
element.value = this.customer.getProperty("Calf");
element.value = this.customer!.getProperty("Calf");
manSizes.add(element);
} else if (element.propertyName == "Ankle") {
element.top = (620 * distortionHeight).toInt();
element.left = (150 * distortionWidth).toInt();
element.value = this.customer.getProperty("Ankle");
element.value = this.customer!.getProperty("Ankle");
manSizes.add(element);
} else if (element.propertyName == "Weight") {
element.top = (402 * distortionHeight).toInt();
element.left = (240 * distortionWidth).toInt();
element.value = this.customer.getProperty("Weight");
element.value = this.customer!.getProperty("Weight");
manSizes.add(element);
}
});
@@ -392,62 +412,62 @@ class CustomerRepository with Logging {
if (element.propertyName == "Shoulder") {
element.top = (122 * distortionHeight).toInt();
element.left = (151 * distortionWidth).toInt();
element.value = this.customer.getProperty("Shoulder");
element.value = this.customer!.getProperty("Shoulder");
manSizes.add(element);
} else if (element.propertyName == "Neck") {
element.top = (78 * distortionHeight).toInt();
element.left = (151 * distortionWidth).toInt();
element.value = this.customer.getProperty("Neck");
element.value = this.customer!.getProperty("Neck");
manSizes.add(element);
} else if (element.propertyName == "Biceps") {
element.top = (178 * distortionHeight).toInt();
element.left = (212 * distortionWidth).toInt();
element.value = this.customer.getProperty("Biceps");
element.value = this.customer!.getProperty("Biceps");
manSizes.add(element);
} else if (element.propertyName == "Chest") {
element.top = (154 * distortionHeight).toInt();
element.left = (151 * distortionWidth).toInt();
element.value = this.customer.getProperty("Chest");
element.value = this.customer!.getProperty("Chest");
manSizes.add(element);
} else if (element.propertyName == "Belly") {
element.top = (230 * distortionHeight).toInt();
element.left = (151 * distortionWidth).toInt();
element.value = this.customer.getProperty("Belly");
element.value = this.customer!.getProperty("Belly");
manSizes.add(element);
} else if (element.propertyName == "Hip") {
element.top = (294 * distortionHeight).toInt();
element.left = (151 * distortionWidth).toInt();
element.value = this.customer.getProperty("Hip");
element.value = this.customer!.getProperty("Hip");
manSizes.add(element);
} else if (element.propertyName == "Thigh Top") {
element.top = (335 * distortionHeight).toInt();
element.left = (185 * distortionWidth).toInt();
element.value = this.customer.getProperty("Thigh Top");
element.value = this.customer!.getProperty("Thigh Top");
manSizes.add(element);
} else if (element.propertyName == "Thigh Middle") {
element.top = (377 * distortionHeight).toInt();
element.left = (125 * distortionWidth).toInt();
element.value = this.customer.getProperty("Thigh Middle");
element.value = this.customer!.getProperty("Thigh Middle");
manSizes.add(element);
} else if (element.propertyName == "Knee") {
element.top = (468 * distortionHeight).toInt();
element.left = (129 * distortionWidth).toInt();
element.value = this.customer.getProperty("Knee");
element.value = this.customer!.getProperty("Knee");
manSizes.add(element);
} else if (element.propertyName == "Calf") {
element.top = (525 * distortionHeight).toInt();
element.left = (129 * distortionWidth).toInt();
element.value = this.customer.getProperty("Calf");
element.value = this.customer!.getProperty("Calf");
manSizes.add(element);
} else if (element.propertyName == "Ankle") {
element.top = (620 * distortionHeight).toInt();
element.left = (162 * distortionWidth).toInt();
element.value = this.customer.getProperty("Ankle");
element.value = this.customer!.getProperty("Ankle");
manSizes.add(element);
} else if (element.propertyName == "Weight") {
element.top = (402 * distortionHeight).toInt();
element.left = (240 * distortionWidth).toInt();
element.value = this.customer.getProperty("Weight");
element.value = this.customer!.getProperty("Weight");
manSizes.add(element);
}
});
+77
View File
@@ -0,0 +1,77 @@
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/customer.dart';
import 'package:aitrainer_app/model/evaluation.dart';
import 'package:aitrainer_app/model/evaluation_attribute.dart';
import 'package:aitrainer_app/util/enums.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
class EvaluationRepository {
List<Evaluation>? evaluations;
EvaluationRepository() {
evaluations = Cache().evaluations;
}
String getEvaluationTextByExerciseType(int exerciseTypeId, double value) {
String? eval;
Evaluation? evaluation = this.getEvaluationByExerciseTypeId(exerciseTypeId);
Customer? customer = Cache().userLoggedIn;
if (evaluation != null && customer != null) {
int? age = customer.age;
if (age != null) {
for (var attribute in evaluation.attributes) {
EvaluationAttribute attr = attribute as EvaluationAttribute;
if (age >= attr.ageMin && age <= attr.ageMax && value >= attr.valueMin && value <= attr.valueMax) {
eval = attr.evaluationText;
break;
}
}
}
}
if (eval == null) {
eval = EvaluationText.fair.toStr();
}
return eval;
}
Evaluation? getEvaluationByExerciseTypeId(int exerciseTypeId) {
Evaluation? eval;
if (evaluations != null) {
for (var evaluation in evaluations!) {
if (evaluation.exerciseTypeId == exerciseTypeId) {
eval = evaluation;
break;
}
}
}
return eval;
}
Color getEvaluationColor(String eval) {
Color color = Colors.yellow[100]!;
if (EvaluationText.very_poor.equalsStringTo(eval)) {
return Colors.red[800]!;
} else if (EvaluationText.poor.equalsStringTo(eval)) {
return Colors.red[400]!;
} else if (EvaluationText.below_average.equalsStringTo(eval)) {
return Colors.orange[600]!;
} else if (EvaluationText.average.equalsStringTo(eval)) {
return Colors.yellow[600]!;
} else if (EvaluationText.above_average.equalsStringTo(eval)) {
return Colors.greenAccent;
} else if (EvaluationText.good.equalsStringTo(eval)) {
return Colors.green[400]!;
} else if (EvaluationText.excellent.equalsStringTo(eval)) {
return Colors.green[600]!;
} else if (EvaluationText.elite.equalsStringTo(eval)) {
return Colors.green[800]!;
}
return color;
}
}
@@ -37,6 +37,7 @@ class ExerciseDeviceRepository {
}
List<ExerciseDevice> getGymDevices() {
if (Cache().getDevices() == null) return [];
final List<ExerciseDevice> gymDevices = [];
if (_devices.isEmpty) {
_devices = Cache().getDevices()!;
+39 -20
View File
@@ -27,8 +27,13 @@ class ExercisePlanRepository {
ExercisePlan? getExercisePlan() => exercisePlan;
void addDetailToPlan() {
if (exercisePlan == null) {
this.createNewPlan();
}
if (exercisePlan != null && actualPlanDetail != null) {
actualPlanDetail!.exercisePlanId = exercisePlan!.exercisePlanId!;
if (exercisePlan!.exercisePlanId != null) {
actualPlanDetail!.exercisePlanId = exercisePlan!.exercisePlanId!;
}
exercisePlanDetails[actualPlanDetail!.exerciseTypeId] = actualPlanDetail!;
Cache().addToMyExercisePlanDetails(actualPlanDetail!);
}
@@ -85,24 +90,14 @@ class ExercisePlanRepository {
}
void removeExerciseTypeFromPlanByExerciseTypeId(int exerciseTypeId) {
if (exercisePlanDetails[exerciseTypeId] == null) return;
exercisePlanDetails[exerciseTypeId]!.change = ModelChange.delete;
Cache().deleteMyExercisePlanDetailByExerciseTypeId(exerciseTypeId);
}
Future<void> saveExercisePlan() async {
if (exercisePlan == null) {
if (Cache().userLoggedIn == null) {
throw Exception("please log in");
}
String exercisePlanName;
if (this.customerId == Cache().userLoggedIn!.customerId) {
exercisePlanName = Cache().userLoggedIn!.name! + " private";
} else {
exercisePlanName = Cache().getTrainee()!.name! + " " + Cache().getTrainee()!.firstname! + " private";
}
exercisePlan = ExercisePlan(exercisePlanName, this.customerId);
this.createNewPlan();
}
if (newPlan) {
exercisePlan!.dateAdd = DateTime.now();
@@ -139,6 +134,22 @@ class ExercisePlanRepository {
}
}
void createNewPlan() {
if (Cache().userLoggedIn == null) {
throw Exception("please log in");
}
String exercisePlanName;
if (this.customerId == Cache().userLoggedIn!.customerId) {
exercisePlanName = Cache().userLoggedIn!.name! + " private";
} else {
exercisePlanName = Cache().getTrainee()!.name! + " " + Cache().getTrainee()!.firstname! + " private";
}
exercisePlan = ExercisePlan(exercisePlanName, this.customerId);
newPlan = true;
}
Future<ExercisePlan?> getLastExercisePlan() async {
if (customerId == 0) {
return null;
@@ -150,7 +161,12 @@ class ExercisePlanRepository {
}
exercisePlan = await ExercisePlanApi().getLastExercisePlan(customerId);
newPlan = (exercisePlan == null);
if (exercisePlan == null) {
this.createNewPlan();
}
;
Cache().setMyExercisePlan(exercisePlan!);
return exercisePlan;
}
@@ -170,16 +186,19 @@ class ExercisePlanRepository {
exercisePlanDetails = listCache;
return;
} else {
list = await ExercisePlanApi().getExercisePlanDetail(exercisePlan!.exercisePlanId!);
if (exercisePlan!.exercisePlanId != null) {
list = await ExercisePlanApi().getExercisePlanDetail(exercisePlan!.exercisePlanId!);
}
}
exercisePlanDetails = LinkedHashMap<int, ExercisePlanDetail>();
list.forEach((element) {
newPlan = false;
ExercisePlanDetail detail = element;
exercisePlanDetails[detail.exerciseTypeId] = detail;
});
if (list.isNotEmpty) {
list.forEach((element) {
newPlan = false;
ExercisePlanDetail detail = element;
exercisePlanDetails[detail.exerciseTypeId] = detail;
});
}
Cache().setMyExercisePlanDetails(exercisePlanDetails);
return;
+153 -2
View File
@@ -270,16 +270,167 @@ class ExerciseRepository {
void getSameExercise(int exerciseTypeId, String day) {
this.actualExerciseList = [];
if (exerciseList != null) {
int index = 0;
for (int i = 0; i < this.exerciseList!.length; i++) {
Exercise exercise = exerciseList![i];
String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
if (exerciseTypeId == exercise.exerciseTypeId && exerciseDate == day) {
final String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
if (exerciseTypeId == exercise.exerciseTypeId && exerciseDate == day && index < 4) {
this.actualExerciseList!.add(exercise);
index++;
}
}
}
}
double calculate1RM(Exercise exercise) {
double weight = exercise.unitQuantity!;
double repeat = exercise.quantity!;
if (weight == 0 || repeat == 0) {
return 0;
}
double rmWendler = weight * repeat * 0.0333 + weight;
double rmOconner = weight * (1 + repeat / 40);
double average = (rmWendler + rmOconner) / 2;
return average;
}
double getBest1RMPercent(Exercise exercise) {
double result = 0;
if (this.exerciseList == null || this.exerciseList!.isEmpty) {
this.exerciseList = Cache().getExercises();
}
final int exerciseTypeId = exercise.exerciseTypeId!;
double toCompare = this.calculate1RM(exercise);
final String today = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(DateTime.now());
List<Exercise> oldExercises = [];
this.exerciseList!.forEach((exercise) {
final String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
if (exercise.exerciseTypeId == exerciseTypeId && exerciseDate.compareTo(today) < 0) {
oldExercises.add(exercise);
}
});
if (oldExercises.isNotEmpty) {
oldExercises.sort((a, b) {
double sumA = 0;
double sumB = 0;
if (a.unitQuantity != null && b.unitQuantity != null) {
sumA = a.quantity! * a.unitQuantity!;
sumB = b.quantity! * b.unitQuantity!;
} else {
sumA = a.quantity!;
sumB = b.quantity!;
}
return sumA >= sumB ? 1 : -1;
});
double withCompare = this.calculate1RM(oldExercises.last);
result = toCompare >= withCompare ? (1 - toCompare / withCompare) * 100 : (1 - toCompare / withCompare) * -100;
}
return result;
}
double getLast1RMPercent(Exercise exercise) {
double result = 0;
if (this.exerciseList == null || this.exerciseList!.isEmpty) {
this.exerciseList = Cache().getExercises();
}
final int exerciseTypeId = exercise.exerciseTypeId!;
double toCompare = this.calculate1RM(exercise);
final String today = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
List<Exercise> oldExercises = [];
this.exerciseList!.forEach((exercise) {
final String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
if (exercise.exerciseTypeId == exerciseTypeId && exerciseDate.compareTo(today) < 0) {
oldExercises.add(exercise);
}
});
if (oldExercises.isNotEmpty) {
double withCompare = this.calculate1RM(oldExercises.first);
result = toCompare >= withCompare ? (toCompare / withCompare) * 100 : (1 - toCompare / withCompare) * -100;
}
return result;
}
double getBestExercisePercent(Exercise exercise) {
double result = 0;
if (this.exerciseList == null || this.exerciseList!.isEmpty) {
this.exerciseList = Cache().getExercises();
}
final int exerciseTypeId = exercise.exerciseTypeId!;
double toCompare = exercise.unitQuantity != null ? exercise.quantity! * exercise.unitQuantity! : exercise.quantity!;
final String today = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(DateTime.now());
List<Exercise> oldExercises = [];
this.exerciseList!.forEach((exercise) {
final String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
if (exercise.exerciseTypeId == exerciseTypeId && exerciseDate.compareTo(today) < 0) {
oldExercises.add(exercise);
}
});
if (oldExercises.isNotEmpty) {
oldExercises.sort((a, b) {
double sumA = 0;
double sumB = 0;
if (a.unitQuantity != null && b.unitQuantity != null) {
sumA = a.quantity! * a.unitQuantity!;
sumB = b.quantity! * b.unitQuantity!;
} else {
sumA = a.quantity!;
sumB = b.quantity!;
}
return sumA >= sumB ? 1 : -1;
});
double withCompare = oldExercises.last.unitQuantity != null
? oldExercises.last.quantity! * oldExercises.last.unitQuantity!
: oldExercises.last.quantity!;
result = toCompare >= withCompare ? (1 - toCompare / withCompare) * 100 : (1 - toCompare / withCompare) * -100;
print("Last Best: ${oldExercises.last} - result: $result");
}
return result;
}
double getLastExercisePercent(Exercise exercise) {
double result = 0;
if (this.exerciseList == null || this.exerciseList!.isEmpty) {
this.exerciseList = Cache().getExercises();
}
final int exerciseTypeId = exercise.exerciseTypeId!;
double toCompare = exercise.unitQuantity != null ? exercise.quantity! * exercise.unitQuantity! : exercise.quantity!;
final String today = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
List<Exercise> oldExercises = [];
this.exerciseList!.forEach((exercise) {
final String exerciseDate = DateFormat("yyyy-MM-dd", AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
if (exercise.exerciseTypeId == exerciseTypeId && exerciseDate.compareTo(today) < 0) {
oldExercises.add(exercise);
}
});
if (oldExercises.isNotEmpty) {
double withCompare = oldExercises.first.unitQuantity != null
? oldExercises.first.quantity! * oldExercises.first.unitQuantity!
: oldExercises.first.quantity!;
result = toCompare >= withCompare ? (toCompare / withCompare) * 100 : (1 - toCompare / withCompare) * -100;
print("Last Last: ${oldExercises.first} vs. $exercise - - result: $result");
}
return result;
}
void sortByDate() {
if (exerciseList == null || exerciseList!.isEmpty) {
return;
+1 -1
View File
@@ -3,7 +3,7 @@ import 'package:aitrainer_app/model/property.dart';
import 'package:aitrainer_app/service/property_service.dart';
class PropertyRepository {
late List<Property>? _properties;
List<Property>? _properties;
Future<List<Property>?> getDBProperties() async {
this._properties = await PropertyApi().getProperties();
+3 -1
View File
@@ -112,7 +112,9 @@ class WorkoutTreeRepository with Logging {
parent != null ? parent.nameEnglish : "",
0);
this.tree[exerciseType.name] = menuItem;
menuAsExercise.add(menuItem);
if (isRunning || is1RM) {
menuAsExercise.add(menuItem);
}
//log("ExerciseType in Menu item ${exerciseType.toJson()} is1RM: $is1RM");
});
} else {