1.1.26+3 development

This commit is contained in:
bossanyit 2022-06-04 08:28:06 +02:00
parent e59e225582
commit 82bed75528
4 changed files with 67 additions and 7 deletions

View File

@ -1,5 +1,6 @@
import 'dart:collection';
import 'package:aitrainer_app/model/exercise.dart'; import 'package:aitrainer_app/model/exercise.dart';
import 'package:aitrainer_app/util/enums.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'dart:async'; import 'dart:async';
import 'package:aitrainer_app/bloc/development_diagram/development_diagram_bloc.dart'; import 'package:aitrainer_app/bloc/development_diagram/development_diagram_bloc.dart';
@ -23,9 +24,11 @@ class BodyDevelopmentBloc extends Bloc<BodyDevelopmentEvent, BodyDevelopmentStat
List<String> legendsFmlm = ['First month', '1 month ago', 'last month']; List<String> legendsFmlm = ['First month', '1 month ago', 'last month'];
List<String> legendsL3m = ['2 months ago', '1 month ago', 'last month']; List<String> legendsL3m = ['2 months ago', '1 month ago', 'last month'];
List<String> legends = []; List<String> legends = [];
List<String> dateGroups = ["", "", ""];
List<int> radarTicks = []; List<int> radarTicks = [];
List<String> radarFeatures = []; List<String> radarFeatures = [];
List<List<int>> radarData = []; List<List<int>> radarData = [];
List<List<double>> tempRadarData = [];
DiagramGroup group = DiagramGroup.sumMass; DiagramGroup group = DiagramGroup.sumMass;
DiagramDateFilterGroup filter = DiagramDateFilterGroup.l3t; DiagramDateFilterGroup filter = DiagramDateFilterGroup.l3t;
@ -43,19 +46,71 @@ class BodyDevelopmentBloc extends Bloc<BodyDevelopmentEvent, BodyDevelopmentStat
Colors.orange, Colors.orange,
]; ];
void resetTempData() {
this.tempRadarData.clear();
this.tempRadarData = [
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]
];
}
void getExerciseData() { void getExerciseData() {
workoutTreeRepository.sortedTree.clear(); workoutTreeRepository.sortedTree.clear();
workoutTreeRepository.sortByMuscleType(); workoutTreeRepository.sortByMuscleType();
this.resetTempData();
int index = 0; int index = 0;
this.workoutTreeRepository.sortedTree.forEach((name, list) { this.workoutTreeRepository.sortedTree.forEach((name, list) {
print("name: $name"); print("name: $name");
int elementIndex = 0;
list.forEach((element) { list.forEach((element) {
exerciseRepository.exerciseList = exerciseRepository.getExercisesByExerciseTypeId(element.exerciseTypeId); exerciseRepository.exerciseList = exerciseRepository.getExercisesByExerciseTypeId(element.exerciseTypeId);
exerciseRepository.sortByDate(); exerciseRepository.sortByDate();
int exerciseIndex = 0;
exerciseRepository.exerciseList!.forEach((exercise) {
final HashMap<String, dynamic> dateGroup = this.getDateGroup(exercise, elementIndex);
if (dateGroup['dateGroupIndex'] != -1) {
double unitQuantity = exercise.unitQuantity == null ? 1 : exercise.unitQuantity!;
//print("index ${dateGroup['dateGroupIndex']} -- dateGroup: ${dateGroup['dateGroup']} -- value ${exercise.quantity! * unitQuantity}");
tempRadarData[dateGroup['dateGroupIndex']][index] += (exercise.quantity! * unitQuantity) / (elementIndex + exerciseIndex + 1);
exerciseIndex++;
}
});
elementIndex++;
}); });
index++; index++;
}); });
print(" temp $tempRadarData");
}
HashMap<String, dynamic> getDateGroup(Exercise exercise, int elementIndex) {
HashMap<String, dynamic> rc = HashMap();
rc['dateGroupIndex'] = -1;
if (elementIndex == 0) {
rc['dateGroupIndex'] = 0;
rc['dateGroup'] = DateFormat(DateFormat.YEAR_MONTH, AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
dateGroups[0] = rc['dateGroup'];
dateGroups[1] =
DateFormat(DateFormat.YEAR_MONTH, AppLanguage().appLocal.toString()).format(DateTime.now().subtract(Duration(days: 32)));
dateGroups[2] = DateFormat(DateFormat.YEAR_MONTH, AppLanguage().appLocal.toString()).format(DateTime.now());
print("DateGroups: ==== $dateGroups");
} else {
final String dateGroup = DateFormat(DateFormat.YEAR_MONTH, AppLanguage().appLocal.toString()).format(exercise.dateAdd!);
if (dateGroup == dateGroups[0]) {
rc['dateGroup'] = dateGroup;
rc['dateGroupIndex'] = 0;
} else if (dateGroup == dateGroups[1]) {
rc['dateGroup'] = dateGroup;
rc['dateGroupIndex'] = 1;
} else if (dateGroup == dateGroups[2]) {
rc['dateGroup'] = dateGroup;
rc['dateGroupIndex'] = 2;
}
}
return rc;
} }
Future<void> getData() async { Future<void> getData() async {

View File

@ -34,7 +34,12 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
Color testColor = Colors.green[800]!; Color testColor = Colors.green[800]!;
bool emailCheckbox = true; bool emailCheckbox = true;
LoginBloc({required this.accountBloc, required this.userRepository, required this.context, required this.isRegistration, this.customerRepository}) LoginBloc(
{required this.accountBloc,
required this.userRepository,
required this.context,
required this.isRegistration,
this.customerRepository})
: super(LoginInitial()) { : super(LoginInitial()) {
this._init(); this._init();
on<LoginEmailChange>(_onEmailChange); on<LoginEmailChange>(_onEmailChange);
@ -88,7 +93,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
Track().track(TrackingEvent.login, eventValue: "email"); Track().track(TrackingEvent.login, eventValue: "email");
Cache().setLoginType(LoginType.email); Cache().setLoginType(LoginType.email);
emit(LoginReady()); emit(LoginSuccess());
} }
void _onLoginFB(LoginFB event, Emitter<LoginState> emit) async { void _onLoginFB(LoginFB event, Emitter<LoginState> emit) async {
@ -97,7 +102,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
await userRepository.getUserByFB(); await userRepository.getUserByFB();
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!)); accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
Track().track(TrackingEvent.login, eventValue: "FB"); Track().track(TrackingEvent.login, eventValue: "FB");
emit(LoginReady()); emit(LoginSuccess());
} }
void _onLoginGoogle(LoginGoogle event, Emitter<LoginState> emit) async { void _onLoginGoogle(LoginGoogle event, Emitter<LoginState> emit) async {

View File

@ -50,11 +50,11 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
getTotalRepeats(); getTotalRepeats();
createEvaluationData(); createEvaluationData();
getMaxLift(); getMaxLift();
if (end == null || DateTime.now().difference(end!).inMinutes > 5) { /* if (end == null || DateTime.now().difference(end!).inMinutes > 5) {
emit(TrainingEvaluationReady()); emit(TrainingEvaluationReady());
} else { } else {
emit(TrainingEvaluationVictoryReady()); emit(TrainingEvaluationVictoryReady());
} } */
} }
void createEvaluationData() { void createEvaluationData() {

View File

@ -45,7 +45,7 @@ dependencies:
flutter_html: ^2.0.0 flutter_html: ^2.0.0
wakelock: ^0.6.1+2 wakelock: ^0.6.1+2
timeline_tile: ^2.0.0 timeline_tile: ^2.0.0
purchases_flutter: ^3.8.0 purchases_flutter: ^3.9.5
package_info: ^2.0.0 package_info: ^2.0.0
ezanimation: ^0.6.0 ezanimation: ^0.6.0
confetti: ^0.6.0 confetti: ^0.6.0