From b912210bbd329eeeb3d092141f385c49be7abc2e Mon Sep 17 00:00:00 2001 From: Reimar Date: Thu, 15 May 2025 10:17:56 +0200 Subject: [PATCH 1/2] Don't return error on empty recipe list --- backend/API/BusinessLogic/RecipeLogic.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/API/BusinessLogic/RecipeLogic.cs b/backend/API/BusinessLogic/RecipeLogic.cs index 3486171..4a286a1 100644 --- a/backend/API/BusinessLogic/RecipeLogic.cs +++ b/backend/API/BusinessLogic/RecipeLogic.cs @@ -21,7 +21,7 @@ namespace API.BusinessLogic public async Task GetRecipes(int userId) { var recipes = await _dbAccess.ReadRecipes(userId); - if (recipes == null || recipes.Count == 0) { return new ConflictObjectResult(new { message = "Could not find any recipes" }); } + if (recipes == null) { return new ConflictObjectResult(new { message = "Could not find any recipes" }); } var recipeDtos = recipes.Select(r => new GetAllRecipesDTO { From a175e1ad3ee7f80870a4c769770125e25668aee9 Mon Sep 17 00:00:00 2001 From: Reimar Date: Thu, 15 May 2025 11:07:52 +0200 Subject: [PATCH 2/2] Create progress bar and empty text for dishes list --- .../easyeat/ui/dishes/DishesFragment.kt | 13 ++++++++ .../src/main/res/layout/fragment_dishes.xml | 33 +++++++++++++++---- app/app/src/main/res/values/strings.xml | 1 + 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/DishesFragment.kt b/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/DishesFragment.kt index b80f99a..5d8d56a 100644 --- a/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/DishesFragment.kt +++ b/app/app/src/main/java/tech/mercantec/easyeat/ui/dishes/DishesFragment.kt @@ -68,7 +68,13 @@ class DishesFragment : Fragment() { return root } + fun DishesFragment.loadRecipes() { + binding.dishesList.visibility = View.GONE + binding.emptyDishesList.visibility = View.GONE + binding.addDish.visibility = View.GONE + binding.loading.visibility = View.VISIBLE + thread { val recipes: List try { @@ -85,6 +91,13 @@ class DishesFragment : Fragment() { } activity?.runOnUiThread { + binding.dishesList.visibility = View.VISIBLE + binding.emptyDishesList.visibility = View.VISIBLE + binding.addDish.visibility = View.VISIBLE + binding.loading.visibility = View.GONE + + binding.dishesList.emptyView = binding.emptyDishesList + val adapter = DishAdapter(requireContext(), dishes) { selectedDish -> // Open details activity val intent = Intent(requireContext(), DishDetailsActivity::class.java) diff --git a/app/app/src/main/res/layout/fragment_dishes.xml b/app/app/src/main/res/layout/fragment_dishes.xml index 62aca2f..0b80bf9 100644 --- a/app/app/src/main/res/layout/fragment_dishes.xml +++ b/app/app/src/main/res/layout/fragment_dishes.xml @@ -1,26 +1,47 @@ - - + + + android:dividerHeight="1dp" + /> + + - - + app:tint="@android:color/white" + /> + + diff --git a/app/app/src/main/res/values/strings.xml b/app/app/src/main/res/values/strings.xml index aca88ad..7dc3ec3 100644 --- a/app/app/src/main/res/values/strings.xml +++ b/app/app/src/main/res/values/strings.xml @@ -57,6 +57,7 @@ Increment portion count Decrement portion size Edit Recipe + You have not created any dishes yet g