WT 1.1.0+39 evaluation, health data
This commit is contained in:
+28
-2
@@ -55,6 +55,7 @@ class Cache {
|
||||
static final String isLoggedInKey = 'is_logged_in';
|
||||
static final String langKey = 'lang';
|
||||
static final String serverKey = 'live';
|
||||
static final String hardwareKey = 'hardware';
|
||||
|
||||
static String baseUrl = 'http://aitrainer.info:8888/api/';
|
||||
static final String mediaUrl = 'https://aitrainer.info:4343/media/';
|
||||
@@ -92,6 +93,7 @@ class Cache {
|
||||
String startPage;
|
||||
String testEnvironment;
|
||||
bool liveServer = true;
|
||||
bool hasHardware = false;
|
||||
|
||||
factory Cache() {
|
||||
return _singleton;
|
||||
@@ -114,7 +116,7 @@ class Cache {
|
||||
return this.authToken;
|
||||
}
|
||||
|
||||
void setServer(bool live) async {
|
||||
Future<void> setServer(bool live) async {
|
||||
if (this.testEnvironment == "1") {
|
||||
liveServer = false;
|
||||
live = false;
|
||||
@@ -123,10 +125,34 @@ class Cache {
|
||||
SharedPreferences sharedPreferences;
|
||||
sharedPreferences = await prefs;
|
||||
liveServer = live;
|
||||
print("Set Live servier. live? " + live.toString() + " env? " + this.testEnvironment);
|
||||
sharedPreferences.setBool(Cache.serverKey, live);
|
||||
}
|
||||
|
||||
void getHardware(SharedPreferences prefs) {
|
||||
final bool hasHardware = prefs.getBool(Cache.hardwareKey);
|
||||
print("Has Hardware: " + hasHardware.toString());
|
||||
this.hasHardware = hasHardware;
|
||||
if (hasHardware == null) {
|
||||
this.hasHardware = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> selectedHardwareBefore() async {
|
||||
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
|
||||
SharedPreferences sharedPreferences = await prefs;
|
||||
|
||||
final bool selectedHardware = sharedPreferences.getBool(Cache.hardwareKey);
|
||||
return selectedHardware == null;
|
||||
}
|
||||
|
||||
Future<void> setHardware(bool hasHardware) async {
|
||||
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
|
||||
SharedPreferences sharedPreferences;
|
||||
sharedPreferences = await prefs;
|
||||
sharedPreferences.setBool(Cache.hardwareKey, hasHardware);
|
||||
this.hasHardware = hasHardware;
|
||||
}
|
||||
|
||||
void setServerAddress(SharedPreferences prefs) {
|
||||
if (this.testEnvironment == "1") {
|
||||
baseUrl = 'http://aitrainer.app:8899/api/';
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
enum ExerciseAbility { oneRepMax, endurance, running, none }
|
||||
|
||||
extension ExerciseAbilityExt on ExerciseAbility {
|
||||
bool equalsTo(ExerciseAbility ability) => this.toString() == ability.toString();
|
||||
bool equalsStringTo(String ability) => this.toString() == ability;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'package:aitrainer_app/model/result.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
class ExerciseResult {
|
||||
int exerciseResultId;
|
||||
int customerId;
|
||||
int exerciseId;
|
||||
int exercisePlanId;
|
||||
String resultType;
|
||||
double value;
|
||||
DateTime dateFrom;
|
||||
DateTime dateTo;
|
||||
|
||||
ResultExt resultExtension;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
String formattedDateTo;
|
||||
if (dateTo != null) {
|
||||
formattedDateTo = DateFormat('yyyy-MM-dd HH:mm').format(dateTo);
|
||||
}
|
||||
|
||||
return {
|
||||
"customerId": customerId,
|
||||
"exerciseId": exerciseId,
|
||||
"exercisePlanId": exercisePlanId,
|
||||
"resultType": resultType,
|
||||
"value": value,
|
||||
"dateFrom": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateFrom),
|
||||
"dateTo": formattedDateTo,
|
||||
};
|
||||
}
|
||||
|
||||
ExerciseResult.fromJson(Map json) {
|
||||
this.exerciseResultId = json['exerciseResultId'];
|
||||
this.exerciseId = json['exerciseId'];
|
||||
this.exercisePlanId = json['exercisePlanId'];
|
||||
this.customerId = json['customerId'];
|
||||
this.resultType = json['resultType'];
|
||||
this.value = json["value"];
|
||||
this.dateFrom = DateTime.parse(json['dateFrom']);
|
||||
this.dateTo = DateTime.parse(json['dateTo']);
|
||||
this.resultExtension = ResultExt(itemString: this.resultType);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ class ExerciseTree {
|
||||
if (parentId != -1) {
|
||||
newTree.parentId = parentId;
|
||||
}
|
||||
newTree.active = this.active;
|
||||
|
||||
return newTree;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:aitrainer_app/model/exercise_ability.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class ExerciseType {
|
||||
@@ -17,8 +18,7 @@ class ExerciseType {
|
||||
List<int> devices = List();
|
||||
List<int> parents = List();
|
||||
|
||||
bool is1RM;
|
||||
bool isEndurance;
|
||||
ExerciseAbility ability;
|
||||
|
||||
ExerciseType({this.name, this.description});
|
||||
|
||||
@@ -70,19 +70,19 @@ class ExerciseType {
|
||||
"parents": this.parents.toString()
|
||||
};
|
||||
|
||||
void set1RM(bool is1RM) {
|
||||
this.is1RM = is1RM;
|
||||
void setAbility(ExerciseAbility ability) {
|
||||
this.ability = ability;
|
||||
}
|
||||
|
||||
bool get1RM() {
|
||||
return this.is1RM;
|
||||
ExerciseAbility getAbility() {
|
||||
return this.ability;
|
||||
}
|
||||
|
||||
void setEndurance(bool isEndurance) {
|
||||
this.isEndurance = isEndurance;
|
||||
bool isEndurance() {
|
||||
return this.ability.equalsTo(ExerciseAbility.endurance);
|
||||
}
|
||||
|
||||
bool getEndurance() {
|
||||
return this.isEndurance;
|
||||
bool is1RM() {
|
||||
return this.ability.equalsTo(ExerciseAbility.oneRepMax);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
enum ResultItem {
|
||||
calorie,
|
||||
development_percent_bodypart,
|
||||
distance,
|
||||
fatburn_percent,
|
||||
bpm_avg,
|
||||
bpm_min,
|
||||
bpm_max,
|
||||
speed_max,
|
||||
reps_volume,
|
||||
steps,
|
||||
//time,
|
||||
weight_volume
|
||||
}
|
||||
|
||||
extension ResultItemExt on ResultItem {
|
||||
static const ResultItemDesc = {
|
||||
ResultItem.calorie: "Calorie",
|
||||
ResultItem.development_percent_bodypart: "Development in %",
|
||||
ResultItem.distance: "Distance",
|
||||
ResultItem.bpm_avg: "Average BPM",
|
||||
ResultItem.bpm_min: "Min BPM",
|
||||
ResultItem.bpm_max: "Max BPM",
|
||||
ResultItem.speed_max: "Max speed",
|
||||
ResultItem.reps_volume: "Repeats volume",
|
||||
ResultItem.steps: "Steps",
|
||||
//ResultItem.time: "Time",
|
||||
ResultItem.weight_volume: "Weight volume",
|
||||
ResultItem.fatburn_percent: "Fatburn %",
|
||||
};
|
||||
|
||||
static const ResultItemImg = {
|
||||
ResultItem.calorie: "pict_calorie.png",
|
||||
ResultItem.development_percent_bodypart: "pic_development_by_bodypart_percent.png",
|
||||
ResultItem.distance: "pict_distance_m.png",
|
||||
ResultItem.bpm_avg: "pict_hravg_bpm.png",
|
||||
ResultItem.bpm_min: "pict_hrmin_bpm.png",
|
||||
ResultItem.bpm_max: "pict_hrmax_bpm.png",
|
||||
ResultItem.speed_max: "pict_maxspeed_kmh.png",
|
||||
ResultItem.reps_volume: "pict_reps_volumen_db.png",
|
||||
ResultItem.steps: "pict_steps.png",
|
||||
//ResultItem.time: "pict_time_h.png",
|
||||
ResultItem.weight_volume: "pict_weight_volumen_tonna.png",
|
||||
ResultItem.fatburn_percent: "pict_fatburn_percent.png",
|
||||
};
|
||||
|
||||
static const HardwareData = {
|
||||
ResultItem.calorie: true,
|
||||
ResultItem.development_percent_bodypart: false,
|
||||
ResultItem.distance: true,
|
||||
ResultItem.bpm_avg: true,
|
||||
ResultItem.bpm_min: true,
|
||||
ResultItem.bpm_max: true,
|
||||
ResultItem.speed_max: true,
|
||||
ResultItem.reps_volume: false,
|
||||
ResultItem.steps: true,
|
||||
//ResultItem.time: false,
|
||||
ResultItem.weight_volume: false,
|
||||
ResultItem.fatburn_percent: true,
|
||||
};
|
||||
|
||||
bool equals(ResultItem item) => this.toString() == item.toString();
|
||||
bool equalsString(String item) => this.description == item;
|
||||
|
||||
String get description => ResultItemDesc[this];
|
||||
String get image => ResultItemImg[this];
|
||||
bool get isHardware => HardwareData[this];
|
||||
|
||||
String displayString() => description;
|
||||
}
|
||||
|
||||
class ResultExt {
|
||||
final String itemString;
|
||||
ResultItem item;
|
||||
String data = "0";
|
||||
|
||||
ResultExt({this.itemString}) {
|
||||
ResultItem.values.forEach((element) {
|
||||
if (element.equalsString(itemString)) {
|
||||
item = element;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String getDescription() => item.description;
|
||||
String getImage() => "asset/image/" + item.image;
|
||||
bool isHardware() {
|
||||
return item.isHardware;
|
||||
}
|
||||
|
||||
bool equals(ResultItem item) => this.item.equals(item);
|
||||
bool equalsString(String item) => this.item.equalsString(item);
|
||||
}
|
||||
@@ -2,6 +2,22 @@ import 'dart:ui';
|
||||
|
||||
import 'exercise_type.dart';
|
||||
|
||||
enum WorkoutType { endurance, oneRepMax, cardio, staticExercise }
|
||||
|
||||
extension WorkoutTypeExt on WorkoutType {
|
||||
static const WorkoutTypeMenu = {
|
||||
WorkoutType.endurance: "Endurance",
|
||||
WorkoutType.cardio: "Cardio",
|
||||
WorkoutType.oneRepMax: "One Rep Max",
|
||||
WorkoutType.staticExercise: "Static"
|
||||
};
|
||||
|
||||
bool equals(WorkoutType type) => this.toString() == type.toString();
|
||||
bool equalsString(String type) => this.toString() == type;
|
||||
|
||||
String get menu => WorkoutTypeMenu[this];
|
||||
}
|
||||
|
||||
class WorkoutMenuTree {
|
||||
int id;
|
||||
int parent;
|
||||
@@ -16,13 +32,15 @@ class WorkoutMenuTree {
|
||||
|
||||
bool is1RM;
|
||||
bool isEndurance;
|
||||
bool isRunning;
|
||||
List<WorkoutType> workoutTypes = List();
|
||||
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.isEndurance, this.nameEnglish);
|
||||
this.exerciseType, this.base, this.is1RM, this.isEndurance, this.isRunning, this.nameEnglish);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
@@ -37,6 +55,7 @@ class WorkoutMenuTree {
|
||||
"base": base.toString(),
|
||||
"is1RM": is1RM.toString(),
|
||||
"isEndurance": isEndurance.toString(),
|
||||
"isRunning": isRunning.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user