WT 1.1.24+5 training plan fixes
This commit is contained in:
parent
e8fc6cd7ec
commit
4c5aff91db
@ -136,10 +136,6 @@ PODS:
|
|||||||
- FirebaseInstallations (~> 8.0)
|
- FirebaseInstallations (~> 8.0)
|
||||||
- GoogleUtilities/Environment (~> 7.4)
|
- GoogleUtilities/Environment (~> 7.4)
|
||||||
- "GoogleUtilities/NSData+zlib (~> 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 (1.0.0)
|
||||||
- flutter_app_badger (0.0.1):
|
- flutter_app_badger (0.0.1):
|
||||||
- Flutter
|
- Flutter
|
||||||
@ -262,7 +258,6 @@ DEPENDENCIES:
|
|||||||
- firebase_in_app_messaging (from `.symlinks/plugins/firebase_in_app_messaging/ios`)
|
- firebase_in_app_messaging (from `.symlinks/plugins/firebase_in_app_messaging/ios`)
|
||||||
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
- firebase_messaging (from `.symlinks/plugins/firebase_messaging/ios`)
|
||||||
- firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`)
|
- firebase_remote_config (from `.symlinks/plugins/firebase_remote_config/ios`)
|
||||||
- flurry_data (from `.symlinks/plugins/flurry_data/ios`)
|
|
||||||
- Flutter (from `Flutter`)
|
- Flutter (from `Flutter`)
|
||||||
- flutter_app_badger (from `.symlinks/plugins/flutter_app_badger/ios`)
|
- flutter_app_badger (from `.symlinks/plugins/flutter_app_badger/ios`)
|
||||||
- flutter_facebook_auth (from `.symlinks/plugins/flutter_facebook_auth/ios`)
|
- flutter_facebook_auth (from `.symlinks/plugins/flutter_facebook_auth/ios`)
|
||||||
@ -303,7 +298,6 @@ SPEC REPOS:
|
|||||||
- FirebaseInstallations
|
- FirebaseInstallations
|
||||||
- FirebaseMessaging
|
- FirebaseMessaging
|
||||||
- FirebaseRemoteConfig
|
- FirebaseRemoteConfig
|
||||||
- Flurry-iOS-SDK
|
|
||||||
- FMDB
|
- FMDB
|
||||||
- GoogleAppMeasurement
|
- GoogleAppMeasurement
|
||||||
- GoogleDataTransport
|
- GoogleDataTransport
|
||||||
@ -338,8 +332,6 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/firebase_messaging/ios"
|
:path: ".symlinks/plugins/firebase_messaging/ios"
|
||||||
firebase_remote_config:
|
firebase_remote_config:
|
||||||
:path: ".symlinks/plugins/firebase_remote_config/ios"
|
:path: ".symlinks/plugins/firebase_remote_config/ios"
|
||||||
flurry_data:
|
|
||||||
:path: ".symlinks/plugins/flurry_data/ios"
|
|
||||||
Flutter:
|
Flutter:
|
||||||
:path: Flutter
|
:path: Flutter
|
||||||
flutter_app_badger:
|
flutter_app_badger:
|
||||||
@ -409,9 +401,7 @@ SPEC CHECKSUMS:
|
|||||||
FirebaseInstallations: 2563cb18a723ef9c6ef18318a49519b75dce613c
|
FirebaseInstallations: 2563cb18a723ef9c6ef18318a49519b75dce613c
|
||||||
FirebaseMessaging: 93227dd71d7888e200baef65043f81acb2b6596e
|
FirebaseMessaging: 93227dd71d7888e200baef65043f81acb2b6596e
|
||||||
FirebaseRemoteConfig: 34300dd83055c06e2768d0932dd8fb2c1575745f
|
FirebaseRemoteConfig: 34300dd83055c06e2768d0932dd8fb2c1575745f
|
||||||
Flurry-iOS-SDK: 494e340b623f1413711603dc0184f1fd4183e0d3
|
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
|
||||||
flurry_data: 49b7066a283aa41f4306974c1f2d74c61231ad74
|
|
||||||
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
|
|
||||||
flutter_app_badger: 65de4d6f0c34a891df49e6cfb8a1c0496426fa68
|
flutter_app_badger: 65de4d6f0c34a891df49e6cfb8a1c0496426fa68
|
||||||
flutter_facebook_auth: 870a465b1afff3ace7a592bd44665d921991726c
|
flutter_facebook_auth: 870a465b1afff3ace7a592bd44665d921991726c
|
||||||
flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec
|
flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
|
9705A1C41CF9048500538489 /* Embed Frameworks */ = {
|
||||||
isa = PBXCopyFilesBuildPhase;
|
isa = PBXCopyFilesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 8;
|
||||||
dstPath = "";
|
dstPath = "";
|
||||||
dstSubfolderSpec = 10;
|
dstSubfolderSpec = 10;
|
||||||
files = (
|
files = (
|
||||||
);
|
);
|
||||||
name = "Embed Frameworks";
|
name = "Embed Frameworks";
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 1;
|
||||||
};
|
};
|
||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
@ -388,7 +388,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 2;
|
CURRENT_PROJECT_VERSION = 5;
|
||||||
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@ -531,7 +531,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 2;
|
CURRENT_PROJECT_VERSION = 5;
|
||||||
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
@ -566,7 +566,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CURRENT_PROJECT_VERSION = 2;
|
CURRENT_PROJECT_VERSION = 5;
|
||||||
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
DEVELOPMENT_TEAM = SFJJBDCU6Z;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
FRAMEWORK_SEARCH_PATHS = (
|
FRAMEWORK_SEARCH_PATHS = (
|
||||||
|
@ -74,7 +74,6 @@
|
|||||||
</dict>
|
</dict>
|
||||||
<key>UIBackgroundModes</key>
|
<key>UIBackgroundModes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>audio</string>
|
|
||||||
<string>fetch</string>
|
<string>fetch</string>
|
||||||
<string>remote-notification</string>
|
<string>remote-notification</string>
|
||||||
</array>
|
</array>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
import 'package:aitrainer_app/bloc/training_plan/training_plan_bloc.dart';
|
import 'package:aitrainer_app/bloc/training_plan/training_plan_bloc.dart';
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
import 'package:aitrainer_app/model/customer_training_plan_details.dart';
|
import 'package:aitrainer_app/model/customer_training_plan_details.dart';
|
||||||
@ -22,6 +22,7 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
|
|||||||
String totalLift = "0";
|
String totalLift = "0";
|
||||||
String maxTotalLift = "0";
|
String maxTotalLift = "0";
|
||||||
String maxRepeats = "0";
|
String maxRepeats = "0";
|
||||||
|
String totalRepeats = "0";
|
||||||
DateTime? end;
|
DateTime? end;
|
||||||
|
|
||||||
List<TrainingEvaluationExercise> evaluationList = [];
|
List<TrainingEvaluationExercise> evaluationList = [];
|
||||||
@ -32,13 +33,14 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
|
|||||||
) async* {
|
) async* {
|
||||||
try {
|
try {
|
||||||
if (event is TrainingEvaluationLoad) {
|
if (event is TrainingEvaluationLoad) {
|
||||||
yield TrainingEvaluationLoading();
|
//yield TrainingEvaluationLoading();
|
||||||
await saveResult();
|
await saveResult();
|
||||||
getDuration();
|
getDuration();
|
||||||
getTotalLift();
|
getTotalLift();
|
||||||
getMaxRepeats();
|
getMaxRepeats();
|
||||||
|
getTotalRepeats();
|
||||||
createEvaluationData();
|
createEvaluationData();
|
||||||
//getMaxTotalLift();
|
getMaxLift();
|
||||||
if (end == null || DateTime.now().difference(end!).inMinutes > 5) {
|
if (end == null || DateTime.now().difference(end!).inMinutes > 5) {
|
||||||
yield TrainingEvaluationReady();
|
yield TrainingEvaluationReady();
|
||||||
} else {
|
} else {
|
||||||
@ -58,15 +60,11 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
|
|||||||
}
|
}
|
||||||
|
|
||||||
trainingPlanBloc.getMyPlan()!.days[day]!.forEach((element) {
|
trainingPlanBloc.getMyPlan()!.days[day]!.forEach((element) {
|
||||||
//if (!element.state.equalsTo(ExercisePlanDetailState.extra)) {
|
|
||||||
if (element.exerciseTypeId != null) {
|
if (element.exerciseTypeId != null) {
|
||||||
if (!findExerciseInEvaluationList(element.exerciseTypeId!)) {
|
if (!findExerciseInEvaluationList(element.exerciseTypeId!)) {
|
||||||
addEvaluationExercise(element);
|
addEvaluationExercise(element);
|
||||||
} else {
|
|
||||||
//editEvaluationExercise(element);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +102,8 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
|
|||||||
exercise.type = TrainingEvaluationExerciseType.weightBased;
|
exercise.type = TrainingEvaluationExerciseType.weightBased;
|
||||||
exercise.oneRepMax = Common.calculate1RM(detail.weight!, detail.repeats!.toDouble());
|
exercise.oneRepMax = Common.calculate1RM(detail.weight!, detail.repeats!.toDouble());
|
||||||
exercise.max1RM = getMax1RMByExerciseType(detail.exerciseTypeId!);
|
exercise.max1RM = getMax1RMByExerciseType(detail.exerciseTypeId!);
|
||||||
exercise.totalLift = (detail.weight! * detail.repeats!).round();
|
exercise.totalLift = getTotalLiftBySameExercise(detail.exerciseTypeId!);
|
||||||
exercise.maxTotalLift = getMaxTotalLiftByExerciseType(detail.exerciseTypeId!).round();
|
exercise.maxTotalLift = getMaxTotalLiftByExerciseType(detail.exerciseTypeId!);
|
||||||
exercise.trend = this.getTrendWeight(exercise.oneRepMax!, exercise.max1RM, exercise.totalLift, exercise.maxTotalLift);
|
exercise.trend = this.getTrendWeight(exercise.oneRepMax!, exercise.max1RM, exercise.totalLift, exercise.maxTotalLift);
|
||||||
}
|
}
|
||||||
exercise.trendText = getTrendText(exercise.trend!);
|
exercise.trendText = getTrendText(exercise.trend!);
|
||||||
@ -189,6 +187,36 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
|
|||||||
totalLift = total.toStringAsFixed(0);
|
totalLift = total.toStringAsFixed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double getTotalLiftBySameExercise(int exerciseTypeId) {
|
||||||
|
if (trainingPlanBloc.getMyPlan() == null || trainingPlanBloc.getMyPlan()!.days[day] == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
double total = 0;
|
||||||
|
trainingPlanBloc.getMyPlan()!.days[day]!.forEach((element) {
|
||||||
|
if (element.exerciseTypeId == exerciseTypeId) {
|
||||||
|
if (element.state.equalsTo(ExercisePlanDetailState.finished) && element.exerciseType!.unitQuantityUnit != null) {
|
||||||
|
total += element.weight! * element.repeats!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
void getMaxLift() {
|
||||||
|
if (trainingPlanBloc.getMyPlan() == null || trainingPlanBloc.getMyPlan()!.days[day] == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
double max = 0;
|
||||||
|
trainingPlanBloc.getMyPlan()!.days[day]!.forEach((element) {
|
||||||
|
if (element.state.equalsTo(ExercisePlanDetailState.finished) && element.exerciseType!.unitQuantityUnit != null) {
|
||||||
|
if (max < element.weight!) {
|
||||||
|
max = element.weight!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
maxTotalLift = max.toStringAsFixed(0);
|
||||||
|
}
|
||||||
|
|
||||||
void getMaxRepeats() {
|
void getMaxRepeats() {
|
||||||
if (trainingPlanBloc.getMyPlan() == null || trainingPlanBloc.getMyPlan()!.days[day] == null) {
|
if (trainingPlanBloc.getMyPlan() == null || trainingPlanBloc.getMyPlan()!.days[day] == null) {
|
||||||
return;
|
return;
|
||||||
@ -205,18 +233,41 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
|
|||||||
maxRepeats = max.toStringAsFixed(0);
|
maxRepeats = max.toStringAsFixed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void getTotalRepeats() {
|
||||||
|
if (trainingPlanBloc.getMyPlan() == null || trainingPlanBloc.getMyPlan()!.days[day] == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int total = 0;
|
||||||
|
trainingPlanBloc.getMyPlan()!.days[day]!.forEach((element) {
|
||||||
|
if (element.state.equalsTo(ExercisePlanDetailState.finished) && element.exerciseType!.unit != "second") {
|
||||||
|
print("Repeats ${element.repeats}");
|
||||||
|
|
||||||
|
total += element.repeats!;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
totalRepeats = total.toStringAsFixed(0);
|
||||||
|
}
|
||||||
|
|
||||||
double getMaxTotalLiftByExerciseType(int exerciseTypeId) {
|
double getMaxTotalLiftByExerciseType(int exerciseTypeId) {
|
||||||
if (Cache().getExercises() == null || Cache().getExercises()!.length == 0) {
|
if (Cache().getExercises() == null || Cache().getExercises()!.length == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var now = new DateTime.now();
|
||||||
|
var formatter = new DateFormat('yyyy-MM-dd');
|
||||||
|
final String formattedToday = formatter.format(now);
|
||||||
|
|
||||||
double maxTotal = 0;
|
double maxTotal = 0;
|
||||||
Cache().getExercises()!.forEach((element) {
|
Cache().getExercises()!.forEach((element) {
|
||||||
if (element.exerciseTypeId == exerciseTypeId) {
|
if (element.dateAdd != null) {
|
||||||
|
final String formattedExerciseDate = formatter.format(element.dateAdd!);
|
||||||
|
if (element.exerciseTypeId == exerciseTypeId && formattedToday != formattedExerciseDate) {
|
||||||
final double total = element.quantity! * element.unitQuantity!;
|
final double total = element.quantity! * element.unitQuantity!;
|
||||||
if (maxTotal < total) {
|
if (maxTotal < total) {
|
||||||
maxTotal = total;
|
maxTotal = total;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return maxTotal;
|
return maxTotal;
|
||||||
@ -226,14 +277,21 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
|
|||||||
if (Cache().getExercises() == null || Cache().getExercises()!.length == 0) {
|
if (Cache().getExercises() == null || Cache().getExercises()!.length == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
var now = new DateTime.now();
|
||||||
|
var formatter = new DateFormat('yyyy-MM-dd');
|
||||||
|
final String formattedToday = formatter.format(now);
|
||||||
|
|
||||||
double max1RM = 0;
|
double max1RM = 0;
|
||||||
Cache().getExercises()!.forEach((element) {
|
Cache().getExercises()!.forEach((element) {
|
||||||
if (element.exerciseTypeId == exerciseTypeId) {
|
if (element.dateAdd != null) {
|
||||||
|
final String formattedExerciseDate = formatter.format(element.dateAdd!);
|
||||||
|
if (element.exerciseTypeId == exerciseTypeId && formattedToday != formattedExerciseDate) {
|
||||||
final double oneRepMax = Common.calculate1RM(element.unitQuantity!, element.quantity!);
|
final double oneRepMax = Common.calculate1RM(element.unitQuantity!, element.quantity!);
|
||||||
if (max1RM < oneRepMax) {
|
if (max1RM < oneRepMax) {
|
||||||
max1RM = oneRepMax;
|
max1RM = oneRepMax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return max1RM;
|
return max1RM;
|
||||||
}
|
}
|
||||||
@ -269,8 +327,8 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
|
|||||||
}
|
}
|
||||||
|
|
||||||
double getTrendWeight(double oneRepMax, max1RM, totalLift, maxTotalLift) {
|
double getTrendWeight(double oneRepMax, max1RM, totalLift, maxTotalLift) {
|
||||||
double oneRepMaxRate = oneRepMax / max1RM;
|
final double oneRepMaxRate = oneRepMax / max1RM;
|
||||||
double totalLiftRate = totalLift / maxTotalLift;
|
//double totalLiftRate = totalLift / maxTotalLift;
|
||||||
return (oneRepMaxRate + totalLiftRate) / 2;
|
return oneRepMaxRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
|
|
||||||
CustomerTrainingPlan? _myPlan;
|
CustomerTrainingPlan? _myPlan;
|
||||||
CustomerTrainingPlanDetails? _myDetail;
|
CustomerTrainingPlanDetails? _myDetail;
|
||||||
|
CustomerTrainingPlanDetails? _backupDetail;
|
||||||
|
|
||||||
TrainingPlan? _myTrainingPlan;
|
TrainingPlan? _myTrainingPlan;
|
||||||
final List<String> trainingPlanDayNames = [];
|
final List<String> trainingPlanDayNames = [];
|
||||||
@ -75,6 +76,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
yield TrainingPlanFinished();
|
yield TrainingPlanFinished();
|
||||||
} else if (event is TrainingPlanWeightChange) {
|
} else if (event is TrainingPlanWeightChange) {
|
||||||
yield TrainingPlanExerciseLoading();
|
yield TrainingPlanExerciseLoading();
|
||||||
|
print("New weight: ${event.weight}");
|
||||||
event.detail.weight = event.weight;
|
event.detail.weight = event.weight;
|
||||||
|
|
||||||
yield TrainingPlanExerciseReady();
|
yield TrainingPlanExerciseReady();
|
||||||
@ -108,10 +110,19 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
} else if (event is TrainingPlanWeightChangeRecalculate) {
|
} else if (event is TrainingPlanWeightChangeRecalculate) {
|
||||||
yield TrainingPlanExerciseLoading();
|
yield TrainingPlanExerciseLoading();
|
||||||
|
|
||||||
print("Base1RM ${event.detail.base1RM}");
|
if (event.detail.baseOneRepMax > 0) {
|
||||||
if (event.detail.base1RM > 0) {
|
if (_myTrainingPlan == null) {
|
||||||
|
setTrainingPlanFromCache();
|
||||||
|
}
|
||||||
|
final int originalRepeats = trainingPlanRepository.getOriginalRepeats(_myTrainingPlan!.trainingPlanId, event.detail);
|
||||||
event.detail.repeats =
|
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().repeats = event.detail.repeats!;
|
||||||
ExerciseSaveStream().getStreamController().add(true);
|
ExerciseSaveStream().getStreamController().add(true);
|
||||||
}
|
}
|
||||||
@ -136,7 +147,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
yield TrainingPlanReady();
|
yield TrainingPlanReady();
|
||||||
throw Exception("Please type your repeats!");
|
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) {
|
if (event.detail.weight == -3) {
|
||||||
print("DropSet");
|
print("DropSet");
|
||||||
event.detail.state = ExercisePlanDetailState.finished;
|
event.detail.state = ExercisePlanDetailState.finished;
|
||||||
@ -152,8 +163,6 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
event.detail.exercises.add(exercise);
|
event.detail.exercises.add(exercise);
|
||||||
if (this.isAllDetailsSameExerciseFinished(event.detail)) {
|
if (this.isAllDetailsSameExerciseFinished(event.detail)) {
|
||||||
event.detail.state = ExercisePlanDetailState.finished;
|
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
|
// recalculate the weight to the original planned repeats for the next details
|
||||||
if (exercise.unitQuantity != null && exercise.unitQuantity! > 0) {
|
if (exercise.unitQuantity != null && exercise.unitQuantity! > 0) {
|
||||||
@ -165,23 +174,23 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
nextDetail.customerTrainingPlanDetailsId != event.detail.customerTrainingPlanDetailsId) {
|
nextDetail.customerTrainingPlanDetailsId != event.detail.customerTrainingPlanDetailsId) {
|
||||||
print("recalculating -2 ${event.detail.customerTrainingPlanDetailsId}");
|
print("recalculating -2 ${event.detail.customerTrainingPlanDetailsId}");
|
||||||
trainingPlanRepository.recalculateDetail(_myPlan!.trainingPlanId!, event.detail, nextDetail);
|
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) {
|
} else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId && weightFromPlan == -1 && nextDetail.set! > 1) {
|
||||||
print("recalculating -1 ${event.detail.customerTrainingPlanDetailsId}");
|
print("recalculating -1 ${event.detail.customerTrainingPlanDetailsId}");
|
||||||
nextDetail = trainingPlanRepository.recalculateDetailFixRepeats(_myPlan!.trainingPlanId!, nextDetail);
|
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) {
|
} else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId && nextDetail.weight == -1 && nextDetail.set! == 1) {
|
||||||
print("recalculating -1, set 1 ${event.detail.customerTrainingPlanDetailsId}");
|
print("recalculating -1, set 1 ${event.detail.customerTrainingPlanDetailsId}");
|
||||||
nextDetail = trainingPlanRepository.recalculateDetailFixRepeatsSet1(_myPlan!.trainingPlanId!, nextDetail, event.detail);
|
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());
|
||||||
} else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId &&
|
} /* else if (nextDetail.exerciseTypeId == event.detail.exerciseTypeId &&
|
||||||
weightFromPlan == -2 &&
|
weightFromPlan == -2 &&
|
||||||
nextDetail.set! == 1 &&
|
nextDetail.set! == 1 &&
|
||||||
nextDetail.exercises.length == 0) {
|
nextDetail.exercises.length == 0) {
|
||||||
print("recalculating -1/ no exercise, set 1 ${event.detail.customerTrainingPlanDetailsId}");
|
print("recalculating -1/ no exercise, set 1 ${event.detail.customerTrainingPlanDetailsId}");
|
||||||
nextDetail = trainingPlanRepository.recalculateDetailFixRepeatsSet1(_myPlan!.trainingPlanId!, nextDetail, event.detail);
|
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<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
}
|
}
|
||||||
Track().track(TrackingEvent.training_plan_custom, eventValue: event.exerciseType.name);
|
Track().track(TrackingEvent.training_plan_custom, eventValue: event.exerciseType.name);
|
||||||
yield TrainingPlanReady();
|
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) {
|
} on Exception catch (e) {
|
||||||
yield TrainingPlanError(message: e.toString());
|
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() {
|
void addNewPlan() {
|
||||||
if (Cache().userLoggedIn == null) {
|
if (Cache().userLoggedIn == null) {
|
||||||
throw Exception("Please log in");
|
throw Exception("Please log in");
|
||||||
@ -603,7 +642,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
final String day = dayNames[this.activeDayIndex];
|
final String day = dayNames[this.activeDayIndex];
|
||||||
CustomerTrainingPlanDetails? prev;
|
CustomerTrainingPlanDetails? prev;
|
||||||
for (var detail in _myPlan!.days[day]!) {
|
for (var detail in _myPlan!.days[day]!) {
|
||||||
//print("Offset detail $detail");
|
print("Offset detail $detail");
|
||||||
if (detail.state == ExercisePlanDetailState.inProgress || detail.state == ExercisePlanDetailState.start) {
|
if (detail.state == ExercisePlanDetailState.inProgress || detail.state == ExercisePlanDetailState.start) {
|
||||||
prev = detail;
|
prev = detail;
|
||||||
break;
|
break;
|
||||||
@ -618,7 +657,7 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
}
|
}
|
||||||
int index = indexInStart > indexInProgress ? indexInStart : indexInProgress;
|
int index = indexInStart > indexInProgress ? indexInStart : indexInProgress;
|
||||||
offset = (index) * 300;
|
offset = (index) * 300;
|
||||||
//print("Offset: $offset day: $day ($indexInStart, $indexInProgress)");
|
print("Offset: $offset day: $day ($indexInStart, $indexInProgress)");
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -770,10 +809,16 @@ class TrainingPlanBloc extends Bloc<TrainingPlanEvent, TrainingPlanState> {
|
|||||||
bool isAllDetailsSameExerciseFinished(CustomerTrainingPlanDetails detail) {
|
bool isAllDetailsSameExerciseFinished(CustomerTrainingPlanDetails detail) {
|
||||||
bool allFinished = true;
|
bool allFinished = true;
|
||||||
List<CustomerTrainingPlanDetails> list = getAllDetailsSameExercise(detail);
|
List<CustomerTrainingPlanDetails> list = getAllDetailsSameExercise(detail);
|
||||||
|
//print("SAME count: ${list.length}");
|
||||||
for (var listDetail in list) {
|
for (var listDetail in list) {
|
||||||
|
//print("SAME $listDetail");
|
||||||
|
if (listDetail.exercises.length >= listDetail.set!) {
|
||||||
|
listDetail.state = ExercisePlanDetailState.finished;
|
||||||
|
}
|
||||||
allFinished =
|
allFinished =
|
||||||
allFinished && (listDetail.exercises.length >= listDetail.set! || listDetail.state.equalsTo(ExercisePlanDetailState.skipped));
|
allFinished && (listDetail.exercises.length >= listDetail.set! || listDetail.state.equalsTo(ExercisePlanDetailState.skipped));
|
||||||
}
|
}
|
||||||
|
print("All finished: $allFinished for ${detail.exerciseTypeId}");
|
||||||
return allFinished;
|
return allFinished;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,14 @@ class TrainingPlanAddExerciseType extends TrainingPlanEvent {
|
|||||||
const TrainingPlanAddExerciseType();
|
const TrainingPlanAddExerciseType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TrainingPlanChangeCancel extends TrainingPlanEvent {
|
||||||
|
final CustomerTrainingPlanDetails detail;
|
||||||
|
const TrainingPlanChangeCancel({required this.detail});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [detail];
|
||||||
|
}
|
||||||
|
|
||||||
class TrainingPlanDeleteExerciseType extends TrainingPlanEvent {
|
class TrainingPlanDeleteExerciseType extends TrainingPlanEvent {
|
||||||
final ExerciseType exerciseType;
|
final ExerciseType exerciseType;
|
||||||
const TrainingPlanDeleteExerciseType({required this.exerciseType});
|
const TrainingPlanDeleteExerciseType({required this.exerciseType});
|
||||||
@ -126,3 +134,11 @@ class TrainingPlanCustomAddLoad extends TrainingPlanEvent {
|
|||||||
@override
|
@override
|
||||||
List<Object> get props => [exerciseType];
|
List<Object> get props => [exerciseType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TrainingPlanFinishDropset extends TrainingPlanEvent {
|
||||||
|
final CustomerTrainingPlanDetails detail;
|
||||||
|
const TrainingPlanFinishDropset({required this.detail});
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [detail];
|
||||||
|
}
|
||||||
|
@ -46,7 +46,7 @@ import 'package:aitrainer_app/widgets/home.dart';
|
|||||||
import 'package:aitrainer_app/library/facebook_app_events/facebook_app_events.dart';
|
import 'package:aitrainer_app/library/facebook_app_events/facebook_app_events.dart';
|
||||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||||
import 'package:firebase_analytics/observer.dart';
|
import 'package:firebase_analytics/observer.dart';
|
||||||
import 'package:flurry_data/flurry_data.dart';
|
//import 'package:flurry_data/flurry_data.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
@ -148,14 +148,10 @@ Future<Null> main() async {
|
|||||||
if (!isInDebugMode) {
|
if (!isInDebugMode) {
|
||||||
FlutterUxcam.startWithKey("wvdstyoml4tiwfd");
|
FlutterUxcam.startWithKey("wvdstyoml4tiwfd");
|
||||||
|
|
||||||
SetupOptions options = (
|
SetupOptions options = (new SetupOptionsBuilder('682883e5cd71a46160c4f6ed070530ee593f49c6')).build();
|
||||||
new SetupOptionsBuilder('682883e5cd71a46160c4f6ed070530ee593f49c6')
|
|
||||||
).build();
|
|
||||||
Smartlook.setupAndStartRecording(options);
|
Smartlook.setupAndStartRecording(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print(" -- FireBase init..");
|
print(" -- FireBase init..");
|
||||||
|
|
||||||
runApp(MultiBlocProvider(
|
runApp(MultiBlocProvider(
|
||||||
@ -203,7 +199,7 @@ Future<Null> main() async {
|
|||||||
|
|
||||||
Future<void> initThirdParty() async {
|
Future<void> initThirdParty() async {
|
||||||
if (!isInDebugMode) {
|
if (!isInDebugMode) {
|
||||||
await FlurryData.initialize(androidKey: "JNYCTCWBT34FM3J8TV36", iosKey: "3QBG7BSMGPDH24S8TRQP", enableLog: true);
|
//await FlurryData.initialize(androidKey: "JNYCTCWBT34FM3J8TV36", iosKey: "3QBG7BSMGPDH24S8TRQP", enableLog: true);
|
||||||
FlutterUxcam.optIntoSchematicRecordings();
|
FlutterUxcam.optIntoSchematicRecordings();
|
||||||
}
|
}
|
||||||
await FirebaseApi().initializeFlutterFire();
|
await FirebaseApi().initializeFlutterFire();
|
||||||
|
@ -31,7 +31,7 @@ import 'package:aitrainer_app/util/enums.dart';
|
|||||||
import 'package:aitrainer_app/util/env.dart';
|
import 'package:aitrainer_app/util/env.dart';
|
||||||
import 'package:aitrainer_app/util/track.dart';
|
import 'package:aitrainer_app/util/track.dart';
|
||||||
import 'package:firebase_remote_config/firebase_remote_config.dart';
|
import 'package:firebase_remote_config/firebase_remote_config.dart';
|
||||||
import 'package:flurry_data/flurry_data.dart';
|
//import 'package:flurry_data/flurry_data.dart';
|
||||||
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
||||||
import 'package:flutter_uxcam/flutter_uxcam.dart';
|
import 'package:flutter_uxcam/flutter_uxcam.dart';
|
||||||
import 'package:package_info/package_info.dart';
|
import 'package:package_info/package_info.dart';
|
||||||
@ -689,7 +689,7 @@ class Cache with Logging {
|
|||||||
await PackageApi().getCustomerPackage(customerId);
|
await PackageApi().getCustomerPackage(customerId);
|
||||||
|
|
||||||
if (!isInDebugMode) {
|
if (!isInDebugMode) {
|
||||||
FlurryData.setUserId(customerId.toString());
|
//FlurryData.setUserId(customerId.toString());
|
||||||
FlutterUxcam.setUserProperty("username", customerId.toString());
|
FlutterUxcam.setUserProperty("username", customerId.toString());
|
||||||
FlutterUxcam.setUserIdentity(customerId.toString());
|
FlutterUxcam.setUserIdentity(customerId.toString());
|
||||||
Smartlook.setUserIdentifier(customerId.toString());
|
Smartlook.setUserIdentifier(customerId.toString());
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import 'dart:collection';
|
import 'dart:collection';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:aitrainer_app/util/common.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
import 'package:aitrainer_app/model/customer_training_plan_details.dart';
|
import 'package:aitrainer_app/model/customer_training_plan_details.dart';
|
||||||
@ -61,6 +62,9 @@ class CustomerTrainingPlan {
|
|||||||
|
|
||||||
Iterable iterable = jsonDecode(jsonDetails);
|
Iterable iterable = jsonDecode(jsonDetails);
|
||||||
this.details = iterable.map((detail) => CustomerTrainingPlanDetails.fromJsonWithExerciseList(detail)).toList();
|
this.details = iterable.map((detail) => CustomerTrainingPlanDetails.fromJsonWithExerciseList(detail)).toList();
|
||||||
|
this.details.forEach((detail) {
|
||||||
|
detail.alternatives = Common.getExerciseTypeAlternatives(detail.exerciseTypeId);
|
||||||
|
});
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
print("JsonDecode error " + e.toString());
|
print("JsonDecode error " + e.toString());
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,9 @@ class CustomerTrainingPlanDetails {
|
|||||||
|
|
||||||
bool isTest = false;
|
bool isTest = false;
|
||||||
|
|
||||||
double base1RM = -1;
|
double baseOneRepMax = -1;
|
||||||
|
|
||||||
|
List<ExerciseType> alternatives = [];
|
||||||
|
|
||||||
CustomerTrainingPlanDetails();
|
CustomerTrainingPlanDetails();
|
||||||
|
|
||||||
@ -92,7 +94,7 @@ class CustomerTrainingPlanDetails {
|
|||||||
|
|
||||||
this.exerciseType = Cache().getExerciseTypeById(exerciseTypeId!);
|
this.exerciseType = Cache().getExerciseTypeById(exerciseTypeId!);
|
||||||
|
|
||||||
this.base1RM = json['base1RM'];
|
this.baseOneRepMax = json['baseOneRepMax'];
|
||||||
}
|
}
|
||||||
|
|
||||||
ExerciseType? getExerciseType() => exerciseType;
|
ExerciseType? getExerciseType() => exerciseType;
|
||||||
@ -122,7 +124,7 @@ class CustomerTrainingPlanDetails {
|
|||||||
'state': this.state.toStr(),
|
'state': this.state.toStr(),
|
||||||
"isTest": this.isTest,
|
"isTest": this.isTest,
|
||||||
"dayId": this.dayId,
|
"dayId": this.dayId,
|
||||||
"base1RM": this.base1RM,
|
"baseOneRepMax": this.baseOneRepMax,
|
||||||
};
|
};
|
||||||
|
|
||||||
//print("Detail toJson $jsonMap");
|
//print("Detail toJson $jsonMap");
|
||||||
@ -147,5 +149,6 @@ class CustomerTrainingPlanDetails {
|
|||||||
this.isTest = from.isTest;
|
this.isTest = from.isTest;
|
||||||
this.day = from.day;
|
this.day = from.day;
|
||||||
this.dayId = from.dayId;
|
this.dayId = from.dayId;
|
||||||
|
this.baseOneRepMax = from.baseOneRepMax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ class TrainingEvaluationExercise {
|
|||||||
int? repeats;
|
int? repeats;
|
||||||
int? maxRepeats;
|
int? maxRepeats;
|
||||||
|
|
||||||
int? totalLift;
|
double? totalLift;
|
||||||
int? maxTotalLift;
|
double? maxTotalLift;
|
||||||
|
|
||||||
double? oneRepMax;
|
double? oneRepMax;
|
||||||
double? max1RM;
|
double? max1RM;
|
||||||
|
@ -99,12 +99,13 @@ class TrainingPlanRepository {
|
|||||||
} else {
|
} else {
|
||||||
detail.weight = elem.weight;
|
detail.weight = elem.weight;
|
||||||
}
|
}
|
||||||
//print("Detail $detail exerciseType: ${detail.exerciseType}");
|
print("Detail $detail exerciseType: ${detail.exerciseType!.exerciseTypeId}");
|
||||||
|
|
||||||
detail.state = ExercisePlanDetailState.start;
|
detail.state = ExercisePlanDetailState.start;
|
||||||
if (detail.weight != null && detail.weight! > 0) {
|
if (detail.weight != null && detail.weight! > 0) {
|
||||||
detail.base1RM = Common.calculate1RM(detail.weight!, detail.repeats!.toDouble());
|
detail.baseOneRepMax = Common.calculate1RM(detail.weight!, detail.repeats!.toDouble());
|
||||||
}
|
}
|
||||||
|
detail.alternatives = Common.getExerciseTypeAlternatives(detail.exerciseTypeId);
|
||||||
plan.details.add(detail);
|
plan.details.add(detail);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import 'package:aitrainer_app/model/exercise_type.dart';
|
|||||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||||
import 'package:aitrainer_app/service/logging.dart';
|
import 'package:aitrainer_app/service/logging.dart';
|
||||||
|
import 'package:aitrainer_app/util/common.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
enum Antagonist { chest, biceps, triceps, back, shoulders, core, thigh, calf }
|
enum Antagonist { chest, biceps, triceps, back, shoulders, core, thigh, calf }
|
||||||
@ -265,24 +266,7 @@ class WorkoutTreeRepository with Logging {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<ExerciseType> getExerciseTypeAlternatives(int? exerciseTypeId) {
|
List<ExerciseType> getExerciseTypeAlternatives(int? exerciseTypeId) {
|
||||||
if (exerciseTypeId == null || exerciseTypeId <= 0) {
|
return Common.getExerciseTypeAlternatives(exerciseTypeId);
|
||||||
return [];
|
|
||||||
}
|
|
||||||
List<ExerciseType> list = [];
|
|
||||||
List<ExerciseType>? exerciseTypes = Cache().getExerciseTypes();
|
|
||||||
if (exerciseTypes != null) {
|
|
||||||
exerciseTypes.forEach((exerciseType) {
|
|
||||||
if (exerciseType.alternatives.isNotEmpty) {
|
|
||||||
exerciseType.alternatives.forEach((childId) {
|
|
||||||
if (childId == exerciseTypeId) {
|
|
||||||
list.add(exerciseType);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAntagonistSort(String type) {
|
String getAntagonistSort(String type) {
|
||||||
|
@ -225,4 +225,25 @@ mixin Common {
|
|||||||
"Initial 1RM: $initialRM repeat: $repeat changedRepeat: $changedRepeats Weight: $weight weightWendler: $weightWendler weight Oconner: $weightOconner. NEW WEIGHT: $newWeight");
|
"Initial 1RM: $initialRM repeat: $repeat changedRepeat: $changedRepeats Weight: $weight weightWendler: $weightWendler weight Oconner: $weightOconner. NEW WEIGHT: $newWeight");
|
||||||
return newWeight;
|
return newWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static List<ExerciseType> getExerciseTypeAlternatives(int? exerciseTypeId) {
|
||||||
|
if (exerciseTypeId == null || exerciseTypeId <= 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
List<ExerciseType> list = [];
|
||||||
|
List<ExerciseType>? exerciseTypes = Cache().getExerciseTypes();
|
||||||
|
if (exerciseTypes != null) {
|
||||||
|
exerciseTypes.forEach((exerciseType) {
|
||||||
|
if (exerciseType.alternatives.isNotEmpty) {
|
||||||
|
exerciseType.alternatives.forEach((childId) {
|
||||||
|
if (childId == exerciseTypeId) {
|
||||||
|
list.add(exerciseType);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import 'package:aitrainer_app/util/enums.dart';
|
|||||||
import 'package:aitrainer_app/model/tracking.dart' as model;
|
import 'package:aitrainer_app/model/tracking.dart' as model;
|
||||||
import 'package:firebase_analytics/firebase_analytics.dart';
|
import 'package:firebase_analytics/firebase_analytics.dart';
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||||
import 'package:flurry_data/flurry_data.dart';
|
//import 'package:flurry_data/flurry_data.dart';
|
||||||
import 'package:flutter_uxcam/flutter_uxcam.dart';
|
import 'package:flutter_uxcam/flutter_uxcam.dart';
|
||||||
import 'package:smartlook/smartlook.dart';
|
import 'package:smartlook/smartlook.dart';
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ class Track with Logging {
|
|||||||
|
|
||||||
void track(TrackingEvent event, {String eventValue = ""}) {
|
void track(TrackingEvent event, {String eventValue = ""}) {
|
||||||
if (!isInDebugMode) {
|
if (!isInDebugMode) {
|
||||||
FlurryData.logEvent(event.enumToString());
|
//FlurryData.logEvent(event.enumToString());
|
||||||
Smartlook.setGlobalEventProperty(event.toString(), eventValue, false);
|
Smartlook.setGlobalEventProperty(event.toString(), eventValue, false);
|
||||||
FlutterUxcam.logEventWithProperties(event.enumToString(), {"value": eventValue});
|
FlutterUxcam.logEventWithProperties(event.enumToString(), {"value": eventValue});
|
||||||
model.Tracking tracking = model.Tracking();
|
model.Tracking tracking = model.Tracking();
|
||||||
|
@ -166,7 +166,7 @@ class _CustomerHeightPageState extends State<CustomerHeightPage> with Trans {
|
|||||||
width: 55,
|
width: 55,
|
||||||
color: Color(0xffb4f500),
|
color: Color(0xffb4f500),
|
||||||
value: changeBloc.height,
|
value: changeBloc.height,
|
||||||
onValueChanged: (value) => {
|
onChanged: (value) => {
|
||||||
changeBloc.add(CustomerHeightChange(height: value.toInt())),
|
changeBloc.add(CustomerHeightChange(height: value.toInt())),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -251,7 +251,7 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
|||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
height: 55,
|
height: 55,
|
||||||
width: 25,
|
width: 25,
|
||||||
onValueChanged: (value) => {
|
onChanged: (value) => {
|
||||||
customerBloc.add(CustomerBirthYearChange(year: value.toInt())),
|
customerBloc.add(CustomerBirthYearChange(year: value.toInt())),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@ -353,7 +353,7 @@ class CustomerModifyPage extends StatelessWidget with Trans {
|
|||||||
width: 55,
|
width: 55,
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
value: customerBloc.height,
|
value: customerBloc.height,
|
||||||
onValueChanged: (value) => {
|
onChanged: (value) => {
|
||||||
customerBloc.add(CustomerHeightChange(height: value.toInt())),
|
customerBloc.add(CustomerHeightChange(height: value.toInt())),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -145,6 +145,10 @@ class TrainingEvaluationPage extends StatelessWidget with Trans {
|
|||||||
Divider(color: Colors.transparent),
|
Divider(color: Colors.transparent),
|
||||||
summaryRow("asset/image/pict_hypertrophy.png", "Maximum Repeats", "${bloc.maxRepeats}" + " " + t("reps")),
|
summaryRow("asset/image/pict_hypertrophy.png", "Maximum Repeats", "${bloc.maxRepeats}" + " " + t("reps")),
|
||||||
Divider(color: Colors.transparent),
|
Divider(color: Colors.transparent),
|
||||||
|
summaryRow("asset/image/pict_1rm.png", "Maximum Lift", "${bloc.maxTotalLift}" + " " + t("kg")),
|
||||||
|
Divider(color: Colors.transparent),
|
||||||
|
summaryRow("asset/image/pict_reps_volumen_db.png", "Total Repeats", "${bloc.totalRepeats}" + " " + t("reps")),
|
||||||
|
Divider(color: Colors.transparent),
|
||||||
//summaryRow("asset/image/pict_reps_volumen_db.png", "Total Lift Ever", "100 kg"),
|
//summaryRow("asset/image/pict_reps_volumen_db.png", "Total Lift Ever", "100 kg"),
|
||||||
//Divider(color: Colors.transparent),
|
//Divider(color: Colors.transparent),
|
||||||
Text(t("Details"),
|
Text(t("Details"),
|
||||||
|
@ -33,7 +33,9 @@ class _TrainingPlanExecuteState extends State<TrainingPlanExecute> with Trans {
|
|||||||
|
|
||||||
setContext(context);
|
setContext(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBarNav(depth: 0),
|
appBar: AppBarNav(
|
||||||
|
depth: 0,
|
||||||
|
),
|
||||||
body: Container(
|
body: Container(
|
||||||
padding: EdgeInsets.all(0),
|
padding: EdgeInsets.all(0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@ -335,6 +337,7 @@ class _ExerciseListState extends State<ExerciseList> with Trans {
|
|||||||
final HashMap args = HashMap();
|
final HashMap args = HashMap();
|
||||||
args['exerciseType'] = next.exerciseType;
|
args['exerciseType'] = next.exerciseType;
|
||||||
args['customerTrainingPlanDetails'] = detail;
|
args['customerTrainingPlanDetails'] = detail;
|
||||||
|
bloc.backupDetail(detail);
|
||||||
Navigator.of(context).pushNamed('myTrainingPlanExercise', arguments: args);
|
Navigator.of(context).pushNamed('myTrainingPlanExercise', arguments: args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,14 @@ class TrainingPlanExercise extends StatelessWidget with Trans {
|
|||||||
|
|
||||||
setContext(context);
|
setContext(context);
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBarNav(depth: 1),
|
appBar: AppBarNav(
|
||||||
|
depth: 1,
|
||||||
|
onTap: () => {
|
||||||
|
print("back"),
|
||||||
|
bloc.add(
|
||||||
|
TrainingPlanChangeCancel(detail: detail),
|
||||||
|
)
|
||||||
|
}),
|
||||||
body: Container(
|
body: Container(
|
||||||
height: double.infinity,
|
height: double.infinity,
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
@ -72,7 +79,14 @@ class TrainingPlanExercise extends StatelessWidget with Trans {
|
|||||||
heroTag: "saveButton",
|
heroTag: "saveButton",
|
||||||
onPressed: () => {
|
onPressed: () => {
|
||||||
Navigator.of(context).pop(),
|
Navigator.of(context).pop(),
|
||||||
|
if (detail.weight != -3)
|
||||||
|
{
|
||||||
bloc.add(TrainingPlanSaveExercise(detail: detail)),
|
bloc.add(TrainingPlanSaveExercise(detail: detail)),
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bloc.add(TrainingPlanFinishDropset(detail: detail)),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
backgroundColor: Colors.orange[800],
|
backgroundColor: Colors.orange[800],
|
||||||
icon: Icon(CustomIcon.save),
|
icon: Icon(CustomIcon.save),
|
||||||
|
@ -19,7 +19,8 @@ class AppBarNav extends StatefulWidget implements PreferredSizeWidget {
|
|||||||
final MenuBloc? menuBloc;
|
final MenuBloc? menuBloc;
|
||||||
final bool? isMenu;
|
final bool? isMenu;
|
||||||
final int? depth;
|
final int? depth;
|
||||||
AppBarNav({this.menuBloc, this.isMenu, this.depth});
|
final VoidCallback? onTap;
|
||||||
|
AppBarNav({this.menuBloc, this.isMenu, this.depth, this.onTap});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_AppBarNav createState() => _AppBarNav();
|
_AppBarNav createState() => _AppBarNav();
|
||||||
@ -92,18 +93,23 @@ class _AppBarNav extends State<AppBarNav> with SingleTickerProviderStateMixin, C
|
|||||||
),
|
),
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: Icon(Icons.arrow_back, color: Colors.white),
|
icon: Icon(Icons.arrow_back, color: Colors.white),
|
||||||
onPressed: () => {
|
onPressed: () {
|
||||||
timerBloc.add(TimerEnd(duration: 0)),
|
timerBloc.add(TimerEnd(duration: 0));
|
||||||
if (widget.isMenu != null)
|
print("tapping ${widget.onTap}");
|
||||||
{
|
if (widget.onTap != null) {
|
||||||
if (menuBloc.workoutItem != null)
|
print("tap");
|
||||||
{
|
widget.onTap!();
|
||||||
menuBloc.add(MenuTreeUp(parent: menuBloc.workoutItem!.parent)),
|
|
||||||
}
|
}
|
||||||
|
if (widget.isMenu != null) {
|
||||||
|
if (menuBloc.workoutItem != null) {
|
||||||
|
menuBloc.add(MenuTreeUp(parent: menuBloc.workoutItem!.parent));
|
||||||
|
}
|
||||||
|
} else if (widget.depth != null) {
|
||||||
|
if (widget.depth == 0) {
|
||||||
|
Navigator.of(context).popAndPushNamed('home');
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
else if (widget.depth != null)
|
|
||||||
{
|
|
||||||
if (widget.depth == 0) {Navigator.of(context).popAndPushNamed('home')} else {Navigator.of(context).pop()}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
29
pubspec.lock
29
pubspec.lock
@ -7,14 +7,14 @@ packages:
|
|||||||
name: _fe_analyzer_shared
|
name: _fe_analyzer_shared
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "22.0.0"
|
version: "30.0.0"
|
||||||
analyzer:
|
analyzer:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: analyzer
|
name: analyzer
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.1"
|
version: "2.7.0"
|
||||||
animated_widgets:
|
animated_widgets:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -42,7 +42,7 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.6.1"
|
version: "2.8.1"
|
||||||
badges:
|
badges:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -147,7 +147,7 @@ packages:
|
|||||||
name: charcode
|
name: charcode
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.1"
|
||||||
checked_yaml:
|
checked_yaml:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -456,13 +456,6 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.36.1"
|
version: "0.36.1"
|
||||||
flurry_data:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: flurry_data
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "0.0.2"
|
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -734,7 +727,7 @@ packages:
|
|||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.0"
|
version: "1.7.0"
|
||||||
mime:
|
mime:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1222,7 +1215,7 @@ packages:
|
|||||||
name: syncfusion_flutter_core
|
name: syncfusion_flutter_core
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "19.2.60"
|
version: "19.3.48"
|
||||||
syncfusion_flutter_datagrid:
|
syncfusion_flutter_datagrid:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1243,7 +1236,7 @@ packages:
|
|||||||
name: syncfusion_flutter_gauges
|
name: syncfusion_flutter_gauges
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "19.2.60"
|
version: "19.3.48"
|
||||||
synchronized:
|
synchronized:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -1264,21 +1257,21 @@ packages:
|
|||||||
name: test
|
name: test
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.8"
|
version: "1.17.10"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.0"
|
version: "0.4.2"
|
||||||
test_core:
|
test_core:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_core
|
name: test_core
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.19"
|
version: "0.4.0"
|
||||||
timeline_tile:
|
timeline_tile:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -1532,5 +1525,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.0"
|
version: "3.1.0"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.12.0 <3.0.0"
|
dart: ">=2.14.0 <3.0.0"
|
||||||
flutter: ">=2.0.0"
|
flutter: ">=2.0.0"
|
||||||
|
@ -28,7 +28,7 @@ dependencies:
|
|||||||
google_fonts: ^2.1.0
|
google_fonts: ^2.1.0
|
||||||
devicelocale: ^0.4.1
|
devicelocale: ^0.4.1
|
||||||
sentry_flutter: ^5.1.0-beta.1
|
sentry_flutter: ^5.1.0-beta.1
|
||||||
flutter_bloc: ^7.1.0
|
flutter_bloc: ^7.3.0
|
||||||
equatable: ^2.0.3
|
equatable: ^2.0.3
|
||||||
|
|
||||||
spider_chart: ^0.1.5
|
spider_chart: ^0.1.5
|
||||||
@ -69,7 +69,7 @@ dependencies:
|
|||||||
firebase_dynamic_links: ^2.0.8
|
firebase_dynamic_links: ^2.0.8
|
||||||
firebase_in_app_messaging: ^0.5.0+8
|
firebase_in_app_messaging: ^0.5.0+8
|
||||||
|
|
||||||
syncfusion_flutter_gauges: ^19.2.60
|
syncfusion_flutter_gauges: ^19.3.48
|
||||||
syncfusion_flutter_datagrid: ^19.1.63
|
syncfusion_flutter_datagrid: ^19.1.63
|
||||||
syncfusion_flutter_charts: ^19.2.60
|
syncfusion_flutter_charts: ^19.2.60
|
||||||
syncfusion_flutter_calendar: ^19.2.60
|
syncfusion_flutter_calendar: ^19.2.60
|
||||||
@ -79,7 +79,7 @@ dependencies:
|
|||||||
sign_in_with_apple: ^3.0.0
|
sign_in_with_apple: ^3.0.0
|
||||||
|
|
||||||
smartlook: ^2.0.1
|
smartlook: ^2.0.1
|
||||||
flurry_data: ^0.0.1
|
#flurry_data: ^0.0.1
|
||||||
flutter_uxcam: ^2.0.1
|
flutter_uxcam: ^2.0.1
|
||||||
|
|
||||||
animated_widgets: ^1.0.6
|
animated_widgets: ^1.0.6
|
||||||
|
Loading…
Reference in New Issue
Block a user