WT1.1.6+3 bodyType animation, bug fixes
This commit is contained in:
+30
-28
@@ -11,18 +11,15 @@ import 'package:aitrainer_app/model/property.dart';
|
||||
import 'package:aitrainer_app/model/purchase.dart';
|
||||
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/customer_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/service/firebase_api.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:aitrainer_app/service/package_service.dart';
|
||||
import 'package:aitrainer_app/util/enums.dart';
|
||||
import 'package:aitrainer_app/util/env.dart';
|
||||
import 'package:aitrainer_app/util/track.dart';
|
||||
import 'package:flurry/flurry.dart';
|
||||
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
|
||||
@@ -76,6 +73,7 @@ class Cache with Logging {
|
||||
Customer userLoggedIn;
|
||||
String firebaseUid;
|
||||
LoginType loginType;
|
||||
PackageInfo packageInfo;
|
||||
|
||||
bool hasPurchased = false;
|
||||
|
||||
@@ -201,7 +199,7 @@ class Cache with Logging {
|
||||
} else if (loginType == LoginType.email.toString()) {
|
||||
type = LoginType.email;
|
||||
}
|
||||
print("LoginType: " + loginType == null ? "NULL" : loginType);
|
||||
//print("LoginType: " + loginType == null ? "NULL" : loginType);
|
||||
Cache().setLoginType(type);
|
||||
}
|
||||
|
||||
@@ -316,7 +314,7 @@ class Cache with Logging {
|
||||
|
||||
List<ExerciseType> getExerciseTypes() => this._exerciseTypes;
|
||||
|
||||
ExerciseType getExercise(int exerciseTypeId) {
|
||||
ExerciseType getExerciseTypeById(int exerciseTypeId) {
|
||||
ExerciseType exerciseType;
|
||||
this._exerciseTypes.forEach((element) {
|
||||
if (element.exerciseTypeId == exerciseTypeId) {
|
||||
@@ -420,6 +418,10 @@ class Cache with Logging {
|
||||
CustomerRepository customerRepository = CustomerRepository();
|
||||
_badges = LinkedHashMap();
|
||||
customerRepository.setCustomer(userLoggedIn);
|
||||
int _ecto = customerRepository.getCustomerPropertyValue(PropertyEnum.Ectomorph.toStr()).toInt();
|
||||
int _mezo = customerRepository.getCustomerPropertyValue(PropertyEnum.Mesomorph.toStr()).toInt();
|
||||
int _endo = customerRepository.getCustomerPropertyValue(PropertyEnum.Endomorph.toStr()).toInt();
|
||||
print("endo " + _endo.toString() + " mezo " + _mezo.toString());
|
||||
if (this.userLoggedIn != null) {
|
||||
if (this.userLoggedIn.birthYear == null || this.userLoggedIn.birthYear == 0) {
|
||||
setBadge("personalData", true);
|
||||
@@ -431,6 +433,7 @@ class Cache with Logging {
|
||||
}
|
||||
if (userLoggedIn.properties == null || userLoggedIn.properties.isEmpty) {
|
||||
setBadge("personalData", true);
|
||||
setBadge("bodyType", true);
|
||||
setBadge("Sizes", true);
|
||||
setBadge("BMI", true);
|
||||
setBadge("BMR", true);
|
||||
@@ -442,12 +445,29 @@ class Cache with Logging {
|
||||
setBadge("My Body", true);
|
||||
setBadgeNr("home", 1);
|
||||
}
|
||||
if (_ecto == 0 && _mezo == 0 && _endo == 0) {
|
||||
setBadge("account", true);
|
||||
setBadge("bodyType", true);
|
||||
}
|
||||
if (this._exercises == null || this._exercises.length == 0) {
|
||||
setBadge("home", true);
|
||||
setBadge("Strength", true);
|
||||
setBadge("Cardio", true);
|
||||
}
|
||||
if (customerRepository.getHeight() == 0) {
|
||||
setBadge("BMI", true);
|
||||
setBadge("BMR", true);
|
||||
setBadge("My Body", true);
|
||||
setBadgeNr("home", 1);
|
||||
}
|
||||
if (userLoggedIn.goal == null) {
|
||||
setBadge("Goal", true);
|
||||
setBadge("account", true);
|
||||
}
|
||||
if (userLoggedIn.fitnessLevel == null) {
|
||||
setBadge("FitnessLevel", true);
|
||||
setBadge("account", true);
|
||||
}
|
||||
}
|
||||
log("Badges: " + _badges.toString());
|
||||
}
|
||||
@@ -463,31 +483,13 @@ class Cache with Logging {
|
||||
|
||||
Future<void> initCustomer(int customerId) async {
|
||||
log(" *** initCustomer");
|
||||
await CustomerApi().getCustomer(customerId);
|
||||
await PackageApi().getCustomerPackage(customerId);
|
||||
|
||||
Flurry.setUserId(customerId.toString());
|
||||
final customerDevices = await CustomerExerciseDeviceApi().getDevices(customerId);
|
||||
Cache().setCustomerDevices(customerDevices);
|
||||
|
||||
if (this._exerciseTree == null) {
|
||||
await ExerciseTreeApi().getExerciseTree();
|
||||
}
|
||||
if (this._exerciseTypes == null) {
|
||||
await ExerciseTypeApi().getExerciseTypes();
|
||||
}
|
||||
|
||||
await ExerciseDeviceApi().getDevices();
|
||||
|
||||
ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||
await exerciseRepository.getExercisesByCustomer(customerId);
|
||||
|
||||
CustomerRepository customerRepository = CustomerRepository(customer: this.userLoggedIn);
|
||||
await customerRepository.getPurchase();
|
||||
await customerRepository.getProductTests();
|
||||
|
||||
//this.hasPurchased = this._purchases.isNotEmpty;
|
||||
await setLoginTypeFromPrefs();
|
||||
Cache().startPage = "home";
|
||||
Track().track(TrackingEvent.enter);
|
||||
}
|
||||
|
||||
AccessToken get getAccessTokenFacebook => accessTokenFacebook;
|
||||
|
||||
+29
-22
@@ -1,4 +1,6 @@
|
||||
import 'dart:collection';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
import 'customer_property.dart';
|
||||
|
||||
class Customer {
|
||||
@@ -11,7 +13,6 @@ class Customer {
|
||||
int customerId;
|
||||
String password;
|
||||
int birthYear;
|
||||
//int weight;
|
||||
String goal;
|
||||
String fitnessLevel;
|
||||
String bodyType;
|
||||
@@ -19,28 +20,30 @@ class Customer {
|
||||
int trainer;
|
||||
int dataPolicyAllowed;
|
||||
String firebaseUid;
|
||||
DateTime dateAdd;
|
||||
DateTime dateChange;
|
||||
|
||||
LinkedHashMap<String, CustomerProperty> properties = LinkedHashMap();
|
||||
|
||||
Customer({
|
||||
this.customerId,
|
||||
this.name,
|
||||
this.firstname,
|
||||
this.email,
|
||||
this.sex,
|
||||
this.age,
|
||||
this.active,
|
||||
this.password,
|
||||
this.birthYear,
|
||||
this.bodyType,
|
||||
this.fitnessLevel,
|
||||
this.goal,
|
||||
//this.weight,
|
||||
this.admin,
|
||||
this.trainer,
|
||||
this.dataPolicyAllowed,
|
||||
this.firebaseUid,
|
||||
});
|
||||
Customer(
|
||||
{this.customerId,
|
||||
this.name,
|
||||
this.firstname,
|
||||
this.email,
|
||||
this.sex,
|
||||
this.age,
|
||||
this.active,
|
||||
this.password,
|
||||
this.birthYear,
|
||||
this.bodyType,
|
||||
this.fitnessLevel,
|
||||
this.goal,
|
||||
this.admin,
|
||||
this.trainer,
|
||||
this.dataPolicyAllowed,
|
||||
this.firebaseUid,
|
||||
this.dateAdd,
|
||||
this.dateChange});
|
||||
|
||||
Customer.fromJson(Map json) {
|
||||
this.customerId = json['customerId'];
|
||||
@@ -54,10 +57,13 @@ class Customer {
|
||||
this.bodyType = json['bodyType'];
|
||||
this.fitnessLevel = json['fitnessLevel'];
|
||||
this.goal = json['goal'];
|
||||
//this.weight = json['weight'];
|
||||
this.admin = json['admin'];
|
||||
|
||||
this.trainer = json['trainer'];
|
||||
this.firebaseUid = json['firebaseUid'];
|
||||
|
||||
this.dateAdd = json['dateAdd'] == null ? DateTime.parse("0000-00-00") : DateTime.parse(json['dateAdd']);
|
||||
this.dateChange = json['dateChange'] == null ? DateTime.parse("0000-00-00") : DateTime.parse(json['dateChange']);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
@@ -72,10 +78,11 @@ class Customer {
|
||||
"bodyType": bodyType,
|
||||
"fitnessLevel": fitnessLevel,
|
||||
"goal": goal,
|
||||
//"weight": weight,
|
||||
"admin": admin,
|
||||
"trainer": trainer,
|
||||
"dataPolicyAllowed": dataPolicyAllowed,
|
||||
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
|
||||
"dateChange": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateChange),
|
||||
};
|
||||
|
||||
double getProperty(String propertyName) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
class CustomerProperty {
|
||||
int customerPropertyId;
|
||||
int propertyId;
|
||||
int customerId;
|
||||
DateTime dateAdd;
|
||||
@@ -10,16 +11,29 @@ class CustomerProperty {
|
||||
CustomerProperty({this.propertyId, this.customerId, this.dateAdd, this.propertyValue});
|
||||
|
||||
CustomerProperty.fromJson(Map json) {
|
||||
this.customerPropertyId = json['customerPropertyId'];
|
||||
this.propertyId = json['propertyId'];
|
||||
this.customerId = json['customerId'];
|
||||
this.dateAdd = json['propertyName'];
|
||||
this.propertyValue = json['propertyValue'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
Map<String, dynamic> toJson() {
|
||||
if (customerPropertyId != null) {
|
||||
return {
|
||||
"customerPropertyId": this.customerPropertyId,
|
||||
"propertyId": this.propertyId,
|
||||
"customerId": this.customerId,
|
||||
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
|
||||
"propertyValue": this.propertyValue
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
"propertyId": this.propertyId,
|
||||
"customerId": this.customerId,
|
||||
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
|
||||
"propertyValue": this.propertyValue
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class Tracking {
|
||||
int customerId;
|
||||
DateTime dateAdd;
|
||||
String event;
|
||||
String eventValue;
|
||||
String area;
|
||||
String platform;
|
||||
String version;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"customerId": customerId,
|
||||
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
|
||||
"event": event,
|
||||
"eventValue": eventValue,
|
||||
"area": Platform.localeName,
|
||||
"platform": Platform.isAndroid ? "Android" : "iOS",
|
||||
"version": Cache().packageInfo.version + "+" + Cache().packageInfo.buildNumber
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user