forked from eatvio/eatvio_app
feat(diary): wakeup, retire, mood, comment
This commit is contained in:
@@ -17,10 +17,7 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
final DiaryRepository diaryRepository;
|
||||
final GlossaryRepository glossaryRepository;
|
||||
|
||||
DiaryCubit({
|
||||
required this.diaryRepository,
|
||||
required this.glossaryRepository,
|
||||
}) : super(const DiaryState.loading()) {
|
||||
DiaryCubit({required this.diaryRepository, required this.glossaryRepository}) : super(const DiaryState.loading()) {
|
||||
today = DateTime.now();
|
||||
selectedDay = today;
|
||||
}
|
||||
@@ -56,16 +53,8 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
}
|
||||
}
|
||||
|
||||
finishDiaryDay({
|
||||
required int diaryId,
|
||||
required String wakeUp,
|
||||
required String retire,
|
||||
}) async {
|
||||
await diaryRepository.finishDiaryDay(
|
||||
diaryId: diaryId,
|
||||
wakeUp: wakeUp,
|
||||
retire: retire,
|
||||
);
|
||||
finishDiaryDay({required int diaryId, required String wakeUp, required String retire, String? comment}) async {
|
||||
await diaryRepository.finishDiaryDay(diaryId: diaryId, wakeUp: wakeUp, retire: retire, comment: comment);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
@@ -126,55 +115,23 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
markEaten({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required int portionId,
|
||||
}) async {
|
||||
await diaryRepository.markEaten(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
portionId: portionId,
|
||||
);
|
||||
markEaten({required int diaryId, required int mealId, required int portionId}) async {
|
||||
await diaryRepository.markEaten(diaryId: diaryId, mealId: mealId, portionId: portionId);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
unmarkEaten({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required int portionId,
|
||||
}) async {
|
||||
await diaryRepository.unmarkEaten(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
portionId: portionId,
|
||||
);
|
||||
unmarkEaten({required int diaryId, required int mealId, required int portionId}) async {
|
||||
await diaryRepository.unmarkEaten(diaryId: diaryId, mealId: mealId, portionId: portionId);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
restore({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required int portionId,
|
||||
}) async {
|
||||
await diaryRepository.restore(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
portionId: portionId,
|
||||
);
|
||||
restore({required int diaryId, required int mealId, required int portionId}) async {
|
||||
await diaryRepository.restore(diaryId: diaryId, mealId: mealId, portionId: portionId);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
deleteProductFromMeal({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required int portionId,
|
||||
}) async {
|
||||
await diaryRepository.deleteProductFromMeal(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
portionId: portionId,
|
||||
);
|
||||
deleteProductFromMeal({required int diaryId, required int mealId, required int portionId}) async {
|
||||
await diaryRepository.deleteProductFromMeal(diaryId: diaryId, mealId: mealId, portionId: portionId);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
@@ -182,27 +139,13 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
return await glossaryRepository.getGlossaryListByQuery(query);
|
||||
}
|
||||
|
||||
uploadPhotos({
|
||||
required List<File> files,
|
||||
required int diaryId,
|
||||
}) async {
|
||||
await diaryRepository.uploadPhotos(
|
||||
files: await ImageCompressUtility.compressFilesList(files),
|
||||
diaryId: diaryId,
|
||||
mealId: selectedMeal,
|
||||
);
|
||||
uploadPhotos({required List<File> files, required int diaryId}) async {
|
||||
await diaryRepository.uploadPhotos(files: await ImageCompressUtility.compressFilesList(files), diaryId: diaryId, mealId: selectedMeal);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
deletePhoto({
|
||||
required DiaryPhotoModel photo,
|
||||
required int diaryId,
|
||||
}) async {
|
||||
await diaryRepository.deletePhoto(
|
||||
photo: photo,
|
||||
diaryId: diaryId,
|
||||
mealId: selectedMeal,
|
||||
);
|
||||
deletePhoto({required DiaryPhotoModel photo, required int diaryId}) async {
|
||||
await diaryRepository.deletePhoto(photo: photo, diaryId: diaryId, mealId: selectedMeal);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
@@ -214,39 +157,37 @@ class DiaryCubit extends Cubit<DiaryState> {
|
||||
required double carbohydrates,
|
||||
}) async {
|
||||
try {
|
||||
return await diaryRepository.sendProductToModeration(
|
||||
name: name,
|
||||
energy: energy,
|
||||
proteins: proteins,
|
||||
fats: fats,
|
||||
carbohydrates: carbohydrates,
|
||||
);
|
||||
return await diaryRepository.sendProductToModeration(name: name, energy: energy, proteins: proteins, fats: fats, carbohydrates: carbohydrates);
|
||||
} catch (e, stackTrace) {
|
||||
log(e.toString(), stackTrace: stackTrace);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
fillTime({
|
||||
required int diaryId,
|
||||
required String time,
|
||||
}) async {
|
||||
await diaryRepository.fillTime(
|
||||
diaryId: diaryId,
|
||||
mealId: selectedMeal,
|
||||
time: time,
|
||||
);
|
||||
fillTime({required int diaryId, required String time}) async {
|
||||
await diaryRepository.fillTime(diaryId: diaryId, mealId: selectedMeal, time: time);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
fillSatiety({
|
||||
required int diaryId,
|
||||
required int satiety,
|
||||
}) async {
|
||||
await diaryRepository.fillSatiety(
|
||||
diaryId: diaryId,
|
||||
mealId: selectedMeal,
|
||||
satiety: satiety,
|
||||
);
|
||||
fillWakeup({required int diaryId, required String time}) async {
|
||||
await diaryRepository.fillWakeup(diaryId: diaryId, time: time);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
fillRetire({required int diaryId, required String time}) async {
|
||||
await diaryRepository.fillRetire(diaryId: diaryId, time: time);
|
||||
await fetchDiary();
|
||||
}
|
||||
|
||||
fillSatiety({required int diaryId, required int satiety}) async {
|
||||
await diaryRepository.fillSatiety(diaryId: diaryId, mealId: selectedMeal, satiety: satiety);
|
||||
}
|
||||
|
||||
fillMood({required int diaryId, required int mood}) async {
|
||||
await diaryRepository.fillMood(diaryId: diaryId, mealId: selectedMeal, mood: mood);
|
||||
}
|
||||
|
||||
fillComment(String comment) {
|
||||
emit((state as DiaryStateLoaded).copyWith(diary: (state as DiaryStateLoaded).diary.copyWith(comment: comment)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user