forked from eatvio/eatvio_app
feat(diary): add gallery
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:io';
|
||||
import 'package:eatvio_app/features/diary/models/diary_day_model.dart';
|
||||
import 'package:eatvio_app/features/diary/services/diary_service.dart';
|
||||
|
||||
@@ -66,4 +67,39 @@ class DiaryRepository {
|
||||
portionId: portionId,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> uploadPhotos({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required List<File> files,
|
||||
}) async {
|
||||
try {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
await diaryService.uploadPhotoOfMeal(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
photo: files[i],
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> deletePhoto({
|
||||
required int diaryId,
|
||||
required int mealId,
|
||||
required DiaryPhotoModel photo,
|
||||
}) async {
|
||||
try {
|
||||
await diaryService.deletePhotoOfMeal(
|
||||
diaryId: diaryId,
|
||||
mealId: mealId,
|
||||
id: photo.id,
|
||||
path: photo.path,
|
||||
);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user