feat(diary): New state variable for moderation button control
This commit is contained in:
@@ -74,6 +74,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
currentMeal: currentState.currentMeal,
|
||||
wakeupExpanded: currentState.wakeupExpanded,
|
||||
moodExpanded: currentState.moodExpanded,
|
||||
moderationExpanded: currentState.moderationExpanded,
|
||||
token: currentState.token,
|
||||
meals: currentState.meals,
|
||||
wakeupController: currentState.wakeupController,
|
||||
@@ -97,6 +98,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
id: 1, title: "Прием пищи 1", isSelected: true),
|
||||
wakeupExpanded: true,
|
||||
moodExpanded: true,
|
||||
moderationExpanded: false,
|
||||
token: token,
|
||||
meals: diary['meals'],
|
||||
portions: diary['meals'][0]['portions'],
|
||||
@@ -267,7 +269,6 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
body: json.encode(credentials),
|
||||
encoding: utf8,
|
||||
);
|
||||
print(response.body);
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -464,9 +465,12 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
.toList(),
|
||||
);
|
||||
|
||||
if (event.input.length > 3) {
|
||||
updatedState = updatedState.copyWith(
|
||||
moderationExpanded: !currentState.moderationExpanded);
|
||||
}
|
||||
|
||||
emit(updatedState); // Emit the updated state
|
||||
} else {
|
||||
print("Ошибка в декодировании ответа из API");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -494,7 +498,6 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
final updatedState = currentState.copyWith(portions: updatedPortions);
|
||||
|
||||
emit(updatedState); // Emit the updated state
|
||||
print("removed");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -513,13 +516,10 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
encoding: utf8,
|
||||
);
|
||||
|
||||
print(response.body);
|
||||
return response;
|
||||
}
|
||||
|
||||
Future<void> _finishDay(FinishDay event, Emitter<DiaryEditState> emit) async {
|
||||
print("imageUrl");
|
||||
|
||||
if (state is DiaryEditLoadedState) {
|
||||
var currentState = state as DiaryEditLoadedState;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
this.currentMeal,
|
||||
required this.diaryId,
|
||||
required this.selectedSatiety,
|
||||
required this.moderationExpanded,
|
||||
required this.wakeupExpanded,
|
||||
required this.moodExpanded})
|
||||
: super(diaryEditModelObj: null);
|
||||
@@ -56,6 +57,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
int selectedSatiety;
|
||||
int diaryId;
|
||||
bool wakeupExpanded;
|
||||
bool moderationExpanded;
|
||||
bool moodExpanded;
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
@@ -75,6 +77,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
diaryId,
|
||||
wakeupExpanded,
|
||||
moodExpanded,
|
||||
moderationExpanded,
|
||||
currentMeal
|
||||
];
|
||||
DiaryEditLoadedState copyWith({
|
||||
@@ -95,6 +98,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
int? selectedSatiety,
|
||||
int? diaryId,
|
||||
bool? wakeupExpanded,
|
||||
bool? moderationExpanded,
|
||||
bool? moodExpanded,
|
||||
}) {
|
||||
return DiaryEditLoadedState(
|
||||
@@ -117,6 +121,7 @@ class DiaryEditLoadedState extends DiaryEditState {
|
||||
diaryId: diaryId ?? this.diaryId,
|
||||
currentMeal: currentMeal ?? this.currentMeal,
|
||||
wakeupExpanded: wakeupExpanded ?? this.wakeupExpanded,
|
||||
moderationExpanded: moderationExpanded ?? this.moderationExpanded,
|
||||
moodExpanded: moodExpanded ?? this.moodExpanded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ void main() {
|
||||
autocompleteList: [],
|
||||
portions: [],
|
||||
wakeupExpanded: false,
|
||||
moderationExpanded: false,
|
||||
moodExpanded: false);
|
||||
|
||||
await tester.pumpWidget(
|
||||
|
||||
Reference in New Issue
Block a user