WT1.1.10 compact test, paralell test
This commit is contained in:
@@ -73,7 +73,7 @@ class ExerciseRepository {
|
||||
|
||||
Exercise getExercise() => this.exercise;
|
||||
|
||||
Future<void> addExercise() async {
|
||||
Future<Exercise> addExercise() async {
|
||||
final Exercise modelExercise = this.exercise;
|
||||
modelExercise.customerId = this.customer.customerId;
|
||||
modelExercise.exerciseTypeId = this.exerciseType.exerciseTypeId;
|
||||
@@ -94,17 +94,18 @@ class ExerciseRepository {
|
||||
Cache().addExerciseTrainee(savedExercise);
|
||||
}
|
||||
|
||||
/* this.actualExerciseList.forEach((element) {
|
||||
print("$index. actual: " + element.toJson().toString());
|
||||
}); */
|
||||
return savedExercise;
|
||||
}
|
||||
|
||||
void initExercise() {
|
||||
this.createNew();
|
||||
this.exerciseType = exerciseType;
|
||||
this.setUnit(exerciseType.unit);
|
||||
exercise.exerciseTypeId = this.exerciseType.exerciseTypeId;
|
||||
this.setQuantity(quantity);
|
||||
this.setUnitQuantity(modelExercise.unitQuantity);
|
||||
this.setQuantity(12);
|
||||
this.setUnitQuantity(30);
|
||||
this.exercise.exercisePlanDetailId = 0;
|
||||
exercise.exerciseId = 0;
|
||||
this.start = DateTime.now();
|
||||
}
|
||||
|
||||
@@ -303,7 +304,7 @@ class ExerciseRepository {
|
||||
double quantity = exercise.quantity == null ? 0 : exercise.quantity;
|
||||
summary += delimiter + quantity.toStringAsFixed(0);
|
||||
ExerciseType exerciseType = Cache().getExerciseTypeById(exercise.exerciseTypeId);
|
||||
//print("exerciseType " + (exerciseType == null ? "NULL" : exerciseType.name) + " ID " + exercise.exerciseTypeId.toString());
|
||||
print("exerciseType " + (exerciseType == null ? "NULL" : exerciseType.name) + " ID " + exercise.exerciseTypeId.toString());
|
||||
if (exerciseType.unitQuantity == "1") {
|
||||
summary += "x" + exercise.unitQuantity.toStringAsFixed(0);
|
||||
}
|
||||
|
||||
@@ -11,23 +11,12 @@ import 'package:aitrainer_app/service/exercise_type_service.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Antagonist {
|
||||
static String chest = "Chest";
|
||||
static int chestNr = 1;
|
||||
static String biceps = "Biceps";
|
||||
static int bicepsNr = 2;
|
||||
static String triceps = "Triceps";
|
||||
static int tricepsNr = 3;
|
||||
static String back = "Back";
|
||||
static int backNr = 4;
|
||||
static String shoulder = "Shoulders";
|
||||
static int shoulderNr = 5;
|
||||
static String core = "Core & ABS";
|
||||
static int coreNr = 6;
|
||||
static String thigh = "Thigh";
|
||||
static int thighNr = 7;
|
||||
static String calf = "Calf";
|
||||
static int calfNr = 8;
|
||||
enum Antagonist { chest, biceps, triceps, back, shoulders, core, thigh, calf }
|
||||
|
||||
extension AntagonistExt on Antagonist {
|
||||
bool equalsTo(Antagonist type) => this.toString() == type.toString();
|
||||
bool equalsStringTo(String type) => this.toString() == type;
|
||||
String enumToString() => this.toString().split(".").last;
|
||||
}
|
||||
|
||||
class WorkoutTreeRepository with Logging {
|
||||
@@ -37,17 +26,6 @@ class WorkoutTreeRepository with Logging {
|
||||
WorkoutType workoutType;
|
||||
final List<WorkoutMenuTree> menuAsExercise = List();
|
||||
|
||||
final Map<String, int> _antagonist = {
|
||||
Antagonist.chest: Antagonist.chestNr,
|
||||
Antagonist.biceps: Antagonist.bicepsNr,
|
||||
Antagonist.triceps: Antagonist.tricepsNr,
|
||||
Antagonist.back: Antagonist.backNr,
|
||||
Antagonist.shoulder: Antagonist.shoulderNr,
|
||||
Antagonist.core: Antagonist.coreNr,
|
||||
Antagonist.thigh: Antagonist.thighNr,
|
||||
Antagonist.calf: Antagonist.calfNr
|
||||
};
|
||||
|
||||
Future<void> createTree() async {
|
||||
//if (Cache().getExerciseTree().length > 0 || Cache().getWorkoutMenuTree().length > 0) return;
|
||||
isEnglish = AppLanguage().appLocal == Locale('en');
|
||||
@@ -66,20 +44,16 @@ class WorkoutTreeRepository with Logging {
|
||||
exerciseTypes = await ExerciseTypeApi().getExerciseTypes();
|
||||
}
|
||||
|
||||
exerciseTree.sort((a, b) => a.sort.compareTo(b.sort));
|
||||
|
||||
exerciseTree.forEach((treeItem) async {
|
||||
//log(" -- TreeItem " + treeItem.toJson().toString() + " active " + treeItem.active.toString());
|
||||
if (treeItem.active == true) {
|
||||
String treeName = isEnglish ? treeItem.name : treeItem.nameTranslation;
|
||||
//String assetImage = await _buildImage(treeItem.imageUrl);
|
||||
|
||||
bool is1RM = treeItem.name == 'One Rep Max' ? true : false;
|
||||
if (is1RM == false && treeItem.parentId != 0) {
|
||||
is1RM = isParent1RM(treeItem.parentId);
|
||||
}
|
||||
|
||||
bool isEndurance = treeItem.name == 'Endurance' ? true : false;
|
||||
if (isEndurance == false && treeItem.parentId != 0) {
|
||||
isEndurance = isParentEndurance(treeItem.parentId);
|
||||
bool is1RM = treeItem.name.contains("Muscle") || treeItem.name.contains("Shape") ? true : false;
|
||||
if (!is1RM) {
|
||||
is1RM = this.isParent1RM(treeItem.parentId);
|
||||
}
|
||||
|
||||
bool isRunning = treeItem.name == "Cardio" ? true : false;
|
||||
@@ -99,7 +73,6 @@ class WorkoutTreeRepository with Logging {
|
||||
null,
|
||||
false,
|
||||
is1RM,
|
||||
isEndurance,
|
||||
isRunning,
|
||||
treeItem.name,
|
||||
parent != null ? parent.name : "",
|
||||
@@ -107,7 +80,7 @@ class WorkoutTreeRepository with Logging {
|
||||
treeItem.sort);
|
||||
menuItem = this.setWorkoutTypes(menuItem, treeItem);
|
||||
this.tree[treeItem.name + "_" + treeItem.parentId.toString()] = menuItem;
|
||||
//log("WorkoutMenuTree item " + menuItem.toJson().toString());
|
||||
//log("WorkoutMenuTree item ${menuItem.toJson()}");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -120,11 +93,14 @@ class WorkoutTreeRepository with Logging {
|
||||
if (exerciseType.parents.isNotEmpty) {
|
||||
exerciseType.parents.forEach((parentId) {
|
||||
bool is1RM = this.isParent1RM(parentId);
|
||||
bool isEndurance = this.isParentEndurance(parentId);
|
||||
if (is1RM) exerciseType.setAbility(ExerciseAbility.oneRepMax);
|
||||
if (isEndurance) exerciseType.setAbility(ExerciseAbility.endurance);
|
||||
if (is1RM) {
|
||||
exerciseType.setAbility(ExerciseAbility.oneRepMax);
|
||||
}
|
||||
bool isRunning = this.isParentRunning(parentId);
|
||||
if (isRunning) exerciseType.setAbility(ExerciseAbility.running);
|
||||
if (isRunning) {
|
||||
is1RM = false;
|
||||
exerciseType.setAbility(ExerciseAbility.running);
|
||||
}
|
||||
WorkoutMenuTree parent = getParentItem(parentId);
|
||||
WorkoutMenuTree menuItem = WorkoutMenuTree(
|
||||
exerciseType.exerciseTypeId,
|
||||
@@ -138,7 +114,6 @@ class WorkoutTreeRepository with Logging {
|
||||
exerciseType,
|
||||
exerciseType.base,
|
||||
is1RM,
|
||||
isEndurance,
|
||||
isRunning,
|
||||
exerciseType.name,
|
||||
parent != null ? parent.name : "",
|
||||
@@ -146,13 +121,7 @@ class WorkoutTreeRepository with Logging {
|
||||
0);
|
||||
this.tree[exerciseType.name] = menuItem;
|
||||
menuAsExercise.add(menuItem);
|
||||
//log("WorkoutMenuTree item " + menuItem.toJson().toString());
|
||||
/* log("ExerciseType in Menu item " +
|
||||
exerciseType.toJson().toString() +
|
||||
" is1RM: " +
|
||||
is1RM.toString() +
|
||||
" isEndurance: " +
|
||||
isEndurance.toString()); */
|
||||
//log("ExerciseType in Menu item ${exerciseType.toJson()} is1RM: $is1RM");
|
||||
});
|
||||
} else {
|
||||
//log("No Parents " + exerciseType.toJson().toString());
|
||||
@@ -215,20 +184,6 @@ class WorkoutTreeRepository with Logging {
|
||||
return isTreeItem1RM;
|
||||
}
|
||||
|
||||
bool isParentEndurance(int treeId) {
|
||||
bool isTreeItemEndurance = false;
|
||||
|
||||
this.tree.forEach((key, value) {
|
||||
WorkoutMenuTree treeItem = value as WorkoutMenuTree;
|
||||
if (treeItem.id == treeId) {
|
||||
isTreeItemEndurance = isTreeItemEndurance || treeItem.isEndurance;
|
||||
//log(treeItem.id.toString() + " " + treeItem.name + " Endurance? " + treeItem.isEndurance.toString());
|
||||
}
|
||||
});
|
||||
|
||||
return isTreeItemEndurance;
|
||||
}
|
||||
|
||||
bool isChild(int parentId) {
|
||||
bool isChild = true;
|
||||
|
||||
@@ -247,7 +202,7 @@ class WorkoutTreeRepository with Logging {
|
||||
this.getBranch(parentId).forEach((key, value) {
|
||||
WorkoutMenuTree workoutTree = value;
|
||||
isChild = isChild && workoutTree.child;
|
||||
isGym = isGym && (workoutTree.is1RM || workoutTree.isEndurance);
|
||||
isGym = isGym && (workoutTree.is1RM);
|
||||
});
|
||||
return isChild && isGym;
|
||||
}
|
||||
@@ -308,7 +263,6 @@ class WorkoutTreeRepository with Logging {
|
||||
}
|
||||
|
||||
List<WorkoutMenuTree> list = List();
|
||||
list.add(workoutMenuTree);
|
||||
alternatives.forEach((element) {
|
||||
final WorkoutMenuTree alternativeMenuItem = this.getMenuItemByExerciseTypeId(element.exerciseTypeId);
|
||||
list.add(alternativeMenuItem);
|
||||
@@ -335,12 +289,23 @@ class WorkoutTreeRepository with Logging {
|
||||
return list;
|
||||
}
|
||||
|
||||
String getAntagonistSort(String type) {
|
||||
String found = "";
|
||||
for (int i = 0; i < Antagonist.values.length; i++) {
|
||||
if (type.toLowerCase().contains((Antagonist.values[i]).enumToString())) {
|
||||
found = (i + 1).toString();
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void sortByMuscleType() {
|
||||
sortedTree = SplayTreeMap<String, List<WorkoutMenuTree>>();
|
||||
tree.forEach((key, value) {
|
||||
WorkoutMenuTree workoutTree = value as WorkoutMenuTree;
|
||||
if (workoutTree.nameEnglish != 'One Rep Max' && workoutTree.is1RM && workoutTree.exerciseTypeId == 0) {
|
||||
String treeName = _antagonist[workoutTree.nameEnglish].toString() + ". " + workoutTree.name;
|
||||
if (!workoutTree.nameEnglish.contains('Muscle Build') && workoutTree.is1RM && workoutTree.exerciseTypeId == 0) {
|
||||
String treeName = getAntagonistSort(workoutTree.nameEnglish) + ". " + workoutTree.name;
|
||||
print("TreeName $treeName ${workoutTree.name}");
|
||||
sortedTree[treeName] = this.getBranchList(workoutTree.id);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user