wt1.1.2f fix for 1.1.3
This commit is contained in:
@@ -1,81 +0,0 @@
|
||||
import 'package:aitrainer_app/model/cache.dart';
|
||||
import 'package:aitrainer_app/model/customer.dart';
|
||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
class ExerciseAddByPlanFormBloc extends FormBloc<String, String> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
final ExercisePlanRepository exercisePlanRepository;
|
||||
final WorkoutMenuTree workoutTree;
|
||||
final customerId;
|
||||
Customer customer;
|
||||
int step = 1;
|
||||
int countSteps = 1;
|
||||
|
||||
final quantity1Field = TextFieldBloc(
|
||||
);
|
||||
|
||||
final unitQuantity1Field = TextFieldBloc(
|
||||
);
|
||||
|
||||
ExerciseAddByPlanFormBloc({this.exerciseRepository, this.exercisePlanRepository, this.customerId, this.workoutTree}) {
|
||||
addFieldBlocs(fieldBlocs: [
|
||||
quantity1Field,
|
||||
unitQuantity1Field,
|
||||
]);
|
||||
|
||||
quantity1Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setQuantity(current.valueToDouble);
|
||||
});
|
||||
|
||||
unitQuantity1Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setUnitQuantity(unitQuantity1Field.valueToDouble);
|
||||
});
|
||||
|
||||
exerciseRepository.exerciseType = workoutTree.exerciseType;
|
||||
if ( Cache().userLoggedIn.customerId == customerId) {
|
||||
customer = Cache().userLoggedIn;
|
||||
} else if ( Cache().getTrainee().customerId == customerId) {
|
||||
customer = Cache().getTrainee();
|
||||
}
|
||||
exercisePlanRepository.setActualPlanDetailByExerciseType(workoutTree.exerciseType);
|
||||
exerciseRepository.customer = customer;
|
||||
countSteps = exercisePlanRepository.getActualPlanDetail().serie;
|
||||
|
||||
unitQuantity1Field.updateInitialValue(exercisePlanRepository.getActualPlanDetail().weightEquation);
|
||||
quantity1Field.updateInitialValue(exercisePlanRepository.getActualPlanDetail().repeats.toString());
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onSubmitting() async {
|
||||
|
||||
try {
|
||||
emitLoading(progress: 30);
|
||||
step++;
|
||||
|
||||
exerciseRepository.setUnitQuantity(unitQuantity1Field.valueToDouble);
|
||||
exerciseRepository.setQuantity(quantity1Field.valueToDouble);
|
||||
exerciseRepository.exercise.exercisePlanDetailId =
|
||||
exercisePlanRepository.getActualPlanDetail().exercisePlanDetailId;
|
||||
exerciseRepository.exercise.unit = workoutTree.exerciseType.unit;
|
||||
workoutTree.executed = true;
|
||||
print("On Submitting Add Exercise By Plan " + exerciseRepository.exercise.toJson().toString());
|
||||
await exerciseRepository.addExercise();
|
||||
|
||||
emitSuccess(canSubmitAgain: true);
|
||||
} on Exception catch (ex) {
|
||||
emitFailure(failureResponse: ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
//@override
|
||||
Future<void> close() {
|
||||
quantity1Field.close();
|
||||
unitQuantity1Field.close();
|
||||
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
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;
|
||||
|
||||
final emailField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
],
|
||||
);
|
||||
|
||||
ResetPasswordFormBloc({this.userRepository}) {
|
||||
addFieldBlocs(fieldBlocs: [
|
||||
emailField
|
||||
]);
|
||||
|
||||
emailField.onValueChanges(onData: (previous, current) async* {
|
||||
userRepository.setEmail(current.value);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onSubmitting() async {
|
||||
try {
|
||||
emitLoading(progress: 30);
|
||||
if ( ! validateEmail(userRepository)) {
|
||||
emailField.addFieldError(EMAIL_ERROR, isPermanent: true);
|
||||
|
||||
emitFailure(failureResponse: EMAIL_ERROR);
|
||||
} else {
|
||||
// Emit either Loaded or Error
|
||||
await userRepository.resetPassword();
|
||||
emitSuccess(canSubmitAgain: false);
|
||||
}
|
||||
} on Exception catch (ex) {
|
||||
emitFailure(failureResponse: ex.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> close() {
|
||||
emailField.close();
|
||||
return super.close();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user