WT 1.1.7+2 SearchBar, Timer for ExerciseControl

This commit is contained in:
bossanyit
2021-02-28 17:03:47 +01:00
parent cf348cebb0
commit 6bea5e70e1
77 changed files with 1581 additions and 1008 deletions
+203 -4
View File
@@ -11,6 +11,7 @@ import 'package:aitrainer_app/service/customer_service.dart';
import 'package:aitrainer_app/service/logging.dart';
import 'package:aitrainer_app/service/product_test_service.dart';
import 'package:aitrainer_app/service/purchase_service.dart';
import 'package:aitrainer_app/util/enums.dart';
import 'package:aitrainer_app/util/not_found_exception.dart';
class GenderItem {
@@ -25,6 +26,14 @@ class CustomerRepository with Logging {
List<Customer> _trainees;
List<CustomerProperty> _allProperties;
final PropertyRepository propertyRepository = PropertyRepository();
final List<Property> womanSizes = List();
final List<Property> manSizes = List();
final double baseWidth = 312;
final double baseHeight = 675.2;
double mediaWidth = 0;
double mediaHeight = 0;
bool isMan = true;
//List<CustomerRepository> customerList = List<CustomerRepository>();
bool visibleDetails = false;
@@ -32,10 +41,10 @@ class CustomerRepository with Logging {
CustomerRepository({this.customer}) {
customer = Customer();
genders = [
GenderItem("m", "Man"),
GenderItem("w", "Woman"),
];
if (Cache().userLoggedIn != null) {
isMan = (Cache().userLoggedIn.sex == "m");
}
}
String getGenderByName(String name) {
@@ -297,4 +306,194 @@ class CustomerRepository with Logging {
Future<void> addProductTest(ProductTest productTest) async {
await ProductTestApi().saveProductTest(productTest);
}
void setMediaDimensions(double width, double height) {
this.mediaHeight = height;
this.mediaWidth = width;
this.addSizes(this.sex);
}
void addSizes(String sex) {
List<Property> properties = Cache().getProperties();
if (properties == null) {
return;
}
final double distortionWidth = mediaWidth / baseWidth;
final double distortionHeight = mediaHeight / baseHeight;
if (isMan) {
properties.forEach((element) {
if (element.propertyName == "Shoulder") {
element.top = (122 * distortionHeight).toInt();
element.left = (130 * distortionWidth).toInt();
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");
manSizes.add(element);
} else if (element.propertyName == "Biceps") {
element.top = (178 * distortionHeight).toInt();
element.left = (208 * distortionWidth).toInt();
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");
manSizes.add(element);
} else if (element.propertyName == "Belly") {
element.top = (244 * distortionHeight).toInt();
element.left = (130 * distortionWidth).toInt();
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");
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");
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");
manSizes.add(element);
} else if (element.propertyName == "Knee") {
element.top = (464 * distortionHeight).toInt();
element.left = (97 * distortionWidth).toInt();
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");
manSizes.add(element);
} else if (element.propertyName == "Ankle") {
element.top = (620 * distortionHeight).toInt();
element.left = (150 * distortionWidth).toInt();
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");
manSizes.add(element);
}
});
} else {
properties.forEach((element) {
if (element.propertyName == "Shoulder") {
element.top = (122 * distortionHeight).toInt();
element.left = (151 * distortionWidth).toInt();
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");
manSizes.add(element);
} else if (element.propertyName == "Biceps") {
element.top = (178 * distortionHeight).toInt();
element.left = (212 * distortionWidth).toInt();
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");
manSizes.add(element);
} else if (element.propertyName == "Belly") {
element.top = (230 * distortionHeight).toInt();
element.left = (151 * distortionWidth).toInt();
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");
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");
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");
manSizes.add(element);
} else if (element.propertyName == "Knee") {
element.top = (468 * distortionHeight).toInt();
element.left = (129 * distortionWidth).toInt();
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");
manSizes.add(element);
} else if (element.propertyName == "Ankle") {
element.top = (620 * distortionHeight).toInt();
element.left = (162 * distortionWidth).toInt();
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");
manSizes.add(element);
}
});
}
}
int getWeightCoordinate(isMan, {isTop = false, isLeft = false}) {
int value = 0;
this.manSizes.forEach((element) {
if (element.propertyName == SizesEnum.Weight.toStr()) {
if (isTop == true) {
value = element.top;
} else if (isLeft == true) {
value = element.left;
}
}
});
return value;
}
Property getPropertyByName(String propertyName) {
Property property;
List<Property> sizes;
if (this.sex == "m") {
sizes = this.manSizes;
} else {
sizes = this.womanSizes;
}
sizes.forEach((element) {
if (element.propertyName == propertyName) {
property = element;
}
});
return property;
}
void updateSizes(String propertyName, double value) {
List<Property> sizes;
if (this.sex == "m") {
sizes = this.manSizes;
} else {
sizes = this.womanSizes;
}
sizes.forEach((element) {
if (element.propertyName == propertyName) {
element.value = value;
}
});
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
import 'dart:collection';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/util/app_language.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/customer.dart';
import 'package:aitrainer_app/model/exercise.dart';
+26 -18
View File
@@ -1,5 +1,5 @@
import 'dart:collection';
import 'package:aitrainer_app/localization/app_language.dart';
import 'package:aitrainer_app/util/app_language.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/exercise_ability.dart';
import 'package:aitrainer_app/model/exercise_tree.dart';
@@ -35,6 +35,7 @@ class WorkoutTreeRepository with Logging {
SplayTreeMap sortedTree = SplayTreeMap<String, List<WorkoutMenuTree>>();
bool isEnglish;
WorkoutType workoutType;
final List<WorkoutMenuTree> menuAsExercise = List();
final Map<String, int> _antagonist = {
Antagonist.chest: Antagonist.chestNr,
@@ -85,23 +86,24 @@ class WorkoutTreeRepository with Logging {
if (isRunning == false && treeItem.parentId != 0) {
isRunning = isParentRunning(treeItem.parentId);
}
WorkoutMenuTree parent = getParentItem(treeItem.parentId);
WorkoutMenuTree menuItem = WorkoutMenuTree(
treeItem.treeId,
treeItem.parentId,
treeName,
treeItem.imageUrl,
Colors.white,
30,
false,
0,
null,
false,
is1RM,
isEndurance,
isRunning,
treeItem.name,
);
treeItem.treeId,
treeItem.parentId,
treeName,
treeItem.imageUrl,
Colors.white,
30,
false,
0,
null,
false,
is1RM,
isEndurance,
isRunning,
treeItem.name,
parent != null ? parent.name : "",
parent != null ? parent.nameEnglish : "");
menuItem = this.setWorkoutTypes(menuItem, treeItem);
this.tree[treeItem.name + "_" + treeItem.parentId.toString()] = menuItem;
//log("WorkoutMenuTree item " + menuItem.toJson().toString());
@@ -113,6 +115,7 @@ class WorkoutTreeRepository with Logging {
exerciseType.active == true) {
String exerciseTypeName = isEnglish ? exerciseType.name : exerciseType.nameTranslation;
//String assetImage = await _buildImage(exerciseType.imageUrl); //'asset/menu/' + exerciseType.imageUrl.substring(7);
if (exerciseType.parents.isNotEmpty) {
exerciseType.parents.forEach((parentId) {
bool is1RM = this.isParent1RM(parentId);
@@ -121,6 +124,7 @@ class WorkoutTreeRepository with Logging {
if (isEndurance) exerciseType.setAbility(ExerciseAbility.endurance);
bool isRunning = this.isParentRunning(parentId);
if (isRunning) exerciseType.setAbility(ExerciseAbility.running);
WorkoutMenuTree parent = getParentItem(parentId);
WorkoutMenuTree menuItem = WorkoutMenuTree(
exerciseType.exerciseTypeId,
parentId,
@@ -135,8 +139,11 @@ class WorkoutTreeRepository with Logging {
is1RM,
isEndurance,
isRunning,
exerciseType.name);
exerciseType.name,
parent != null ? parent.name : "",
parent != null ? parent.nameEnglish : "");
this.tree[exerciseType.name] = menuItem;
menuAsExercise.add(menuItem);
//log("WorkoutMenuTree item " + menuItem.toJson().toString());
/* log("ExerciseType in Menu item " +
exerciseType.toJson().toString() +
@@ -156,6 +163,7 @@ class WorkoutTreeRepository with Logging {
Cache().setWorkoutMenuTree(tree);
ExerciseRepository exerciseRepository = ExerciseRepository();
exerciseRepository.getBaseExerciseFinishedPercent();
menuAsExercise.sort((a, b) => a.name.compareTo(b.name));
}
WorkoutMenuTree setWorkoutTypes(WorkoutMenuTree menu, ExerciseTree treeItem) {