WT1.1.6+3 bodyType animation, bug fixes
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/customer.dart';
|
||||
import 'package:aitrainer_app/repository/customer_repository.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:aitrainer_app/util/enums.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
@@ -16,12 +17,47 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
bool loggedIn = false;
|
||||
int traineeId = 0;
|
||||
AccountBloc({this.customerRepository}) : super(AccountInitial()) {
|
||||
if ( Cache().userLoggedIn != null ) {
|
||||
if (Cache().userLoggedIn != null) {
|
||||
customerRepository.customer = Cache().userLoggedIn;
|
||||
loggedIn = true;
|
||||
}
|
||||
}
|
||||
|
||||
String getAccurateBodyType() {
|
||||
String bodyType = ("Set your body type");
|
||||
int _ecto = 0;
|
||||
int _mezo = 0;
|
||||
int _endo = 0;
|
||||
_ecto = customerRepository.getCustomerPropertyValue(PropertyEnum.Ectomorph.toStr()).toInt();
|
||||
_mezo = customerRepository.getCustomerPropertyValue(PropertyEnum.Mesomorph.toStr()).toInt();
|
||||
_endo = customerRepository.getCustomerPropertyValue(PropertyEnum.Endomorph.toStr()).toInt();
|
||||
if (_ecto == 0 && _mezo == 0 && _endo == 0) {
|
||||
return bodyType;
|
||||
}
|
||||
int bodyTypeValue;
|
||||
if (_ecto < 50) {
|
||||
bodyTypeValue = (50 + ((50 / (_mezo + _endo)) * _endo)).toInt();
|
||||
} else if (_endo < 50) {
|
||||
bodyTypeValue = (0 + ((50 / (_mezo + _ecto)) * _mezo)).toInt();
|
||||
} else {
|
||||
// random answers probably
|
||||
bodyTypeValue = (0 + ((100 / (_endo + _ecto))) * _endo).toInt();
|
||||
}
|
||||
print("BodyType value " + bodyTypeValue.toString());
|
||||
if (bodyTypeValue < 20) {
|
||||
bodyType = ("Ectomorph");
|
||||
} else if (bodyTypeValue >= 25 && bodyTypeValue < 40) {
|
||||
bodyType = ("Ecto") + "-" + ("Mesomorph");
|
||||
} else if (bodyTypeValue >= 40 && bodyTypeValue < 60) {
|
||||
bodyType = ("Mesomorph");
|
||||
} else if (bodyTypeValue >= 60 && bodyTypeValue < 80) {
|
||||
bodyType = ("Meso") + "-" + ("Endomorph");
|
||||
} else {
|
||||
bodyType = ("Endomorph");
|
||||
}
|
||||
return bodyType;
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<AccountState> mapEventToState(
|
||||
AccountEvent event,
|
||||
@@ -42,11 +78,11 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
customerRepository.emptyTrainees();
|
||||
loggedIn = false;
|
||||
yield AccountLoggedOut();
|
||||
} else if ( event is AccountGetTrainees) {
|
||||
} else if (event is AccountGetTrainees) {
|
||||
yield AccountLoading();
|
||||
await customerRepository.getTrainees();
|
||||
yield AccountReady();
|
||||
} else if ( event is AccountSelectTrainee ) {
|
||||
} else if (event is AccountSelectTrainee) {
|
||||
yield AccountLoading();
|
||||
customerRepository.setTrainee(event.traineeId);
|
||||
Cache().setTrainee(customerRepository.getTraineeById(event.traineeId));
|
||||
@@ -55,7 +91,7 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
this.traineeId = event.traineeId;
|
||||
yield AccountReady();
|
||||
}
|
||||
} on Exception catch(e) {
|
||||
} on Exception catch (e) {
|
||||
yield AccountError(message: e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user