normalize ingredient ratios to add up to 1
This commit is contained in:
parent
231b83ba17
commit
453926e6d3
2 changed files with 6 additions and 1 deletions
|
@ -188,6 +188,12 @@ class EditRecipePageState extends State<EditRecipePage> {
|
|||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
// Normalize ratios so they add up to 1
|
||||
final totalRatio = pizzaRecipe.ingredients.map<double>((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 {
|
||||
|
|
1
todo.md
1
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)
|
Loading…
Add table
Reference in a new issue