wt1.1.2e NumberPicker
This commit is contained in:
@@ -34,6 +34,7 @@ class AccountBloc extends Bloc<AccountEvent, AccountState> {
|
||||
//route to Login Page
|
||||
} else if (event is AccountLogInFinished) {
|
||||
customerRepository.customer = event.customer;
|
||||
this.loggedIn = true;
|
||||
yield AccountLoggedIn();
|
||||
} else if (event is AccountLogout) {
|
||||
await Cache().logout();
|
||||
|
||||
@@ -188,7 +188,7 @@ class GroupChart extends GroupData with Calculate {
|
||||
BarChartGroupData data = BarChartGroupData(
|
||||
x: exercise.dateAdd.millisecondsSinceEpoch,
|
||||
barRods: [
|
||||
BarChartRodData(y: diagramValue, width: 12, color: Colors.lightBlue)
|
||||
BarChartRodData(y: diagramValue, width: 12, colors: [Colors.lightBlue, Colors.lightBlueAccent])
|
||||
]
|
||||
);
|
||||
_chartData.add(data);
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
part of 'exercise_by_plan_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseByPlanEvent extends Equatable {
|
||||
const ExerciseByPlanEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class AddExerciseByPlanEvent extends ExerciseByPlanEvent {
|
||||
final ExerciseType exerciseType;
|
||||
const AddExerciseByPlanEvent({this.exerciseType});
|
||||
|
||||
@override
|
||||
List<Object> get props => [exerciseType];
|
||||
}
|
||||
|
||||
class ExerciseByPlanLoad extends ExerciseByPlanEvent {
|
||||
const ExerciseByPlanLoad();
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
part of 'exercise_by_plan_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseByPlanState extends Equatable {
|
||||
const ExerciseByPlanState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseByPlanStateInitial extends ExerciseByPlanState {
|
||||
const ExerciseByPlanStateInitial();
|
||||
}
|
||||
|
||||
class ExerciseByPlanLoading extends ExerciseByPlanState {
|
||||
const ExerciseByPlanLoading();
|
||||
}
|
||||
|
||||
// updated screen
|
||||
class ExerciseByPlanReady extends ExerciseByPlanState {
|
||||
const ExerciseByPlanReady();
|
||||
}
|
||||
|
||||
// error splash screen
|
||||
class ExerciseByPlanError extends ExerciseByPlanState {
|
||||
final String message;
|
||||
const ExerciseByPlanError({this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import 'dart:async';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'exercise_control_event.dart';
|
||||
|
||||
part 'exercise_control_state.dart';
|
||||
|
||||
class ExerciseControlBloc extends Bloc<ExerciseControlEvent, ExerciseControlState> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
final bool readonly;
|
||||
final double percentToCalculate;
|
||||
int step = 1;
|
||||
final List<double> repeats = List();
|
||||
|
||||
double initialRM;
|
||||
double unitQuantity;
|
||||
double quantity;
|
||||
double origQuantity;
|
||||
|
||||
double firstQuantity; // quantity of the first test
|
||||
double firstUnitQuantity; // unit quantity of the first test
|
||||
|
||||
@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);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<ExerciseControlState> mapEventToState(ExerciseControlEvent event) async* {
|
||||
try {
|
||||
if (event is ExerciseControlLoad) {
|
||||
yield ExerciseControlLoading();
|
||||
step = 1;
|
||||
yield ExerciseControlReady();
|
||||
} else if (event is ExerciseControlQuantityChange ) {
|
||||
yield ExerciseControlLoading();
|
||||
if ( event.step == step) {
|
||||
exerciseRepository.setQuantity(event.quantity);
|
||||
quantity = event.quantity;
|
||||
}
|
||||
yield ExerciseControlReady();
|
||||
} else if (event is ExerciseControlSubmit ) {
|
||||
yield ExerciseControlLoading();
|
||||
if ( event.step == step) {
|
||||
step++;
|
||||
//print("step " + step.toString() + " quantity " + quantity.toString() + " origQ: " + origQuantity.toString());
|
||||
repeats.add(quantity);
|
||||
quantity = origQuantity;
|
||||
await exerciseRepository.addExercise();
|
||||
|
||||
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
}
|
||||
yield ExerciseControlReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
yield ExerciseControlError(message: e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
double calculate1RM({bool percent75}) {
|
||||
if (exerciseRepository.exercise == null) {
|
||||
exerciseRepository.getLastExercise();
|
||||
}
|
||||
double weight = exerciseRepository.exercise.unitQuantity;
|
||||
double repeat = exerciseRepository.exercise.quantity;
|
||||
if ( weight == 0 || repeat == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double rmWendler = weight * repeat * 0.0333 + weight;
|
||||
double rmOconner = weight * (1 + repeat / 40);
|
||||
double average = (rmWendler + rmOconner) / 2;
|
||||
|
||||
return percent75 ? average * this.percentToCalculate : average;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
part of 'exercise_control_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseControlEvent extends Equatable {
|
||||
const ExerciseControlEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseControlLoad extends ExerciseControlEvent {
|
||||
const ExerciseControlLoad();
|
||||
}
|
||||
|
||||
class ExerciseControlQuantityChange extends ExerciseControlEvent {
|
||||
final double quantity;
|
||||
final int step;
|
||||
const ExerciseControlQuantityChange({this.quantity, this.step});
|
||||
}
|
||||
|
||||
class ExerciseControlSubmit extends ExerciseControlEvent {
|
||||
final int step;
|
||||
const ExerciseControlSubmit({this.step});
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
part of 'exercise_control_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseControlState extends Equatable {
|
||||
const ExerciseControlState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseControlInitial extends ExerciseControlState {
|
||||
const ExerciseControlInitial();
|
||||
}
|
||||
|
||||
class ExerciseControlLoading extends ExerciseControlState {
|
||||
const ExerciseControlLoading();
|
||||
}
|
||||
|
||||
class ExerciseControlReady extends ExerciseControlState {
|
||||
const ExerciseControlReady();
|
||||
}
|
||||
|
||||
class ExerciseControlError extends ExerciseControlState {
|
||||
final String message;
|
||||
const ExerciseControlError({this.message});
|
||||
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
class ExerciseControlFormBloc extends FormBloc<String, String> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
int step = 1;
|
||||
final double percentToCalculate;
|
||||
final bool readonly;
|
||||
String times;
|
||||
|
||||
final initialRMField = TextFieldBloc(
|
||||
);
|
||||
|
||||
final quantity1Field = TextFieldBloc(
|
||||
);
|
||||
|
||||
final unitQuantity1Field = TextFieldBloc(
|
||||
);
|
||||
|
||||
final quantity2Field = TextFieldBloc(
|
||||
);
|
||||
|
||||
final unitQuantity2Field = TextFieldBloc(
|
||||
);
|
||||
|
||||
final quantity3Field = TextFieldBloc(
|
||||
);
|
||||
|
||||
final unitQuantity3Field = TextFieldBloc(
|
||||
);
|
||||
|
||||
|
||||
|
||||
ExerciseControlFormBloc({this.exerciseRepository, this.percentToCalculate, this.readonly}) {
|
||||
addFieldBlocs(fieldBlocs: [
|
||||
initialRMField,
|
||||
quantity1Field,
|
||||
unitQuantity1Field,
|
||||
quantity2Field,
|
||||
unitQuantity2Field,
|
||||
quantity3Field,
|
||||
unitQuantity3Field,
|
||||
|
||||
]);
|
||||
|
||||
initialRMField.updateInitialValue(calculate1RM(percent75: false).toStringAsFixed(0));
|
||||
unitQuantity1Field.updateInitialValue(calculate1RM(percent75: true).toStringAsFixed(0));
|
||||
unitQuantity2Field.updateInitialValue(calculate1RM(percent75: true).toStringAsFixed(0));
|
||||
unitQuantity3Field.updateInitialValue(calculate1RM(percent75: true).toStringAsFixed(0));
|
||||
|
||||
quantity1Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setQuantity(current.valueToDouble);
|
||||
exerciseRepository.setUnitQuantity(unitQuantity1Field.valueToDouble);
|
||||
});
|
||||
|
||||
quantity2Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setQuantity(current.valueToDouble);
|
||||
exerciseRepository.setUnitQuantity(unitQuantity2Field.valueToDouble);
|
||||
});
|
||||
|
||||
quantity3Field.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setQuantity(current.valueToDouble);
|
||||
exerciseRepository.setUnitQuantity(unitQuantity3Field.valueToDouble);
|
||||
});
|
||||
|
||||
times = percentToCalculate == 0.5 ? "30-35" : "12";
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void onLoading() {
|
||||
step = 1;
|
||||
super.onLoading();
|
||||
}
|
||||
|
||||
@override
|
||||
void onSubmitting() async {
|
||||
print("on Submitting Custom form");
|
||||
try {
|
||||
emitLoading(progress: 30);
|
||||
if ( step == 1) {
|
||||
|
||||
//unitQuantity2Field.updateInitialValue(calculate1RM(percent75: true).toStringAsFixed(0));
|
||||
//unitQuantity3Field.updateInitialValue(calculate1RM(percent75: true).toStringAsFixed(0));
|
||||
step = 2;
|
||||
} else if ( step == 2) {
|
||||
//unitQuantity3Field.updateInitialValue(calculate1RM(percent75: true).toStringAsFixed(0));
|
||||
step = 3;
|
||||
} else if ( step == 3 ) {
|
||||
//updatedRMField.updateInitialValue(calculate1RM(percent75: false).toStringAsFixed(0));
|
||||
}
|
||||
|
||||
if ( ! readonly ) {
|
||||
await exerciseRepository.addExercise();
|
||||
}
|
||||
|
||||
emitSuccess(canSubmitAgain: true);
|
||||
} on Exception catch (ex) {
|
||||
emitFailure(failureResponse: ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
double calculate1RM({bool percent75}) {
|
||||
if (exerciseRepository.exercise == null) {
|
||||
exerciseRepository.getLastExercise();
|
||||
}
|
||||
double weight = exerciseRepository.exercise.unitQuantity;
|
||||
double repeat = exerciseRepository.exercise.quantity;
|
||||
if ( weight == 0 || repeat == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double rmWendler = weight * repeat * 0.0333 + weight;
|
||||
double rmOconner = weight * (1 + repeat / 40);
|
||||
double average = (rmWendler + rmOconner) / 2;
|
||||
|
||||
return percent75 ? average * this.percentToCalculate : average;
|
||||
}
|
||||
|
||||
//@override
|
||||
Future<void> close() {
|
||||
initialRMField.close();
|
||||
quantity1Field.close();
|
||||
unitQuantity1Field.close();
|
||||
quantity2Field.close();
|
||||
unitQuantity2Field.close();
|
||||
quantity3Field.close();
|
||||
unitQuantity3Field.close();
|
||||
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -7,16 +7,16 @@ import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'exercise_by_plan_event.dart';
|
||||
part 'exercise_execute_plan_event.dart';
|
||||
|
||||
part 'exercise_by_plan_state.dart';
|
||||
part 'exercise_execute_plan_state.dart';
|
||||
|
||||
class ExerciseByPlanBloc extends Bloc<ExerciseByPlanEvent, ExerciseByPlanState> {
|
||||
class ExerciseExecutePlanBloc extends Bloc<ExerciseExecutePlanEvent, ExerciseExecutePlanState> {
|
||||
final WorkoutTreeRepository menuTreeRepository;
|
||||
final ExercisePlanRepository exercisePlanRepository = ExercisePlanRepository();
|
||||
int customerId;
|
||||
@override
|
||||
ExerciseByPlanBloc({this.menuTreeRepository}) : super(ExerciseByPlanStateInitial());
|
||||
ExerciseExecutePlanBloc({this.menuTreeRepository}) : super(ExerciseByPlanStateInitial());
|
||||
|
||||
Future<void> getData() async {
|
||||
exercisePlanRepository.setCustomerId(customerId);
|
||||
@@ -39,7 +39,7 @@ class ExerciseByPlanBloc extends Bloc<ExerciseByPlanEvent, ExerciseByPlanState>
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<ExerciseByPlanState> mapEventToState(ExerciseByPlanEvent event) async* {
|
||||
Stream<ExerciseExecutePlanState> mapEventToState(ExerciseExecutePlanEvent event) async* {
|
||||
try {
|
||||
if (event is ExerciseByPlanLoad) {
|
||||
yield ExerciseByPlanLoading();
|
||||
@@ -0,0 +1,21 @@
|
||||
part of 'exercise_execute_plan_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseExecutePlanEvent extends Equatable {
|
||||
const ExerciseExecutePlanEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class AddExerciseByPlanEvent extends ExerciseExecutePlanEvent {
|
||||
final ExerciseType exerciseType;
|
||||
const AddExerciseByPlanEvent({this.exerciseType});
|
||||
|
||||
@override
|
||||
List<Object> get props => [exerciseType];
|
||||
}
|
||||
|
||||
class ExerciseByPlanLoad extends ExerciseExecutePlanEvent {
|
||||
const ExerciseByPlanLoad();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
part of 'exercise_execute_plan_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseExecutePlanState extends Equatable {
|
||||
const ExerciseExecutePlanState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseByPlanStateInitial extends ExerciseExecutePlanState {
|
||||
const ExerciseByPlanStateInitial();
|
||||
}
|
||||
|
||||
class ExerciseByPlanLoading extends ExerciseExecutePlanState {
|
||||
const ExerciseByPlanLoading();
|
||||
}
|
||||
|
||||
// updated screen
|
||||
class ExerciseByPlanReady extends ExerciseExecutePlanState {
|
||||
const ExerciseByPlanReady();
|
||||
}
|
||||
|
||||
// error splash screen
|
||||
class ExerciseByPlanError extends ExerciseExecutePlanState {
|
||||
final String message;
|
||||
const ExerciseByPlanError({this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import 'dart:async';
|
||||
import 'package:aitrainer_app/bloc/exercise_execute_plan/exercise_execute_plan_bloc.dart';
|
||||
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:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'exercise_execute_plan_add_event.dart';
|
||||
|
||||
part 'exercise_execute_plan_add_state.dart';
|
||||
|
||||
class ExerciseExecutePlanAddBloc extends Bloc<ExerciseExecutePlanAddEvent, ExerciseExecutePlanAddState> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
final ExercisePlanRepository exercisePlanRepository;
|
||||
final WorkoutMenuTree workoutTree;
|
||||
final ExerciseExecutePlanBloc planBloc;
|
||||
final int customerId;
|
||||
|
||||
Customer customer;
|
||||
int step = 1;
|
||||
int countSteps = 1;
|
||||
|
||||
double quantity;
|
||||
double unitQuantity;
|
||||
|
||||
double scrollOffset = 0;
|
||||
|
||||
@override
|
||||
ExerciseExecutePlanAddBloc({
|
||||
this.exerciseRepository,
|
||||
this.exercisePlanRepository,
|
||||
this.customerId,
|
||||
this.workoutTree,
|
||||
this.planBloc}): super(ExerciseExecutePlanAddInitial()) {
|
||||
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;
|
||||
|
||||
unitQuantity = double.parse(exercisePlanRepository.getActualPlanDetail().weightEquation);
|
||||
quantity = exercisePlanRepository.getActualPlanDetail().repeats.toDouble();
|
||||
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
exerciseRepository.setUnitQuantity(unitQuantity);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<ExerciseExecutePlanAddState> mapEventToState(ExerciseExecutePlanAddEvent event) async* {
|
||||
try {
|
||||
if (event is ExerciseExecutePlanAddLoad) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
yield ExerciseExecutePlanAddReady();
|
||||
} else if (event is ExerciseExecutePlanAddChangeQuantity) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
quantity = event.quantity;
|
||||
exerciseRepository.setQuantity(quantity);
|
||||
yield ExerciseExecutePlanAddReady();
|
||||
} else if (event is ExerciseExecutePlanAddChangeUnitQuantity) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
unitQuantity = event.quantity;
|
||||
exerciseRepository.setUnitQuantity(unitQuantity);
|
||||
yield ExerciseExecutePlanAddReady();
|
||||
} else if (event is ExerciseExecutePlanAddSubmit) {
|
||||
yield ExerciseExecutePlanAddLoading();
|
||||
exerciseRepository.exercise.exercisePlanDetailId =
|
||||
exercisePlanRepository.getActualPlanDetail().exercisePlanDetailId;
|
||||
exerciseRepository.exercise.unit = workoutTree.exerciseType.unit;
|
||||
workoutTree.executed = true;
|
||||
print("On Submitting Exercise Execute Plan Add " + exerciseRepository.exercise.toJson().toString());
|
||||
await exerciseRepository.addExercise();
|
||||
step++;
|
||||
scrollOffset = step * 200.0;
|
||||
planBloc.add(ExerciseByPlanLoad());
|
||||
yield ExerciseExecutePlanAddReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
yield ExerciseExecutePlanAddError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
part of 'exercise_execute_plan_add_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseExecutePlanAddEvent extends Equatable {
|
||||
const ExerciseExecutePlanAddEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddLoad extends ExerciseExecutePlanAddEvent {
|
||||
const ExerciseExecutePlanAddLoad();
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddChangeQuantity extends ExerciseExecutePlanAddEvent {
|
||||
final double quantity;
|
||||
const ExerciseExecutePlanAddChangeQuantity({this.quantity});
|
||||
|
||||
@override
|
||||
List<Object> get props => [quantity];
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddChangeUnitQuantity extends ExerciseExecutePlanAddEvent {
|
||||
final double quantity;
|
||||
const ExerciseExecutePlanAddChangeUnitQuantity({this.quantity});
|
||||
|
||||
@override
|
||||
List<Object> get props => [quantity];
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddSubmit extends ExerciseExecutePlanAddEvent {
|
||||
const ExerciseExecutePlanAddSubmit();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
part of 'exercise_execute_plan_add_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseExecutePlanAddState extends Equatable {
|
||||
const ExerciseExecutePlanAddState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddInitial extends ExerciseExecutePlanAddState {
|
||||
const ExerciseExecutePlanAddInitial();
|
||||
}
|
||||
|
||||
class ExerciseExecutePlanAddLoading extends ExerciseExecutePlanAddState {
|
||||
const ExerciseExecutePlanAddLoading();
|
||||
}
|
||||
|
||||
// updated screen
|
||||
class ExerciseExecutePlanAddReady extends ExerciseExecutePlanAddState {
|
||||
const ExerciseExecutePlanAddReady();
|
||||
}
|
||||
|
||||
// error splash screen
|
||||
class ExerciseExecutePlanAddError extends ExerciseExecutePlanAddState {
|
||||
final String message;
|
||||
const ExerciseExecutePlanAddError({this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
import 'menu/menu_bloc.dart';
|
||||
|
||||
class ExerciseFormBloc extends FormBloc<String, String> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
final MenuBloc menuBloc;
|
||||
|
||||
final quantityField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
],
|
||||
);
|
||||
|
||||
final unitField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
],
|
||||
);
|
||||
|
||||
final unitQuantityField = TextFieldBloc();
|
||||
final unitQuantityUnitField = TextFieldBloc();
|
||||
|
||||
ExerciseFormBloc({this.exerciseRepository, this.menuBloc}) {
|
||||
addFieldBlocs(fieldBlocs: [
|
||||
quantityField,
|
||||
unitField,
|
||||
unitQuantityField,
|
||||
unitQuantityUnitField
|
||||
]);
|
||||
|
||||
quantityField.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setQuantity(current.valueToDouble);
|
||||
});
|
||||
|
||||
unitField.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setUnit(current.value);
|
||||
});
|
||||
|
||||
unitQuantityField.onValueChanges(onData: (previous, current) async* {
|
||||
exerciseRepository.setUnitQuantity(current.valueToDouble);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onSubmitting() async {
|
||||
try {
|
||||
emitLoading(progress: 30);
|
||||
// Emit either Loaded or Error
|
||||
await exerciseRepository.addExercise();
|
||||
menuBloc.add(MenuTreeDown(parent: 0));
|
||||
emitSuccess(canSubmitAgain: false);
|
||||
|
||||
} on Exception catch (ex) {
|
||||
emitFailure(failureResponse: ex.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close() {
|
||||
unitQuantityField.close();
|
||||
unitQuantityUnitField.close();
|
||||
return super.close();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import 'dart:async';
|
||||
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:meta/meta.dart';
|
||||
|
||||
part 'exercise_log_event.dart';
|
||||
|
||||
part 'exercise_log_state.dart';
|
||||
|
||||
class ExerciseLogBloc extends Bloc<ExerciseLogEvent, ExerciseLogState> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
@override
|
||||
ExerciseLogBloc({this.exerciseRepository}) : super(ExerciseLogInitial());
|
||||
|
||||
|
||||
@override
|
||||
Stream<ExerciseLogState> mapEventToState(ExerciseLogEvent event) async* {
|
||||
try {
|
||||
if (event is ExerciseLogLoad) {
|
||||
yield ExerciseLogLoading();
|
||||
yield ExerciseLogReady();
|
||||
} else if ( event is ExerciseLogDelete ) {
|
||||
yield ExerciseLogLoading();
|
||||
exerciseRepository.exerciseList.remove(event.exercise);
|
||||
await exerciseRepository.deleteExercise(event.exercise);
|
||||
yield ExerciseLogReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
yield ExerciseLogError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
part of 'exercise_log_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseLogEvent extends Equatable {
|
||||
const ExerciseLogEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseLogLoad extends ExerciseLogEvent {
|
||||
const ExerciseLogLoad();
|
||||
}
|
||||
|
||||
class ExerciseLogDelete extends ExerciseLogEvent {
|
||||
final Exercise exercise;
|
||||
const ExerciseLogDelete({this.exercise});
|
||||
|
||||
@override
|
||||
List<Object> get props => [exercise];
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
part of 'exercise_log_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseLogState extends Equatable {
|
||||
const ExerciseLogState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseLogInitial extends ExerciseLogState {
|
||||
const ExerciseLogInitial();
|
||||
}
|
||||
|
||||
class ExerciseLogLoading extends ExerciseLogState {
|
||||
const ExerciseLogLoading();
|
||||
}
|
||||
|
||||
class ExerciseLogReady extends ExerciseLogState {
|
||||
const ExerciseLogReady();
|
||||
}
|
||||
|
||||
class ExerciseLogError extends ExerciseLogState {
|
||||
final String message;
|
||||
const ExerciseLogError({this.message});
|
||||
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'dart:async';
|
||||
import 'package:aitrainer_app/bloc/menu/menu_bloc.dart';
|
||||
import 'package:aitrainer_app/model/exercise_type.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_repository.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'exercise_new_event.dart';
|
||||
|
||||
part 'exercise_new_state.dart';
|
||||
|
||||
class ExerciseNewBloc extends Bloc<ExerciseNewEvent, ExerciseNewState> {
|
||||
final ExerciseRepository exerciseRepository;
|
||||
final MenuBloc menuBloc;
|
||||
double quantity = 12;
|
||||
double unitQuantity = 30;
|
||||
|
||||
@override
|
||||
ExerciseNewBloc({this.exerciseRepository, this.menuBloc, ExerciseType exerciseType}) : super(ExerciseNewInitial()) {
|
||||
exerciseRepository.setUnit(exerciseType.unit);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<ExerciseNewState> mapEventToState(ExerciseNewEvent event) async* {
|
||||
try {
|
||||
if (event is ExerciseNewLoad) {
|
||||
yield ExerciseNewLoading();
|
||||
yield ExerciseNewReady();
|
||||
} else if ( event is ExerciseNewQuantityChange ) {
|
||||
yield ExerciseNewLoading();
|
||||
exerciseRepository.setQuantity(event.quantity);
|
||||
quantity = event.quantity;
|
||||
yield ExerciseNewReady();
|
||||
} else if ( event is ExerciseNewQuantityUnitChange ) {
|
||||
yield ExerciseNewLoading();
|
||||
exerciseRepository.setUnitQuantity(event.quantity);
|
||||
unitQuantity = event.quantity;
|
||||
yield ExerciseNewReady();
|
||||
} else if ( event is ExerciseNewSubmit ) {
|
||||
yield ExerciseNewLoading();
|
||||
await exerciseRepository.addExercise();
|
||||
menuBloc.add(MenuTreeDown(parent: 0));
|
||||
yield ExerciseNewReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
yield ExerciseNewError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
part of 'exercise_new_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseNewEvent extends Equatable {
|
||||
const ExerciseNewEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseNewLoad extends ExerciseNewEvent {
|
||||
const ExerciseNewLoad();
|
||||
}
|
||||
|
||||
class ExerciseNewQuantityChange extends ExerciseNewEvent {
|
||||
final double quantity;
|
||||
const ExerciseNewQuantityChange({this.quantity});
|
||||
|
||||
@override
|
||||
List<Object> get props => [quantity];
|
||||
}
|
||||
|
||||
class ExerciseNewQuantityUnitChange extends ExerciseNewEvent {
|
||||
final double quantity;
|
||||
const ExerciseNewQuantityUnitChange({this.quantity});
|
||||
|
||||
@override
|
||||
List<Object> get props => [quantity];
|
||||
}
|
||||
|
||||
class ExerciseNewSubmit extends ExerciseNewEvent {
|
||||
const ExerciseNewSubmit();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
part of 'exercise_new_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExerciseNewState extends Equatable {
|
||||
const ExerciseNewState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExerciseNewInitial extends ExerciseNewState {
|
||||
const ExerciseNewInitial();
|
||||
}
|
||||
|
||||
class ExerciseNewLoading extends ExerciseNewState {
|
||||
const ExerciseNewLoading();
|
||||
}
|
||||
|
||||
class ExerciseNewReady extends ExerciseNewState {
|
||||
const ExerciseNewReady();
|
||||
}
|
||||
|
||||
class ExerciseNewError extends ExerciseNewState {
|
||||
final String message;
|
||||
const ExerciseNewError({this.message});
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
@@ -30,7 +30,8 @@ class ExercisePlanBloc extends Bloc<ExercisePlanEvent, ExercisePlanState> {
|
||||
listWorkoutTree.forEach((workoutTree) {
|
||||
workoutTree.selected = false;
|
||||
if (exercisePlanRepository.getExercisePlanDetailSize() > 0) {
|
||||
if (exercisePlanRepository.getExercisePlanDetailByExerciseId(workoutTree.exerciseTypeId) != null) {
|
||||
ExercisePlanDetail planDetail = exercisePlanRepository.getExercisePlanDetailByExerciseId(workoutTree.exerciseTypeId);
|
||||
if (planDetail != null && planDetail.change != ExercisePlanDetailChange.deleted) {
|
||||
workoutTree.selected = true;
|
||||
}
|
||||
}
|
||||
@@ -66,23 +67,22 @@ class ExercisePlanBloc extends Bloc<ExercisePlanEvent, ExercisePlanState> {
|
||||
ExercisePlanDetail planDetail = event.exercisePlanDetail;
|
||||
exercisePlanRepository.actualPlanDetail = planDetail;
|
||||
|
||||
/*if ( exercisePlanRepository.exercisePlanDetails[planDetail.exerciseTypeId] == null ) {
|
||||
print("Add plan detail " + planDetail.toJson().toString());
|
||||
exercisePlanRepository.actualPlanDetail.change = ExercisePlanDetailChange.add;
|
||||
} else {
|
||||
print("Update plan detail " + planDetail.toJson().toString());
|
||||
exercisePlanRepository.actualPlanDetail.change = ExercisePlanDetailChange.update;
|
||||
}
|
||||
exercisePlanRepository.addDetailToPlan();*/
|
||||
|
||||
if (exercisePlanRepository.getExercisePlanDetailSize() != 0) {
|
||||
await exercisePlanRepository.saveExercisePlan();
|
||||
}
|
||||
|
||||
this.menuTreeRepository.sortedTree.forEach((key, value) {
|
||||
List<WorkoutMenuTree> listTreeItem = value;
|
||||
listTreeItem.forEach((element) {
|
||||
if ( element.exerciseType.exerciseTypeId == planDetail.exerciseTypeId) {
|
||||
element.selected = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
yield ExercisePlanReady();
|
||||
}
|
||||
|
||||
|
||||
else if (event is ExercisePlanRemoveExercise) {
|
||||
yield ExercisePlanLoading();
|
||||
ExercisePlanDetail planDetail = event.exercisePlanDetail;
|
||||
@@ -101,6 +101,7 @@ class ExercisePlanBloc extends Bloc<ExercisePlanEvent, ExercisePlanState> {
|
||||
exercisePlanRepository.saveExercisePlan();
|
||||
}
|
||||
|
||||
|
||||
yield ExercisePlanReady();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
import 'dart:async';
|
||||
import 'package:aitrainer_app/bloc/exercise_plan/exercise_plan_bloc.dart';
|
||||
import 'package:aitrainer_app/model/workout_menu_tree.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
|
||||
import 'package:bloc/bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
part 'exercise_plan_custom_add_event.dart';
|
||||
|
||||
part 'exercise_plan_custom_add_state.dart';
|
||||
|
||||
class ExercisePlanDetailChange {
|
||||
static const String add = "add";
|
||||
static const String delete = "delete";
|
||||
static const String update = "update";
|
||||
static const String deleted = "deleted";
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddBloc extends Bloc<ExercisePlanCustomAddEvent, ExercisePlanCustomAddState> {
|
||||
final ExercisePlanRepository exercisePlanRepository;
|
||||
final ExercisePlanBloc planBloc;
|
||||
final WorkoutMenuTree workoutMenuTree;
|
||||
|
||||
double quantity;
|
||||
double serie;
|
||||
double quantityUnit;
|
||||
|
||||
@override
|
||||
ExercisePlanCustomAddBloc({this.exercisePlanRepository, this.planBloc, this.workoutMenuTree}) : super(ExercisePlanCustomAddInitial()) {
|
||||
exercisePlanRepository.setActualPlanDetailByExerciseType(workoutMenuTree.exerciseType);
|
||||
quantity = exercisePlanRepository.getActualPlanDetail().repeats != null ?
|
||||
exercisePlanRepository.getActualPlanDetail().repeats.toDouble() : 12;
|
||||
serie = exercisePlanRepository.getActualPlanDetail().serie != null ?
|
||||
exercisePlanRepository.getActualPlanDetail().serie.toDouble() : 3;
|
||||
quantityUnit = exercisePlanRepository.getActualPlanDetail().weightEquation != null ?
|
||||
double.parse(exercisePlanRepository.getActualPlanDetail().weightEquation) : 30;
|
||||
|
||||
exercisePlanRepository.getActualPlanDetail().weightEquation = quantityUnit.toString();
|
||||
exercisePlanRepository.getActualPlanDetail().serie = serie.toInt();
|
||||
exercisePlanRepository.getActualPlanDetail().repeats = quantity.toInt();
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<ExercisePlanCustomAddState> mapEventToState(ExercisePlanCustomAddEvent event) async* {
|
||||
try {
|
||||
if (event is ExercisePlanCustomAddLoad) {
|
||||
yield ExercisePlanCustomAddLoading();
|
||||
yield ExercisePlanCustomAddReady();
|
||||
} else if ( event is ExercisePlanCustomAddChangeSerie ) {
|
||||
yield ExercisePlanCustomAddLoading();
|
||||
serie = event.quantity;
|
||||
exercisePlanRepository.getActualPlanDetail().serie = event.quantity.toInt();
|
||||
yield ExercisePlanCustomAddReady();
|
||||
} else if ( event is ExercisePlanCustomAddChangeQuantity ) {
|
||||
yield ExercisePlanCustomAddLoading();
|
||||
quantity = event.quantity;
|
||||
exercisePlanRepository.getActualPlanDetail().repeats = event.quantity.toInt();
|
||||
yield ExercisePlanCustomAddReady();
|
||||
} else if ( event is ExercisePlanCustomAddChangeQuantityUnit ) {
|
||||
yield ExercisePlanCustomAddLoading();
|
||||
quantityUnit = event.quantity;
|
||||
exercisePlanRepository.getActualPlanDetail().weightEquation = event.quantity.toStringAsFixed(0);
|
||||
yield ExercisePlanCustomAddReady();
|
||||
} else if ( event is ExercisePlanCustomAddSubmit) {
|
||||
yield ExercisePlanCustomAddLoading();
|
||||
if ( exercisePlanRepository.exercisePlanDetails[exercisePlanRepository.getActualPlanDetail()] == null ) {
|
||||
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.add;
|
||||
} else {
|
||||
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.update;
|
||||
}
|
||||
exercisePlanRepository.addDetailToPlan();
|
||||
planBloc.add(ExercisePlanAddExercise(exercisePlanDetail: exercisePlanRepository.getActualPlanDetail()));
|
||||
yield ExercisePlanCustomAddReady();
|
||||
} else if ( event is ExercisePlanCustomAddRemove ) {
|
||||
yield ExercisePlanCustomAddLoading();
|
||||
print("Remove " + exercisePlanRepository.getActualPlanDetail().exerciseType.name);
|
||||
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.delete;
|
||||
planBloc.add(ExercisePlanRemoveExercise(exercisePlanDetail: exercisePlanRepository.getActualPlanDetail()));
|
||||
|
||||
yield ExercisePlanCustomAddReady();
|
||||
}
|
||||
} on Exception catch (e) {
|
||||
yield ExercisePlanCustomAddError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
part of 'exercise_plan_custom_add_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExercisePlanCustomAddEvent extends Equatable {
|
||||
const ExercisePlanCustomAddEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddLoad extends ExercisePlanCustomAddEvent {
|
||||
const ExercisePlanCustomAddLoad();
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddChangeSerie extends ExercisePlanCustomAddEvent {
|
||||
final double quantity;
|
||||
const ExercisePlanCustomAddChangeSerie({this.quantity});
|
||||
|
||||
@override
|
||||
List<Object> get props => [quantity];
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddChangeQuantity extends ExercisePlanCustomAddEvent {
|
||||
final double quantity;
|
||||
const ExercisePlanCustomAddChangeQuantity({this.quantity});
|
||||
|
||||
@override
|
||||
List<Object> get props => [quantity];
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddChangeQuantityUnit extends ExercisePlanCustomAddEvent {
|
||||
final double quantity;
|
||||
const ExercisePlanCustomAddChangeQuantityUnit({this.quantity});
|
||||
|
||||
@override
|
||||
List<Object> get props => [quantity];
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddSubmit extends ExercisePlanCustomAddEvent {
|
||||
const ExercisePlanCustomAddSubmit();
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddRemove extends ExercisePlanCustomAddEvent {
|
||||
const ExercisePlanCustomAddRemove();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
part of 'exercise_plan_custom_add_bloc.dart';
|
||||
|
||||
@immutable
|
||||
abstract class ExercisePlanCustomAddState extends Equatable {
|
||||
const ExercisePlanCustomAddState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddInitial extends ExercisePlanCustomAddState {
|
||||
const ExercisePlanCustomAddInitial();
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddLoading extends ExercisePlanCustomAddState {
|
||||
const ExercisePlanCustomAddLoading();
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddReady extends ExercisePlanCustomAddState {
|
||||
const ExercisePlanCustomAddReady();
|
||||
}
|
||||
|
||||
class ExercisePlanCustomAddError extends ExercisePlanCustomAddState {
|
||||
final String message;
|
||||
const ExercisePlanCustomAddError({this.message});
|
||||
|
||||
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
import 'package:aitrainer_app/bloc/exercise_plan/exercise_plan_bloc.dart';
|
||||
import 'package:aitrainer_app/model/exercise_plan_detail.dart';
|
||||
import 'package:aitrainer_app/repository/exercise_plan_repository.dart';
|
||||
import 'package:flutter_form_bloc/flutter_form_bloc.dart';
|
||||
|
||||
class ExercisePlanCustomerFormBloc extends FormBloc<String, String> {
|
||||
final ExercisePlanRepository exercisePlanRepository;
|
||||
final ExercisePlanBloc planBloc;
|
||||
final serieField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
],
|
||||
);
|
||||
|
||||
final quantityField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
],
|
||||
);
|
||||
|
||||
final weightField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
],
|
||||
);
|
||||
|
||||
final exerciseTypeField = TextFieldBloc(
|
||||
validators: [
|
||||
FieldBlocValidators.required,
|
||||
],
|
||||
);
|
||||
|
||||
ExercisePlanCustomerFormBloc({this.exercisePlanRepository, this.planBloc}) {
|
||||
addFieldBlocs(fieldBlocs: [
|
||||
quantityField,
|
||||
serieField,
|
||||
weightField
|
||||
]);
|
||||
|
||||
String repeatsInitial = exercisePlanRepository.getActualPlanDetail() != null &&
|
||||
exercisePlanRepository.getActualPlanDetail().repeats != null ?
|
||||
exercisePlanRepository.getActualPlanDetail().repeats.toString() : "12";
|
||||
quantityField.updateInitialValue(repeatsInitial);
|
||||
|
||||
String serieInitial = exercisePlanRepository.getActualPlanDetail() != null &&
|
||||
exercisePlanRepository.getActualPlanDetail().serie != null ?
|
||||
exercisePlanRepository.getActualPlanDetail().serie.toString() : "3";
|
||||
serieField.updateInitialValue(serieInitial);
|
||||
|
||||
String weightInitial = exercisePlanRepository.getActualPlanDetail() != null &&
|
||||
exercisePlanRepository.getActualPlanDetail().weightEquation != null ?
|
||||
exercisePlanRepository.getActualPlanDetail().weightEquation : "30";
|
||||
weightField.updateInitialValue(weightInitial);
|
||||
|
||||
quantityField.onValueChanges(onData: (previous, current) async* {
|
||||
exercisePlanRepository.getActualPlanDetail().repeats = current.valueToInt;
|
||||
});
|
||||
serieField.onValueChanges(onData: (previous, current) async* {
|
||||
exercisePlanRepository.getActualPlanDetail().serie = current.valueToInt;
|
||||
});
|
||||
weightField.onValueChanges(onData: (previous, current) async* {
|
||||
exercisePlanRepository.getActualPlanDetail().weightEquation = current.value;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void onSubmitting() async {
|
||||
print("On Submitting Custom Plan form");
|
||||
try {
|
||||
emitLoading(progress: 30);
|
||||
// Emit either Loaded or Error
|
||||
|
||||
exercisePlanRepository.getActualPlanDetail().repeats = quantityField.valueToInt;
|
||||
exercisePlanRepository.getActualPlanDetail().serie = serieField.valueToInt;
|
||||
exercisePlanRepository.getActualPlanDetail().weightEquation = weightField.value;
|
||||
if ( exercisePlanRepository.exercisePlanDetails[exercisePlanRepository.getActualPlanDetail()] == null ) {
|
||||
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.add;
|
||||
} else {
|
||||
exercisePlanRepository.getActualPlanDetail().change = ExercisePlanDetailChange.update;
|
||||
}
|
||||
exercisePlanRepository.addDetailToPlan();
|
||||
planBloc.add(ExercisePlanAddExercise(exercisePlanDetail: exercisePlanRepository.getActualPlanDetail()));
|
||||
|
||||
emitSuccess(canSubmitAgain: false);
|
||||
} on Exception catch (ex) {
|
||||
emitFailure(failureResponse: ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//@override
|
||||
Future<void> close() {
|
||||
quantityField.close();
|
||||
serieField.close();
|
||||
weightField.close();
|
||||
exerciseTypeField.close();
|
||||
return super.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user