forked from eatvio/eatvio_app
feat(diary): Text field cleared after product addition
This commit is contained in:
@@ -593,6 +593,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
emit(currentState.copyWith(isAdded: true));
|
||||
await reloadScreen(event, emit);
|
||||
} else {
|
||||
print(
|
||||
|
||||
@@ -40,6 +40,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
this.proteinsController,
|
||||
this.carbsController,
|
||||
this.isLoading = false,
|
||||
this.isAdded = false,
|
||||
required this.recommendedChartValues,
|
||||
required this.consumedChartValues,
|
||||
required this.diaryId,
|
||||
@@ -77,6 +78,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
bool moderationExpanded;
|
||||
bool moodExpanded;
|
||||
bool isLoading;
|
||||
bool isAdded;
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
diaryEditModelObj,
|
||||
@@ -106,6 +108,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
moodExpanded,
|
||||
moderationExpanded,
|
||||
isLoading,
|
||||
isAdded,
|
||||
currentMeal
|
||||
];
|
||||
DiaryEditLoadedState copyWith({
|
||||
@@ -137,6 +140,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
bool? moderationExpanded,
|
||||
bool? moodExpanded,
|
||||
bool? isLoading,
|
||||
bool? isAdded,
|
||||
}) {
|
||||
return DiaryEditLoadedState(
|
||||
diaryEditModelObj: diaryEditModelObj ?? this.diaryEditModelObj,
|
||||
@@ -169,6 +173,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
wakeupExpanded: wakeupExpanded ?? this.wakeupExpanded,
|
||||
moderationExpanded: moderationExpanded ?? this.moderationExpanded,
|
||||
moodExpanded: moodExpanded ?? this.moodExpanded,
|
||||
isAdded: isAdded ?? this.isAdded,
|
||||
isLoading: isLoading ?? this.isLoading);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,6 +341,10 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
FocusNode focusNodeName,
|
||||
VoidCallback onFieldSubmitted,
|
||||
) {
|
||||
if (state.isAdded) {
|
||||
print("Clear");
|
||||
productEditingController.clear();
|
||||
}
|
||||
return CustomTextFormField(
|
||||
hintText: "Введите название продукта",
|
||||
controller: productEditingController,
|
||||
|
||||
Reference in New Issue
Block a user