diff --git a/lib/entities/PizzaRecipe/Ingredient.dart b/lib/entities/PizzaRecipe/Ingredient.dart index 1d2bceb..53e7f1c 100644 --- a/lib/entities/PizzaRecipe/Ingredient.dart +++ b/lib/entities/PizzaRecipe/Ingredient.dart @@ -25,13 +25,21 @@ class Ingredient extends HiveObject { return TableRow( children: [ TableCell(child: Center(child: Text("${this.name.capitalize()}"))), - TableCell(child: Center(child: Text("${this.getAbsolute(doughBallSize)}$unit"))), - TableCell(child: Center(child: Text("${this.getAbsolute(pizzaCount * doughBallSize)}$unit"))), + TableCell(child: Center(child: Text("${this.getAbsoluteString(doughBallSize)}$unit"))), + TableCell(child: Center(child: Text("${this.getAbsoluteString(pizzaCount * doughBallSize)}$unit"))), ], ); } - int getAbsolute(int weight) { - return (this.value * weight).toInt(); + double getAbsolute(int weight) { + return (this.value * weight); + } + + String getAbsoluteString(int weight){ + double ingredientWeight = this.getAbsolute(weight); + if (this.value < 0.05){ + return ingredientWeight.toStringAsFixed(2); + } + return ingredientWeight.toStringAsFixed(0); } } \ No newline at end of file diff --git a/lib/pages/PizzaEventPage.dart b/lib/pages/PizzaEventPage.dart index eefda3f..0f4a01b 100644 --- a/lib/pages/PizzaEventPage.dart +++ b/lib/pages/PizzaEventPage.dart @@ -108,7 +108,7 @@ class PizzaEventPageState extends State { return TableRow( children: [ TableCell(child: Text(ingredient.name)), - TableCell(child: Text("${ingredient.getAbsolute(totalWeight)}")), + TableCell(child: Text("${ingredient.getAbsoluteString(totalWeight)}")), TableCell(child: Center(child: Checkbox( value: ingredient.bought, onChanged: (bool? newValue) { diff --git a/todo.md b/todo.md index 6474a38..db7f71c 100644 --- a/todo.md +++ b/todo.md @@ -5,6 +5,5 @@ - make the recipeStep+substep page from a notification - PageView with 'complete' button that completes steps -- add decimals to ingredients table when below a certain % or <5g whatever - theres a bug when waiting on the confirmation screen for a new pizza event too long, where the scheduled date is in the past \ No newline at end of file