wt1.1.1 ExercisePlan + ExercisePlan detail, Trainee
This commit is contained in:
+45
-1
@@ -1,6 +1,7 @@
|
||||
import 'dart:collection';
|
||||
|
||||
import 'package:aitrainer_app/model/customer.dart';
|
||||
import 'package:aitrainer_app/model/exercise_plan.dart';
|
||||
import 'package:aitrainer_app/model/exercise_plan_detail.dart';
|
||||
import 'package:aitrainer_app/model/exercise_tree.dart';
|
||||
import 'package:aitrainer_app/model/exercise.dart';
|
||||
import 'package:aitrainer_app/model/workout_tree.dart';
|
||||
@@ -55,10 +56,19 @@ class Cache {
|
||||
|
||||
List<ExerciseType> _exerciseTypes;
|
||||
List<ExerciseTree> _exerciseTree;
|
||||
|
||||
List<Exercise> _exercises;
|
||||
ExercisePlan _myExercisePlan;
|
||||
List<ExercisePlanDetail> _myExercisesPlanDetail;
|
||||
|
||||
LinkedHashMap _tree = LinkedHashMap<String, WorkoutTree>();
|
||||
double _percentExercises = -1;
|
||||
|
||||
Customer _trainee;
|
||||
List<Exercise> _exercisesTrainee;
|
||||
ExercisePlan _traineeExercisePlan;
|
||||
List<ExercisePlanDetail> _traineeExercisesPlanDetail;
|
||||
|
||||
List deviceLanguages;
|
||||
String startPage;
|
||||
|
||||
@@ -73,6 +83,10 @@ class Cache {
|
||||
}
|
||||
}
|
||||
|
||||
void setTestBaseUrl() {
|
||||
baseUrl = 'http://aitrainer.app:8899/api/';
|
||||
}
|
||||
|
||||
String getAuthToken() {
|
||||
return this.authToken;
|
||||
}
|
||||
@@ -106,6 +120,12 @@ class Cache {
|
||||
logout() async {
|
||||
userLoggedIn = null;
|
||||
authToken = "";
|
||||
_trainee = null;
|
||||
_percentExercises = -1;
|
||||
_exercisesTrainee = null;
|
||||
_traineeExercisePlan = null;
|
||||
_exercises = List();
|
||||
print("Trainees is null? " + (_trainee == null).toString() );
|
||||
//firstLoad = true;
|
||||
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
|
||||
await setPreferences(prefs, SharePrefsChange.logout, 0);
|
||||
@@ -154,6 +174,10 @@ class Cache {
|
||||
this._exercises = exercises;
|
||||
}
|
||||
|
||||
void setExercisesTrainee( List<Exercise> exercises ) {
|
||||
this._exercisesTrainee = exercises;
|
||||
}
|
||||
|
||||
void setWorkoutTree( LinkedHashMap<String, WorkoutTree> tree) {
|
||||
this._tree = tree;
|
||||
}
|
||||
@@ -170,6 +194,10 @@ class Cache {
|
||||
return this._exercises;
|
||||
}
|
||||
|
||||
List<Exercise> getExercisesTrainee() {
|
||||
return this._exercisesTrainee;
|
||||
}
|
||||
|
||||
LinkedHashMap<String, WorkoutTree> getWorkoutTree() {
|
||||
return this._tree;
|
||||
}
|
||||
@@ -186,4 +214,20 @@ class Cache {
|
||||
_exercises.add(exercise);
|
||||
}
|
||||
|
||||
void addExerciseTrainee(Exercise exercise) {
|
||||
_exercisesTrainee.add(exercise);
|
||||
}
|
||||
|
||||
Customer getTrainee() {
|
||||
return this._trainee;
|
||||
}
|
||||
|
||||
void setTrainee(Customer trainee) {
|
||||
this._trainee = trainee;
|
||||
}
|
||||
|
||||
void setTraineeExercisePlan(ExercisePlan exercisePlan) {
|
||||
this._traineeExercisePlan = exercisePlan;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,7 @@ class Customer {
|
||||
String fitnessLevel;
|
||||
String bodyType;
|
||||
int admin;
|
||||
int trainer;
|
||||
int dataPolicyAllowed;
|
||||
|
||||
|
||||
@@ -30,6 +31,7 @@ class Customer {
|
||||
this.goal,
|
||||
this.weight,
|
||||
this.admin,
|
||||
this.trainer,
|
||||
this.dataPolicyAllowed
|
||||
});
|
||||
|
||||
@@ -47,6 +49,7 @@ class Customer {
|
||||
this.goal = json['goal'];
|
||||
this.weight = json['weight'];
|
||||
this.admin = json['admin'];
|
||||
this.trainer = json['trainer'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
@@ -64,6 +67,7 @@ class Customer {
|
||||
"goal": goal,
|
||||
"weight": weight,
|
||||
"admin": admin,
|
||||
"trainer": trainer,
|
||||
"dataPolicyAllowed": dataPolicyAllowed,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ class Exercise {
|
||||
String unit;
|
||||
double unitQuantity;
|
||||
DateTime dateAdd;
|
||||
int exercisePlanDetailId;
|
||||
|
||||
|
||||
|
||||
@@ -30,5 +31,6 @@ class Exercise {
|
||||
"unit": unit,
|
||||
"unitQuantity": unitQuantity,
|
||||
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
|
||||
"exercisePlanDetailId": exercisePlanDetailId,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class ExercisePlan {
|
||||
int exercisePlanId;
|
||||
int customerId;
|
||||
String name;
|
||||
String description;
|
||||
bool private;
|
||||
DateTime dateAdd;
|
||||
DateTime dateUpd;
|
||||
|
||||
ExercisePlan(String name, int customerId) {
|
||||
this.customerId = customerId;
|
||||
this.name = name;
|
||||
this.dateUpd = DateTime.now();
|
||||
}
|
||||
|
||||
ExercisePlan.fromJson(Map json) {
|
||||
this.exercisePlanId = json['exercisePlanId'];
|
||||
this.customerId = json['customerId'];
|
||||
this.name = json['name'];
|
||||
this.private = json['private'];
|
||||
this.description = json['description'];
|
||||
this.dateAdd = json['dateAdd'] == null ? null : DateTime.parse( json['dateAdd'] );
|
||||
this.dateUpd = json['dateUpd'] == null ? null : DateTime.parse( json['dateUpd'] );
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
String formattedDateAdd;
|
||||
if ( dateAdd != null) {
|
||||
formattedDateAdd = DateFormat('yyyy-MM-dd HH:mm').format(dateAdd);
|
||||
}
|
||||
String formattedDateUpd = DateFormat('yyyy-MM-dd HH:mm').format(dateUpd);
|
||||
|
||||
print("DateAdd $formattedDateAdd");
|
||||
if ( exercisePlanId == null ) {
|
||||
return {
|
||||
"customerId": customerId,
|
||||
"name": name,
|
||||
"description": description,
|
||||
"private": private,
|
||||
"dateAdd": formattedDateAdd,
|
||||
"dateUpd": formattedDateUpd,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
"exercisePlanId": exercisePlanId,
|
||||
"customerId": customerId,
|
||||
"name": name,
|
||||
"description": description,
|
||||
"private": private,
|
||||
"dateAdd": formattedDateAdd,
|
||||
"dateUpd": formattedDateUpd,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:aitrainer_app/model/exercise_plan.dart';
|
||||
|
||||
import 'exercise_type.dart';
|
||||
|
||||
class ExercisePlanDetail {
|
||||
int exercisePlanDetailId;
|
||||
int exercisePlanId;
|
||||
int exerciseTypeId;
|
||||
int serie;
|
||||
int repeats;
|
||||
String weightEquation;
|
||||
|
||||
ExerciseType exerciseType;
|
||||
|
||||
ExercisePlanDetail(int exerciseTypeId) {
|
||||
this.exerciseTypeId = exerciseTypeId;
|
||||
}
|
||||
|
||||
ExercisePlanDetail.fromJson(Map json) {
|
||||
this.exercisePlanDetailId = json['exercisePlanDetailId'];
|
||||
this.exercisePlanId = json['exercisePlanId'];
|
||||
this.exerciseTypeId = json['exerciseTypeId'];
|
||||
this.serie = json['serie'];
|
||||
this.repeats = json['repeats'];
|
||||
this.weightEquation = json['weightEquation'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
"exercisePlanId": exercisePlanId,
|
||||
"exerciseTypeId": exerciseTypeId,
|
||||
"serie": serie,
|
||||
"repeats": repeats,
|
||||
"weightEquation": weightEquation
|
||||
};
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import 'exercise_type.dart';
|
||||
class WorkoutTree {
|
||||
int id;
|
||||
int parent;
|
||||
String name; // is also the key
|
||||
String name;
|
||||
String imageName;
|
||||
Color color;
|
||||
double fontSize;
|
||||
@@ -15,7 +15,26 @@ class WorkoutTree {
|
||||
bool base;
|
||||
|
||||
bool is1RM;
|
||||
bool selected = false;
|
||||
bool executed = false;
|
||||
String exerciseDetail;
|
||||
String nameEnglish;
|
||||
|
||||
WorkoutTree(this.id, this.parent, this.name, this.imageName, this.color, this.fontSize, this.child, this.exerciseTypeId, this.exerciseType, this.base, this.is1RM);
|
||||
WorkoutTree(this.id, this.parent, this.name, this.imageName, this.color, this.fontSize, this.child,
|
||||
this.exerciseTypeId, this.exerciseType, this.base, this.is1RM, this.nameEnglish);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"id": id,
|
||||
"parent": parent,
|
||||
"name": name,
|
||||
"imageName": imageName,
|
||||
"color": color.toString(),
|
||||
"fontSize": fontSize.toString(),
|
||||
"child": child.toString(),
|
||||
"exerciseTypeId": exerciseTypeId.toString(),
|
||||
"base": base.toString(),
|
||||
"is1RM": is1RM.toString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user