From 20e2f8e6960e54f3644cb5ac7c9878dc7f47a5cd Mon Sep 17 00:00:00 2001 From: broodjeaap89 Date: Sat, 10 Jul 2021 21:44:14 +0200 Subject: [PATCH] added super simple ingredients overview to addPizzaEventPage --- lib/entities/PizzaRecipe/Ingredient.dart | 17 +++++++++++++++++ lib/entities/PizzaRecipe/Ingredients.dart | 9 +++++++++ lib/entities/PizzaRecipe/PizzaRecipe.dart | 9 +++++++++ lib/entities/PizzaRecipe/RecipeStep.dart | 3 ++- lib/pages/AddPizzaEventPage.dart | 2 ++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/entities/PizzaRecipe/Ingredient.dart b/lib/entities/PizzaRecipe/Ingredient.dart index 63fd3b6..02cdd48 100644 --- a/lib/entities/PizzaRecipe/Ingredient.dart +++ b/lib/entities/PizzaRecipe/Ingredient.dart @@ -1,7 +1,24 @@ +import 'package:flutter/material.dart'; + +import 'package:pizzaplanner/util.dart'; + class Ingredient { final String name; final String unit; final double value; Ingredient(this.name, this.unit, this.value); + + Widget getIngredientWidget(int weight){ + return Row( + children: [ + Text("${this.name}: "), + Text("${this.getAbsolute(weight)}$unit") + ], + ); + } + + int getAbsolute(int weight) { + return (this.value * weight).toInt(); + } } \ No newline at end of file diff --git a/lib/entities/PizzaRecipe/Ingredients.dart b/lib/entities/PizzaRecipe/Ingredients.dart index 040d87d..2cab95a 100644 --- a/lib/entities/PizzaRecipe/Ingredients.dart +++ b/lib/entities/PizzaRecipe/Ingredients.dart @@ -1,3 +1,4 @@ +import 'package:flutter/material.dart'; import 'package:pizzaplanner/entities/PizzaRecipe/Ingredient.dart'; class Ingredients { @@ -5,4 +6,12 @@ class Ingredients { final String method; Ingredients(this.ingredients, this.method); + + Widget getIngredientsWidget(int weight) { + return Container( + child: Column( + children: ingredients.values.map((ingredient) => ingredient.getIngredientWidget(weight)).toList() + ) + ); + } } \ No newline at end of file diff --git a/lib/entities/PizzaRecipe/PizzaRecipe.dart b/lib/entities/PizzaRecipe/PizzaRecipe.dart index 784c3c9..8f49054 100644 --- a/lib/entities/PizzaRecipe/PizzaRecipe.dart +++ b/lib/entities/PizzaRecipe/PizzaRecipe.dart @@ -1,3 +1,4 @@ +import 'package:flutter/material.dart'; import 'package:pizzaplanner/entities/PizzaRecipe/Ingredient.dart'; import 'package:pizzaplanner/entities/PizzaRecipe/Ingredients.dart'; @@ -15,6 +16,10 @@ class PizzaRecipe { PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps); + Widget getIngredientsWidget(int weight){ + return ingredients.getIngredientsWidget(weight); + } + static Future fromYaml(yamlPath) async{ String yamlString = await loadAsset(yamlPath); var yaml = loadYaml(yamlString); @@ -39,11 +44,14 @@ class PizzaRecipe { String stepDescription = step["description"]; String waitUnit = "none"; + String waitDescription = ""; int waitMin = 0; int waitMax = 0; if (step.containsKey("wait")) { YamlMap waitMap = step["wait"]; + + waitDescription = waitMap["description"]; waitUnit = waitMap["unit"]; waitMin = waitMap["min"]; waitMax = waitMap["max"]; @@ -57,6 +65,7 @@ class PizzaRecipe { return RecipeStep( stepName, stepDescription, + waitDescription, waitUnit, waitMin, waitMax, diff --git a/lib/entities/PizzaRecipe/RecipeStep.dart b/lib/entities/PizzaRecipe/RecipeStep.dart index 218cd8c..a631f8f 100644 --- a/lib/entities/PizzaRecipe/RecipeStep.dart +++ b/lib/entities/PizzaRecipe/RecipeStep.dart @@ -2,11 +2,12 @@ import 'package:pizzaplanner/entities/PizzaRecipe/RecipeSubStep.dart'; class RecipeStep { final String name; + final String waitDescription; final String waitUnit; final int waitMin; final int waitMax; final String description; final List subSteps; - RecipeStep(this.name, this.description, this.waitUnit, this.waitMin, this.waitMax, this.subSteps); + RecipeStep(this.name, this.waitDescription, this.description, this.waitUnit, this.waitMin, this.waitMax, this.subSteps); } \ No newline at end of file diff --git a/lib/pages/AddPizzaEventPage.dart b/lib/pages/AddPizzaEventPage.dart index a0600f5..5a3e23c 100644 --- a/lib/pages/AddPizzaEventPage.dart +++ b/lib/pages/AddPizzaEventPage.dart @@ -151,6 +151,8 @@ class AddPizzaEventPageState extends State { ) ] ), + Divider(), + this.initialized ? this.pizzaRecipe.getIngredientsWidget(this.doughBallSize * this.pizzaCount) : Container(), Spacer(), SizedBox( width: double.infinity,