WT 1.1.11+3 Evaluation, null-safe fixes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:collection';
|
||||
import 'dart:convert';
|
||||
import 'package:aitrainer_app/model/customer.dart';
|
||||
import 'package:aitrainer_app/model/evaluation.dart';
|
||||
import 'package:aitrainer_app/model/exercise_plan.dart';
|
||||
import 'package:aitrainer_app/model/exercise_plan_detail.dart';
|
||||
import 'package:aitrainer_app/model/exercise_plan_template.dart';
|
||||
@@ -21,7 +22,7 @@ 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';
|
||||
import 'package:aitrainer_app/library/flurry.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';
|
||||
@@ -84,8 +85,8 @@ class Cache with Logging {
|
||||
AccessToken? accessTokenFacebook;
|
||||
Customer? userLoggedIn;
|
||||
String? firebaseUid;
|
||||
late LoginType loginType;
|
||||
late PackageInfo packageInfo;
|
||||
LoginType? loginType;
|
||||
PackageInfo? packageInfo;
|
||||
|
||||
bool hasPurchased = false;
|
||||
|
||||
@@ -93,6 +94,7 @@ class Cache with Logging {
|
||||
|
||||
List<ExerciseType>? _exerciseTypes;
|
||||
List<ExerciseTree>? _exerciseTree;
|
||||
List<Evaluation>? _evaluations;
|
||||
|
||||
List<Exercise>? _exercises;
|
||||
ExercisePlan? _myExercisePlan;
|
||||
@@ -204,7 +206,6 @@ class Cache with Logging {
|
||||
|
||||
String? detailsJson = sharedPreferences.getString(Cache.activeExercisePlanDetailsKey);
|
||||
if (detailsJson != null) {
|
||||
print("Details $detailsJson");
|
||||
Iterable json = jsonDecode(detailsJson);
|
||||
this.activeExercisePlanDetails = json.map((details) => ExercisePlanDetail.fromJsonWithExerciseList(details)).toList();
|
||||
}
|
||||
@@ -641,4 +642,7 @@ class Cache with Logging {
|
||||
}
|
||||
return isMuscleDevelopmentSeen!;
|
||||
}
|
||||
|
||||
List<Evaluation>? get evaluations => this._evaluations;
|
||||
set evaluations(List<Evaluation>? value) => this._evaluations = value;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import 'package:aitrainer_app/model/evaluation_attribute.dart';
|
||||
|
||||
class Evaluation {
|
||||
late int evaluationId;
|
||||
late String name;
|
||||
late int exerciseTypeId;
|
||||
late String unit;
|
||||
late List attributes;
|
||||
|
||||
Evaluation.fromJson(Map json) {
|
||||
evaluationId = json['evaluationId'];
|
||||
name = json['name'];
|
||||
exerciseTypeId = json['exerciseTypeId'];
|
||||
unit = json['unit'];
|
||||
this.attributes = json['attributes'].map((attr) => EvaluationAttribute.fromJson(attr)).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
Map<String, dynamic> json = {
|
||||
'evaluationId': this.evaluationId,
|
||||
'name': this.name,
|
||||
'exerciseTypeId': this.exerciseTypeId,
|
||||
'unit': this.unit
|
||||
};
|
||||
return json.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
class EvaluationAttribute {
|
||||
late int evaluationAttrId;
|
||||
late int evaluationId;
|
||||
late String name;
|
||||
late String sex;
|
||||
late int ageMin;
|
||||
late int ageMax;
|
||||
late double valueMin;
|
||||
late double valueMax;
|
||||
late String evaluationText;
|
||||
String? suggestion;
|
||||
|
||||
EvaluationAttribute.fromJson(Map json) {
|
||||
evaluationAttrId = json['evaluationAttrId'];
|
||||
evaluationId = json['evaluationId'];
|
||||
name = json['name'];
|
||||
sex = json['sex'];
|
||||
ageMin = json['ageMin'];
|
||||
ageMax = json['ageMax'];
|
||||
valueMin = json['valueMin'];
|
||||
valueMax = json['valueMax'];
|
||||
evaluationText = json['evaluation_text'];
|
||||
suggestion = json['suggestion'];
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
Map<String, dynamic> json = {
|
||||
'evaluationAttrId': this.evaluationAttrId,
|
||||
'evaluationId': this.evaluationId,
|
||||
'name': this.name,
|
||||
'sex': this.sex,
|
||||
'ageMin': this.ageMin,
|
||||
'ageMax': this.ageMax,
|
||||
'valueMin': this.valueMin,
|
||||
'valueMax': this.valueMax,
|
||||
'evaluation_text': this.evaluationText,
|
||||
};
|
||||
return json.toString();
|
||||
}
|
||||
}
|
||||
@@ -61,4 +61,10 @@ class ExercisePlan {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
Map<String, dynamic> json = toJson();
|
||||
return json.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,16 @@ extension ExericisePlanDetailStateExt on ExercisePlanDetailState {
|
||||
|
||||
class ExercisePlanDetail {
|
||||
int? exercisePlanDetailId;
|
||||
late int exercisePlanId;
|
||||
int? exercisePlanId;
|
||||
late int exerciseTypeId;
|
||||
int? serie;
|
||||
int? repeats;
|
||||
String? weightEquation;
|
||||
|
||||
List? exercises;
|
||||
/// List<Exercise>
|
||||
List<Exercise>? exercises;
|
||||
|
||||
/// bool finished
|
||||
bool? finished;
|
||||
ExercisePlanDetailState state = ExercisePlanDetailState.start;
|
||||
|
||||
@@ -53,7 +56,7 @@ class ExercisePlanDetail {
|
||||
|
||||
jsonExercises = jsonExercises.replaceAll(r'\"null\"', 'null');
|
||||
|
||||
print("Exercises $jsonExercises");
|
||||
//print("Exercises $jsonExercises");
|
||||
Iterable iterable = jsonDecode(jsonExercises);
|
||||
this.exercises = iterable.map((exercise) => Exercise.fromJson(exercise)).toList();
|
||||
} on Exception catch (e) {
|
||||
@@ -62,7 +65,7 @@ class ExercisePlanDetail {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"exercisePlanId": exercisePlanId,
|
||||
"exercisePlanId": exercisePlanId == null ? 0 : exercisePlanId,
|
||||
"exerciseTypeId": exerciseTypeId,
|
||||
"serie": serie,
|
||||
"repeats": repeats,
|
||||
@@ -76,6 +79,12 @@ class ExercisePlanDetail {
|
||||
"serie": serie,
|
||||
"repeats": repeats,
|
||||
"weightEquation": weightEquation,
|
||||
'exercises': exercises!.map((exercise) => exercise.toJson()).toList().toString(),
|
||||
'exercises': exercises == null ? [].toString() : exercises!.map((exercise) => exercise.toJson()).toList().toString(),
|
||||
};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
Map<String, dynamic> json = toJsonWithExerciseList();
|
||||
return json.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
enum Sport { football, fitness, footgolf }
|
||||
|
||||
extension SportExt on Sport {
|
||||
String toStr() => this.toString().split(".").last;
|
||||
bool equalsTo(Sport sport) => this.toString() == sport.toString();
|
||||
bool equalsStringTo(String sport) => this.toStr() == sport;
|
||||
|
||||
String description(Sport sport) {
|
||||
if (Sport.football.equalsTo(sport)) {
|
||||
return "Football";
|
||||
} else if (Sport.fitness.equalsTo(sport)) {
|
||||
return "Fitness / Body Building";
|
||||
} else if (Sport.footgolf.equalsTo(sport)) {
|
||||
return "Footgolf";
|
||||
} else {
|
||||
return "Sport";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FitnessState {
|
||||
late final String value;
|
||||
late final String stateText;
|
||||
|
||||
@@ -7,7 +7,7 @@ class Tracking {
|
||||
late int customerId;
|
||||
late DateTime dateAdd;
|
||||
late String event;
|
||||
late String eventValue;
|
||||
String? eventValue;
|
||||
late String area;
|
||||
late String platform;
|
||||
late String version;
|
||||
@@ -19,6 +19,6 @@ class Tracking {
|
||||
"eventValue": eventValue,
|
||||
"area": Platform.localeName,
|
||||
"platform": Platform.isAndroid ? "Android" : "iOS",
|
||||
"version": Cache().packageInfo.version + "+" + Cache().packageInfo.buildNumber
|
||||
"version": Cache().packageInfo != null ? Cache().packageInfo!.version + "+" + Cache().packageInfo!.buildNumber : ""
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user