WT 1.1.20 Training Plan improvements, InApp Messageing

This commit is contained in:
bossanyit
2021-06-25 17:30:14 +02:00
parent a595ffb358
commit 211307e63e
36 changed files with 693 additions and 300 deletions
+8 -2
View File
@@ -19,6 +19,7 @@ import 'package:aitrainer_app/model/purchase.dart';
import 'package:aitrainer_app/model/split_test.dart';
import 'package:aitrainer_app/model/sport.dart';
import 'package:aitrainer_app/model/training_plan.dart';
import 'package:aitrainer_app/model/training_plan_day.dart';
import 'package:aitrainer_app/model/tutorial.dart';
import 'package:aitrainer_app/model/workout_menu_tree.dart';
import 'package:aitrainer_app/repository/customer_repository.dart';
@@ -30,7 +31,7 @@ import 'package:aitrainer_app/util/enums.dart';
import 'package:aitrainer_app/util/env.dart';
import 'package:aitrainer_app/util/track.dart';
import 'package:firebase_remote_config/firebase_remote_config.dart';
import 'package:flurry/flurry.dart';
import 'package:flurry_data/flurry_data.dart';
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
import 'package:flutter_uxcam/flutter_uxcam.dart';
import 'package:package_info/package_info.dart';
@@ -137,6 +138,7 @@ class Cache with Logging {
List<wt_product.Product>? _products;
List<Purchase> _purchases = [];
List<SplitTest> _splitTests = [];
List<TrainingPlanDay> _trainingPlanDays = [];
List<ExercisePlanTemplate> _exercisePlanTemplates = [];
@@ -184,6 +186,7 @@ class Cache with Logging {
String testEnv = EnvironmentConfig.test_env;
this.testEnvironment = testEnv;
if (testEnv == "1") {
print("testEnv $testEnv");
baseUrl = baseUrlTest;
liveServer = false;
}
@@ -668,7 +671,7 @@ class Cache with Logging {
await PackageApi().getCustomerPackage(customerId);
if (!isInDebugMode) {
Flurry.setUserId(customerId.toString());
FlurryData.setUserId(customerId.toString());
//Smartlook.setUserIdentifier(customerId.toString());
FlutterUxcam.setUserProperty("username", customerId.toString());
FlutterUxcam.setUserIdentity(customerId.toString());
@@ -737,4 +740,7 @@ class Cache with Logging {
List<SplitTest> getSplitTests() => this._splitTests;
setSplitTests(value) => this._splitTests = value;
List<TrainingPlanDay> getTrainingPlanDays() => this._trainingPlanDays;
setTrainingPlanDays(value) => this._trainingPlanDays = value;
}
+4 -4
View File
@@ -4,7 +4,7 @@ class CustomerProperty {
int? customerPropertyId;
late int propertyId;
late int customerId;
late DateTime dateAdd;
DateTime? dateAdd;
late double propertyValue;
bool newData = false;
@@ -14,7 +14,7 @@ class CustomerProperty {
this.customerPropertyId = json['customerPropertyId'];
this.propertyId = json['propertyId'];
this.customerId = json['customerId'];
this.dateAdd = json['propertyName'];
this.dateAdd = json['dataAdd'] ?? DateTime.now();
this.propertyValue = json['propertyValue'];
}
@@ -24,14 +24,14 @@ class CustomerProperty {
"customerPropertyId": this.customerPropertyId,
"propertyId": this.propertyId,
"customerId": this.customerId,
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
"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),
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd!),
"propertyValue": this.propertyValue
};
}
+26 -8
View File
@@ -2,6 +2,7 @@ import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/exercise.dart';
import 'package:aitrainer_app/model/exercise_plan_detail.dart';
import 'package:aitrainer_app/model/exercise_type.dart';
import 'package:aitrainer_app/repository/training_plan_day_repository.dart';
class CustomerTrainingPlanDetails {
/// customerTrainingPlanDetails
@@ -26,6 +27,8 @@ class CustomerTrainingPlanDetails {
bool? parallel;
String? day;
int? dayId;
/// exerciseType
ExerciseType? exerciseType;
@@ -63,10 +66,10 @@ class CustomerTrainingPlanDetails {
: json['parallel'] == "true"
? true
: null;
this.day = json['day'].toString();
if (this.day == null || this.day == "null") {
this.day = "";
}
this.dayId = json['dayId'] == "null" ? null : json['dayId'];
TrainingPlanDayRepository trainingPlanDayRepository = TrainingPlanDayRepository();
this.day = trainingPlanDayRepository.getNameById(this.dayId);
try {
Iterable iterable = json['exercises'];
this.exercises = iterable.map((exercise) => Exercise.fromJson(exercise)).toList();
@@ -114,15 +117,30 @@ class CustomerTrainingPlanDetails {
'exercises': exercises.isEmpty ? [].toString() : exercises.map((exercise) => exercise.toJson()).toList().toString(),
'state': this.state.toStr(),
"isTest": this.isTest,
"dayId": this.dayId,
};
if (this.day != null && this.day!.isNotEmpty) {
jsonMap["day"] = this.day;
}
//print("Detail $jsonMap");
//print("Detail toJson $jsonMap");
return jsonMap;
}
@override
String toString() => this.toJsonWithExercises().toString();
void copy(CustomerTrainingPlanDetails from) {
this.customerTrainingPlanDetailsId = from.customerTrainingPlanDetailsId;
this.trainingPlanDetailsId = from.trainingPlanDetailsId;
this.exerciseTypeId = from.exerciseTypeId;
this.exerciseType = from.exerciseType;
this.set = from.set;
this.repeats = from.repeats;
this.weight = from.weight;
this.restingTime = from.restingTime;
this.parallel = from.parallel;
this.exercises = from.exercises;
this.state = from.state;
this.isTest = from.isTest;
this.day = from.day;
this.dayId = from.dayId;
}
}
+3 -3
View File
@@ -1,10 +1,10 @@
import 'package:aitrainer_app/model/evaluation_attribute.dart';
class Evaluation {
late int evaluationId;
int? evaluationId;
late String name;
late int exerciseTypeId;
late String unit;
int? exerciseTypeId;
String? unit;
late List attributes;
Evaluation.fromJson(Map json) {
+1 -1
View File
@@ -1,6 +1,6 @@
class EvaluationAttribute {
late int evaluationAttrId;
late int evaluationId;
int? evaluationId;
late String name;
late String sex;
late int ageMin;
+6 -1
View File
@@ -17,7 +17,7 @@ class ExerciseType {
late String unit;
/// unitQuantity
late String unitQuantity;
String? unitQuantity;
/// unitQuantityUnit
String? unitQuantityUnit;
@@ -28,6 +28,8 @@ class ExerciseType {
/// base
late bool base;
late bool buddyWarning;
/// imageUrl
String imageUrl = "";
@@ -65,6 +67,7 @@ class ExerciseType {
this.unitQuantityUnit = json['unitQuantityUnit'];
this.active = json['active'];
this.base = json['base'];
this.buddyWarning = json['buddyWarning'];
if (json['images'].length > 0) {
this.imageUrl = json['images'][0]['url'];
}
@@ -105,6 +108,8 @@ class ExerciseType {
"unitQuantity": unitQuantity,
"unitQuantityUnit": unitQuantityUnit,
"active": active,
"base": base,
"buddyWarning": buddyWarning,
"devices": this.devices.toString(),
"nameTranslation": this.nameTranslation,
"parents": this.parents.toString()
+4 -4
View File
@@ -4,10 +4,10 @@ import 'package:aitrainer_app/model/training_plan_detail.dart';
class TrainingPlan {
late int trainingPlanId;
late String type;
String? type;
late String name;
late String internalName;
late String description;
String? internalName;
String? description;
late bool free;
late bool active;
int? treeId;
@@ -28,7 +28,7 @@ class TrainingPlan {
this.treeId = json['treeId'];
nameTranslations['en'] = name;
descriptionTranslations['en'] = description;
descriptionTranslations['en'] = description ?? "";
if (json['translations'] != null && json['translations'].length > 0) {
json['translations'].forEach((translation) {
nameTranslations[translation['languageCode']] = translation['nameTranslation'];
+29
View File
@@ -0,0 +1,29 @@
import 'dart:collection';
class TrainingPlanDay {
late int dayId;
late String name;
HashMap<String, String> nameTranslations = HashMap();
TrainingPlanDay.fromJson(Map json) {
this.dayId = json['dayId'];
this.name = json['name'];
nameTranslations['en'] = name;
if (json['translations'] != null && json['translations'].length > 0) {
json['translations'].forEach((translation) {
nameTranslations[translation['languageCode']] = translation['nameTranslation'];
});
}
}
Map<String, dynamic> toJson() => {
"dayId": this.dayId,
"name": this.name,
"nameTranslation": this.nameTranslations.toString(),
};
@override
String toString() => this.toJson().toString();
}
+9 -7
View File
@@ -1,14 +1,15 @@
class TrainingPlanDetail {
late int trainingPlanDetailId;
late int trainingPlanId;
int? trainingPlanId;
late int exerciseTypeId;
late int sort;
late int set;
late int repeats;
late double weight;
late int restingTime;
late bool parallel;
late String day;
int? repeats;
double? weight;
int? restingTime;
bool? parallel;
int? dayId;
String? day;
TrainingPlanDetail.fromJson(Map<String, dynamic> json) {
this.trainingPlanDetailId = json['trainingPlanDetailId'];
@@ -20,7 +21,7 @@ class TrainingPlanDetail {
this.weight = json['weight'];
this.restingTime = json['restingTime'];
this.parallel = json['parallel'];
this.day = json['day'];
this.dayId = json['dayId'];
}
Map<String, dynamic> toJson() => {
@@ -32,6 +33,7 @@ class TrainingPlanDetail {
"weight": this.weight,
"restingTime": this.restingTime,
"parallel": this.parallel,
"dayId": this.dayId,
"day": this.day,
};