@@ -4,29 +4,33 @@ import 'drink_repository.dart';
44
55/// Implementation of DrinkRepository using API services
66///
7- /// Delegates to BeerApiService, FavoritesService, and RatingsService .
7+ /// Delegates to BeerApiService, FavoritesService, RatingsService, and TastingLogService .
88class ApiDrinkRepository implements DrinkRepository {
99 final BeerApiService _apiService;
1010 final FavoritesService _favoritesService;
1111 final RatingsService _ratingsService;
12+ final TastingLogService _tastingLogService;
1213
1314 ApiDrinkRepository ({
1415 required BeerApiService apiService,
1516 required FavoritesService favoritesService,
1617 required RatingsService ratingsService,
18+ required TastingLogService tastingLogService,
1719 }) : _apiService = apiService,
1820 _favoritesService = favoritesService,
19- _ratingsService = ratingsService;
21+ _ratingsService = ratingsService,
22+ _tastingLogService = tastingLogService;
2023
2124 @override
2225 Future <List <Drink >> getDrinks (Festival festival) async {
2326 final drinks = await _apiService.fetchAllDrinks (festival);
2427
25- // Populate favorite status and ratings in a single pass
28+ // Populate favorite status, ratings, and tasted status in a single pass
2629 final favorites = _favoritesService.getFavorites (festival.id);
2730 for (final drink in drinks) {
2831 drink.isFavorite = favorites.contains (drink.id);
2932 drink.rating = _ratingsService.getRating (festival.id, drink.id);
33+ drink.isTasted = _tastingLogService.hasTasted (festival.id, drink.id);
3034 }
3135
3236 return drinks;
@@ -56,4 +60,20 @@ class ApiDrinkRepository implements DrinkRepository {
5660 Future <void > removeRating (String festivalId, String drinkId) {
5761 return _ratingsService.removeRating (festivalId, drinkId);
5862 }
63+
64+ @override
65+ Future <bool > hasTasted (String festivalId, String drinkId) {
66+ return Future .value (_tastingLogService.hasTasted (festivalId, drinkId));
67+ }
68+
69+ @override
70+ Future <bool > toggleTasted (String festivalId, String drinkId) async {
71+ await _tastingLogService.toggleTasted (festivalId, drinkId);
72+ return _tastingLogService.hasTasted (festivalId, drinkId);
73+ }
74+
75+ @override
76+ Future <List <String >> getTastedDrinks (String festivalId) {
77+ return Future .value (_tastingLogService.getTastedDrinkIds (festivalId));
78+ }
5979}
0 commit comments