added super simple ingredients overview to addPizzaEventPage
This commit is contained in:
parent
e31edd91af
commit
20e2f8e696
5 changed files with 39 additions and 1 deletions
|
@ -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: <Widget>[
|
||||
Text("${this.name}: "),
|
||||
Text("${this.getAbsolute(weight)}$unit")
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
int getAbsolute(int weight) {
|
||||
return (this.value * weight).toInt();
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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<PizzaRecipe> 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,
|
||||
|
|
|
@ -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<RecipeSubStep> 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);
|
||||
}
|
|
@ -151,6 +151,8 @@ class AddPizzaEventPageState extends State<AddPizzaEventPage> {
|
|||
)
|
||||
]
|
||||
),
|
||||
Divider(),
|
||||
this.initialized ? this.pizzaRecipe.getIngredientsWidget(this.doughBallSize * this.pizzaCount) : Container(),
|
||||
Spacer(),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
|
|
Loading…
Add table
Reference in a new issue