forked from eatvio/eatvio_app
fixed profile, recipeis and diets
This commit is contained in:
@@ -101,12 +101,20 @@ class CreateRecipeCubit extends Cubit<CreateRecipeState> {
|
||||
emit(state.copyWith.entity(energyInOnePortion: energy));
|
||||
}
|
||||
|
||||
replaceTotalTime(String time) {
|
||||
emit(state.copyWith.entity(totalCookTime: time));
|
||||
setTotalCookingMinutes(int minutes) {
|
||||
emit(state.copyWith.entity(totalCookMinutes: minutes));
|
||||
}
|
||||
|
||||
replaceActiveTime(String time) {
|
||||
emit(state.copyWith.entity(activeCookTime: time));
|
||||
setTotalCookingHours(int hours) {
|
||||
emit(state.copyWith.entity(totalCookHours: hours));
|
||||
}
|
||||
|
||||
setActiveCookingMinutes(int minutes) {
|
||||
emit(state.copyWith.entity(activeCookMinutes: minutes));
|
||||
}
|
||||
|
||||
setActiveCookingHours(int hours) {
|
||||
emit(state.copyWith.entity(activeCookHours: hours));
|
||||
}
|
||||
|
||||
replaceVideoUrl(String videoUrl) {
|
||||
@@ -190,7 +198,7 @@ class CreateRecipeCubit extends Cubit<CreateRecipeState> {
|
||||
}
|
||||
|
||||
bool validateActiveCookTime() {
|
||||
if (state.entity.activeCookTime == null || state.entity.activeCookTime == '00:00') {
|
||||
if (state.entity.activeCookHours == null && state.entity.activeCookMinutes == null) {
|
||||
emit(state.copyWith(activeTimeValidationError: 'Поле не заполнено'));
|
||||
return false;
|
||||
} else {
|
||||
@@ -200,7 +208,7 @@ class CreateRecipeCubit extends Cubit<CreateRecipeState> {
|
||||
}
|
||||
|
||||
bool validateTotalCookTime() {
|
||||
if (state.entity.totalCookTime == null || state.entity.totalCookTime == '00:00') {
|
||||
if (state.entity.totalCookHours == null || state.entity.totalCookMinutes == null) {
|
||||
emit(state.copyWith(cookingTimeValidationError: 'Поле не заполнено'));
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -72,11 +72,9 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
|
||||
hasError: state.cookingTimeValidationError != null,
|
||||
textInputType: TextInputType.number,
|
||||
onChanged: (value) {
|
||||
if (createRecipeCubit.state.entity.totalCookTime == null) {
|
||||
createRecipeCubit.replaceTotalTime('${value.padLeft(2, '0')}:00');
|
||||
} else {
|
||||
createRecipeCubit.replaceTotalTime('${value.padLeft(2, '0')}:${createRecipeCubit.state.entity.totalCookTime!.substring(3, 5)}');
|
||||
}
|
||||
final hours = int.tryParse(value);
|
||||
if (hours == null) return;
|
||||
createRecipeCubit.setTotalCookingHours(hours);
|
||||
if (state.cookingTimeValidationError != null) {
|
||||
createRecipeCubit.validateTotalCookTime();
|
||||
}
|
||||
@@ -100,11 +98,9 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
|
||||
hasError: state.cookingTimeValidationError != null,
|
||||
textInputType: TextInputType.number,
|
||||
onChanged: (value) {
|
||||
if (createRecipeCubit.state.entity.totalCookTime == null) {
|
||||
createRecipeCubit.replaceTotalTime('00:${value.padLeft(2, '0')}');
|
||||
} else {
|
||||
createRecipeCubit.replaceTotalTime('${createRecipeCubit.state.entity.totalCookTime!.substring(0, 2)}:${value.padLeft(2, '0')}');
|
||||
}
|
||||
final minutes = int.tryParse(value);
|
||||
if (minutes == null) return;
|
||||
createRecipeCubit.setTotalCookingMinutes(minutes);
|
||||
if (state.cookingTimeValidationError != null) {
|
||||
createRecipeCubit.validateTotalCookTime();
|
||||
}
|
||||
@@ -162,11 +158,9 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
|
||||
hasError: state.activeTimeValidationError != null,
|
||||
textInputType: TextInputType.number,
|
||||
onChanged: (value) {
|
||||
if (createRecipeCubit.state.entity.activeCookTime == null) {
|
||||
createRecipeCubit.replaceActiveTime('${value.padLeft(2, '0')}:00');
|
||||
} else {
|
||||
createRecipeCubit.replaceActiveTime('${value.padLeft(2, '0')}:${createRecipeCubit.state.entity.activeCookTime!.substring(3, 5)}');
|
||||
}
|
||||
final hours = int.tryParse(value);
|
||||
if (hours == null) return;
|
||||
createRecipeCubit.setActiveCookingHours(hours);
|
||||
|
||||
if (state.activeTimeValidationError != null) {
|
||||
createRecipeCubit.validateActiveCookTime();
|
||||
@@ -191,11 +185,9 @@ class _TimeOfCookWidgetState extends State<TimeOfCookWidget> {
|
||||
hasError: state.activeTimeValidationError != null,
|
||||
textInputType: TextInputType.number,
|
||||
onChanged: (value) {
|
||||
if (createRecipeCubit.state.entity.activeCookTime == null) {
|
||||
createRecipeCubit.replaceActiveTime('00:${value.padLeft(2, '0')}');
|
||||
} else {
|
||||
createRecipeCubit.replaceActiveTime('${createRecipeCubit.state.entity.activeCookTime!.substring(0, 2)}:${value.padLeft(2, '0')}');
|
||||
}
|
||||
final minutes = int.tryParse(value);
|
||||
if (minutes == null) return;
|
||||
createRecipeCubit.setActiveCookingMinutes(minutes);
|
||||
|
||||
if (state.activeTimeValidationError != null) {
|
||||
createRecipeCubit.validateActiveCookTime();
|
||||
|
||||
Reference in New Issue
Block a user