forked from eatvio/eatvio_app
feat: implement recipe drafting functionality and refactor MyRecipesTab to be stateless
This commit is contained in:
@@ -11,6 +11,7 @@ class MyRecipesCubit extends Cubit<MyRecipesState> {
|
||||
|
||||
static const String active = 'active';
|
||||
static const String archived = 'archived';
|
||||
static const String drafted = 'drafted';
|
||||
|
||||
MyRecipesCubit({
|
||||
required this.myRecipesRepository,
|
||||
@@ -50,6 +51,17 @@ class MyRecipesCubit extends Cubit<MyRecipesState> {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setDraftedState() async {
|
||||
emit(const MyRecipesState.loading());
|
||||
try {
|
||||
final myRecipes = await myRecipesRepository.getMyRecipes();
|
||||
final List<MyRecipeModel> draftedRecipes = myRecipes.where((recipe) => recipe.state == drafted).toList();
|
||||
emit(MyRecipesState.loaded(recipes: draftedRecipes, selectedState: drafted));
|
||||
} catch (e) {
|
||||
emit(const MyRecipesState.error());
|
||||
}
|
||||
}
|
||||
|
||||
Future<Recipe> getRecipeById(String slug) async {
|
||||
return await aboutRecipeRepository.getRecipe(slug);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user