WT1.1.0+40 Premium feature settings
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:aitrainer_app/model/exercise.dart';
|
||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/repository/workout_tree_repository.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:aitrainer_app/util/calculate.dart';
|
||||
import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:aitrainer_app/util/group_data.dart';
|
||||
@@ -48,18 +49,16 @@ class GroupDate extends GroupData with Calculate, Common {
|
||||
|
||||
GroupDate({this.inputList, this.outputList});
|
||||
|
||||
|
||||
|
||||
double getQuantityByDate(Exercise exercise) {
|
||||
double sum = 0;
|
||||
if ( this.diagramType == DiagramType.sumMass ) {
|
||||
if ( exercise.unitQuantity != null ) {
|
||||
if (this.diagramType == DiagramType.sumMass) {
|
||||
if (exercise.unitQuantity != null) {
|
||||
sum = exercise.quantity * exercise.unitQuantity;
|
||||
} else {
|
||||
sum = exercise.quantity;
|
||||
}
|
||||
} else if ( this.diagramType == DiagramType.oneRepMax || this.diagramType == DiagramType.percent ) {
|
||||
if ( exercise.unitQuantity != null ) {
|
||||
} else if (this.diagramType == DiagramType.oneRepMax || this.diagramType == DiagramType.percent) {
|
||||
if (exercise.unitQuantity != null) {
|
||||
sum = calculate1RM(exercise.quantity, exercise.unitQuantity);
|
||||
} else {
|
||||
sum = exercise.quantity;
|
||||
@@ -93,8 +92,8 @@ class GroupDate extends GroupData with Calculate, Common {
|
||||
Exercise tempExercise;
|
||||
inputList.forEach((element) {
|
||||
tempExercise = element;
|
||||
if ( this.checkNewType(element)) {
|
||||
if ( _origDatePart == null ) {
|
||||
if (this.checkNewType(element)) {
|
||||
if (_origDatePart == null) {
|
||||
this.addTempData(element);
|
||||
} else {
|
||||
this.temp2Output(_origExercise);
|
||||
@@ -105,7 +104,7 @@ class GroupDate extends GroupData with Calculate, Common {
|
||||
this.addTempData(element);
|
||||
}
|
||||
});
|
||||
if ( tempExercise != null) {
|
||||
if (tempExercise != null) {
|
||||
this.temp2Output(tempExercise);
|
||||
}
|
||||
}
|
||||
@@ -134,7 +133,6 @@ class GroupDate extends GroupData with Calculate, Common {
|
||||
=========== CHART DATA CLASS
|
||||
*/
|
||||
class GroupChart extends GroupData with Calculate {
|
||||
|
||||
final List<dynamic> inputList;
|
||||
LinkedHashMap<int, ChartDataExtended> outputList = LinkedHashMap();
|
||||
|
||||
@@ -149,7 +147,7 @@ class GroupChart extends GroupData with Calculate {
|
||||
GroupChart({this.inputList, this.outputList});
|
||||
|
||||
double getBasePercent(Exercise exercise) {
|
||||
if ( exercise.unitQuantity != null ) {
|
||||
if (exercise.unitQuantity != null) {
|
||||
this._basePercent = calculate1RM(exercise.quantity, exercise.unitQuantity);
|
||||
} else {
|
||||
this._basePercent = exercise.quantity;
|
||||
@@ -160,14 +158,14 @@ class GroupChart extends GroupData with Calculate {
|
||||
double getDiagramValue(Exercise exercise) {
|
||||
double value = 0;
|
||||
|
||||
if ( diagramType == DiagramType.percent) {
|
||||
if ( exercise.unitQuantity != null ) {
|
||||
if (diagramType == DiagramType.percent) {
|
||||
if (exercise.unitQuantity != null) {
|
||||
double oneRepMax = calculate1RM(exercise.quantity, exercise.unitQuantity);
|
||||
value = (oneRepMax / this._basePercent) * 100;
|
||||
} else {
|
||||
value = (exercise.quantity / this._basePercent ) * 100;
|
||||
value = (exercise.quantity / this._basePercent) * 100;
|
||||
}
|
||||
} else if ( diagramType == DiagramType.oneRepMax || diagramType == DiagramType.sumMass) {
|
||||
} else if (diagramType == DiagramType.oneRepMax || diagramType == DiagramType.sumMass) {
|
||||
value = exercise.calculated;
|
||||
}
|
||||
return value;
|
||||
@@ -175,7 +173,6 @@ class GroupChart extends GroupData with Calculate {
|
||||
|
||||
@override
|
||||
void addTempData(Exercise exercise) {
|
||||
|
||||
double diagramValue = this.getDiagramValue(exercise);
|
||||
|
||||
if (_maxData < diagramValue) {
|
||||
@@ -185,32 +182,27 @@ class GroupChart extends GroupData with Calculate {
|
||||
_minData = diagramValue;
|
||||
}
|
||||
|
||||
BarChartGroupData data = BarChartGroupData(
|
||||
x: exercise.dateAdd.millisecondsSinceEpoch,
|
||||
barRods: [
|
||||
BarChartRodData(y: diagramValue, width: 12, colors: [Colors.lightBlue, Colors.lightBlueAccent])
|
||||
]
|
||||
);
|
||||
BarChartGroupData data = BarChartGroupData(x: exercise.dateAdd.millisecondsSinceEpoch, barRods: [
|
||||
BarChartRodData(y: diagramValue, width: 12, colors: [Colors.lightBlue, Colors.lightBlueAccent])
|
||||
]);
|
||||
_chartData.add(data);
|
||||
_origExerciseTypeId = exercise.exerciseTypeId;
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
bool checkNewType(Exercise exercise) {
|
||||
return _origExerciseTypeId != exercise.exerciseTypeId;
|
||||
return _origExerciseTypeId != exercise.exerciseTypeId;
|
||||
}
|
||||
|
||||
@override
|
||||
void iteration() {
|
||||
|
||||
this.resetTemp();
|
||||
Exercise tempExercise;
|
||||
inputList.forEach((element) {
|
||||
tempExercise = element;
|
||||
|
||||
if ( this.checkNewType(element)) {
|
||||
if ( _origExerciseTypeId == null ) {
|
||||
if (this.checkNewType(element)) {
|
||||
if (_origExerciseTypeId == null) {
|
||||
_basePercent = getBasePercent(element);
|
||||
this.addTempData(element);
|
||||
} else {
|
||||
@@ -223,7 +215,7 @@ class GroupChart extends GroupData with Calculate {
|
||||
this.addTempData(element);
|
||||
}
|
||||
});
|
||||
if ( tempExercise != null) {
|
||||
if (tempExercise != null) {
|
||||
this.temp2Output(tempExercise);
|
||||
}
|
||||
}
|
||||
@@ -234,9 +226,8 @@ class GroupChart extends GroupData with Calculate {
|
||||
int gridInterval = (dInterval / 3).floor();
|
||||
|
||||
ChartDataExtended extended;
|
||||
if ( outputList[_origExerciseTypeId] == null ) {
|
||||
extended = ChartDataExtended(
|
||||
data: _chartData, interval: dInterval, gridInterval: gridInterval);
|
||||
if (outputList[_origExerciseTypeId] == null) {
|
||||
extended = ChartDataExtended(data: _chartData, interval: dInterval, gridInterval: gridInterval);
|
||||
outputList[_origExerciseTypeId] = extended;
|
||||
} else {
|
||||
extended = outputList[_origExerciseTypeId];
|
||||
@@ -252,7 +243,6 @@ class GroupChart extends GroupData with Calculate {
|
||||
_maxData = 0;
|
||||
_chartData = List();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ChartDataExtended {
|
||||
@@ -272,7 +262,6 @@ class ChartDataExtended {
|
||||
};
|
||||
listBarChartData.add(barChartData);
|
||||
});
|
||||
|
||||
});
|
||||
var chartData = {
|
||||
"data": listBarChartData.toString(),
|
||||
@@ -281,10 +270,9 @@ class ChartDataExtended {
|
||||
};
|
||||
return chartData;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, DevelopmentByMuscleState> with Calculate {
|
||||
class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, DevelopmentByMuscleState> with Calculate, Logging {
|
||||
final WorkoutTreeRepository workoutTreeRepository;
|
||||
final ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||
LinkedHashMap<int, ChartDataExtended> listChartData = LinkedHashMap();
|
||||
@@ -294,12 +282,9 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
||||
double basePercent = 0;
|
||||
|
||||
@override
|
||||
DevelopmentByMuscleBloc({
|
||||
this.workoutTreeRepository}) :
|
||||
super(DevelopmentByMuscleStateInitial());
|
||||
DevelopmentByMuscleBloc({this.workoutTreeRepository}) : super(DevelopmentByMuscleStateInitial());
|
||||
|
||||
Future<void> getData() async {
|
||||
|
||||
workoutTreeRepository.sortedTree = null;
|
||||
workoutTreeRepository.sortByMuscleType();
|
||||
|
||||
@@ -311,7 +296,6 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
||||
});
|
||||
|
||||
this.getChartData();
|
||||
|
||||
}
|
||||
|
||||
void getChartData() {
|
||||
@@ -331,21 +315,18 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
||||
groupChart.iteration();
|
||||
listChartData = groupChart.outputList;
|
||||
|
||||
|
||||
listChartData.forEach((key, value) {
|
||||
print ("typeid " + key.toString() + " chardata " + value.toJson().toString());
|
||||
trace("typeid " + key.toString() + " chardata " + value.toJson().toString());
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
List<Exercise> groupByDate(List<Exercise> exercises) {
|
||||
List<Exercise> groupedExercises = List();
|
||||
|
||||
exercises = sort(exercises, false);
|
||||
exercises.forEach((exercise) {
|
||||
print ("Date exercise " + exercise.toJsonDatePart().toString());
|
||||
trace("Date exercise " + exercise.toJsonDatePart().toString());
|
||||
});
|
||||
|
||||
GroupDate groupDate = GroupDate(inputList: exercises, outputList: groupedExercises);
|
||||
@@ -358,12 +339,11 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
||||
print("Grouped " + element.toJsonDatePart().toString());
|
||||
});*/
|
||||
|
||||
|
||||
return groupedExercises;
|
||||
}
|
||||
|
||||
List<Exercise> sort(List<Exercise> exercises, bool asc) {
|
||||
exercises.sort( (a, b) {
|
||||
exercises.sort((a, b) {
|
||||
var aDateId = a.exerciseTypeId.toString() + "_" + a.datePart.toString();
|
||||
var bDateId = b.exerciseTypeId.toString() + "_" + b.datePart.toString();
|
||||
|
||||
@@ -383,13 +363,13 @@ class DevelopmentByMuscleBloc extends Bloc<DevelopmentByMuscleEvent, Development
|
||||
yield DevelopmentByMuscleLoadingState();
|
||||
await getData();
|
||||
yield DevelopmentByMuscleReadyState();
|
||||
} else if ( event is DevelopmentByMuscleDiagramTypeChange ) {
|
||||
} else if (event is DevelopmentByMuscleDiagramTypeChange) {
|
||||
yield DevelopmentByMuscleLoadingState();
|
||||
String type = event.diagramType;
|
||||
this.diagramType = type;
|
||||
getChartData();
|
||||
yield DevelopmentByMuscleReadyState();
|
||||
} else if ( event is DevelopmentByMuscleDateRateChange ) {
|
||||
} else if (event is DevelopmentByMuscleDateRateChange) {
|
||||
yield DevelopmentByMuscleLoadingState();
|
||||
String dateRate = event.dateRate;
|
||||
this.dateRate = dateRate;
|
||||
|
||||
Reference in New Issue
Block a user