WT 1.1.0+35 Design, Menü filter, Test Server
This commit is contained in:
+37
-2
@@ -10,6 +10,7 @@ import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/service/customer_exercise_device_service.dart';
|
||||
import 'package:aitrainer_app/service/exercise_device_service.dart';
|
||||
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
||||
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
||||
import 'package:aitrainer_app/util/env.dart';
|
||||
@@ -53,6 +54,7 @@ class Cache {
|
||||
static final String isRegisteredKey = 'is_registered';
|
||||
static final String isLoggedInKey = 'is_logged_in';
|
||||
static final String langKey = 'lang';
|
||||
static final String serverKey = 'live';
|
||||
|
||||
static String baseUrl = 'http://aitrainer.info:8888/api/';
|
||||
static final String mediaUrl = 'https://aitrainer.info:4343/media/';
|
||||
@@ -88,6 +90,8 @@ class Cache {
|
||||
|
||||
List deviceLanguages;
|
||||
String startPage;
|
||||
String testEnvironment;
|
||||
bool liveServer = true;
|
||||
|
||||
factory Cache() {
|
||||
return _singleton;
|
||||
@@ -95,8 +99,10 @@ class Cache {
|
||||
|
||||
Cache._internal() {
|
||||
String testEnv = EnvironmentConfig.test_env;
|
||||
this.testEnvironment = testEnv;
|
||||
if (testEnv == "1") {
|
||||
baseUrl = 'http://aitrainer.app:8899/api/';
|
||||
liveServer = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,6 +114,33 @@ class Cache {
|
||||
return this.authToken;
|
||||
}
|
||||
|
||||
void setServer(bool live) async {
|
||||
if (this.testEnvironment == "1") {
|
||||
liveServer = false;
|
||||
live = false;
|
||||
}
|
||||
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
|
||||
SharedPreferences sharedPreferences;
|
||||
sharedPreferences = await prefs;
|
||||
liveServer = live;
|
||||
print("Set Live servier. live? " + live.toString() + " env? " + this.testEnvironment);
|
||||
sharedPreferences.setBool(Cache.serverKey, live);
|
||||
}
|
||||
|
||||
void setServerAddress(SharedPreferences prefs) {
|
||||
if (this.testEnvironment == "1") {
|
||||
return;
|
||||
}
|
||||
final bool live = prefs.getBool(Cache.serverKey);
|
||||
if (live == null) {
|
||||
return;
|
||||
}
|
||||
liveServer = live;
|
||||
if (live) {
|
||||
baseUrl = 'http://aitrainer.info:8888/api/';
|
||||
}
|
||||
}
|
||||
|
||||
static String getToken(SharedPreferences prefs) {
|
||||
return prefs.getString(authTokenKey);
|
||||
}
|
||||
@@ -163,27 +196,29 @@ class Cache {
|
||||
ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||
if (type == SharePrefsChange.registration) {
|
||||
Cache().startPage = "home";
|
||||
Flurry.setUserId(customerId.toString());
|
||||
sharedPreferences.setInt(Cache.customerIdKey, customerId);
|
||||
sharedPreferences.setBool(Cache.isRegisteredKey, true);
|
||||
sharedPreferences.setBool(Cache.isLoggedInKey, true);
|
||||
sharedPreferences.setString(Cache.firebaseUidKey, firebaseUid);
|
||||
await ExerciseTypeApi().getExerciseTypes();
|
||||
await ExerciseTreeApi().getExerciseTree();
|
||||
await ExerciseDeviceApi().getDevices();
|
||||
final customerDevices = await CustomerExerciseDeviceApi().getDevices(customerId);
|
||||
Cache().setCustomerDevices(customerDevices);
|
||||
await exerciseRepository.getExercisesByCustomer(customerId);
|
||||
Flurry.setUserId(customerId.toString());
|
||||
} else if (type == SharePrefsChange.login) {
|
||||
Flurry.setUserId(customerId.toString());
|
||||
Cache().startPage = "home";
|
||||
sharedPreferences.setInt(Cache.customerIdKey, customerId);
|
||||
sharedPreferences.setString(Cache.firebaseUidKey, firebaseUid);
|
||||
sharedPreferences.setBool(Cache.isLoggedInKey, true);
|
||||
await ExerciseTypeApi().getExerciseTypes();
|
||||
await ExerciseTreeApi().getExerciseTree();
|
||||
await ExerciseDeviceApi().getDevices();
|
||||
final customerDevices = await CustomerExerciseDeviceApi().getDevices(customerId);
|
||||
Cache().setCustomerDevices(customerDevices);
|
||||
await exerciseRepository.getExercisesByCustomer(customerId);
|
||||
Flurry.setUserId(customerId.toString());
|
||||
} else if (type == SharePrefsChange.logout) {
|
||||
sharedPreferences.setBool(Cache.isLoggedInKey, false);
|
||||
sharedPreferences.setInt(Cache.customerIdKey, 0);
|
||||
|
||||
@@ -7,6 +7,8 @@ class ExerciseDevice {
|
||||
int sort;
|
||||
bool place;
|
||||
|
||||
bool isGym;
|
||||
|
||||
ExerciseDevice.fromJson(Map json) {
|
||||
this.exerciseDeviceId = json['exerciseDeviceId'];
|
||||
this.name = json['name'];
|
||||
|
||||
@@ -6,15 +6,38 @@ class ExerciseTree {
|
||||
bool active;
|
||||
String nameTranslation;
|
||||
|
||||
ExerciseTree();
|
||||
|
||||
ExerciseTree.fromJson(Map json) {
|
||||
this.treeId = json['treeId'];
|
||||
this.name = json['name'];
|
||||
this.parentId = json['parentId'];
|
||||
this.parentId = -1;
|
||||
this.imageUrl = json['imageUrl'];
|
||||
this.active = json['active'];
|
||||
this.nameTranslation =
|
||||
json['translations'] != null && (json['translations']).length > 0
|
||||
? json['translations'][0]['name']
|
||||
: this.name;
|
||||
this.nameTranslation = json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['name'] : this.name;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"treeId": treeId,
|
||||
"parentId": parentId,
|
||||
"name": name,
|
||||
"imageUrl": imageUrl,
|
||||
"active": active.toString(),
|
||||
"nameTranslation": nameTranslation,
|
||||
};
|
||||
}
|
||||
|
||||
ExerciseTree copy(int parentId) {
|
||||
ExerciseTree newTree = ExerciseTree();
|
||||
newTree.treeId = this.treeId;
|
||||
newTree.name = this.name;
|
||||
newTree.imageUrl = this.imageUrl;
|
||||
newTree.nameTranslation = this.nameTranslation;
|
||||
if (parentId != -1) {
|
||||
newTree.parentId = parentId;
|
||||
}
|
||||
|
||||
return newTree;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class ExerciseTreeParents {
|
||||
int exerciseTreeParentsId;
|
||||
int exerciseTreeParentId;
|
||||
int exerciseTreeChildId;
|
||||
|
||||
ExerciseTreeParents.fromJson(Map json) {
|
||||
this.exerciseTreeParentsId = json['exerciseTreeParentsId'];
|
||||
this.exerciseTreeParentId = json['exerciseTreeParentId'];
|
||||
this.exerciseTreeChildId = json['exerciseTreeChildId'];
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
class ExerciseType {
|
||||
int exerciseTypeId;
|
||||
int treeId;
|
||||
//int treeId;
|
||||
String name;
|
||||
String description;
|
||||
BinaryCodec video;
|
||||
@@ -11,17 +11,20 @@ class ExerciseType {
|
||||
String unitQuantityUnit;
|
||||
bool active;
|
||||
bool base;
|
||||
String imageUrl;
|
||||
String nameTranslation;
|
||||
String descriptionTranslation;
|
||||
String imageUrl = "";
|
||||
String nameTranslation = "";
|
||||
String descriptionTranslation = "";
|
||||
List<int> devices = List();
|
||||
List<int> parents = List();
|
||||
|
||||
bool is1RM;
|
||||
bool isEndurance;
|
||||
|
||||
ExerciseType({this.name, this.description});
|
||||
|
||||
ExerciseType.fromJson(Map json) {
|
||||
this.exerciseTypeId = json['exerciseTypeId'];
|
||||
this.treeId = json['treeId'];
|
||||
//this.treeId = json['treeId'];
|
||||
this.name = json['name'];
|
||||
this.description = json['description'];
|
||||
this.unit = json['unit'];
|
||||
@@ -29,19 +32,42 @@ class ExerciseType {
|
||||
this.unitQuantityUnit = json['unitQuantityUnit'];
|
||||
this.active = json['active'];
|
||||
this.base = json['base'];
|
||||
this.imageUrl = json['images'][0]['url'];
|
||||
this.nameTranslation = json['translations'][0]['name'];
|
||||
this.descriptionTranslation = json['translations'][0]['description'];
|
||||
if (json['images'].length > 0) {
|
||||
this.imageUrl = json['images'][0]['url'];
|
||||
}
|
||||
if (json['translations'].length > 0) {
|
||||
this.nameTranslation = json['translations'][0]['name'];
|
||||
this.descriptionTranslation = json['translations'][0]['description'];
|
||||
}
|
||||
|
||||
if (json['devices'].length > 0) {
|
||||
final List jsonDevices = json['devices'];
|
||||
|
||||
jsonDevices.forEach((device) {
|
||||
this.devices.add(device['exerciseDeviceId']);
|
||||
});
|
||||
}
|
||||
|
||||
if (json['parents'].length > 0) {
|
||||
final List jsonParents = json['parents'];
|
||||
|
||||
jsonParents.forEach((parent) {
|
||||
this.parents.add(parent['exerciseTreeId']);
|
||||
});
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
Map<String, dynamic> toJson() => {
|
||||
"name": name,
|
||||
"description": description,
|
||||
"unit": unit,
|
||||
"unitQuantity": unitQuantity,
|
||||
"unitQuantityUnit": unitQuantityUnit,
|
||||
"active": active
|
||||
"active": active,
|
||||
"devices": this.devices.toString(),
|
||||
"nameTranslation": this.nameTranslation,
|
||||
"parents": this.parents.toString()
|
||||
};
|
||||
|
||||
void set1RM(bool is1RM) {
|
||||
@@ -51,4 +77,12 @@ class ExerciseType {
|
||||
bool get1RM() {
|
||||
return this.is1RM;
|
||||
}
|
||||
}
|
||||
|
||||
void setEndurance(bool isEndurance) {
|
||||
this.isEndurance = isEndurance;
|
||||
}
|
||||
|
||||
bool getEndurance() {
|
||||
return this.isEndurance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class ExerciseTypeDevice {
|
||||
int exerciseTypeDeviceId;
|
||||
int exerciseDeviceId;
|
||||
|
||||
ExerciseTypeDevice();
|
||||
|
||||
ExerciseTypeDevice.fromJson(Map json) {
|
||||
this.exerciseTypeDeviceId = json['exerciseTypeDeviceId'];
|
||||
this.exerciseDeviceId = json['exerciseDeviceId'];
|
||||
}
|
||||
}
|
||||
@@ -15,13 +15,14 @@ class WorkoutMenuTree {
|
||||
bool base;
|
||||
|
||||
bool is1RM;
|
||||
bool isEndurance;
|
||||
bool selected = false;
|
||||
bool executed = false;
|
||||
String exerciseDetail;
|
||||
String nameEnglish;
|
||||
|
||||
WorkoutMenuTree(this.id, this.parent, this.name, this.imageName, this.color, this.fontSize, this.child,
|
||||
this.exerciseTypeId, this.exerciseType, this.base, this.is1RM, this.nameEnglish);
|
||||
WorkoutMenuTree(this.id, this.parent, this.name, this.imageName, this.color, this.fontSize, this.child, this.exerciseTypeId,
|
||||
this.exerciseType, this.base, this.is1RM, this.isEndurance, this.nameEnglish);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
@@ -35,6 +36,12 @@ class WorkoutMenuTree {
|
||||
"exerciseTypeId": exerciseTypeId.toString(),
|
||||
"base": base.toString(),
|
||||
"is1RM": is1RM.toString(),
|
||||
"isEndurance": isEndurance.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return this.toJson().toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user