WT1.1.4 build 45 android fb, iap
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
||||
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class Antagonist {
|
||||
static String chest = "Chest";
|
||||
@@ -47,6 +48,19 @@ class WorkoutTreeRepository with Logging {
|
||||
Antagonist.calf: Antagonist.calfNr
|
||||
};
|
||||
|
||||
Future<String> _buildImage(String imageUrl) async {
|
||||
String assetImage = 'asset/menu/' + imageUrl.substring(7);
|
||||
//print("Loading image " + assetImage);
|
||||
return rootBundle.load(assetImage).then((value) {
|
||||
return assetImage;
|
||||
}).catchError((_) {
|
||||
String imagePath = assetImage.substring(10);
|
||||
String url = Cache.mediaUrl + 'images' + imagePath;
|
||||
//print("Exception: " + assetImage + " will be loaded from the network " + url);
|
||||
return url;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> createTree() async {
|
||||
isEnglish = AppLanguage().appLocal == Locale('en');
|
||||
log("** Start creating tree on lang: " + AppLanguage().appLocal.languageCode);
|
||||
@@ -65,7 +79,7 @@ class WorkoutTreeRepository with Logging {
|
||||
//log(" -- TreeItem " + treeItem.toJson().toString() + " active " + treeItem.active.toString());
|
||||
if (treeItem.active == true) {
|
||||
String treeName = isEnglish ? treeItem.name : treeItem.nameTranslation;
|
||||
String assetImage = 'asset/menu/' + treeItem.imageUrl.substring(7);
|
||||
//String assetImage = await _buildImage(treeItem.imageUrl);
|
||||
|
||||
bool is1RM = treeItem.name == 'One Rep Max' ? true : false;
|
||||
if (is1RM == false && treeItem.parentId != 0) {
|
||||
@@ -86,7 +100,7 @@ class WorkoutTreeRepository with Logging {
|
||||
treeItem.treeId,
|
||||
treeItem.parentId,
|
||||
treeName,
|
||||
assetImage,
|
||||
treeItem.imageUrl,
|
||||
Colors.white,
|
||||
30,
|
||||
false,
|
||||
@@ -104,11 +118,11 @@ class WorkoutTreeRepository with Logging {
|
||||
}
|
||||
});
|
||||
|
||||
exerciseTypes.forEach((exerciseType) {
|
||||
exerciseTypes.forEach((exerciseType) async {
|
||||
if (!(exerciseType.imageUrl.isEmpty || exerciseType.name.isEmpty || exerciseType.nameTranslation.isEmpty) &&
|
||||
exerciseType.active == true) {
|
||||
String exerciseTypeName = isEnglish ? exerciseType.name : exerciseType.nameTranslation;
|
||||
String assetImage = 'asset/menu/' + exerciseType.imageUrl.substring(7);
|
||||
//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);
|
||||
@@ -117,8 +131,21 @@ class WorkoutTreeRepository with Logging {
|
||||
if (isEndurance) exerciseType.setAbility(ExerciseAbility.endurance);
|
||||
bool isRunning = this.isParentRunning(parentId);
|
||||
if (isRunning) exerciseType.setAbility(ExerciseAbility.running);
|
||||
WorkoutMenuTree menuItem = WorkoutMenuTree(exerciseType.exerciseTypeId, parentId, exerciseTypeName, assetImage, Colors.white,
|
||||
24, true, exerciseType.exerciseTypeId, exerciseType, exerciseType.base, is1RM, isEndurance, isRunning, exerciseType.name);
|
||||
WorkoutMenuTree menuItem = WorkoutMenuTree(
|
||||
exerciseType.exerciseTypeId,
|
||||
parentId,
|
||||
exerciseTypeName,
|
||||
exerciseType.imageUrl,
|
||||
Colors.white,
|
||||
24,
|
||||
true,
|
||||
exerciseType.exerciseTypeId,
|
||||
exerciseType,
|
||||
exerciseType.base,
|
||||
is1RM,
|
||||
isEndurance,
|
||||
isRunning,
|
||||
exerciseType.name);
|
||||
this.tree[exerciseType.name] = menuItem;
|
||||
//log("WorkoutMenuTree item " + menuItem.toJson().toString());
|
||||
/* log("ExerciseType in Menu item " +
|
||||
|
||||
Reference in New Issue
Block a user