WT1.1.2f Purchase, Product, Property, BMR, BMI, Sizes

This commit is contained in:
bossanyit
2020-11-16 15:42:40 +01:00
parent 5fa5382e3f
commit e28f1edf50
48 changed files with 2631 additions and 1441 deletions
+22 -23
View File
@@ -4,6 +4,7 @@ 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/property.dart';
import 'package:aitrainer_app/model/workout_menu_tree.dart';
import 'package:aitrainer_app/repository/exercise_repository.dart';
import 'package:aitrainer_app/service/exercise_tree_service.dart';
@@ -62,6 +63,7 @@ class Cache {
List<Exercise> _exercises;
ExercisePlan _myExercisePlan;
List<Property> _properties;
LinkedHashMap<int, ExercisePlanDetail> _myExercisesPlanDetails = LinkedHashMap<int, ExercisePlanDetail>();
@@ -82,7 +84,7 @@ class Cache {
Cache._internal() {
String testEnv = EnvironmentConfig.test_env;
if ( testEnv == "1") {
if (testEnv == "1") {
baseUrl = 'http://aitrainer.app:8899/api/';
}
}
@@ -136,22 +138,19 @@ class Cache {
_traineeExercisePlan = null;
_exercises = List();
_myExercisesPlanDetails = LinkedHashMap();
print("Trainees is null? " + (_trainee == null).toString() );
print("Trainees is null? " + (_trainee == null).toString());
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
await setPreferences(prefs, SharePrefsChange.logout, 0, "");
}
setPreferences(Future<SharedPreferences> prefs,
SharePrefsChange type,
int customerId,
String firebaseUid) async {
setPreferences(Future<SharedPreferences> prefs, SharePrefsChange type, int customerId, String firebaseUid) async {
SharedPreferences sharedPreferences;
sharedPreferences = await prefs;
DateTime now = DateTime.now();
sharedPreferences.setString(Cache.lastStoreDateKey, now.toString());
ExerciseRepository exerciseRepository = ExerciseRepository();
if ( type == SharePrefsChange.registration ) {
if (type == SharePrefsChange.registration) {
Cache().startPage = "home";
sharedPreferences.setInt(Cache.customerIdKey, customerId);
sharedPreferences.setBool(Cache.isRegisteredKey, true);
@@ -160,7 +159,7 @@ class Cache {
await ExerciseTypeApi().getExerciseTypes();
await ExerciseTreeApi().getExerciseTree();
await exerciseRepository.getExercisesByCustomer(customerId);
} else if ( type == SharePrefsChange.login ) {
} else if (type == SharePrefsChange.login) {
Cache().startPage = "home";
sharedPreferences.setInt(Cache.customerIdKey, customerId);
sharedPreferences.setString(Cache.firebaseUidKey, firebaseUid);
@@ -168,7 +167,7 @@ class Cache {
await ExerciseTypeApi().getExerciseTypes();
await ExerciseTreeApi().getExerciseTree();
await exerciseRepository.getExercisesByCustomer(customerId);
} else if ( type == SharePrefsChange.logout ) {
} else if (type == SharePrefsChange.logout) {
sharedPreferences.setBool(Cache.isLoggedInKey, false);
sharedPreferences.setInt(Cache.customerIdKey, 0);
sharedPreferences.setString(Cache.firebaseUidKey, null);
@@ -176,23 +175,23 @@ class Cache {
}
}
void setExerciseTypes( List<ExerciseType> exerciseTypes) {
void setExerciseTypes(List<ExerciseType> exerciseTypes) {
this._exerciseTypes = exerciseTypes;
}
void setExerciseTree( List<ExerciseTree> exerciseTree) {
void setExerciseTree(List<ExerciseTree> exerciseTree) {
this._exerciseTree = exerciseTree;
}
void setExercises( List<Exercise> exercises ) {
void setExercises(List<Exercise> exercises) {
this._exercises = exercises;
}
void setExercisesTrainee( List<Exercise> exercises ) {
void setExercisesTrainee(List<Exercise> exercises) {
this._exercisesTrainee = exercises;
}
void setWorkoutMenuTree( LinkedHashMap<String, WorkoutMenuTree> tree) {
void setWorkoutMenuTree(LinkedHashMap<String, WorkoutMenuTree> tree) {
this._tree = tree;
}
@@ -218,7 +217,7 @@ class Cache {
void setTrainee(Customer trainee) => _trainee = trainee;
void setTraineeExercisePlan(ExercisePlan exercisePlan) => this._traineeExercisePlan = exercisePlan;
void setTraineeExercisePlan(ExercisePlan exercisePlan) => this._traineeExercisePlan = exercisePlan;
ExercisePlan getTraineesExercisePlan() => this._traineeExercisePlan;
@@ -226,8 +225,8 @@ class Cache {
ExercisePlan getMyExercisePlan() => _myExercisePlan;
void setMyExercisePlanDetails(LinkedHashMap<int, ExercisePlanDetail> listExercisePlanDetail)
=> _myExercisesPlanDetails = listExercisePlanDetail;
void setMyExercisePlanDetails(LinkedHashMap<int, ExercisePlanDetail> listExercisePlanDetail) =>
_myExercisesPlanDetails = listExercisePlanDetail;
void addToMyExercisePlanDetails(ExercisePlanDetail detail) => _myExercisesPlanDetails[detail.exerciseTypeId] = detail;
@@ -239,16 +238,16 @@ class Cache {
this.addToMyExercisePlanDetails(detail);
}
void deleteMyExercisePlanDetail(ExercisePlanDetail detail)
=> this.deleteMyExercisePlanDetailByExerciseTypeId(detail.exerciseTypeId);
void deleteMyExercisePlanDetail(ExercisePlanDetail detail) => this.deleteMyExercisePlanDetailByExerciseTypeId(detail.exerciseTypeId);
void deletedMyExercisePlanDetail(ExercisePlanDetail detail)
=> this._myExercisesPlanDetails[detail.exerciseTypeId].change = ExercisePlanDetailChange.deleted;
void deletedMyExercisePlanDetail(ExercisePlanDetail detail) =>
this._myExercisesPlanDetails[detail.exerciseTypeId].change = ExercisePlanDetailChange.deleted;
void deleteMyExercisePlanDetailByExerciseTypeId(int exerciseTypeId) {
this._myExercisesPlanDetails[exerciseTypeId].change = ExercisePlanDetailChange.delete;
}
void setProperties(List<Property> properties) => this._properties = properties;
}
List<Property> getProperties() => _properties;
}
+54 -38
View File
@@ -1,24 +1,29 @@
import 'dart:collection';
import 'customer_property.dart';
class Customer {
String name;
String email;
String firstname;
String sex;
int age;
String active;
int customerId;
String password;
int birthYear;
int weight;
String goal;
String fitnessLevel;
String bodyType;
int admin;
int trainer;
int dataPolicyAllowed;
String firebaseUid;
String name;
String email;
String firstname;
String sex;
int age;
String active;
int customerId;
String password;
int birthYear;
//int weight;
String goal;
String fitnessLevel;
String bodyType;
int admin;
int trainer;
int dataPolicyAllowed;
String firebaseUid;
LinkedHashMap<String, CustomerProperty> properties = LinkedHashMap();
Customer({this.customerId,
Customer({
this.customerId,
this.name,
this.firstname,
this.email,
@@ -30,7 +35,7 @@ class Customer {
this.bodyType,
this.fitnessLevel,
this.goal,
this.weight,
//this.weight,
this.admin,
this.trainer,
this.dataPolicyAllowed,
@@ -49,28 +54,39 @@ class Customer {
this.bodyType = json['bodyType'];
this.fitnessLevel = json['fitnessLevel'];
this.goal = json['goal'];
this.weight = json['weight'];
//this.weight = json['weight'];
this.admin = json['admin'];
this.trainer = json['trainer'];
this.firebaseUid = json['firebaseUid'];
}
Map<String, dynamic> toJson() =>
{
"name": name,
"firstname": firstname,
"email": email,
"age": age,
"sex": sex,
"active": 'Y',
"password": password,
"birthYear": birthYear,
"bodyType": bodyType,
"fitnessLevel": fitnessLevel,
"goal": goal,
"weight": weight,
"admin": admin,
"trainer": trainer,
"dataPolicyAllowed": dataPolicyAllowed,
};
Map<String, dynamic> toJson() => {
"name": name,
"firstname": firstname,
"email": email,
"age": age,
"sex": sex,
"active": 'Y',
"password": password,
"birthYear": birthYear,
"bodyType": bodyType,
"fitnessLevel": fitnessLevel,
"goal": goal,
//"weight": weight,
"admin": admin,
"trainer": trainer,
"dataPolicyAllowed": dataPolicyAllowed,
};
double getProperty(String propertyName) {
if (this.properties[propertyName] == null) {
return 0;
} else {
return this.properties[propertyName].propertyValue;
}
}
setProperty(String propertyName, double value) {
this.properties[propertyName].propertyValue = value;
}
}
+8 -2
View File
@@ -1,3 +1,5 @@
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
class CustomerProperty {
int propertyId;
int customerId;
@@ -14,6 +16,10 @@ class CustomerProperty {
this.propertyValue = json['propertyValue'];
}
Map<String, dynamic> toJson() =>
{"propertyId": this.propertyId, "customerId": this.customerId, "dateAdd": this.dateAdd, "propertyValue": this.propertyValue};
Map<String, dynamic> toJson() => {
"propertyId": this.propertyId,
"customerId": this.customerId,
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
"propertyValue": this.propertyValue
};
}
+12 -15
View File
@@ -1,20 +1,17 @@
class ExerciseTree {
int treeId;
int parentId;
class Product {
int productId;
String name;
String imageUrl;
bool active;
String nameTranslation;
String description;
String type;
DateTime validFrom;
DateTime validTo;
ExerciseTree.fromJson(Map json) {
this.treeId = json['treeId'];
Product.fromJson(Map json) {
this.productId = json['productId'];
this.name = json['name'];
this.parentId = json['parentId'];
this.imageUrl = json['imageUrl'];
this.active = json['active'];
this.nameTranslation =
json['translations'] != null && (json['translations']).length > 0
? json['translations'][0]['name']
: this.name;
this.description = json['description'];
this.type = json['type'];
this.validFrom = json['validFrom'];
this.validTo = json['validTo'];
}
}
+11 -12
View File
@@ -1,17 +1,16 @@
class Product {
class ProductTest {
int productTestId;
int customerId;
int productId;
String name;
String description;
String type;
DateTime validFrom;
DateTime validTo;
Product.fromJson(Map json) {
DateTime dateView;
bool purchaseClick;
ProductTest.fromJson(Map json) {
this.productTestId = json['productTestId'];
this.customerId = json['customerId'];
this.productId = json['productId'];
this.name = json['name'];
this.description = json['description'];
this.type = json['type'];
this.validFrom = json['validFrom'];
this.validTo = json['validTo'];
this.dateView = json['dateView'];
this.purchaseClick = json['purchaseClick'];
}
}
+4 -3
View File
@@ -3,14 +3,15 @@ class Property {
String propertyName;
String propertyUnit;
String propertyNameTranslation;
int top;
int left;
double value;
Property.fromJson(Map json) {
this.propertyId = json['propertyId'];
this.propertyName = json['propertyName'];
this.propertyUnit = json['propertyUnit'];
this.propertyNameTranslation =
json['translations'] != null && (json['translations']).length > 0
? json['translations'][0]['propertyName']
: this.propertyName;
json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['propertyName'] : this.propertyName;
}
}
+26 -13
View File
@@ -1,17 +1,30 @@
class Product {
int productId;
String name;
String description;
String type;
DateTime validFrom;
DateTime validTo;
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
Product.fromJson(Map json) {
class Purchase {
int purchaseId;
int customerId;
int productId;
DateTime dateAdd;
double purchaseSum;
String currency;
Purchase.fromJson(Map json) {
this.purchaseId = json['purchaseId'];
this.customerId = json['customerId'];
this.productId = json['productId'];
this.name = json['name'];
this.description = json['description'];
this.type = json['type'];
this.validFrom = json['validFrom'];
this.validTo = json['validTo'];
this.dateAdd = json['dateAdd'];
this.purchaseSum = json['purchaseSum'];
this.customerId = json['currency'];
}
Map<String, dynamic> toJson() =>
{
"purchaseId": purchaseId,
"customerId": customerId,
"productId": productId,
"purchaseSum": purchaseSum,
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
"currency": currency,
};
}