removed 'Ingredient' entity, and removed 'method' from yaml shema
This commit is contained in:
parent
592c6f8b7e
commit
bdd09a9a3a
6 changed files with 75 additions and 101 deletions
|
@ -3,20 +3,18 @@ recipe:
|
||||||
description: >
|
description: >
|
||||||
A Neapolitan Style pizza with a multi day cold rise
|
A Neapolitan Style pizza with a multi day cold rise
|
||||||
ingredients:
|
ingredients:
|
||||||
method: ratio
|
- name: flour
|
||||||
items:
|
unit: g
|
||||||
- name: flour
|
value: 0.595
|
||||||
unit: g
|
- name: water
|
||||||
value: 0.595
|
unit: ml
|
||||||
- name: water
|
value: 0.386
|
||||||
unit: ml
|
- name: salt
|
||||||
value: 0.386
|
unit: g
|
||||||
- name: salt
|
value: 0.0178
|
||||||
unit: g
|
- name: yeast
|
||||||
value: 0.0178
|
unit: g
|
||||||
- name: yeast
|
value: 0.0012
|
||||||
unit: g
|
|
||||||
value: 0.0012
|
|
||||||
steps:
|
steps:
|
||||||
- name: Make the dough
|
- name: Make the dough
|
||||||
wait:
|
wait:
|
||||||
|
|
|
@ -3,20 +3,18 @@ recipe:
|
||||||
description: >
|
description: >
|
||||||
A Neapolitan Style pizza with a multi day cold rise
|
A Neapolitan Style pizza with a multi day cold rise
|
||||||
ingredients:
|
ingredients:
|
||||||
method: ratio
|
- name: flour
|
||||||
items:
|
unit: g
|
||||||
- name: flour
|
value: 0.595
|
||||||
unit: g
|
- name: water
|
||||||
value: 0.595
|
unit: ml
|
||||||
- name: water
|
value: 0.386
|
||||||
unit: ml
|
- name: salt
|
||||||
value: 0.386
|
unit: g
|
||||||
- name: salt
|
value: 0.0178
|
||||||
unit: g
|
- name: yeast
|
||||||
value: 0.0178
|
unit: g
|
||||||
- name: yeast
|
value: 0.0012
|
||||||
unit: g
|
|
||||||
value: 0.0012
|
|
||||||
steps:
|
steps:
|
||||||
- name: Make the dough
|
- name: Make the dough
|
||||||
wait:
|
wait:
|
||||||
|
|
|
@ -3,20 +3,18 @@ recipe:
|
||||||
description: >
|
description: >
|
||||||
A Neapolitan Style pizza prepared in a day
|
A Neapolitan Style pizza prepared in a day
|
||||||
ingredients:
|
ingredients:
|
||||||
method: ratio
|
- name: flour
|
||||||
items:
|
unit: g
|
||||||
- name: flour
|
value: 0.595
|
||||||
unit: g
|
- name: water
|
||||||
value: 0.595
|
unit: ml
|
||||||
- name: water
|
value: 0.386
|
||||||
unit: ml
|
- name: salt
|
||||||
value: 0.386
|
unit: g
|
||||||
- name: salt
|
value: 0.0178
|
||||||
unit: g
|
- name: yeast
|
||||||
value: 0.0178
|
unit: g
|
||||||
- name: yeast
|
value: 0.0012
|
||||||
unit: g
|
|
||||||
value: 0.0012
|
|
||||||
steps:
|
steps:
|
||||||
- name: Make the dough
|
- name: Make the dough
|
||||||
wait:
|
wait:
|
||||||
|
|
|
@ -3,20 +3,18 @@ recipe:
|
||||||
description: >
|
description: >
|
||||||
A Neapolitan Style pizza prepared in a day
|
A Neapolitan Style pizza prepared in a day
|
||||||
ingredients:
|
ingredients:
|
||||||
method: ratio
|
- name: flour
|
||||||
items:
|
unit: g
|
||||||
- name: flour
|
value: 0.545
|
||||||
unit: g
|
- name: water
|
||||||
value: 0.545
|
unit: ml
|
||||||
- name: water
|
value: 0.436
|
||||||
unit: ml
|
- name: salt
|
||||||
value: 0.436
|
unit: g
|
||||||
- name: salt
|
value: 0.0178
|
||||||
unit: g
|
- name: yeast
|
||||||
value: 0.0178
|
unit: g
|
||||||
- name: yeast
|
value: 0.0012
|
||||||
unit: g
|
|
||||||
value: 0.0012
|
|
||||||
steps:
|
steps:
|
||||||
- name: Make the dough
|
- name: Make the dough
|
||||||
wait:
|
wait:
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:pizzaplanner/entities/PizzaRecipe/Ingredient.dart';
|
|
||||||
|
|
||||||
class Ingredients {
|
|
||||||
final Map<String, Ingredient> ingredients;
|
|
||||||
final String method;
|
|
||||||
|
|
||||||
Ingredients(this.ingredients, this.method);
|
|
||||||
|
|
||||||
Table getIngredientsTable(int pizzaCount, int doughBallSize) {
|
|
||||||
return Table(
|
|
||||||
border: TableBorder.all(),
|
|
||||||
columnWidths: const <int, TableColumnWidth>{
|
|
||||||
0: FlexColumnWidth(2),
|
|
||||||
1: FlexColumnWidth(1),
|
|
||||||
2: FlexColumnWidth(2),
|
|
||||||
},
|
|
||||||
children: <TableRow>[
|
|
||||||
TableRow(
|
|
||||||
children: <TableCell>[
|
|
||||||
TableCell(child: Center(child: Text("Ingredient"))),
|
|
||||||
TableCell(child: Center(child: Text("Per Ball"))),
|
|
||||||
TableCell(child: Center(child: Text("Total"))),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
] +
|
|
||||||
ingredients.values.map((ingredient) =>
|
|
||||||
ingredient.getIngredientTableRow(pizzaCount, doughBallSize))
|
|
||||||
.toList()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,14 +11,34 @@ import 'package:yaml/yaml.dart';
|
||||||
class PizzaRecipe {
|
class PizzaRecipe {
|
||||||
final String name;
|
final String name;
|
||||||
final String description;
|
final String description;
|
||||||
final Ingredients ingredients;
|
final List<Ingredient> ingredients;
|
||||||
|
|
||||||
final List<RecipeStep> recipeSteps;
|
final List<RecipeStep> recipeSteps;
|
||||||
|
|
||||||
PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps);
|
PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps);
|
||||||
|
|
||||||
Widget getIngredientsTable(int pizzaCount, int doughBallSize){
|
Table getIngredientsTable(int pizzaCount, int doughBallSize) {
|
||||||
return ingredients.getIngredientsTable(pizzaCount, doughBallSize);
|
return Table(
|
||||||
|
border: TableBorder.all(),
|
||||||
|
columnWidths: const <int, TableColumnWidth>{
|
||||||
|
0: FlexColumnWidth(2),
|
||||||
|
1: FlexColumnWidth(1),
|
||||||
|
2: FlexColumnWidth(2),
|
||||||
|
},
|
||||||
|
children: <TableRow>[
|
||||||
|
TableRow(
|
||||||
|
children: <TableCell>[
|
||||||
|
TableCell(child: Center(child: Text("Ingredient"))),
|
||||||
|
TableCell(child: Center(child: Text("Per Ball"))),
|
||||||
|
TableCell(child: Center(child: Text("Total"))),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
] +
|
||||||
|
ingredients.map((ingredient) =>
|
||||||
|
ingredient.getIngredientTableRow(pizzaCount, doughBallSize))
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<PizzaRecipe> fromYaml(yamlPath) async{
|
static Future<PizzaRecipe> fromYaml(yamlPath) async{
|
||||||
|
@ -29,14 +49,9 @@ class PizzaRecipe {
|
||||||
String name = recipe["name"];
|
String name = recipe["name"];
|
||||||
String description = recipe["description"];
|
String description = recipe["description"];
|
||||||
|
|
||||||
YamlMap ingredientsBlock = recipe["ingredients"];
|
YamlList ingredients = recipe["ingredients"];;
|
||||||
String ingredientMethod = ingredientsBlock["method"];
|
|
||||||
YamlList ingredients = ingredientsBlock["items"];
|
|
||||||
|
|
||||||
var newIngredients = Map<String, Ingredient>.fromIterable(ingredients,
|
List<Ingredient> newIngredients = ingredients.map((ingredient) => Ingredient(ingredient["name"], ingredient["unit"], ingredient["value"])).toList();
|
||||||
key: (ingredient) => ingredient["name"],
|
|
||||||
value: (ingredient) => Ingredient(ingredient["name"], ingredient["unit"], ingredient["value"])
|
|
||||||
);
|
|
||||||
|
|
||||||
YamlList steps = recipe["steps"];
|
YamlList steps = recipe["steps"];
|
||||||
var newRecipeSteps = List.generate(steps.length, (i) {
|
var newRecipeSteps = List.generate(steps.length, (i) {
|
||||||
|
@ -77,7 +92,7 @@ class PizzaRecipe {
|
||||||
return PizzaRecipe(
|
return PizzaRecipe(
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
Ingredients(newIngredients, ingredientMethod),
|
newIngredients,
|
||||||
newRecipeSteps
|
newRecipeSteps
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +106,7 @@ class PizzaRecipe {
|
||||||
}
|
}
|
||||||
|
|
||||||
String toString() {
|
String toString() {
|
||||||
return "PizzaRecipe(${this.name}, ${this.ingredients.ingredients.length}, ${this.recipeSteps.length})";
|
return "PizzaRecipe(${this.name}, ${this.ingredients.length}, ${this.recipeSteps.length})";
|
||||||
}
|
}
|
||||||
|
|
||||||
Table getStepTimeTable(DateTime startTime) {
|
Table getStepTimeTable(DateTime startTime) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue