WT1.1.11 Null-Safe migration

This commit is contained in:
bossanyit
2021-04-02 11:42:26 +02:00
parent a656562c49
commit 01148c6e39
219 changed files with 3208 additions and 5334 deletions
+113 -108
View File
@@ -8,6 +8,7 @@ import 'package:aitrainer_app/model/exercise_tree.dart';
import 'package:aitrainer_app/model/exercise.dart';
import 'package:aitrainer_app/model/model_change.dart';
import 'package:aitrainer_app/model/product.dart' as wt_product;
import 'package:aitrainer_app/model/product.dart';
import 'package:aitrainer_app/model/product_test.dart';
import 'package:aitrainer_app/model/property.dart';
import 'package:aitrainer_app/model/purchase.dart';
@@ -20,7 +21,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:flurry/flurry.dart';
import 'package:aitrainer_app/library/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';
@@ -57,22 +58,22 @@ class Cache with Logging {
static final Cache _singleton = Cache._internal();
// Keys to store and fetch data from SharedPreferences
static final String authTokenKey = 'auth_token';
static final String customerIdKey = 'customer_id';
static final String firebaseUidKey = 'firebase_uid';
static final String lastStoreDateKey = 'last_date';
static final String isRegisteredKey = 'is_registered';
static final String isLoggedInKey = 'is_logged_in';
static final String langKey = 'lang';
static final String serverKey = 'live';
static final String hardwareKey = 'hardware';
static final String loginTypeKey = 'login_type';
static final String timerDisplayKey = 'timer_display';
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 final String authTokenKey = "auth_token";
static final String customerIdKey = "customer_id";
static final String firebaseUidKey = "firebase_uid";
static final String lastStoreDateKey = "last_date";
static final String isRegisteredKey = "is_registered";
static final String isLoggedInKey = "is_logged_in";
static final String langKey = "lang";
static final String serverKey = "live";
static final String hardwareKey = "hardware";
static final String loginTypeKey = "login_type";
static final String timerDisplayKey = "timer_display";
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/';
@@ -80,51 +81,51 @@ class Cache with Logging {
static final String password = 'andio2009';
String authToken = "";
AccessToken accessTokenFacebook;
Customer userLoggedIn;
String firebaseUid;
LoginType loginType;
PackageInfo packageInfo;
AccessToken? accessTokenFacebook;
Customer? userLoggedIn;
String? firebaseUid;
late LoginType loginType;
late PackageInfo packageInfo;
bool hasPurchased = false;
bool firstLoad = true;
List<ExerciseType> _exerciseTypes;
List<ExerciseTree> _exerciseTree;
List<ExerciseType>? _exerciseTypes;
List<ExerciseTree>? _exerciseTree;
List<Exercise> _exercises;
ExercisePlan _myExercisePlan;
List<Property> _properties;
List<wt_product.Product> _products;
List<Purchase> _purchases = List();
List<ProductTest> _productTests;
List<ExercisePlanTemplate> _exercisePlanTemplates = List();
List<Exercise>? _exercises;
ExercisePlan? _myExercisePlan;
List<Property>? _properties;
List<wt_product.Product>? _products;
List<Purchase> _purchases = [];
List<ProductTest>? _productTests;
List<ExercisePlanTemplate> _exercisePlanTemplates = [];
ExercisePlan activeExercisePlan;
List<ExercisePlanDetail> activeExercisePlanDetails;
ExercisePlan? activeExercisePlan;
List<ExercisePlanDetail>? activeExercisePlanDetails;
List<ExerciseDevice> _devices;
List<CustomerExerciseDevice> _customerDevices;
List<ExerciseDevice>? _devices;
List<CustomerExerciseDevice>? _customerDevices;
LinkedHashMap<int, ExercisePlanDetail> _myExercisesPlanDetails = LinkedHashMap<int, ExercisePlanDetail>();
LinkedHashMap _tree = LinkedHashMap<String, WorkoutMenuTree>();
LinkedHashMap<String, WorkoutMenuTree> _tree = LinkedHashMap<String, WorkoutMenuTree>();
double _percentExercises = -1;
Customer _trainee;
List<Exercise> _exercisesTrainee;
ExercisePlan _traineeExercisePlan;
Customer? _trainee;
List<Exercise>? _exercisesTrainee;
ExercisePlan? _traineeExercisePlan;
LinkedHashMap<String, int> _badges = LinkedHashMap();
List deviceLanguages;
List? deviceLanguages;
String startPage = "home";
String testEnvironment;
late String testEnvironment;
bool liveServer = true;
bool hasHardware = false;
bool isExerciseLogSeen = false;
bool isMuscleDevelopmentSeen = false;
bool? hasHardware = false;
bool? isExerciseLogSeen = false;
bool? isMuscleDevelopmentSeen = false;
factory Cache() {
return _singleton;
@@ -186,11 +187,8 @@ class Cache with Logging {
DateFormat format = DateFormat("yyyy-MM-dd HH:mm:ss");
DateTime savedPlanDate;
try {
savedPlanDate = format.parse(savedPlanDateString);
} on Exception catch (e) {
return;
}
savedPlanDate = format.parse(savedPlanDateString);
final DateTime now = DateTime.now();
final DateTime added = savedPlanDate.add(Duration(days: 1));
@@ -198,13 +196,13 @@ class Cache with Logging {
return;
}
String exercisePlanJson = sharedPreferences.getString(Cache.activeExercisePlanKey);
String? exercisePlanJson = sharedPreferences.getString(Cache.activeExercisePlanKey);
if (exercisePlanJson != null) {
final Map<String, dynamic> map = JsonDecoder().convert(exercisePlanJson);
this.activeExercisePlan = ExercisePlan.fromJson(map);
}
String detailsJson = sharedPreferences.getString(Cache.activeExercisePlanDetailsKey);
String? detailsJson = sharedPreferences.getString(Cache.activeExercisePlanDetailsKey);
if (detailsJson != null) {
print("Details $detailsJson");
Iterable json = jsonDecode(detailsJson);
@@ -225,7 +223,7 @@ class Cache with Logging {
}
void getHardware(SharedPreferences prefs) {
final bool hasHardware = prefs.getBool(Cache.hardwareKey);
final bool? hasHardware = prefs.getBool(Cache.hardwareKey);
this.hasHardware = hasHardware;
if (hasHardware == null) {
this.hasHardware = false;
@@ -236,7 +234,7 @@ class Cache with Logging {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
final bool selectedHardware = sharedPreferences.getBool(Cache.hardwareKey);
final bool? selectedHardware = sharedPreferences.getBool(Cache.hardwareKey);
return selectedHardware == null;
}
@@ -254,7 +252,7 @@ class Cache with Logging {
print("TestEnv $baseUrl");
return;
}
final bool live = prefs.getBool(Cache.serverKey);
final bool? live = prefs.getBool(Cache.serverKey);
if (live == null) {
baseUrl = 'http://aitrainer.app:8888/api/';
print("Live Env $baseUrl");
@@ -274,7 +272,7 @@ class Cache with Logging {
Future<void> setLoginTypeFromPrefs() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
final String loginType = sharedPreferences.getString(Cache.loginTypeKey);
final String? loginType = sharedPreferences.getString(Cache.loginTypeKey);
LoginType type = LoginType.email;
if (loginType == LoginType.apple.toString()) {
type = LoginType.apple;
@@ -289,7 +287,7 @@ class Cache with Logging {
Cache().setLoginType(type);
}
static String getToken(SharedPreferences prefs) {
static String? getToken(SharedPreferences prefs) {
return prefs.getString(authTokenKey);
}
@@ -305,10 +303,10 @@ class Cache with Logging {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
userLoggedIn = customer;
final String uid = Cache().firebaseUid;
final String uid = Cache().firebaseUid!;
SharedPreferences sharedPreferences = await prefs;
sharedPreferences.setString(Cache.loginTypeKey, Cache().getLoginType().toString());
await setPreferences(prefs, SharePrefsChange.registration, customer.customerId, uid);
await setPreferences(prefs, SharePrefsChange.registration, customer.customerId!, uid);
}
afterLogin(Customer customer) async {
@@ -317,21 +315,21 @@ class Cache with Logging {
userLoggedIn = customer;
SharedPreferences sharedPreferences = await prefs;
sharedPreferences.setString(Cache.loginTypeKey, Cache().getLoginType().toString());
await setPreferences(prefs, SharePrefsChange.login, customer.customerId, Cache().firebaseUid);
await setPreferences(prefs, SharePrefsChange.login, customer.customerId!, Cache().firebaseUid!);
}
afterFirebaseLogin() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
sharedPreferences.setString(Cache.loginTypeKey, Cache().getLoginType().toString());
await setPreferences(prefs, SharePrefsChange.login, userLoggedIn.customerId, Cache().firebaseUid);
await setPreferences(prefs, SharePrefsChange.login, userLoggedIn!.customerId!, Cache().firebaseUid!);
}
afterFacebookLogin() async {
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
SharedPreferences sharedPreferences = await prefs;
sharedPreferences.setString(Cache.loginTypeKey, Cache().getLoginType().toString());
await setPreferences(prefs, SharePrefsChange.login, userLoggedIn.customerId, Cache().firebaseUid);
await setPreferences(prefs, SharePrefsChange.login, userLoggedIn!.customerId!, Cache().firebaseUid!);
}
logout() async {
@@ -345,7 +343,7 @@ class Cache with Logging {
_percentExercises = -1;
_exercisesTrainee = null;
_traineeExercisePlan = null;
_exercises = List();
_exercises = [];
_myExercisesPlanDetails = LinkedHashMap();
log("Trainees is null? " + (_trainee == null).toString());
Future<SharedPreferences> prefs = SharedPreferences.getInstance();
@@ -372,7 +370,7 @@ class Cache with Logging {
} else if (type == SharePrefsChange.logout) {
sharedPreferences.setBool(Cache.isLoggedInKey, false);
sharedPreferences.setInt(Cache.customerIdKey, 0);
sharedPreferences.setString(Cache.firebaseUidKey, null);
sharedPreferences.setString(Cache.firebaseUidKey, "");
sharedPreferences.setString(authTokenKey, "");
}
initBadges();
@@ -396,23 +394,25 @@ class Cache with Logging {
this._tree = tree;
}
List<ExerciseType> getExerciseTypes() => this._exerciseTypes;
List<ExerciseType>? getExerciseTypes() => this._exerciseTypes;
ExerciseType getExerciseTypeById(int exerciseTypeId) {
ExerciseType exerciseType;
this._exerciseTypes.forEach((element) {
if (element.exerciseTypeId == exerciseTypeId) {
exerciseType = element;
}
});
ExerciseType? getExerciseTypeById(int exerciseTypeId) {
ExerciseType? exerciseType;
if (_exerciseTypes != null) {
this._exerciseTypes!.forEach((element) {
if (element.exerciseTypeId == exerciseTypeId) {
exerciseType = element;
}
});
}
return exerciseType;
}
List<ExerciseTree> getExerciseTree() => this._exerciseTree;
List<ExerciseTree>? getExerciseTree() => this._exerciseTree;
List<Exercise> getExercises() => this._exercises;
List<Exercise>? getExercises() => this._exercises;
List<Exercise> getExercisesTrainee() => this._exercisesTrainee;
List<Exercise>? getExercisesTrainee() => this._exercisesTrainee;
LinkedHashMap<String, WorkoutMenuTree> getWorkoutMenuTree() => this._tree;
@@ -420,21 +420,21 @@ class Cache with Logging {
double getPercentExercises() => this._percentExercises;
void addExercise(Exercise exercise) => _exercises.add(exercise);
void addExercise(Exercise exercise) => _exercises!.add(exercise);
void addExerciseTrainee(Exercise exercise) => _exercisesTrainee.add(exercise);
void addExerciseTrainee(Exercise exercise) => _exercisesTrainee!.add(exercise);
Customer getTrainee() => this._trainee;
Customer? getTrainee() => this._trainee;
void setTrainee(Customer trainee) => _trainee = trainee;
void setTraineeExercisePlan(ExercisePlan exercisePlan) => this._traineeExercisePlan = exercisePlan;
ExercisePlan getTraineesExercisePlan() => this._traineeExercisePlan;
ExercisePlan? getTraineesExercisePlan() => this._traineeExercisePlan;
void setMyExercisePlan(ExercisePlan exercisePlan) => _myExercisePlan = exercisePlan;
ExercisePlan getMyExercisePlan() => _myExercisePlan;
ExercisePlan? getMyExercisePlan() => _myExercisePlan;
void setMyExercisePlanDetails(LinkedHashMap<int, ExercisePlanDetail> listExercisePlanDetail) =>
_myExercisesPlanDetails = listExercisePlanDetail;
@@ -452,30 +452,30 @@ class Cache with Logging {
void deleteMyExercisePlanDetail(ExercisePlanDetail detail) => this.deleteMyExercisePlanDetailByExerciseTypeId(detail.exerciseTypeId);
void deletedMyExercisePlanDetail(ExercisePlanDetail detail) =>
this._myExercisesPlanDetails[detail.exerciseTypeId].change = ModelChange.deleted;
this._myExercisesPlanDetails[detail.exerciseTypeId]!.change = ModelChange.deleted;
void deleteMyExercisePlanDetailByExerciseTypeId(int exerciseTypeId) {
this._myExercisesPlanDetails[exerciseTypeId].change = ModelChange.delete;
this._myExercisesPlanDetails[exerciseTypeId]!.change = ModelChange.delete;
}
void setProperties(List<Property> properties) => this._properties = properties;
List<Property> getProperties() => _properties;
List<Property>? getProperties() => _properties;
void setDevices(List<ExerciseDevice> devices) => this._devices = devices;
List<ExerciseDevice> getDevices() => this._devices;
List<ExerciseDevice>? getDevices() => this._devices;
void setCustomerDevices(List<CustomerExerciseDevice> devices) => this._customerDevices = devices;
List<CustomerExerciseDevice> getCustomerDevices() => this._customerDevices;
List<CustomerExerciseDevice>? getCustomerDevices() => this._customerDevices;
LinkedHashMap getBadges() => _badges;
void setBadge(String key, bool inc) {
if (inc) {
if (_badges[key] != null) {
_badges[key]++;
_badges[key] = _badges[key]! + 1;
} else {
_badges[key] = 1;
}
@@ -484,7 +484,7 @@ class Cache with Logging {
if (_badges[key] == 1) {
_badges.remove(key);
} else {
_badges[key]--;
_badges[key] = _badges[key]! - 1;
}
}
}
@@ -492,31 +492,34 @@ class Cache with Logging {
void setBadgeNr(String key, int counter) {
if (_badges[key] != null) {
_badges[key] += counter;
_badges[key] = _badges[key]! + counter;
} else {
_badges[key] = counter;
}
}
void initBadges() async {
void initBadges() {
CustomerRepository customerRepository = CustomerRepository();
_badges = LinkedHashMap();
customerRepository.setCustomer(userLoggedIn);
if (userLoggedIn == null) {
return;
}
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) {
if (this.userLoggedIn!.birthYear == null || this.userLoggedIn!.birthYear == 0) {
setBadge("personalData", true);
setBadge("account", true);
}
if (this._customerDevices == null || this._customerDevices.isEmpty) {
if (this._customerDevices == null || this._customerDevices!.isEmpty) {
setBadge("customerDevice", true);
setBadge("account", true);
}
if (userLoggedIn.properties == null || userLoggedIn.properties.isEmpty) {
if (userLoggedIn!.properties.isEmpty) {
setBadge("personalData", true);
setBadge("bodyType", true);
setBadge("Sizes", true);
@@ -534,7 +537,7 @@ class Cache with Logging {
setBadge("account", true);
setBadge("bodyType", true);
}
if (this._exercises == null || this._exercises.length == 0) {
if (this._exercises == null || this._exercises!.isEmpty) {
setBadge("home", true);
setBadge("Muscle Build / Shape Toning", true);
setBadge("Cardio", true);
@@ -545,20 +548,20 @@ class Cache with Logging {
setBadge("My Body", true);
setBadgeNr("home", 1);
}
if (userLoggedIn.goal == null) {
if (userLoggedIn!.goal == null) {
setBadge("Goal", true);
setBadge("account", true);
}
if (userLoggedIn.fitnessLevel == null) {
if (userLoggedIn!.fitnessLevel == null) {
setBadge("FitnessLevel", true);
setBadge("account", true);
}
if (this._exercises != null && this._exercises.isNotEmpty) {
if (!isExerciseLogSeen) {
if (this._exercises != null && this._exercises!.isNotEmpty) {
if (!isExerciseLogSeen!) {
setBadge("exerciseLog", true);
setBadge("development", true);
}
if (!isMuscleDevelopmentSeen) {
if (!isMuscleDevelopmentSeen!) {
setBadge("muscleDevelopment", true);
setBadge("development", true);
}
@@ -567,14 +570,16 @@ class Cache with Logging {
log("Badges: " + _badges.toString());
}
List get products => _products;
void setProducts(List value) => _products = value;
List<Product>? get products => _products;
void setProducts(List<wt_product.Product> value) => _products = value;
List get purchases => _purchases;
setPurchases(List value) => _purchases = value;
List<Purchase> get purchases => _purchases;
setPurchases(List<Purchase> value) => _purchases = value;
List get productTests => _productTests;
set productTests(List value) => _productTests = value;
// ignore: unnecessary_getters_setters
List<ProductTest>? get productTests => _productTests;
// ignore: unnecessary_getters_setters
set productTests(List<ProductTest>? value) => _productTests = value;
Future<void> initCustomer(int customerId) async {
log(" *** initCustomer");
@@ -593,10 +598,10 @@ class Cache with Logging {
Cache().startPage = "home";
}
AccessToken get getAccessTokenFacebook => accessTokenFacebook;
AccessToken? get getAccessTokenFacebook => accessTokenFacebook;
set setAccessTokenFacebook(AccessToken accessTokenFacebook) => this.accessTokenFacebook = accessTokenFacebook;
LoginType getLoginType() => loginType;
LoginType? getLoginType() => loginType;
void setLoginType(LoginType type) => this.loginType = type;
List get exercisePlanTemplates => this._exercisePlanTemplates;
@@ -617,7 +622,7 @@ class Cache with Logging {
isExerciseLogSeen = false;
}
//print("ExerciseLogSeen $isExerciseLogSeen");
return isExerciseLogSeen;
return isExerciseLogSeen!;
}
setMuscleDevelopmentSeen() async {
@@ -634,6 +639,6 @@ class Cache with Logging {
if (isMuscleDevelopmentSeen == null) {
isMuscleDevelopmentSeen = false;
}
return isMuscleDevelopmentSeen;
return isMuscleDevelopmentSeen!;
}
}
+27 -24
View File
@@ -1,27 +1,27 @@
import 'dart:collection';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import 'package:intl/intl.dart';
import 'customer_property.dart';
class Customer {
String name;
String email;
String firstname;
String sex;
int age;
String active;
int customerId;
String password;
int birthYear;
String goal;
String fitnessLevel;
String bodyType;
int admin;
int trainer;
int dataPolicyAllowed;
String firebaseUid;
DateTime dateAdd;
DateTime dateChange;
String? name;
late String? email;
String? firstname;
String? sex;
int? age;
String? active;
int? customerId;
String? password;
int? birthYear;
String? goal;
String? fitnessLevel;
String? bodyType;
int? admin;
int? trainer;
int? dataPolicyAllowed;
String? firebaseUid;
DateTime? dateAdd;
DateTime? dateChange;
LinkedHashMap<String, CustomerProperty> properties = LinkedHashMap();
@@ -43,7 +43,10 @@ class Customer {
this.dataPolicyAllowed,
this.firebaseUid,
this.dateAdd,
this.dateChange});
this.dateChange}) {
dateAdd = DateTime.now();
dateChange = DateTime.now();
}
Customer.fromJson(Map json) {
this.customerId = json['customerId'];
@@ -81,19 +84,19 @@ class Customer {
"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),
"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) {
if (this.properties[propertyName] == null) {
return 0;
} else {
return this.properties[propertyName].propertyValue;
return this.properties[propertyName]!.propertyValue;
}
}
setProperty(String propertyName, double value) {
this.properties[propertyName].propertyValue = value;
this.properties[propertyName]!.propertyValue = value;
}
}
+8 -8
View File
@@ -1,15 +1,15 @@
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import 'package:intl/intl.dart';
class CustomerExerciseDevice {
int customerExerciseDeviceId;
int exerciseDeviceId;
int customerId;
bool favourite;
DateTime dateAdd;
int? customerExerciseDeviceId;
late int exerciseDeviceId;
late int customerId;
late bool favourite;
late DateTime dateAdd;
String change;
late String change;
CustomerExerciseDevice({this.exerciseDeviceId, this.customerId, this.favourite}) {
CustomerExerciseDevice({required this.exerciseDeviceId, required this.customerId, required this.favourite}) {
dateAdd = DateTime.now();
}
+7 -7
View File
@@ -1,14 +1,14 @@
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import 'package:intl/intl.dart';
class CustomerProperty {
int customerPropertyId;
int propertyId;
int customerId;
DateTime dateAdd;
double propertyValue;
int? customerPropertyId;
late int propertyId;
late int customerId;
late DateTime dateAdd;
late double propertyValue;
bool newData = false;
CustomerProperty({this.propertyId, this.customerId, this.dateAdd, this.propertyValue});
CustomerProperty({required this.propertyId, required this.customerId, required this.dateAdd, required this.propertyValue});
CustomerProperty.fromJson(Map json) {
this.customerPropertyId = json['customerPropertyId'];
+15 -18
View File
@@ -1,18 +1,18 @@
import 'package:intl/intl.dart';
class Exercise {
int exerciseId;
int exerciseTypeId;
int customerId;
double quantity;
String unit;
double unitQuantity;
DateTime dateAdd;
int exercisePlanDetailId;
int? exerciseId;
int? exerciseTypeId;
int? customerId;
double? quantity;
String? unit;
double? unitQuantity;
DateTime? dateAdd;
int? exercisePlanDetailId;
String datePart;
double calculated;
String summary;
String? datePart;
double? calculated;
String? summary;
Exercise({this.exerciseTypeId, this.customerId, this.quantity, this.dateAdd});
@@ -24,7 +24,7 @@ class Exercise {
this.unit = json['unit'];
this.unitQuantity = json['unitQuantity'];
this.dateAdd = DateTime.parse(json['dateAdd']);
this.datePart = DateFormat('yyyy-MM-dd').format(this.dateAdd);
this.datePart = DateFormat('yyyy-MM-dd').format(this.dateAdd!);
this.calculated = quantity;
}
@@ -34,7 +34,7 @@ class Exercise {
"quantity": quantity,
"unit": unit,
"unitQuantity": unitQuantity,
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd),
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd!),
"exercisePlanDetailId": exercisePlanDetailId,
};
@@ -49,13 +49,10 @@ class Exercise {
};
Exercise copy() {
Exercise newExercise = Exercise();
newExercise.exerciseTypeId = this.exerciseTypeId;
newExercise.customerId = this.customerId;
newExercise.quantity = this.quantity;
Exercise newExercise =
Exercise(exerciseTypeId: this.exerciseTypeId, customerId: this.customerId, quantity: this.quantity, dateAdd: this.dateAdd);
newExercise.unit = this.unit;
newExercise.unitQuantity = this.unitQuantity;
newExercise.dateAdd = this.dateAdd;
newExercise.exercisePlanDetailId = this.exercisePlanDetailId;
return newExercise;
}
+8 -8
View File
@@ -1,13 +1,13 @@
class ExerciseDevice {
int exerciseDeviceId;
String name;
String description;
String imageUrl;
String nameTranslation;
int sort;
bool place;
late int exerciseDeviceId;
late String name;
late String description;
late String imageUrl;
late String nameTranslation;
late int sort;
late bool place;
bool isGym;
bool? isGym;
ExerciseDevice.fromJson(Map json) {
this.exerciseDeviceId = json['exerciseDeviceId'];
+13 -13
View File
@@ -1,15 +1,15 @@
import 'package:intl/intl.dart';
class ExercisePlan {
int exercisePlanId;
int customerId;
String name;
String description;
bool private;
DateTime dateAdd;
DateTime dateUpd;
String type;
int exercisePlanTemplateId;
int? exercisePlanId;
late int customerId;
late String name;
String? description;
late bool private;
late DateTime? dateAdd;
late DateTime dateUpd;
String? type;
int? exercisePlanTemplateId;
ExercisePlan(String name, int customerId) {
this.customerId = customerId;
@@ -23,16 +23,16 @@ class ExercisePlan {
this.name = json['name'];
this.private = json['private'];
this.description = json['description'];
this.dateAdd = json['dateAdd'] == null ? null : DateTime.parse(json['dateAdd']);
this.dateUpd = json['dateUpd'] == null ? null : DateTime.parse(json['dateUpd']);
this.dateAdd = (json['dateAdd'] == null ? null : DateTime.parse(json['dateAdd']))!;
this.dateUpd = (json['dateUpd'] == null ? null : DateTime.parse(json['dateUpd']))!;
this.type = json['type'];
this.exercisePlanTemplateId = json['exercisePlanTemplateId'];
}
Map<String, dynamic> toJson() {
String formattedDateAdd;
String? formattedDateAdd;
if (dateAdd != null) {
formattedDateAdd = DateFormat('yyyy-MM-dd HH:mm').format(dateAdd);
formattedDateAdd = DateFormat('yyyy-MM-dd HH:mm').format(dateAdd!);
}
String formattedDateUpd = DateFormat('yyyy-MM-dd HH:mm').format(dateUpd);
+12 -11
View File
@@ -11,19 +11,20 @@ extension ExericisePlanDetailStateExt on ExercisePlanDetailState {
}
class ExercisePlanDetail {
int exercisePlanDetailId;
int exercisePlanId;
int exerciseTypeId;
int serie;
int repeats;
String weightEquation;
int? exercisePlanDetailId;
late int exercisePlanId;
late int exerciseTypeId;
int? serie;
int? repeats;
String? weightEquation;
List exercises;
bool finished;
List? exercises;
bool? finished;
ExercisePlanDetailState state = ExercisePlanDetailState.start;
ExerciseType exerciseType;
String change; // 1: update -1:delete 0: new
ExerciseType? exerciseType;
String? change; // 1: update -1:delete 0: new
ExercisePlanDetail(int exerciseTypeId) {
this.exerciseTypeId = exerciseTypeId;
@@ -75,6 +76,6 @@ class ExercisePlanDetail {
"serie": serie,
"repeats": repeats,
"weightEquation": weightEquation,
'exercises': exercises.map((exercise) => exercise.toJson()).toList().toString(),
'exercises': exercises!.map((exercise) => exercise.toJson()).toList().toString(),
};
}
+7 -7
View File
@@ -3,13 +3,13 @@ import 'dart:ui';
import 'package:aitrainer_app/util/app_language.dart';
class ExercisePlanTemplate {
int exercisePlanTemplateId;
String name;
String description;
String templateType;
String nameTranslation;
String descriptionTranslation;
List<int> exerciseTypes = List();
late int? exercisePlanTemplateId;
late String name;
late String description;
late String templateType;
late String nameTranslation;
late String descriptionTranslation;
List<int> exerciseTypes = [];
ExercisePlanTemplate.fromJson(Map json) {
this.exercisePlanTemplateId = json['exercisePlanId'];
+12 -12
View File
@@ -1,24 +1,24 @@
import 'package:aitrainer_app/model/result.dart';
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
import 'package:intl/intl.dart';
class ExerciseResult {
int exerciseResultId;
int customerId;
int exerciseId;
int exercisePlanId;
String resultType;
double value;
DateTime dateFrom;
DateTime dateTo;
late int? exerciseResultId;
late int customerId;
late int exerciseId;
late int exercisePlanId;
late String resultType;
late double value;
late DateTime dateFrom;
late DateTime? dateTo;
ResultExt resultExtension;
ResultExt? resultExtension;
ExerciseResult();
Map<String, dynamic> toJson() {
String formattedDateTo;
String? formattedDateTo;
if (dateTo != null) {
formattedDateTo = DateFormat('yyyy-MM-dd HH:mm').format(dateTo);
formattedDateTo = DateFormat('yyyy-MM-dd HH:mm').format(dateTo!);
}
return {
+9 -8
View File
@@ -1,24 +1,24 @@
class ExerciseTree {
/// treeId
int treeId;
late int treeId;
/// parentId
int parentId;
late int parentId;
/// name
String name;
late String name;
/// imageUrl
String imageUrl;
late String imageUrl;
/// active
bool active;
late bool active;
/// nameTranslation
String nameTranslation;
late String nameTranslation;
/// sort
int sort;
late int? sort;
ExerciseTree();
@@ -29,6 +29,7 @@ class ExerciseTree {
this.imageUrl = json['imageUrl'];
this.active = json['active'];
this.nameTranslation = json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['name'] : this.name;
this.sort = 99;
}
Map<String, dynamic> toJson() {
@@ -53,7 +54,7 @@ class ExerciseTree {
newTree.parentId = parentId;
}
newTree.active = this.active;
newTree.sort = this.sort;
newTree.sort = this.sort == null ? 99 : this.sort;
return newTree;
}
+4 -4
View File
@@ -1,8 +1,8 @@
class ExerciseTreeParents {
int exerciseTreeParentsId;
int exerciseTreeParentId;
int exerciseTreeChildId;
int sort;
late int exerciseTreeParentsId;
late int exerciseTreeParentId;
late int exerciseTreeChildId;
late int sort;
ExerciseTreeParents.fromJson(Map json) {
this.exerciseTreeParentsId = json['exerciseTreeParentsId'];
+15 -15
View File
@@ -4,28 +4,28 @@ import 'package:flutter/material.dart';
class ExerciseType {
///exerciseTypeId
int exerciseTypeId;
late int exerciseTypeId;
/// name
String name;
late String name;
/// description
String description;
late String description;
/// unit
String unit;
late String unit;
/// unitQuantity
String unitQuantity;
late String unitQuantity;
/// unitQuantityUnit
String unitQuantityUnit;
String? unitQuantityUnit;
///active
bool active;
late bool active;
/// base
bool base;
late bool base;
/// imageUrl
String imageUrl = "";
@@ -37,18 +37,18 @@ class ExerciseType {
String descriptionTranslation = "";
/// devices[]
List<int> devices = List();
List<int> devices = [];
/// parents[]
List<int> parents = List();
List<int> parents = [];
/// alternatives []
List<int> alternatives = List();
List<int> alternatives = [];
/// ability
ExerciseAbility ability;
ExerciseAbility? ability;
ExerciseType({this.name, this.description});
ExerciseType({required this.name, required this.description});
ExerciseType.fromJson(Map json) {
this.exerciseTypeId = json['exerciseTypeId'];
@@ -110,11 +110,11 @@ class ExerciseType {
}
ExerciseAbility getAbility() {
return this.ability;
return this.ability!;
}
bool is1RM() {
return this.ability.equalsTo(ExerciseAbility.oneRepMax);
return this.ability!.equalsTo(ExerciseAbility.oneRepMax);
}
@override
+2 -2
View File
@@ -1,6 +1,6 @@
class ExerciseTypeDevice {
int exerciseTypeDeviceId;
int exerciseDeviceId;
late int exerciseTypeDeviceId;
late int exerciseDeviceId;
ExerciseTypeDevice();
+8 -8
View File
@@ -1,16 +1,16 @@
class FitnessState {
final String value;
final String stateText;
final String explanation;
late final String value;
late final String stateText;
late final String explanation;
static String beginner = "beginner";
static String intermediate = "intermediate";
static String advanced = "advanced";
static String professional = "professional";
FitnessState({this.value, this.stateText, this.explanation});
FitnessState({required this.value, required this.stateText, required this.explanation});
bool isEqual(FitnessState state) {
bool isEqual(FitnessState? state) {
if (state == null) {
return false;
}
@@ -25,7 +25,7 @@ class FitnessState {
class FitnessItem {
static final FitnessItem _singleton = FitnessItem._internal();
List<FitnessState> elements = List();
List<FitnessState> elements = [];
factory FitnessItem() {
return _singleton;
@@ -52,11 +52,11 @@ class FitnessItem {
List<FitnessState> toList() => elements;
FitnessState getItem(String value) {
FitnessState? getItem(String? value) {
if (value == null || value.length == 0) {
return elements[0];
}
FitnessState selected;
FitnessState? selected;
elements.forEach((element) {
if (element.value == value) {
selected = element;
+15 -15
View File
@@ -1,18 +1,18 @@
class Product {
int productId;
String name;
String description;
String type;
String appVersion;
int sort;
int productSet;
DateTime validFrom;
DateTime validTo;
String productIdIos;
String productIdAndroid;
double priceIos;
double priceAndroid;
String localizedPrice;
late int productId;
late String name;
late String description;
late String type;
late String appVersion;
late int sort;
late int productSet;
late DateTime validFrom;
late DateTime? validTo;
late String? productIdIos;
late String? productIdAndroid;
late double? priceIos;
late double? priceAndroid;
String? localizedPrice;
Product.fromJson(Map json) {
this.productId = json['productId'];
@@ -22,7 +22,7 @@ class Product {
this.appVersion = json['appVersion'];
this.sort = json['sort'];
this.productSet = json['productSet'];
this.validFrom = json['validFrom'] == null ? null : DateTime.parse(json['validFrom']);
this.validFrom = (json['validFrom'] == null ? null : DateTime.parse(json['validFrom']))!;
this.validTo = json['validTo'] == null ? null : DateTime.parse(json['validTo']);
this.productIdIos = json['productIdIos'];
this.productIdAndroid = json['productIdAndroid'];
+5 -5
View File
@@ -1,12 +1,12 @@
import 'package:intl/intl.dart';
class ProductTest {
int productTestId;
int customerId;
int productId;
late int? productTestId;
late int customerId;
late int productId;
DateTime dateView;
bool purchaseClick;
late DateTime dateView;
late bool purchaseClick;
ProductTest();
+7 -7
View File
@@ -1,11 +1,11 @@
class Property {
int propertyId;
String propertyName;
String propertyUnit;
String propertyNameTranslation;
int top;
int left;
double value;
late int propertyId;
late String propertyName;
late String propertyUnit;
late String propertyNameTranslation;
int? top;
int? left;
double? value;
Property.fromJson(Map json) {
this.propertyId = json['propertyId'];
+7 -7
View File
@@ -1,15 +1,15 @@
import 'package:intl/intl.dart';
class Purchase {
int purchaseId;
int customerId;
int productId;
int? purchaseId;
late int customerId;
late int productId;
DateTime dateAdd;
double purchaseSum;
String currency;
late DateTime dateAdd;
late double purchaseSum;
late String currency;
Purchase({this.customerId, this.productId});
Purchase({required this.customerId, required this.productId});
Purchase.fromJson(Map json) {
this.purchaseId = json['purchaseId'];
+16 -16
View File
@@ -62,23 +62,23 @@ extension ResultItemExt on ResultItem {
bool equals(ResultItem item) => this.toString() == item.toString();
bool equalsString(String item) => this.description == item;
String get description => ResultItemDesc[this];
String get image => ResultItemImg[this];
bool get isHardware => HardwareData[this];
String? get description => ResultItemDesc[this];
String? get image => ResultItemImg[this];
bool? get isHardware => HardwareData[this];
String displayString() => description;
String? displayString() => description;
}
class ResultExt {
final String itemString;
ResultItem item;
late final String itemString;
late ResultItem item;
double data = 0;
int exerciseId;
DateTime dateFrom;
int? exerciseId;
DateTime? dateFrom;
DateTime dateTo;
DateTime? dateTo;
ResultExt({this.itemString}) {
ResultExt({required this.itemString}) {
ResultItem.values.forEach((element) {
if (element.equalsString(itemString)) {
item = element;
@@ -86,15 +86,15 @@ class ResultExt {
});
}
String getDescription() => item.description;
String getImage() => "asset/image/" + item.image;
bool isHardware() => item.isHardware;
int get getExerciseId => exerciseId;
String? getDescription() => item.description;
String getImage() => "asset/image/" + item.image!;
bool? isHardware() => item.isHardware;
int? get getExerciseId => exerciseId;
set setExerciseId(int exerciseId) => this.exerciseId = exerciseId;
set setDateFrom(DateTime dateFrom) => this.dateFrom = dateFrom;
DateTime get getDateFrom => dateFrom;
DateTime? get getDateFrom => dateFrom;
set setDateTo(DateTime dateTo) => this.dateTo = dateTo;
DateTime get getDateTo => dateTo;
DateTime? get getDateTo => dateTo;
bool equals(ResultItem item) => this.item.equals(item);
bool equalsString(String item) => this.item.equalsString(item);
+7 -7
View File
@@ -4,13 +4,13 @@ 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;
late int customerId;
late DateTime dateAdd;
late String event;
late String eventValue;
late String area;
late String platform;
late String version;
Map<String, dynamic> toJson() => {
"customerId": customerId,
+11 -14
View File
@@ -1,17 +1,14 @@
class User {
String email;
String password;
int customerId;
String firebaseUid;
class User {
String? email;
String? password;
int? customerId;
String? firebaseUid;
User();
User({this.customerId, this.email, this.password});
Map<String, dynamic> toJson() =>
{
"username": email,
"password": password,
"firebaseUid": firebaseUid,
};
Map<String, dynamic> toJson() => {
"username": email,
"password": password,
"firebaseUid": firebaseUid,
};
}
+19 -19
View File
@@ -15,31 +15,31 @@ extension WorkoutTypeExt on WorkoutType {
bool equals(WorkoutType type) => this.toString() == type.toString();
bool equalsString(String type) => this.toString() == type;
String get menu => WorkoutTypeMenu[this];
String? get menu => WorkoutTypeMenu[this];
}
class WorkoutMenuTree {
int id;
int parent;
String name;
String imageName;
Color color;
double fontSize;
bool child;
int exerciseTypeId;
ExerciseType exerciseType;
bool base;
late int id;
late int parent;
late String name;
late String imageName;
late Color color;
late double fontSize;
late bool child;
late int exerciseTypeId;
ExerciseType? exerciseType;
late bool base;
bool is1RM;
bool isRunning;
List<WorkoutType> workoutTypes = List();
late bool is1RM;
late bool isRunning;
List<WorkoutType> workoutTypes = [];
bool selected = false;
bool executed = false;
String exerciseDetail;
String nameEnglish;
String parentName;
String parentNameEnglish;
int sort;
late String exerciseDetail;
late String nameEnglish;
late String parentName;
late String parentNameEnglish;
late int sort;
WorkoutMenuTree(this.id, this.parent, this.name, this.imageName, this.color, this.fontSize, this.child, this.exerciseTypeId,
this.exerciseType, this.base, this.is1RM, this.isRunning, this.nameEnglish, this.parentName, this.parentNameEnglish, this.sort);