diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index d0c6822..5395b86 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -136,10 +136,6 @@ PODS:
- FirebaseInstallations (~> 8.0)
- GoogleUtilities/Environment (~> 7.4)
- "GoogleUtilities/NSData+zlib (~> 7.4)"
- - Flurry-iOS-SDK/FlurrySDK (11.3.0)
- - flurry_data (0.0.1):
- - Flurry-iOS-SDK/FlurrySDK
- - Flutter
- Flutter (1.0.0)
- flutter_app_badger (0.0.1):
- Flutter
@@ -262,7 +258,6 @@ DEPENDENCIES:
- firebase_in_app_messaging (from `.symlinks/plugins/firebase_in_app_messaging/ios`)
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
- firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`)
- - flurry_data (from `.symlinks/plugins/flurry_data/ios`)
- Flutter (from `Flutter`)
- flutter_app_badger (from `.symlinks/plugins/flutter_app_badger/ios`)
- flutter_facebook_auth (from `.symlinks/plugins/flutter_facebook_auth/ios`)
@@ -303,7 +298,6 @@ SPEC REPOS:
- FirebaseInstallations
- FirebaseMessaging
- FirebaseRemoteConfig
- - Flurry-iOS-SDK
- FMDB
- GoogleAppMeasurement
- GoogleDataTransport
@@ -338,8 +332,6 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/firebase_messaging/ios"
firebase_remote_config:
:path: ".symlinks/plugins/firebase_remote_config/ios"
- flurry_data:
- :path: ".symlinks/plugins/flurry_data/ios"
Flutter:
:path: Flutter
flutter_app_badger:
@@ -409,9 +401,7 @@ SPEC CHECKSUMS:
FirebaseInstallations: 2563cb18a723ef9c6ef18318a49519b75dce613c
FirebaseMessaging: 93227dd71d7888e200baef65043f81acb2b6596e
FirebaseRemoteConfig: 34300dd83055c06e2768d0932dd8fb2c1575745f
- Flurry-iOS-SDK: 494e340b623f1413711603dc0184f1fd4183e0d3
- flurry_data: 49b7066a283aa41f4306974c1f2d74c61231ad74
- Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
+ Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
flutter_app_badger: 65de4d6f0c34a891df49e6cfb8a1c0496426fa68
flutter_facebook_auth: 870a465b1afff3ace7a592bd44665d921991726c
flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 2bc8233..3142358 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -22,13 +22,13 @@
/* Begin PBXCopyFilesBuildPhase section */
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
- buildActionMask = 2147483647;
+ buildActionMask = 8;
dstPath = "";
dstSubfolderSpec = 10;
files = (
);
name = "Embed Frameworks";
- runOnlyForDeploymentPostprocessing = 0;
+ runOnlyForDeploymentPostprocessing = 1;
};
/* End PBXCopyFilesBuildPhase section */
@@ -388,7 +388,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
- CURRENT_PROJECT_VERSION = 2;
+ CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_TEAM = SFJJBDCU6Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@@ -531,7 +531,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
- CURRENT_PROJECT_VERSION = 2;
+ CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_TEAM = SFJJBDCU6Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
@@ -566,7 +566,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
- CURRENT_PROJECT_VERSION = 2;
+ CURRENT_PROJECT_VERSION = 5;
DEVELOPMENT_TEAM = SFJJBDCU6Z;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 7d0290a..fdd86ea 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -74,7 +74,6 @@
UIBackgroundModes
- audio
fetch
remote-notification
diff --git a/lib/bloc/training_evaluation/training_evaluation_bloc.dart b/lib/bloc/training_evaluation/training_evaluation_bloc.dart
index e3a14e4..d5fe225 100644
--- a/lib/bloc/training_evaluation/training_evaluation_bloc.dart
+++ b/lib/bloc/training_evaluation/training_evaluation_bloc.dart
@@ -1,5 +1,5 @@
import 'dart:async';
-
+import 'package:intl/intl.dart';
import 'package:aitrainer_app/bloc/training_plan/training_plan_bloc.dart';
import 'package:aitrainer_app/model/cache.dart';
import 'package:aitrainer_app/model/customer_training_plan_details.dart';
@@ -22,6 +22,7 @@ class TrainingEvaluationBloc extends Bloc evaluationList = [];
@@ -32,13 +33,14 @@ class TrainingEvaluationBloc extends Bloc 5) {
yield TrainingEvaluationReady();
} else {
@@ -58,15 +60,11 @@ class TrainingEvaluationBloc extends Bloc {
CustomerTrainingPlan? _myPlan;
CustomerTrainingPlanDetails? _myDetail;
+ CustomerTrainingPlanDetails? _backupDetail;
TrainingPlan? _myTrainingPlan;
final List trainingPlanDayNames = [];
@@ -75,6 +76,7 @@ class TrainingPlanBloc extends Bloc {
yield TrainingPlanFinished();
} else if (event is TrainingPlanWeightChange) {
yield TrainingPlanExerciseLoading();
+ print("New weight: ${event.weight}");
event.detail.weight = event.weight;
yield TrainingPlanExerciseReady();
@@ -108,10 +110,19 @@ class TrainingPlanBloc extends Bloc {
} else if (event is TrainingPlanWeightChangeRecalculate) {
yield TrainingPlanExerciseLoading();
- print("Base1RM ${event.detail.base1RM}");
- if (event.detail.base1RM > 0) {
+ if (event.detail.baseOneRepMax > 0) {
+ if (_myTrainingPlan == null) {
+ setTrainingPlanFromCache();
+ }
+ final int originalRepeats = trainingPlanRepository.getOriginalRepeats(_myTrainingPlan!.trainingPlanId, event.detail);
event.detail.repeats =
- Common.calculateQuantityByChangedWeight(event.detail.base1RM, event.weight, event.detail.repeats!.toDouble());
+ Common.calculateQuantityByChangedWeight(event.detail.baseOneRepMax, event.weight, originalRepeats.toDouble());
+
+ print("Base1RM ${event.detail.baseOneRepMax} repeats: ${event.detail.repeats}");
+ if (event.detail.repeats! < 1) {
+ event.detail.repeats = 1;
+ event.detail.weight = trainingPlanRepository.getOriginalWeight(_myTrainingPlan!.trainingPlanId, event.detail);
+ }
ExerciseSaveStream().repeats = event.detail.repeats!;
ExerciseSaveStream().getStreamController().add(true);
}
@@ -136,7 +147,7 @@ class TrainingPlanBloc extends Bloc {
yield TrainingPlanReady();
throw Exception("Please type your repeats!");
}
- print("ExerciseTypeUID: ${event.detail.exerciseTypeId}");
+ print("SAVE for ExerciseTypeID: ${event.detail.exerciseTypeId} weight: ${event.detail.weight}");
if (event.detail.weight == -3) {
print("DropSet");
event.detail.state = ExercisePlanDetailState.finished;
@@ -152,8 +163,6 @@ class TrainingPlanBloc extends Bloc {
event.detail.exercises.add(exercise);
if (this.isAllDetailsSameExerciseFinished(event.detail)) {
event.detail.state = ExercisePlanDetailState.finished;
- } else if (event.detail.exercises.length >= 0) {
- event.detail.state = ExercisePlanDetailState.inProgress;
}
// recalculate the weight to the original planned repeats for the next details
if (exercise.unitQuantity != null && exercise.unitQuantity! > 0) {
@@ -165,23 +174,23 @@ class TrainingPlanBloc extends Bloc {
nextDetail.customerTrainingPlanDetailsId != event.detail.customerTrainingPlanDetailsId) {
print("recalculating -2 ${event.detail.customerTrainingPlanDetailsId}");
trainingPlanRepository.recalculateDetail(_myPlan!.trainingPlanId!, event.detail, nextDetail);
- nextDetail.base1RM = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
+ nextDetail.baseOneRepMax = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
} else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId && weightFromPlan == -1 && nextDetail.set! > 1) {
print("recalculating -1 ${event.detail.customerTrainingPlanDetailsId}");
nextDetail = trainingPlanRepository.recalculateDetailFixRepeats(_myPlan!.trainingPlanId!, nextDetail);
- nextDetail.base1RM = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
+ nextDetail.baseOneRepMax = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
} else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId && nextDetail.weight == -1 && nextDetail.set! == 1) {
print("recalculating -1, set 1 ${event.detail.customerTrainingPlanDetailsId}");
nextDetail = trainingPlanRepository.recalculateDetailFixRepeatsSet1(_myPlan!.trainingPlanId!, nextDetail, event.detail);
- nextDetail.base1RM = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
- } else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId &&
+ nextDetail.baseOneRepMax = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
+ } /* else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId &&
weightFromPlan == -2 &&
nextDetail.set! == 1 &&
nextDetail.exercises.length == 0) {
print("recalculating -1/ no exercise, set 1 ${event.detail.customerTrainingPlanDetailsId}");
nextDetail = trainingPlanRepository.recalculateDetailFixRepeatsSet1(_myPlan!.trainingPlanId!, nextDetail, event.detail);
- nextDetail.base1RM = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
- }
+ nextDetail.baseOneRepMax = Common.calculate1RM(nextDetail.weight!, nextDetail.repeats!.toDouble());
+ }*/
}
}
@@ -288,12 +297,42 @@ class TrainingPlanBloc extends Bloc {
}
Track().track(TrackingEvent.training_plan_custom, eventValue: event.exerciseType.name);
yield TrainingPlanReady();
+ } else if (event is TrainingPlanChangeCancel) {
+ yield TrainingPlanLoading();
+ print("Backup $_backupDetail");
+ if (_backupDetail != null) {
+ event.detail.repeats = _backupDetail!.repeats;
+ event.detail.weight = _backupDetail!.weight;
+ }
+ yield TrainingPlanReady();
+ } else if (event is TrainingPlanFinishDropset) {
+ yield TrainingPlanLoading();
+ event.detail.state = ExercisePlanDetailState.finished;
+ yield TrainingPlanReady();
}
} on Exception catch (e) {
yield TrainingPlanError(message: e.toString());
}
}
+ void backupDetail(CustomerTrainingPlanDetails detail) {
+ if (_backupDetail == null) {
+ _backupDetail = CustomerTrainingPlanDetails();
+ }
+ _backupDetail!.copy(detail);
+ }
+
+ void setTrainingPlanFromCache() {
+ if (_myPlan == null) {
+ setMyPlan(Cache().myTrainingPlan);
+ }
+ Cache().getTrainingPlans()!.forEach((element) {
+ if (_myPlan!.trainingPlanId == element.trainingPlanId) {
+ _myTrainingPlan = element;
+ }
+ });
+ }
+
void addNewPlan() {
if (Cache().userLoggedIn == null) {
throw Exception("Please log in");
@@ -603,7 +642,7 @@ class TrainingPlanBloc extends Bloc {
final String day = dayNames[this.activeDayIndex];
CustomerTrainingPlanDetails? prev;
for (var detail in _myPlan!.days[day]!) {
- //print("Offset detail $detail");
+ print("Offset detail $detail");
if (detail.state == ExercisePlanDetailState.inProgress || detail.state == ExercisePlanDetailState.start) {
prev = detail;
break;
@@ -618,7 +657,7 @@ class TrainingPlanBloc extends Bloc {
}
int index = indexInStart > indexInProgress ? indexInStart : indexInProgress;
offset = (index) * 300;
- //print("Offset: $offset day: $day ($indexInStart, $indexInProgress)");
+ print("Offset: $offset day: $day ($indexInStart, $indexInProgress)");
return offset;
}
@@ -770,10 +809,16 @@ class TrainingPlanBloc extends Bloc {
bool isAllDetailsSameExerciseFinished(CustomerTrainingPlanDetails detail) {
bool allFinished = true;
List list = getAllDetailsSameExercise(detail);
+ //print("SAME count: ${list.length}");
for (var listDetail in list) {
+ //print("SAME $listDetail");
+ if (listDetail.exercises.length >= listDetail.set!) {
+ listDetail.state = ExercisePlanDetailState.finished;
+ }
allFinished =
allFinished && (listDetail.exercises.length >= listDetail.set! || listDetail.state.equalsTo(ExercisePlanDetailState.skipped));
}
+ print("All finished: $allFinished for ${detail.exerciseTypeId}");
return allFinished;
}
}
diff --git a/lib/bloc/training_plan/training_plan_event.dart b/lib/bloc/training_plan/training_plan_event.dart
index f91b357..6971190 100644
--- a/lib/bloc/training_plan/training_plan_event.dart
+++ b/lib/bloc/training_plan/training_plan_event.dart
@@ -111,6 +111,14 @@ class TrainingPlanAddExerciseType extends TrainingPlanEvent {
const TrainingPlanAddExerciseType();
}
+class TrainingPlanChangeCancel extends TrainingPlanEvent {
+ final CustomerTrainingPlanDetails detail;
+ const TrainingPlanChangeCancel({required this.detail});
+
+ @override
+ List