9fe85a719c
Test Suite / test (24.15.0) (push) Has been cancelled
- Added RecipeAnalysisService to handle recipe ingredient analysis, including methods for checking ingredient availability and calculating quantities. - Introduced new TypeScript definitions for recipe analysis results, including ingredient status and summary. - Created corresponding Dart models for recipe analysis, including RecipeIngredientAnalysis, RecipeAnalysisSummary, and RecipeShoppingCandidate. - Updated Flutter UI to reflect changes in ingredient availability status. - Fixed color opacity issue in recipe image card.
53 lines
1.6 KiB
Dart
53 lines
1.6 KiB
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../../core/api/api_providers.dart';
|
|
import '../../../core/api/guarded_api_call.dart';
|
|
import '../../../features/auth/data/auth_providers.dart';
|
|
import '../domain/recipe.dart';
|
|
import '../domain/inventory_preview.dart';
|
|
import '../domain/recipe_analysis.dart';
|
|
import 'recipe_repository.dart';
|
|
|
|
final recipeRepositoryProvider = Provider<RecipeRepository>((ref) {
|
|
return RecipeRepository(ref.watch(apiClientProvider));
|
|
});
|
|
|
|
final recipesProvider = FutureProvider<List<Recipe>>((ref) async {
|
|
final token = await ref.watch(authStateProvider.future);
|
|
return guardedApiCall(
|
|
ref,
|
|
() => ref.read(recipeRepositoryProvider).fetchRecipes(token: token),
|
|
);
|
|
});
|
|
|
|
final recipeDetailProvider =
|
|
FutureProvider.family<Recipe, int>((ref, id) async {
|
|
final token = await ref.watch(authStateProvider.future);
|
|
return guardedApiCall(
|
|
ref,
|
|
() => ref.read(recipeRepositoryProvider).fetchRecipeDetail(id, token: token),
|
|
);
|
|
});
|
|
|
|
final inventoryPreviewProvider =
|
|
FutureProvider.family<InventoryPreview, int>((ref, id) async {
|
|
final token = await ref.watch(authStateProvider.future);
|
|
return guardedApiCall(
|
|
ref,
|
|
() => ref
|
|
.read(recipeRepositoryProvider)
|
|
.fetchInventoryPreview(id, token: token),
|
|
);
|
|
});
|
|
|
|
final recipeAnalysisProvider =
|
|
FutureProvider.family<RecipeAnalysis, int>((ref, id) async {
|
|
final token = await ref.watch(authStateProvider.future);
|
|
return guardedApiCall(
|
|
ref,
|
|
() => ref
|
|
.read(recipeRepositoryProvider)
|
|
.fetchRecipeAnalysis(id, token: token),
|
|
);
|
|
});
|