diff --git a/lib/pages/edit_recipe_page.dart b/lib/pages/edit_recipe_page.dart index d643684..662833f 100644 --- a/lib/pages/edit_recipe_page.dart +++ b/lib/pages/edit_recipe_page.dart @@ -188,6 +188,12 @@ class EditRecipePageState extends State { ), TextButton( onPressed: () async { + // Normalize ratios so they add up to 1 + final totalRatio = pizzaRecipe.ingredients.map((ingredient) => ingredient.value).reduce((a, b) => a + b); + for (final ingredient in pizzaRecipe.ingredients){ + ingredient.value = ingredient.value / totalRatio; + } + if (pizzaRecipe.isInBox){ pizzaRecipe.save(); } else { diff --git a/todo.md b/todo.md index 66b0b12..3c2433b 100644 --- a/todo.md +++ b/todo.md @@ -15,6 +15,5 @@ ## Bug - add option to start recipe step instruction after step datetime and not completed -- recalculate ingredient ratios to total=1 before saving when creating/editing recipes - when deleting recipes, it deletes 2, but not when deleting the last one - user should only be able to archive a pizza event that has taken place (dateTime>now) \ No newline at end of file