This commit is contained in:
Tibor Bossanyi (Freelancer)
2022-04-09 11:22:34 +02:00
parent dfeac33176
commit 3b96d81a85
43 changed files with 1559 additions and 1855 deletions
+14 -4
View File
@@ -2,6 +2,7 @@ import 'dart:collection';
import 'dart:convert';
import 'package:aitrainer_app/model/customer.dart';
import 'package:aitrainer_app/model/customer_activity.dart';
import 'package:aitrainer_app/model/customer_property.dart';
import 'package:aitrainer_app/model/customer_training_plan.dart';
import 'package:aitrainer_app/model/description.dart';
import 'package:aitrainer_app/model/evaluation.dart';
@@ -158,6 +159,7 @@ class Cache with Logging {
List<CustomerExerciseDevice>? _customerDevices;
List<CustomerActivity>? _customerActivities;
List<CustomerTrainingPlan>? _customerTrainingPlans;
List<CustomerProperty>? _customerPropertyAll;
List<Tutorial>? _tutorials;
List<Description>? _descriptions;
@@ -542,8 +544,7 @@ class Cache with Logging {
ExercisePlan? getMyExercisePlan() => _myExercisePlan;
void setMyExercisePlanDetails(LinkedHashMap<int, ExercisePlanDetail> listExercisePlanDetail) =>
_myExercisesPlanDetails = listExercisePlanDetail;
void setMyExercisePlanDetails(LinkedHashMap<int, ExercisePlanDetail> listExercisePlanDetail) => _myExercisesPlanDetails = listExercisePlanDetail;
void addToMyExercisePlanDetails(ExercisePlanDetail detail) => _myExercisesPlanDetails[detail.exerciseTypeId] = detail;
@@ -557,8 +558,7 @@ class Cache with Logging {
void deleteMyExercisePlanDetail(ExercisePlanDetail detail) => this.deleteMyExercisePlanDetailByExerciseTypeId(detail.exerciseTypeId);
void deletedMyExercisePlanDetail(ExercisePlanDetail detail) =>
this._myExercisesPlanDetails[detail.exerciseTypeId]!.change = ModelChange.deleted;
void deletedMyExercisePlanDetail(ExercisePlanDetail detail) => this._myExercisesPlanDetails[detail.exerciseTypeId]!.change = ModelChange.deleted;
void deleteMyExercisePlanDetailByExerciseTypeId(int exerciseTypeId) {
this._myExercisesPlanDetails[exerciseTypeId]!.change = ModelChange.delete;
@@ -772,10 +772,20 @@ class Cache with Logging {
List<TrainingPlanDay> getTrainingPlanDays() => this._trainingPlanDays;
setTrainingPlanDays(value) => this._trainingPlanDays = value;
List<CustomerProperty>? getCustomerPropertyAll() => this._customerPropertyAll;
setCustomerPropertyAll(value) => this._customerPropertyAll = value;
addCustomerProperty(CustomerProperty property) {
if (this._customerPropertyAll == null) {
this._customerPropertyAll = [];
}
this._customerPropertyAll!.add(property);
}
bool canTrial() {
bool can = true;
if (Cache().userLoggedIn == null) {
can = false;
return can;
}
for (var element in _purchases) {
if (element.customerId == Cache().userLoggedIn!.customerId) {
+32 -2
View File
@@ -5,17 +5,33 @@ class CustomerProperty {
late int propertyId;
late int customerId;
DateTime? dateAdd;
String? dateYmd;
String? dateYm;
String? dateY;
late double propertyValue;
bool newData = false;
CustomerProperty({required this.propertyId, required this.customerId, required this.dateAdd, required this.propertyValue});
CustomerProperty(
{required this.propertyId,
required this.customerId,
required this.dateAdd,
required this.propertyValue});
CustomerProperty.fromJson(Map json) {
this.customerPropertyId = json['customerPropertyId'];
this.propertyId = json['propertyId'];
this.customerId = json['customerId'];
this.dateAdd = json['dataAdd'] ?? DateTime.now();
this.dateAdd = DateTime.parse(json['dateAdd']);
if (this.dateAdd != null) {
dateYmd = DateFormat('yyyy-MM-dd').format(this.dateAdd!);
dateYm = DateFormat('yyyy-MM').format(this.dateAdd!);
dateY = DateFormat('yyyy').format(this.dateAdd!);
}
this.propertyValue = json['propertyValue'];
print("Json $json, ${this.toString()}");
}
Map<String, dynamic> toJson() {
@@ -36,4 +52,18 @@ class CustomerProperty {
};
}
}
String toString() {
Map<String, dynamic> json = {
"customerPropertyId": this.customerPropertyId,
"propertyId": this.propertyId,
"customerId": this.customerId,
"dateAdd": DateFormat('yyyy-MM-dd HH:mm:ss').format(this.dateAdd!),
"propertyValue": this.propertyValue,
"dateYmd": this.dateYmd,
"dateYm": this.dateYm,
"dateY": this.dateY,
};
return json.toString();
}
}
+12 -1
View File
@@ -12,6 +12,17 @@ class Property {
this.propertyName = json['propertyName'];
this.propertyUnit = json['propertyUnit'];
this.propertyNameTranslation =
json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['propertyName'] : this.propertyName;
json['translations'] != null && (json['translations']).length > 0
? json['translations'][0]['propertyName']
: this.propertyName;
}
String toString() {
Map<String, dynamic> json = {
"propertyId": propertyId,
"propertyName": propertyName,
"propertyUnit": propertyUnit
};
return json.toString();
}
}