v1.26 ios v2
This commit is contained in:
@@ -133,25 +133,28 @@ class CustomerChangeBloc extends Bloc<CustomerChangeEvent, CustomerChangeState>
|
||||
void _onSaveFitness(CustomerSaveFitness event, Emitter<CustomerChangeState> emit) {
|
||||
emit(CustomerChangeLoading());
|
||||
if (customerRepository.customer!.fitnessLevel == null) {
|
||||
throw Exception("Please select your fitness level");
|
||||
emit(CustomerSaveError(message: "Please selectyour fitness level"));
|
||||
} else {
|
||||
emit(CustomerSaveSuccess());
|
||||
}
|
||||
emit(CustomerSaveSuccess());
|
||||
}
|
||||
|
||||
void _onSaveGoal(CustomerSaveGoal event, Emitter<CustomerChangeState> emit) {
|
||||
emit(CustomerChangeLoading());
|
||||
if (customerRepository.customer!.goal == null) {
|
||||
throw Exception("Please select your goal");
|
||||
emit(CustomerSaveError(message: "Please select your goal"));
|
||||
} else {
|
||||
emit(CustomerSaveSuccess());
|
||||
}
|
||||
emit(CustomerSaveSuccess());
|
||||
}
|
||||
|
||||
void _onSaveSex(CustomerSaveSex event, Emitter<CustomerChangeState> emit) {
|
||||
emit(CustomerChangeLoading());
|
||||
if (customerRepository.customer!.sex == null) {
|
||||
throw Exception("Please select your biologial gender");
|
||||
emit(CustomerSaveError(message: "Please selectyour biological gender"));
|
||||
} else {
|
||||
emit(CustomerSaveSuccess());
|
||||
}
|
||||
emit(CustomerSaveSuccess());
|
||||
}
|
||||
|
||||
void _onSaveWeight(CustomerSaveWeight event, Emitter<CustomerChangeState> emit) {
|
||||
@@ -166,25 +169,29 @@ class CustomerChangeBloc extends Bloc<CustomerChangeEvent, CustomerChangeState>
|
||||
|
||||
void _onSave(CustomerSave event, Emitter<CustomerChangeState> emit) async {
|
||||
emit(CustomerSaving());
|
||||
if (validation()) {
|
||||
if (selectedFitnessItem != null) {
|
||||
customerRepository.setFitnessLevel(selectedFitnessItem!);
|
||||
}
|
||||
if (selectedSport != null) {
|
||||
customerRepository.customer!.sportId = selectedSport!.sportId;
|
||||
}
|
||||
try {
|
||||
if (validation()) {
|
||||
if (selectedFitnessItem != null) {
|
||||
customerRepository.setFitnessLevel(selectedFitnessItem!);
|
||||
}
|
||||
if (selectedSport != null) {
|
||||
customerRepository.customer!.sportId = selectedSport!.sportId;
|
||||
}
|
||||
|
||||
if (customerRepository.customer!.lang == null) {
|
||||
customerRepository.customer!.lang = AppLanguage().appLocal.languageCode;
|
||||
}
|
||||
if (customerRepository.customer!.lang == null) {
|
||||
customerRepository.customer!.lang = AppLanguage().appLocal.languageCode;
|
||||
}
|
||||
|
||||
await customerRepository.saveCustomer();
|
||||
MauticRepository mauticRepository = MauticRepository(customerRepository: customerRepository);
|
||||
await mauticRepository.sendMauticDataChange();
|
||||
Cache().initBadges();
|
||||
emit(CustomerSaveSuccess());
|
||||
} else {
|
||||
emit(CustomerSaveError(message: "Please provide the necessary information"));
|
||||
await customerRepository.saveCustomer();
|
||||
MauticRepository mauticRepository = MauticRepository(customerRepository: customerRepository);
|
||||
await mauticRepository.sendMauticDataChange();
|
||||
Cache().initBadges();
|
||||
emit(CustomerSaveSuccess());
|
||||
} else {
|
||||
emit(CustomerSaveError(message: "Please provide the necessary information"));
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
emit(CustomerSaveError(message: e.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
|
||||
menuBloc.add(MenuTreeDown(parent: 0));
|
||||
Cache().initBadges();
|
||||
Track().track(TrackingEvent.exercise_new, eventValue: exerciseRepository.exerciseType!.name);
|
||||
emit(ExerciseNewReady());
|
||||
emit(ExerciseNewSaved());
|
||||
}
|
||||
|
||||
void _onSubmitNoRegistration(ExerciseNewSubmitNoRegistration event, Emitter<ExerciseNewState> emit) async {
|
||||
@@ -190,7 +190,7 @@ class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> with Logg
|
||||
exerciseRepository.addExerciseNoRegistration();
|
||||
menuBloc.add(MenuTreeDown(parent: 0));
|
||||
Track().track(TrackingEvent.exercise_new_no_registration, eventValue: exerciseRepository.exerciseType!.name);
|
||||
emit(ExerciseNewReady());
|
||||
emit(ExerciseNewSaved());
|
||||
}
|
||||
|
||||
void _onBMIAnimate(ExerciseNewBMIAnimate event, Emitter<ExerciseNewState> emit) async {
|
||||
|
||||
@@ -93,7 +93,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "email");
|
||||
Cache().setLoginType(LoginType.email);
|
||||
} on Exception catch(e) {
|
||||
} on Exception catch (e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
@@ -107,7 +107,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
|
||||
await userRepository.getUserByFB();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "FB");
|
||||
} on Exception catch(e) {
|
||||
} on Exception catch (e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
@@ -121,8 +121,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
|
||||
await userRepository.getUserByGoogle();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "Google");
|
||||
|
||||
} on Exception catch(e) {
|
||||
} on Exception catch (e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
@@ -136,7 +135,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
|
||||
await userRepository.getUserByApple();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
Track().track(TrackingEvent.login, eventValue: "Apple");
|
||||
} on Exception catch(e) {
|
||||
} on Exception catch (e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
@@ -145,47 +144,67 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> with Trans {
|
||||
|
||||
void _onRegistrationSubmit(RegistrationSubmit event, Emitter<LoginState> emit) async {
|
||||
emit(LoginLoading());
|
||||
final String? validationError = this.validate();
|
||||
if (validationError != null) {
|
||||
emit(LoginError(message: validationError));
|
||||
} else {
|
||||
await userRepository.addUser();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
customerRepository!.customer!.emailSubscription = emailSubscription == true ? 1 : 0;
|
||||
await afterRegistration("email");
|
||||
Cache().setLoginType(LoginType.email);
|
||||
try {
|
||||
final String? validationError = this.validate();
|
||||
if (validationError != null) {
|
||||
emit(LoginError(message: validationError));
|
||||
} else {
|
||||
await userRepository.addUser();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
customerRepository!.customer!.emailSubscription = emailSubscription == true ? 1 : 0;
|
||||
await afterRegistration("email");
|
||||
Cache().setLoginType(LoginType.email);
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
}
|
||||
emit(LoginSuccess());
|
||||
}
|
||||
|
||||
void _onRegistrationFB(RegistrationFB event, Emitter<LoginState> emit) async {
|
||||
emit(LoginLoading());
|
||||
Cache().setLoginType(LoginType.fb);
|
||||
await userRepository.addUserFB();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
customerRepository!.customer!.emailSubscription = emailSubscription == true ? 1 : 0;
|
||||
await afterRegistration("FB");
|
||||
emit(LoginSuccess());
|
||||
try {
|
||||
Cache().setLoginType(LoginType.fb);
|
||||
await userRepository.addUserFB();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
customerRepository!.customer!.emailSubscription = emailSubscription == true ? 1 : 0;
|
||||
await afterRegistration("FB");
|
||||
} on Exception catch (e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
void _onRegistrationGoogle(RegistrationGoogle event, Emitter<LoginState> emit) async {
|
||||
emit(LoginLoading());
|
||||
Cache().setLoginType(LoginType.google);
|
||||
await userRepository.addUserGoogle();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
customerRepository!.customer!.emailSubscription = emailSubscription == true ? 1 : 0;
|
||||
await afterRegistration("Google");
|
||||
emit(LoginSuccess());
|
||||
try {
|
||||
Cache().setLoginType(LoginType.google);
|
||||
await userRepository.addUserGoogle();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
customerRepository!.customer!.emailSubscription = emailSubscription == true ? 1 : 0;
|
||||
await afterRegistration("Google");
|
||||
} on Exception catch (e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
void _onRegistrationApple(RegistrationApple event, Emitter<LoginState> emit) async {
|
||||
emit(LoginLoading());
|
||||
Cache().setLoginType(LoginType.apple);
|
||||
await userRepository.addUserApple();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
customerRepository!.customer!.emailSubscription = emailSubscription == true ? 1 : 0;
|
||||
await afterRegistration("Apple");
|
||||
emit(LoginSuccess());
|
||||
try {
|
||||
Cache().setLoginType(LoginType.apple);
|
||||
await userRepository.addUserApple();
|
||||
accountBloc.add(AccountLogInFinished(customer: Cache().userLoggedIn!));
|
||||
customerRepository!.customer!.emailSubscription = emailSubscription == true ? 1 : 0;
|
||||
await afterRegistration("Apple");
|
||||
} on Exception catch (e) {
|
||||
emit(LoginError(message: e.toString()));
|
||||
} finally {
|
||||
emit(LoginSuccess());
|
||||
}
|
||||
}
|
||||
|
||||
void _onDataProtectionClicked(DataProtectionClicked event, Emitter<LoginState> emit) async {
|
||||
|
||||
@@ -113,103 +113,6 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> with Trans, Logging {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/* @override
|
||||
Stream<MenuState> mapEventToState(
|
||||
MenuEvent event,
|
||||
) async* {
|
||||
try {
|
||||
if (event is MenuCreate) {
|
||||
yield MenuLoading();
|
||||
//await menuTreeRepository.createTree();
|
||||
//menuTreeRepository.getBranch(this.parent);
|
||||
//setMenuInfo();
|
||||
if (Cache().getDevices() != null) {
|
||||
exerciseDeviceRepository.setDevices(Cache().getDevices()!);
|
||||
}
|
||||
yield MenuReady();
|
||||
} else if (event is MenuRecreateTree) {
|
||||
yield MenuLoading();
|
||||
// ie. at language changes
|
||||
menuTreeRepository.createTree();
|
||||
yield MenuReady();
|
||||
} else if (event is MenuTreeDown) {
|
||||
yield MenuLoading();
|
||||
parent = event.parent;
|
||||
workoutItem = event.item;
|
||||
|
||||
if (workoutItem != null) {
|
||||
setAbility(workoutItem!.internalName);
|
||||
}
|
||||
final LinkedHashMap<String, WorkoutMenuTree> branch = menuTreeRepository.getBranch(event.parent);
|
||||
|
||||
await getImages(branch);
|
||||
yield MenuReady();
|
||||
} else if (event is MenuTreeUp) {
|
||||
yield MenuLoading();
|
||||
// get parent menus or exercises
|
||||
parent = event.parent;
|
||||
workoutItem = menuTreeRepository.getParentItem(parent);
|
||||
|
||||
LinkedHashMap<String, WorkoutMenuTree> branch;
|
||||
if (workoutItem != null) {
|
||||
setAbility(workoutItem!.internalName);
|
||||
branch = menuTreeRepository.getBranch(workoutItem!.parent);
|
||||
await getImages(branch);
|
||||
}
|
||||
|
||||
yield MenuReady();
|
||||
} else if (event is MenuTreeJump) {
|
||||
yield MenuLoading();
|
||||
parent = event.parent;
|
||||
workoutItem = menuTreeRepository.getParentItem(parent);
|
||||
|
||||
if (workoutItem != null) {
|
||||
setAbility(workoutItem!.internalName);
|
||||
}
|
||||
final LinkedHashMap<String, WorkoutMenuTree> branch = menuTreeRepository.getBranch(workoutItem!.parent);
|
||||
await getImages(branch);
|
||||
|
||||
yield MenuReady();
|
||||
} else if (event is MenuClickExercise) {
|
||||
yield MenuLoading();
|
||||
// get exercise page
|
||||
yield MenuReady();
|
||||
} else if (event is MenuFilterExerciseType) {
|
||||
yield MenuLoading();
|
||||
final int deviceId = event.deviceId;
|
||||
if (selectedDevice(deviceId)) {
|
||||
listFilterDevice.add(deviceId);
|
||||
} else {
|
||||
listFilterDevice.remove(deviceId);
|
||||
}
|
||||
yield MenuReady();
|
||||
} else if (event is MenuStartTrial) {
|
||||
yield MenuLoading();
|
||||
final DateTime start = event.start;
|
||||
CustomerRepository customerRepository = CustomerRepository();
|
||||
customerRepository.customer = Cache().userLoggedIn;
|
||||
customerRepository.customer!.trialDate = start;
|
||||
Cache().userLoggedIn!.trialDate = start;
|
||||
|
||||
customerRepository.saveCustomer();
|
||||
|
||||
if (DateTime.now().difference(start).inHours < 1) {
|
||||
Cache().hasPurchased = true;
|
||||
log("Trial mode on!");
|
||||
Track().track(TrackingEvent.trial, eventValue: DateFormat('yyyy-MM-dd HH:mm:ss').format(start));
|
||||
|
||||
if (!isInDebugMode) {
|
||||
MauticRepository mauticRepository = MauticRepository(customerRepository: customerRepository);
|
||||
await mauticRepository.sendMauticTrial();
|
||||
}
|
||||
}
|
||||
yield MenuReady();
|
||||
}
|
||||
} on Exception catch (ex) {
|
||||
yield MenuError(message: ex.toString());
|
||||
}
|
||||
} */
|
||||
|
||||
void setAbility(String name) {
|
||||
switch (name) {
|
||||
case "one_rep_max":
|
||||
|
||||
@@ -161,10 +161,10 @@ class SalesBloc extends Bloc<SalesEvent, SalesState> with Logging {
|
||||
return;
|
||||
}
|
||||
|
||||
String productSetString = splitTestRepository.getSplitTestValue("product_set_5");
|
||||
log("ProductSetString: $productSetString");
|
||||
//String productSetString = splitTestRepository.getSplitTestValue("product_set_5");
|
||||
//log("ProductSetString: $productSetString");
|
||||
try {
|
||||
productSet = int.parse(productSetString);
|
||||
productSet = 5;
|
||||
} on Exception catch (e) {
|
||||
log("Define the right productset! $e");
|
||||
productSet = 2;
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:aitrainer_app/service/logging.dart';
|
||||
import 'package:aitrainer_app/util/session.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:upgrader/upgrader.dart';
|
||||
|
||||
part 'session_event.dart';
|
||||
part 'session_state.dart';
|
||||
@@ -30,6 +31,11 @@ class SessionBloc extends Bloc<SessionEvent, SessionState> with Logging {
|
||||
String lang = AppLanguage().appLocal.languageCode;
|
||||
log("Change lang to $lang");
|
||||
settingsBloc!.add(SettingsChangeLanguage(language: lang));
|
||||
final iTunes = ITunesSearchAPI();
|
||||
final resultsFuture = iTunes.lookupByBundleId('com.aitrainer.app');
|
||||
resultsFuture.then((results) {
|
||||
print('iTunes results: $results');
|
||||
});
|
||||
emit(SessionReady());
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class TrainingEvaluationBloc extends Bloc<TrainingEvaluationEvent, TrainingEvalu
|
||||
final String day;
|
||||
TrainingEvaluationBloc({required this.trainingPlanBloc, required this.day}) : super(TrainingEvaluationInitial()) {
|
||||
_load();
|
||||
//on<TrainingEvaluationLoad>(_onLoad);
|
||||
on<TrainingEvaluationLoad>(_onLoad);
|
||||
}
|
||||
|
||||
String duration = "-";
|
||||
|
||||
Reference in New Issue
Block a user