v.1.28.2 save exercise async
This commit is contained in:
parent
a8af8f7c7e
commit
45cebbbdd2
@ -174,10 +174,10 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
|
|||||||
}
|
}
|
||||||
|
|
||||||
exerciseRepository.end = DateTime.now();
|
exerciseRepository.end = DateTime.now();
|
||||||
await exerciseRepository.addExercise();
|
exerciseRepository.addExercise();
|
||||||
if (kReleaseMode) {
|
if (kReleaseMode) {
|
||||||
MauticRepository mauticRepository = MauticRepository(customerRepository: customerRepository);
|
MauticRepository mauticRepository = MauticRepository(customerRepository: customerRepository);
|
||||||
await mauticRepository.sendMauticExercise();
|
mauticRepository.sendMauticExercise();
|
||||||
}
|
}
|
||||||
menuBloc.add(MenuTreeDown(parent: 0));
|
menuBloc.add(MenuTreeDown(parent: 0));
|
||||||
Cache().initBadges();
|
Cache().initBadges();
|
||||||
|
@ -2,7 +2,7 @@ import 'dart:math' as math;
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:aitrainer_app/model/cache.dart';
|
import 'package:aitrainer_app/model/cache.dart';
|
||||||
import 'package:aitrainer_app/service/logging.dart' as logging;
|
import 'package:aitrainer_app/service/logging.dart' as logger;
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
|
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
|
||||||
import 'package:firebase_auth/firebase_auth.dart';
|
import 'package:firebase_auth/firebase_auth.dart';
|
||||||
@ -12,7 +12,7 @@ import 'package:firebase_remote_config/firebase_remote_config.dart';
|
|||||||
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
|
||||||
import 'package:google_sign_in/google_sign_in.dart';
|
import 'package:google_sign_in/google_sign_in.dart';
|
||||||
|
|
||||||
class FirebaseApi with logging.Logging {
|
class FirebaseApi with logger.Logging {
|
||||||
bool appleSignInAvailable = false;
|
bool appleSignInAvailable = false;
|
||||||
|
|
||||||
static final FirebaseAuth auth = FirebaseAuth.instance;
|
static final FirebaseAuth auth = FirebaseAuth.instance;
|
||||||
@ -199,9 +199,9 @@ class FirebaseApi with logging.Logging {
|
|||||||
throw Exception(e);
|
throw Exception(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache().firebaseUid = userCredential!.user!.uid;
|
Cache().firebaseUid = userCredential.user!.uid;
|
||||||
|
|
||||||
userData['email'] = userCredential!.user!.email;
|
userData['email'] = userCredential.user!.email;
|
||||||
|
|
||||||
return userData;
|
return userData;
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,21 @@ mixin Common {
|
|||||||
return average;
|
return average;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double getRepeatByOneRepMax(double oneRepMax, double weight) {
|
||||||
|
double repeats = ( 80 * oneRepMax - 80 * weight ) / ( weight * ( 40 * 0.0333 + 1) );
|
||||||
|
//print("getRepeatsByOneRepMax: $repeats");
|
||||||
|
return repeats;
|
||||||
|
}
|
||||||
|
|
||||||
|
int calculateRepeatBy1RMPercent(double oneRepMax, double weight, double percent) {
|
||||||
|
return getRepeatByOneRepMax(oneRepMax , weight * percent).round();
|
||||||
|
}
|
||||||
|
|
||||||
|
double calculate1RMPercentByRepeat(double oneRepMax, double weight, double repeat) {
|
||||||
|
double percent = 80 * oneRepMax / (weight * ( repeat * ( 40 * 0.0333 + 1 ) + 80));
|
||||||
|
return percent;
|
||||||
|
}
|
||||||
|
|
||||||
static double get1RMPercent(int repeats) {
|
static double get1RMPercent(int repeats) {
|
||||||
double percent = 1;
|
double percent = 1;
|
||||||
|
|
||||||
@ -231,3 +246,5 @@ mixin Common {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CommonHoldingClass with Common {}
|
66
test/onerepmax.dart
Normal file
66
test/onerepmax.dart
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
|
||||||
|
import 'package:aitrainer_app/util/common.dart';
|
||||||
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
|
main() {
|
||||||
|
late CommonHoldingClass commonClass;
|
||||||
|
setUp(() {
|
||||||
|
commonClass = CommonHoldingClass();
|
||||||
|
});
|
||||||
|
|
||||||
|
group('OneRepMax', () {
|
||||||
|
test('test OneRepMax', () async {
|
||||||
|
double weight = 60.0;
|
||||||
|
double repeats = 10;
|
||||||
|
double oneRepMax = commonClass.calculate1RM(weight, repeats);
|
||||||
|
//print("1RM: $oneRepMax");
|
||||||
|
print("1RM 100%: 1");
|
||||||
|
int repeat95 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.95);
|
||||||
|
print("1RM 95%: $repeat95");
|
||||||
|
int repeat90 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.9);
|
||||||
|
print("1RM 90%: $repeat90");
|
||||||
|
int repeat85 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.85);
|
||||||
|
print("1RM 85%: $repeat85");
|
||||||
|
int repeat83 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.82);
|
||||||
|
print("1RM 82%: $repeat83");
|
||||||
|
int repeat80 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.8);
|
||||||
|
print("1RM 80%: $repeat80");
|
||||||
|
int repeat77 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.775);
|
||||||
|
print("1RM 77,5%: $repeat77");
|
||||||
|
int repeat75 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.75);
|
||||||
|
print("1RM 75%: $repeat75");
|
||||||
|
int repeat74 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.74);
|
||||||
|
print("1RM 74%: $repeat74");
|
||||||
|
int repeat71 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.71);
|
||||||
|
print("1RM 71%: $repeat71");
|
||||||
|
int repeat70 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.7);
|
||||||
|
print("1RM 70%: $repeat70");
|
||||||
|
int repeat68 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.685);
|
||||||
|
print("1RM 68,5%: $repeat68");
|
||||||
|
int repeat65 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.65);
|
||||||
|
print("1RM 65%: $repeat65");
|
||||||
|
int repeat62 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.628);
|
||||||
|
print("1RM 62,8%: $repeat62");
|
||||||
|
int repeat60 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.6);
|
||||||
|
print("1RM 60%: $repeat60");
|
||||||
|
int repeat59 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.59);
|
||||||
|
print("1RM 59%: $repeat59");
|
||||||
|
int repeat53 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.535);
|
||||||
|
print("1RM 53,5%: $repeat53");
|
||||||
|
int repeat50 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.5);
|
||||||
|
print("1RM 50%: $repeat50");
|
||||||
|
int repeat49 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.495);
|
||||||
|
print("1RM 49,5%: $repeat49");
|
||||||
|
int repeat46 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.46);
|
||||||
|
print("1RM 45%: $repeat46");
|
||||||
|
int repeat40 = commonClass.calculateRepeatBy1RMPercent(oneRepMax, oneRepMax, 0.405);
|
||||||
|
print("1RM 40,5%: $repeat40");
|
||||||
|
|
||||||
|
expect(repeat90, 4);
|
||||||
|
expect(repeat50, 34);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user