WT1.1.3 logo change, error fixes
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
class CustomExerciseFormBloc extends FormBloc<String, String> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
bool loading = false;
|
||||
final quantityField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
@@ -66,10 +67,12 @@ class CustomExerciseFormBloc extends FormBloc<String, String> {
|
||||
@override
|
||||
void onSubmitting() async {
|
||||
try {
|
||||
loading = true;
|
||||
emitLoading(progress: 30);
|
||||
// Emit either Loaded or Error
|
||||
|
||||
emitSuccess(canSubmitAgain: false);
|
||||
loading = false;
|
||||
} on Exception catch (ex) {
|
||||
emitFailure(failureResponse: ex.toString());
|
||||
}
|
||||
|
||||
@@ -2,26 +2,30 @@ import 'dart:async';
|
||||
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'customer_change_event.dart';
|
||||
part 'customer_change_state.dart';
|
||||
|
||||
class CustomerChangeBloc extends Bloc<CustomerChangeEvent, CustomerChangeState> {
|
||||
class CustomerChangeBloc extends Bloc<CustomerChangeEvent, CustomerChangeState> with Trans {
|
||||
final CustomerRepository customerRepository;
|
||||
final BuildContext context;
|
||||
bool visiblePassword = false;
|
||||
int year = 1990;
|
||||
double weight = 60;
|
||||
double height = 170;
|
||||
CustomerChangeBloc({this.customerRepository}) : super(CustomerChangeInitial()) {
|
||||
CustomerChangeBloc({this.customerRepository, this.context}) : super(CustomerChangeInitial()) {
|
||||
year = this.customerRepository.customer.birthYear;
|
||||
if (year == 0) {
|
||||
year = 1990;
|
||||
}
|
||||
weight = this.customerRepository.getWeight();
|
||||
height = this.customerRepository.getHeight();
|
||||
weight = this.customerRepository.getWeight() == 0 ? 60 : this.customerRepository.getWeight();
|
||||
height = this.customerRepository.getHeight() == 0 ? 170 : this.customerRepository.getHeight();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -98,21 +102,24 @@ class CustomerChangeBloc extends Bloc<CustomerChangeEvent, CustomerChangeState>
|
||||
}
|
||||
|
||||
String emailValidation(String email) {
|
||||
bool emailValid = RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+").hasMatch(email);
|
||||
return emailValid ? null : "Please type an email address";
|
||||
String message = Common.emailValidation(email);
|
||||
if (message != null) {
|
||||
message = t(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
String passwordValidation(String value) {
|
||||
if (value == null || value.length == 0) {
|
||||
return null;
|
||||
String message = Common.passwordValidation(value);
|
||||
if (message != null) {
|
||||
message = t(message);
|
||||
}
|
||||
bool valid = 8 < value.length;
|
||||
return valid ? null : "Password too short";
|
||||
return message;
|
||||
}
|
||||
|
||||
String nameValidation(String value) {
|
||||
if (value == null || value.length == 0) {
|
||||
return "Name too short";
|
||||
return t("Name too short");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
final bool readonly;
|
||||
final double percentToCalculate;
|
||||
int step = 1;
|
||||
final List<double> repeats = List();
|
||||
|
||||
double initialRM;
|
||||
double unitQuantity;
|
||||
@@ -27,17 +26,13 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
|
||||
@override
|
||||
ExerciseControlBloc({this.exerciseRepository, this.readonly, this.percentToCalculate}) : super(ExerciseControlInitial()) {
|
||||
firstUnitQuantity = exerciseRepository.exercise.unitQuantity;
|
||||
firstQuantity = exerciseRepository.exercise.quantity;
|
||||
repeats.add(firstUnitQuantity);
|
||||
repeats.add(firstQuantity);
|
||||
|
||||
initialRM = this.calculate1RM(percent75: false);
|
||||
unitQuantity = this.calculate1RM(percent75: true).roundToDouble();
|
||||
quantity = percentToCalculate == 0.75 ? 12 : 30;
|
||||
origQuantity = quantity;
|
||||
|
||||
exerciseRepository.setUnitQuantity(unitQuantity);
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -48,31 +43,24 @@ class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlStat
|
||||
step = 1;
|
||||
yield ExerciseControlReady();
|
||||
} else if (event is ExerciseControlQuantityChange) {
|
||||
yield ExerciseControlLoading();
|
||||
//yield ExerciseControlLoading();
|
||||
if (event.step == step) {
|
||||
exerciseRepository.setQuantity(event.quantity);
|
||||
quantity = event.quantity;
|
||||
}
|
||||
yield ExerciseControlReady();
|
||||
//yield ExerciseControlReady();
|
||||
} else if (event is ExerciseControlSubmit) {
|
||||
yield ExerciseControlLoading();
|
||||
if (event.step == step) {
|
||||
step++;
|
||||
scrollOffset = step * 200.0;
|
||||
/* print("step " +
|
||||
step.toString() +
|
||||
" quantity " +
|
||||
quantity.toString() +
|
||||
" origQuantity: " +
|
||||
origQuantity.toString() +
|
||||
" scrollOffset: " +
|
||||
scrollOffset.toString()); */
|
||||
repeats.add(quantity);
|
||||
scrollOffset = step * 400.0;
|
||||
|
||||
quantity = origQuantity;
|
||||
exerciseRepository.end = DateTime.now();
|
||||
await exerciseRepository.addExercise();
|
||||
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
exerciseRepository.exercise.exerciseId = null;
|
||||
}
|
||||
yield ExerciseControlReady();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class ExerciseExecutePlanBloc extends Bloc<ExerciseExecutePlanEvent, ExerciseExe
|
||||
final WorkoutTreeRepository menuTreeRepository;
|
||||
final ExercisePlanRepository exercisePlanRepository = ExercisePlanRepository();
|
||||
int customerId;
|
||||
int selectedNumber = 0;
|
||||
@override
|
||||
ExerciseExecutePlanBloc({this.menuTreeRepository}) : super(ExerciseByPlanStateInitial());
|
||||
|
||||
@@ -32,6 +33,7 @@ class ExerciseExecutePlanBloc extends Bloc<ExerciseExecutePlanEvent, ExerciseExe
|
||||
if (exercisePlanRepository.getExercisePlanDetailSize() > 0) {
|
||||
if (exercisePlanRepository.getExercisePlanDetailByExerciseId(workoutTree.exerciseTypeId) != null) {
|
||||
workoutTree.selected = true;
|
||||
this.selectedNumber++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -55,6 +55,7 @@ class ExerciseExecutePlanAddBloc extends Bloc<ExerciseExecutePlanAddEvent, Exerc
|
||||
try {
|
||||
if (event is ExerciseExecutePlanAddLoad) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
Flurry.logEvent("ExecuteExercisePlanOpen");
|
||||
yield ExerciseExecutePlanAddReady();
|
||||
} else if (event is ExerciseExecutePlanAddChangeQuantity) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
@@ -72,7 +73,7 @@ class ExerciseExecutePlanAddBloc extends Bloc<ExerciseExecutePlanAddEvent, Exerc
|
||||
exerciseRepository.exercise.unit = workoutTree.exerciseType.unit;
|
||||
workoutTree.executed = true;
|
||||
await exerciseRepository.addExercise();
|
||||
Flurry.logEvent("ExecuteExercisePlan");
|
||||
Flurry.logEvent("ExecuteExercisePlanSave");
|
||||
step++;
|
||||
scrollOffset = step * 200.0;
|
||||
planBloc.add(ExerciseByPlanLoad());
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:aitrainer_app/model/exercise.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flurry/flurry.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'exercise_log_event.dart';
|
||||
@@ -14,17 +15,22 @@ class ExerciseLogBloc extends Bloc<ExerciseLogEvent, ExerciseLogState> {
|
||||
@override
|
||||
ExerciseLogBloc({this.exerciseRepository}) : super(ExerciseLogInitial());
|
||||
|
||||
|
||||
@override
|
||||
Stream<ExerciseLogState> mapEventToState(ExerciseLogEvent event) async* {
|
||||
try {
|
||||
if (event is ExerciseLogLoad) {
|
||||
yield ExerciseLogLoading();
|
||||
Flurry.logEvent("exerciseLog");
|
||||
yield ExerciseLogReady();
|
||||
} else if ( event is ExerciseLogDelete ) {
|
||||
} else if (event is ExerciseLogDelete) {
|
||||
yield ExerciseLogLoading();
|
||||
exerciseRepository.exerciseList.remove(event.exercise);
|
||||
await exerciseRepository.deleteExercise(event.exercise);
|
||||
Flurry.logEvent("exerciseDelete");
|
||||
yield ExerciseLogReady();
|
||||
} else if (event is ExerciseResult) {
|
||||
yield ExerciseLogLoading();
|
||||
Flurry.logEvent("exerciseResult");
|
||||
yield ExerciseLogReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
|
||||
@@ -18,5 +18,8 @@ class ExerciseLogDelete extends ExerciseLogEvent {
|
||||
|
||||
@override
|
||||
List<Object> get props => [exercise];
|
||||
}
|
||||
|
||||
class ExerciseResult extends ExerciseLogEvent {
|
||||
const ExerciseResult();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import 'dart:async';
|
||||
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/exercise_ability.dart';
|
||||
import 'package:aitrainer_app/model/property.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
import 'package:aitrainer_app/model/fitness_state.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flurry/flurry.dart';
|
||||
@@ -18,7 +20,7 @@ import 'package:stop_watch_timer/stop_watch_timer.dart';
|
||||
part 'exercise_new_event.dart';
|
||||
part 'exercise_new_state.dart';
|
||||
|
||||
class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logging {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
final CustomerRepository customerRepository;
|
||||
final MenuBloc menuBloc;
|
||||
@@ -45,6 +47,7 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
double mediaWidth = 0;
|
||||
double mediaHeight = 0;
|
||||
bool isMan = true;
|
||||
String exerciseTask = "";
|
||||
|
||||
final StopWatchTimer stopWatchTimer = StopWatchTimer(
|
||||
isLapHours: false,
|
||||
@@ -54,8 +57,8 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
@override
|
||||
ExerciseNewBloc({this.exerciseRepository, this.menuBloc, this.customerRepository, ExerciseType exerciseType})
|
||||
: super(ExerciseNewInitial()) {
|
||||
exerciseRepository.exerciseType = exerciseType;
|
||||
exerciseRepository.setUnit(exerciseType.unit);
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
exerciseRepository.setUnitQuantity(unitQuantity);
|
||||
exerciseRepository.exercise.exercisePlanDetailId = 0;
|
||||
exerciseRepository.start = DateTime.now();
|
||||
@@ -66,7 +69,38 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
fitnessLevel = customerRepository.customer.fitnessLevel;
|
||||
this.isMan = (customerRepository.customer.sex == "m");
|
||||
}
|
||||
stopWatchTimer.rawTime.listen((value) => timerValue = value);
|
||||
if (exerciseType.unit == "second") {
|
||||
stopWatchTimer.rawTime.listen((value) => {timerValue = value, this.setQuantity((value / 1000).toDouble())});
|
||||
}
|
||||
this.setExerciseTask(init: true);
|
||||
}
|
||||
|
||||
String setExerciseTask({bool init = false}) {
|
||||
if (this.exerciseRepository.exerciseType == null) {
|
||||
print("WTF, exerciseType is null");
|
||||
return "";
|
||||
}
|
||||
if (this.exerciseRepository.exerciseType.unit != "second") {
|
||||
if (menuBloc.ability.toString() == ExerciseAbility.oneRepMax.toString()) {
|
||||
this.exerciseTask = "Please take a relative bigger weight and repeat 12-20 times";
|
||||
if (init) {
|
||||
this.setQuantity(12);
|
||||
}
|
||||
} else if (this.exerciseRepository.exerciseType.isEndurance() &&
|
||||
menuBloc.ability.toString() == ExerciseAbility.endurance.toString() &&
|
||||
exerciseRepository.exerciseType.unitQuantity == "1") {
|
||||
this.exerciseTask = "Please take a medium weight and repeat 20-30 times";
|
||||
if (init) {
|
||||
this.setQuantity(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.exerciseTask;
|
||||
}
|
||||
|
||||
void setQuantity(double quantity) {
|
||||
this.quantity = quantity;
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
}
|
||||
|
||||
void setMediaDimensions(double width, double height) {
|
||||
@@ -213,6 +247,37 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
}
|
||||
}
|
||||
|
||||
int getWeightCoordinate(isMan, {isTop = false, isLeft = false}) {
|
||||
int value = 0;
|
||||
this.manSizes.forEach((element) {
|
||||
if (element.propertyName == "Weight") {
|
||||
if (isTop == true) {
|
||||
value = element.top;
|
||||
} else if (isLeft == true) {
|
||||
value = element.left;
|
||||
}
|
||||
}
|
||||
});
|
||||
return value;
|
||||
}
|
||||
|
||||
Property getPropertyByName(String propertyName) {
|
||||
Property property;
|
||||
List<Property> sizes;
|
||||
if (customerRepository.sex == "Man") {
|
||||
sizes = this.manSizes;
|
||||
} else {
|
||||
sizes = this.womanSizes;
|
||||
}
|
||||
|
||||
sizes.forEach((element) {
|
||||
if (element.propertyName == propertyName) {
|
||||
property = element;
|
||||
}
|
||||
});
|
||||
return property;
|
||||
}
|
||||
|
||||
void updateSizes(String propertyName, double value) {
|
||||
List<Property> sizes;
|
||||
if (customerRepository.sex == "Man") {
|
||||
@@ -236,8 +301,8 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
yield ExerciseNewReady();
|
||||
} else if (event is ExerciseNewQuantityChange) {
|
||||
yield ExerciseNewLoading();
|
||||
exerciseRepository.setQuantity(event.quantity);
|
||||
quantity = event.quantity;
|
||||
log("Event quantity " + event.quantity.toStringAsFixed(0));
|
||||
this.setQuantity(event.quantity);
|
||||
yield ExerciseNewReady();
|
||||
} else if (event is ExerciseNewQuantityUnitChange) {
|
||||
yield ExerciseNewLoading();
|
||||
@@ -288,6 +353,7 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
menuBloc.add(MenuTreeDown(parent: 0));
|
||||
Cache().initBadges();
|
||||
Flurry.logEvent("newExercise");
|
||||
Flurry.logEvent("newExercise " + exerciseRepository.exerciseType.name);
|
||||
yield ExerciseNewReady();
|
||||
} else if (event is ExerciseNewBMIAnimate) {
|
||||
yield ExerciseNewLoading();
|
||||
@@ -342,19 +408,32 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
getBMI();
|
||||
}
|
||||
final double distortionWidth = mediaWidth / baseWidth;
|
||||
final double distortionHeight = mediaHeight / baseHeight;
|
||||
final double distortionHeight = distortionWidth - 0.02; //mediaHeight / baseHeight;
|
||||
/* log("Width: " +
|
||||
mediaWidth.toStringAsFixed(0) +
|
||||
" Height: " +
|
||||
mediaHeight.toStringAsFixed(0) +
|
||||
" BaseW: " +
|
||||
baseWidth.toStringAsFixed(0) +
|
||||
" BaseH: " +
|
||||
baseHeight.toStringAsFixed(0) +
|
||||
" DistW: " +
|
||||
distortionWidth.toStringAsFixed(2) +
|
||||
" DistH: " +
|
||||
distortionHeight.toStringAsFixed(2)); */
|
||||
|
||||
this.bmiAngle = (bmi * 90 / 25) - 90;
|
||||
if (bmi < 18.5) {
|
||||
goalBMI = 19;
|
||||
this.bmiTop = 99 * distortionHeight;
|
||||
this.bmiLeft = 77 * distortionWidth;
|
||||
bmiAngle = -62;
|
||||
} else if (bmi < 25 && 18.5 < bmi) {
|
||||
goalBMI = 27;
|
||||
} else if (bmi > 18.5 && bmi < 25) {
|
||||
goalBMI = this.bmi;
|
||||
this.bmiTop = 48 * distortionHeight;
|
||||
this.bmiLeft = 130 * distortionWidth;
|
||||
bmiAngle = -23;
|
||||
} else if (bmi < 30 && 24.9 < bmi) {
|
||||
} else if (bmi < 30 && bmi > 24.9) {
|
||||
goalBMI = 24;
|
||||
this.bmiTop = 40.0 * distortionHeight;
|
||||
this.bmiLeft = 184.0 * distortionWidth;
|
||||
@@ -376,9 +455,4 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
|
||||
return goalBMI;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() async {
|
||||
await stopWatchTimer.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:aitrainer_app/repository/workout_tree_repository.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flurry/flurry.dart';
|
||||
import 'package:flurry/flurry.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'exercise_plan_event.dart';
|
||||
@@ -48,6 +49,7 @@ class ExercisePlanBloc extends Bloc<ExercisePlanEvent, ExercisePlanState> {
|
||||
try {
|
||||
if (event is ExercisePlanLoad) {
|
||||
yield ExercisePlanLoading();
|
||||
Flurry.logEvent("exercisePlan");
|
||||
await this.getData();
|
||||
yield ExercisePlanReady();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aitrainer_app/bloc/account/account_bloc.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:aitrainer_app/repository/user_repository.dart';
|
||||
import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flurry/flurry.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
part 'login_event.dart';
|
||||
part 'login_state.dart';
|
||||
|
||||
class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
|
||||
final AccountBloc accountBloc;
|
||||
final UserRepository userRepository;
|
||||
final CustomerRepository customerRepository = CustomerRepository();
|
||||
final BuildContext context;
|
||||
final bool isRegistration;
|
||||
bool dataPolicyAllowed = false;
|
||||
LoginBloc({this.accountBloc, this.userRepository, this.context, this.isRegistration}) : super(LoginInitial());
|
||||
|
||||
@override
|
||||
Stream<LoginState> mapEventToState(
|
||||
LoginEvent event,
|
||||
) async* {
|
||||
try {
|
||||
if (event is LoginEmailChange) {
|
||||
yield LoginLoading();
|
||||
final String email = event.email;
|
||||
userRepository.setEmail(email);
|
||||
yield LoginReady();
|
||||
} else if (event is LoginPasswordChange) {
|
||||
yield LoginLoading();
|
||||
final String password = event.password;
|
||||
userRepository.setPassword(password);
|
||||
yield LoginReady();
|
||||
} else if (event is LoginSubmit) {
|
||||
yield LoginLoading();
|
||||
await userRepository.getUser();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
|
||||
Flurry.logEvent("Login");
|
||||
yield LoginSuccess();
|
||||
} else if (event is LoginFB) {
|
||||
yield LoginLoading();
|
||||
await userRepository.getUserByFB();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
|
||||
Flurry.logEvent("Login");
|
||||
Flurry.logEvent("LoginFB");
|
||||
yield LoginSuccess();
|
||||
} else if (event is RegistrationSubmit) {
|
||||
yield LoginLoading();
|
||||
if (!this.dataPolicyAllowed) {
|
||||
yield LoginError();
|
||||
throw Exception("Please accept our data policy");
|
||||
}
|
||||
await userRepository.addUser();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
|
||||
await saveCustomer();
|
||||
Flurry.logEvent("Registration");
|
||||
|
||||
yield LoginSuccess();
|
||||
} else if (event is RegistrationFB) {
|
||||
yield LoginLoading();
|
||||
if (!this.dataPolicyAllowed) {
|
||||
yield LoginError();
|
||||
throw Exception("Please accept our data policy");
|
||||
}
|
||||
await userRepository.addUserFB();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
|
||||
await saveCustomer();
|
||||
Flurry.logEvent("RegistrationFB");
|
||||
Flurry.logEvent("Registration");
|
||||
yield LoginSuccess();
|
||||
} else if (event is DataProtectionClicked) {
|
||||
this.dataPolicyAllowed = event.marked;
|
||||
yield LoginReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
yield LoginError(message: e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> saveCustomer() async {
|
||||
customerRepository.customer = Cache().userLoggedIn;
|
||||
customerRepository.customer.dataPolicyAllowed = 1;
|
||||
await customerRepository.saveCustomer();
|
||||
}
|
||||
|
||||
String emailValidation(String email) {
|
||||
String message = Common.emailValidation(email);
|
||||
if (message != null) {
|
||||
message = t(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
String passwordValidation(String value) {
|
||||
String message = Common.passwordValidation(value);
|
||||
if (message != null) {
|
||||
message = t(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
part of 'login_bloc.dart';
|
||||
|
||||
abstract class LoginEvent extends Equatable {
|
||||
const LoginEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class LoginEmailChange extends LoginEvent {
|
||||
final String email;
|
||||
const LoginEmailChange({this.email});
|
||||
|
||||
@override
|
||||
List<Object> get props => [email];
|
||||
}
|
||||
|
||||
class LoginPasswordChange extends LoginEvent {
|
||||
final String password;
|
||||
const LoginPasswordChange({this.password});
|
||||
|
||||
@override
|
||||
List<Object> get props => [password];
|
||||
}
|
||||
|
||||
class LoginPasswordChangeObscure extends LoginEvent {
|
||||
const LoginPasswordChangeObscure();
|
||||
}
|
||||
|
||||
class LoginSubmit extends LoginEvent {
|
||||
const LoginSubmit();
|
||||
}
|
||||
|
||||
class LoginFB extends LoginEvent {
|
||||
const LoginFB();
|
||||
}
|
||||
|
||||
class DataProtectionClicked extends LoginEvent {
|
||||
final bool marked;
|
||||
const DataProtectionClicked({this.marked});
|
||||
}
|
||||
|
||||
class RegistrationSubmit extends LoginEvent {
|
||||
const RegistrationSubmit();
|
||||
}
|
||||
|
||||
class RegistrationFB extends LoginEvent {
|
||||
const RegistrationFB();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
part of 'login_bloc.dart';
|
||||
|
||||
abstract class LoginState extends Equatable {
|
||||
const LoginState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class LoginInitial extends LoginState {
|
||||
const LoginInitial();
|
||||
}
|
||||
|
||||
class LoginLoading extends LoginState {
|
||||
const LoginLoading();
|
||||
}
|
||||
|
||||
class LoginReady extends LoginState {
|
||||
const LoginReady();
|
||||
}
|
||||
|
||||
class LoginSuccess extends LoginState {
|
||||
const LoginSuccess();
|
||||
}
|
||||
|
||||
class LoginError extends LoginState {
|
||||
final String message;
|
||||
const LoginError({this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
|
||||
class DataPolicyError extends LoginState {
|
||||
const DataPolicyError();
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
import 'package:aitrainer_app/bloc/account/account_bloc.dart';
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/repository/user_repository.dart';
|
||||
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
||||
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
||||
import 'package:aitrainer_app/service/property_service.dart';
|
||||
import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
class LoginFormBloc extends FormBloc<String, String> with Common {
|
||||
final AccountBloc accountBloc;
|
||||
final UserRepository userRepository;
|
||||
|
||||
final emailField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
],
|
||||
);
|
||||
final passwordField = TextFieldBloc(validators: [
|
||||
FieldBlocValidators.required,
|
||||
]);
|
||||
|
||||
LoginFormBloc({this.userRepository, this.accountBloc}) {
|
||||
addFieldBlocs(fieldBlocs: [emailField, passwordField]);
|
||||
|
||||
emailField.onValueChanges(onData: (previous, current) async* {
|
||||
userRepository.setEmail(current.value);
|
||||
});
|
||||
|
||||
passwordField.onValueChanges(onData: (previous, current) async* {
|
||||
userRepository.setPassword(current.value);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onSubmitting() async {
|
||||
try {
|
||||
emitLoading(progress: 30);
|
||||
if (!validateEmail(userRepository)) {
|
||||
emailField.addFieldError(EMAIL_ERROR, isPermanent: true);
|
||||
|
||||
emitFailure(failureResponse: EMAIL_ERROR);
|
||||
} else if (!validatePassword(userRepository)) {
|
||||
passwordField.addFieldError(PASSWORD_ERROR, isPermanent: true);
|
||||
emitFailure(failureResponse: PASSWORD_ERROR);
|
||||
} else {
|
||||
// Emit either Loaded or Error
|
||||
await PropertyApi().getProperties();
|
||||
await userRepository.getUser();
|
||||
await ExerciseTypeApi().getExerciseTypes();
|
||||
await ExerciseTreeApi().getExerciseTree();
|
||||
if (Cache().userLoggedIn != null && Cache().userLoggedIn.customerId > 0) {
|
||||
ExerciseRepository exerciseRepository = ExerciseRepository();
|
||||
await exerciseRepository.getExercisesByCustomer(Cache().userLoggedIn.customerId);
|
||||
}
|
||||
emitSuccess(canSubmitAgain: false);
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
|
||||
Cache().initBadges();
|
||||
}
|
||||
} on Exception catch (ex) {
|
||||
emitFailure(failureResponse: ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/repository/user_repository.dart';
|
||||
import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'account/account_bloc.dart';
|
||||
|
||||
class RegistrationFormBloc extends FormBloc<String, String> with Common {
|
||||
final AccountBloc accountBloc;
|
||||
final emailField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
],
|
||||
);
|
||||
final passwordField = TextFieldBloc(validators: [
|
||||
FieldBlocValidators.required,
|
||||
]);
|
||||
final UserRepository userRepository;
|
||||
|
||||
RegistrationFormBloc({this.userRepository, this.accountBloc}) {
|
||||
addFieldBlocs(fieldBlocs: [emailField, passwordField]);
|
||||
|
||||
emailField.onValueChanges(onData: (previous, current) async* {
|
||||
userRepository.setEmail(current.value);
|
||||
});
|
||||
|
||||
passwordField.onValueChanges(onData: (previous, current) async* {
|
||||
userRepository.setPassword(current.value);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onSubmitting() async {
|
||||
try {
|
||||
emitLoading(progress: 30);
|
||||
if (!validateEmail(userRepository)) {
|
||||
emailField.addFieldError(EMAIL_ERROR, isPermanent: true);
|
||||
|
||||
emitFailure(failureResponse: EMAIL_ERROR);
|
||||
} else if (!validatePassword(userRepository)) {
|
||||
passwordField.addFieldError(PASSWORD_ERROR, isPermanent: true);
|
||||
emitFailure(failureResponse: PASSWORD_ERROR);
|
||||
} else {
|
||||
// Emit either Loaded or Error
|
||||
await userRepository.addUser();
|
||||
emitSuccess(canSubmitAgain: false);
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn));
|
||||
Cache().initBadges();
|
||||
}
|
||||
} on Exception catch (ex) {
|
||||
emitFailure(failureResponse: ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
import 'package:aitrainer_app/repository/user_repository.dart';
|
||||
import 'package:aitrainer_app/util/common.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
class ResetPasswordFormBloc extends FormBloc<String, String> with Common {
|
||||
final UserRepository userRepository;
|
||||
bool loading = false;
|
||||
|
||||
final emailField = TextFieldBloc(
|
||||
validators: [
|
||||
@@ -13,9 +13,7 @@ class ResetPasswordFormBloc extends FormBloc<String, String> with Common {
|
||||
);
|
||||
|
||||
ResetPasswordFormBloc({this.userRepository}) {
|
||||
addFieldBlocs(fieldBlocs: [
|
||||
emailField
|
||||
]);
|
||||
addFieldBlocs(fieldBlocs: [emailField]);
|
||||
|
||||
emailField.onValueChanges(onData: (previous, current) async* {
|
||||
userRepository.setEmail(current.value);
|
||||
@@ -26,7 +24,8 @@ class ResetPasswordFormBloc extends FormBloc<String, String> with Common {
|
||||
void onSubmitting() async {
|
||||
try {
|
||||
emitLoading(progress: 30);
|
||||
if ( ! validateEmail(userRepository)) {
|
||||
loading = true;
|
||||
if (!validateEmail(userRepository)) {
|
||||
emailField.addFieldError(EMAIL_ERROR, isPermanent: true);
|
||||
|
||||
emitFailure(failureResponse: EMAIL_ERROR);
|
||||
@@ -35,9 +34,9 @@ class ResetPasswordFormBloc extends FormBloc<String, String> with Common {
|
||||
await userRepository.resetPassword();
|
||||
emitSuccess(canSubmitAgain: false);
|
||||
}
|
||||
loading = false;
|
||||
} on Exception catch (ex) {
|
||||
emitFailure(failureResponse: ex.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,5 +44,4 @@ class ResetPasswordFormBloc extends FormBloc<String, String> with Common {
|
||||
emailField.close();
|
||||
return super.close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,21 +5,24 @@ import 'package:aitrainer_app/model/result.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_result_repository.dart';
|
||||
import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:aitrainer_app/util/trans.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:health/health.dart';
|
||||
//import 'package:health/health.dart';
|
||||
|
||||
part 'result_event.dart';
|
||||
part 'result_state.dart';
|
||||
|
||||
class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging, Trans {
|
||||
final ExerciseResultRepository resultRepository;
|
||||
final ExerciseRepository exerciseRepository;
|
||||
List<HealthDataPoint> _healthDataList = List();
|
||||
final BuildContext context;
|
||||
//List<HealthDataPoint> _healthDataList = List();
|
||||
DateTime startTime;
|
||||
DateTime endTime;
|
||||
final HealthFactory health = HealthFactory();
|
||||
/* final HealthFactory health = HealthFactory();
|
||||
final List<HealthDataType> types = [
|
||||
HealthDataType.ACTIVE_ENERGY_BURNED,
|
||||
HealthDataType.WATER,
|
||||
@@ -30,9 +33,9 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
HealthDataType.HIGH_HEART_RATE_EVENT,
|
||||
HealthDataType.LOW_HEART_RATE_EVENT,
|
||||
HealthDataType.RESTING_HEART_RATE
|
||||
];
|
||||
]; */
|
||||
|
||||
ResultBloc({this.resultRepository, this.exerciseRepository}) : super(ResultInitial()) {
|
||||
ResultBloc({this.resultRepository, this.exerciseRepository, this.context}) : super(ResultInitial()) {
|
||||
this.startTime = exerciseRepository.start;
|
||||
this.endTime = exerciseRepository.end;
|
||||
}
|
||||
@@ -45,7 +48,7 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
if (event is ResultLoad) {
|
||||
yield ResultLoading();
|
||||
|
||||
await _fetchHealthData();
|
||||
//await _fetchHealthData();
|
||||
_matchExerciseData();
|
||||
await resultRepository.saveExerciseResults();
|
||||
yield ResultReady();
|
||||
@@ -62,16 +65,16 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
element.exerciseId = exerciseRepository.actualExerciseList[0].exerciseId;
|
||||
switch (element.item) {
|
||||
case ResultItem.bpm_avg:
|
||||
element.data = _gethHealthDataPointValueAvg(HealthDataType.HEART_RATE);
|
||||
//element.data = _gethHealthDataPointValueAvg(HealthDataType.HEART_RATE);
|
||||
break;
|
||||
case ResultItem.bpm_min:
|
||||
element.data = element.data = _gethHealthDataPointValueMin(HealthDataType.HEART_RATE);
|
||||
//element.data = element.data = _gethHealthDataPointValueMin(HealthDataType.HEART_RATE);
|
||||
break;
|
||||
case ResultItem.bpm_max:
|
||||
element.data = element.data = _gethHealthDataPointValueMax(HealthDataType.HEART_RATE);
|
||||
//element.data = element.data = _gethHealthDataPointValueMax(HealthDataType.HEART_RATE);
|
||||
break;
|
||||
case ResultItem.calorie:
|
||||
element.data = _gethHealthDataPointValueSum(HealthDataType.ACTIVE_ENERGY_BURNED);
|
||||
//element.data = _gethHealthDataPointValueSum(HealthDataType.ACTIVE_ENERGY_BURNED);
|
||||
break;
|
||||
case ResultItem.development_percent_bodypart:
|
||||
// TODO: Handle this case.
|
||||
@@ -82,7 +85,7 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
}
|
||||
break;
|
||||
case ResultItem.fatburn_percent:
|
||||
DateTime today = DateTime.now();
|
||||
/* DateTime today = DateTime.now();
|
||||
int age = today.year - Cache().userLoggedIn.birthYear;
|
||||
double minBpm = (200 - age) * 0.6;
|
||||
double maxBpm = (200 - age) * 0.7;
|
||||
@@ -100,7 +103,7 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
element.data = (burnCounter / counter * 100);
|
||||
} else {
|
||||
element.data = 0;
|
||||
}
|
||||
} */
|
||||
break;
|
||||
case ResultItem.speed_max:
|
||||
// TODO: Handle this case.
|
||||
@@ -108,14 +111,14 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
case ResultItem.reps_volume:
|
||||
if (exerciseRepository.exerciseType.unit == "repeat") {
|
||||
double value = 0;
|
||||
exerciseRepository.actualExerciseList.forEach((element) {
|
||||
value += element.quantity;
|
||||
exerciseRepository.actualExerciseList.forEach((actual) {
|
||||
value += actual.quantity;
|
||||
});
|
||||
element.data = value;
|
||||
}
|
||||
break;
|
||||
case ResultItem.steps:
|
||||
element.data = _gethHealthDataPointValueSum(HealthDataType.STEPS);
|
||||
element.data = 0; //_gethHealthDataPointValueSum(HealthDataType.STEPS);
|
||||
break;
|
||||
/* case ResultItem.time:
|
||||
final Duration duration = this.endTime.difference(this.startTime);
|
||||
@@ -124,8 +127,8 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
case ResultItem.weight_volume:
|
||||
if (exerciseRepository.exerciseType.unitQuantityUnit == "kilogram") {
|
||||
double value = 0;
|
||||
exerciseRepository.actualExerciseList.forEach((element) {
|
||||
value += element.quantity * element.unitQuantity;
|
||||
exerciseRepository.actualExerciseList.forEach((actual) {
|
||||
value += actual.quantity * actual.unitQuantity;
|
||||
});
|
||||
element.data = value;
|
||||
}
|
||||
@@ -134,15 +137,31 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
});
|
||||
}
|
||||
|
||||
String _printDuration(Duration duration) {
|
||||
String printDuration(Duration duration, {isText = false, isDecimal = false}) {
|
||||
String twoDigits(int n) => n.toString().padLeft(2, "0");
|
||||
String twoDigitMinutes = twoDigits(duration.inMinutes);
|
||||
String twoDigitSeconds = twoDigits(duration.inSeconds.remainder(60));
|
||||
String twoDigitMilliSeconds = duration.inMilliseconds.remainder(1000).toString();
|
||||
return "$twoDigitMinutes:$twoDigitSeconds:$twoDigitMilliSeconds" + '"';
|
||||
if (isText) {
|
||||
if (isDecimal) {
|
||||
return "$twoDigitMinutes" + t("min") + "$twoDigitSeconds" + t("sec") + ":$twoDigitMilliSeconds" + '"';
|
||||
} else {
|
||||
return "$twoDigitMinutes" + t("min") + "$twoDigitSeconds" + t("sec");
|
||||
}
|
||||
} else {
|
||||
return "$twoDigitMinutes:$twoDigitSeconds:$twoDigitMilliSeconds" + '"';
|
||||
}
|
||||
}
|
||||
|
||||
double _gethHealthDataPointValueAvg(HealthDataType dataType) {
|
||||
String printTime(double duration) {
|
||||
String twoDigits(int n) => n.toString().padLeft(1, "0");
|
||||
String twoDigitMinutes = twoDigits((duration ~/ 60).toInt());
|
||||
String twoDigitSeconds = (duration % 60).toStringAsFixed(0);
|
||||
|
||||
return "$twoDigitMinutes " + t("minutes") + " $twoDigitSeconds";
|
||||
}
|
||||
|
||||
/* double _gethHealthDataPointValueAvg(HealthDataType dataType) {
|
||||
double value = 0;
|
||||
double counter = 0;
|
||||
_healthDataList.forEach((dataPoint) {
|
||||
@@ -193,9 +212,9 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
min = 0;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
} */
|
||||
|
||||
Future<void> _fetchHealthData() async {
|
||||
/* Future<void> _fetchHealthData() async {
|
||||
if (health == null) {
|
||||
return;
|
||||
}
|
||||
@@ -209,7 +228,7 @@ class ResultBloc extends Bloc<ResultEvent, ResultState> with Logging {
|
||||
log("Caught exception in getHealthDataFromTypes: $e");
|
||||
throw Exception(e);
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
double calculate1RM({double percent}) {
|
||||
if (exerciseRepository.exercise == null) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:aitrainer_app/service/product_test_service.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flurry/flurry.dart';
|
||||
|
||||
part 'sales_event.dart';
|
||||
part 'sales_state.dart';
|
||||
@@ -25,11 +26,13 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
|
||||
try {
|
||||
if (event is SalesLoad) {
|
||||
yield SalesLoading();
|
||||
Flurry.logEvent("SalesPageOpen");
|
||||
this.getProductSet();
|
||||
yield SalesReady();
|
||||
} else if (event is SalesPurchase) {
|
||||
final int productId = event.productId;
|
||||
trace("Requesting purchase for" + productId.toString());
|
||||
Flurry.logEvent("PurchaseRequest");
|
||||
//PlatformPurchaseApi().requestPurchase(null);
|
||||
}
|
||||
} on Exception catch (ex) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:aitrainer_app/util/platform_purchase.dart';
|
||||
import 'package:aitrainer_app/util/session.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flurry/flurry.dart';
|
||||
|
||||
part 'session_event.dart';
|
||||
part 'session_state.dart';
|
||||
@@ -31,6 +32,7 @@ class SessionBloc extends Bloc<SessionEvent, SessionState> with Logging {
|
||||
String lang = AppLanguage().appLocal.languageCode;
|
||||
log("Change lang to $lang");
|
||||
settingsBloc.add(SettingsChangeLanguage(language: lang));
|
||||
Flurry.logEvent("Enter");
|
||||
yield SessionReady();
|
||||
}
|
||||
} on Exception catch (ex) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:health/health.dart';
|
||||
//import 'package:health/health.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'settings_event.dart';
|
||||
@@ -50,17 +50,19 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> with Logging {
|
||||
|
||||
bool selectedHardwareBefore = await Cache().selectedHardwareBefore();
|
||||
log("selectedBefore " + selectedHardwareBefore.toString());
|
||||
if (!selectedHardwareBefore) {
|
||||
await _accessHealthData();
|
||||
}
|
||||
|
||||
final bool hasHardware = event.hasHardware;
|
||||
await Cache().setHardware(hasHardware);
|
||||
if (hasHardware == true) {
|
||||
await _accessHealthData();
|
||||
}
|
||||
Cache().initBadges();
|
||||
yield SettingsReady(_locale);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _accessHealthData() async {
|
||||
final List<HealthDataType> types = [
|
||||
/* final List<HealthDataType> types = [
|
||||
HealthDataType.ACTIVE_ENERGY_BURNED,
|
||||
HealthDataType.WATER,
|
||||
HealthDataType.STEPS,
|
||||
@@ -71,10 +73,10 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> with Logging {
|
||||
HealthDataType.LOW_HEART_RATE_EVENT,
|
||||
HealthDataType.RESTING_HEART_RATE
|
||||
];
|
||||
final HealthFactory health = HealthFactory();
|
||||
final HealthFactory health = HealthFactory(); */
|
||||
DateTime now = DateTime.now();
|
||||
List<HealthDataPoint> _healthDataList = await health.getHealthDataFromTypes(now.subtract(Duration(minutes: 5)), now, types);
|
||||
log(_healthDataList.toString());
|
||||
//List<HealthDataPoint> _healthDataList = await health.getHealthDataFromTypes(now.subtract(Duration(minutes: 5)), now, types);
|
||||
//log(_healthDataList.toString());
|
||||
}
|
||||
|
||||
Future<void> _changeLang(String lang) async {
|
||||
@@ -94,6 +96,7 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> with Logging {
|
||||
this.language = lang;
|
||||
AppLanguage().changeLanguage(_locale);
|
||||
await loadLang();
|
||||
await Cache().initBadges();
|
||||
}
|
||||
|
||||
Future<void> loadLang() async {
|
||||
|
||||
Reference in New Issue
Block a user