WT1.1.10+5 bugfix

This commit is contained in:
bossanyit
2021-03-28 12:45:14 +02:00
parent f724737ea3
commit 1962ba24cb
41 changed files with 397 additions and 173 deletions
+69 -6
View File
@@ -16,6 +16,7 @@ import 'package:aitrainer_app/repository/customer_repository.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/main.dart';
import 'package:aitrainer_app/util/enums.dart';
import 'package:aitrainer_app/util/env.dart';
import 'package:aitrainer_app/util/track.dart';
@@ -25,6 +26,7 @@ import 'package:package_info/package_info.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:aitrainer_app/model/exercise_type.dart';
import 'package:intl/intl.dart';
import 'package:smartlook/smartlook.dart';
import 'customer_exercise_device.dart';
import 'exercise_device.dart';
@@ -69,6 +71,8 @@ class Cache with Logging {
static final String activeExercisePlanKey = 'active_exercise_plan';
static final String activeExercisePlanDateKey = 'active_exercise_plan_date';
static final String activeExercisePlanDetailsKey = 'active_exercise_details_plan';
static final String exerciseLogSeenKey = 'exercise_log_seen';
static final String muscleDevelopmentSeenKey = 'muscle_development_seen_key';
static String baseUrl = 'http://aitrainer.info:8888/api/';
static final String mediaUrl = 'https://aitrainer.info:4343/media/';
@@ -111,7 +115,6 @@ class Cache with Logging {
Customer _trainee;
List<Exercise> _exercisesTrainee;
ExercisePlan _traineeExercisePlan;
List<ExercisePlanDetail> _traineeExercisesPlanDetail;
LinkedHashMap<String, int> _badges = LinkedHashMap();
@@ -120,6 +123,8 @@ class Cache with Logging {
String testEnvironment;
bool liveServer = true;
bool hasHardware = false;
bool isExerciseLogSeen = false;
bool isMuscleDevelopmentSeen = false;
factory Cache() {
return _singleton;
@@ -246,10 +251,14 @@ class Cache with Logging {
void setServerAddress(SharedPreferences prefs) {
if (this.testEnvironment == "1") {
baseUrl = 'http://aitrainer.app:8899/api/';
print("TestEnv $baseUrl");
return;
}
final bool live = prefs.getBool(Cache.serverKey);
if (live == null) {
baseUrl = 'http://aitrainer.app:8888/api/';
print("Live Env $baseUrl");
liveServer = true;
return;
}
liveServer = live;
@@ -258,6 +267,8 @@ class Cache with Logging {
} else {
baseUrl = 'http://aitrainer.app:8899/api/';
}
print("Env $baseUrl");
}
Future<void> setLoginTypeFromPrefs() async {
@@ -364,7 +375,7 @@ class Cache with Logging {
sharedPreferences.setString(Cache.firebaseUidKey, null);
sharedPreferences.setString(authTokenKey, "");
}
await initBadges();
initBadges();
}
void setExerciseTypes(List<ExerciseType> exerciseTypes) {
@@ -487,13 +498,14 @@ class Cache with Logging {
}
}
Future<void> initBadges() async {
void initBadges() async {
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) {
@@ -524,7 +536,7 @@ class Cache with Logging {
}
if (this._exercises == null || this._exercises.length == 0) {
setBadge("home", true);
setBadge("Strength", true);
setBadge("Muscle Build / Shape Toning", true);
setBadge("Cardio", true);
}
if (customerRepository.getHeight() == 0) {
@@ -541,6 +553,16 @@ class Cache with Logging {
setBadge("FitnessLevel", true);
setBadge("account", true);
}
if (this._exercises != null && this._exercises.isNotEmpty) {
if (!isExerciseLogSeen) {
setBadge("exerciseLog", true);
setBadge("development", true);
}
if (!isMuscleDevelopmentSeen) {
setBadge("muscleDevelopment", true);
setBadge("development", true);
}
}
}
log("Badges: " + _badges.toString());
}
@@ -557,12 +579,18 @@ class Cache with Logging {
Future<void> initCustomer(int customerId) async {
log(" *** initCustomer");
await PackageApi().getCustomerPackage(customerId);
Flurry.setUserId(customerId.toString());
if (!isInDebugMode) {
Flurry.setUserId(customerId.toString());
Smartlook.setUserIdentifier(customerId.toString());
Track().track(TrackingEvent.enter);
}
await setLoginTypeFromPrefs();
await getActiveExercisePlan();
await isExerciseLogSeenPrefs();
await isMuscleDevelopmentSeenPrefs();
Cache().startPage = "home";
Track().track(TrackingEvent.enter);
}
AccessToken get getAccessTokenFacebook => accessTokenFacebook;
@@ -573,4 +601,39 @@ class Cache with Logging {
List get exercisePlanTemplates => this._exercisePlanTemplates;
setExercisePlanTemplates(value) => this._exercisePlanTemplates = value;
setExerciseLogSeen() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
isExerciseLogSeen = true;
sharedPreferences.setBool(Cache.exerciseLogSeenKey, true);
}
Future<bool> isExerciseLogSeenPrefs() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
isExerciseLogSeen = sharedPreferences.getBool(Cache.exerciseLogSeenKey);
if (isExerciseLogSeen == null) {
isExerciseLogSeen = false;
}
//print("ExerciseLogSeen $isExerciseLogSeen");
return isExerciseLogSeen;
}
setMuscleDevelopmentSeen() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
isMuscleDevelopmentSeen = true;
sharedPreferences.setBool(Cache.muscleDevelopmentSeenKey, true);
}
Future<bool> isMuscleDevelopmentSeenPrefs() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
isMuscleDevelopmentSeen = sharedPreferences.getBool(Cache.muscleDevelopmentSeenKey);
if (isMuscleDevelopmentSeen == null) {
isMuscleDevelopmentSeen = false;
}
return isMuscleDevelopmentSeen;
}
}
+9 -3
View File
@@ -1,3 +1,7 @@
import 'dart:ui';
import 'package:aitrainer_app/util/app_language.dart';
class ExercisePlanTemplate {
int exercisePlanTemplateId;
String name;
@@ -12,9 +16,11 @@ class ExercisePlanTemplate {
this.name = json['name'];
this.description = json['description'];
this.templateType = json['templateType'];
this.nameTranslation = json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['name'] : this.name;
this.descriptionTranslation =
json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['description'] : this.description;
if (json['translations'].length > 0) {
this.nameTranslation = AppLanguage().appLocal == Locale('hu') ? json['translations'][0]['name'] : json['name'];
this.descriptionTranslation = AppLanguage().appLocal == Locale('hu') ? json['translations'][0]['description'] : json['description'];
}
if (json['details'] != null && (json['details']).length > 0) {
List details = json['details'];
details.forEach((element) {