forked from eatvio/eatvio_app
feat(diary):
This commit is contained in:
@@ -10,6 +10,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
class DiaryCubit extends Cubit<DiaryState> {
|
||||
final DiaryRepository diaryRepository;
|
||||
final GlossaryRepository glossaryRepository;
|
||||
double currentSelectedSatietyRating = 3;
|
||||
|
||||
DiaryCubit({
|
||||
required this.diaryRepository,
|
||||
@@ -19,7 +20,12 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
getDiaryDay(String date, [bool needLoading = true]) async {
|
||||
if (needLoading) emit(const DiaryState.loading());
|
||||
try {
|
||||
emit(DiaryState.loaded(diary: await diaryRepository.getDiaryByDate(date)));
|
||||
emit(
|
||||
DiaryState.loaded(
|
||||
diary: await diaryRepository.getDiaryByDate(date),
|
||||
currentSelectedSatietyRating: currentSelectedSatietyRating,
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
emit(DiaryState.error(errorMessage: e.toString()));
|
||||
throw e;
|
||||
@@ -109,4 +115,9 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
);
|
||||
await getDiaryDay(date, false);
|
||||
}
|
||||
|
||||
updateCurrentSelectedSatietyRating(double value) {
|
||||
currentSelectedSatietyRating = value;
|
||||
emit((state as DiaryStateLoaded).copyWith(currentSelectedSatietyRating: currentSelectedSatietyRating));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user