switched to a Table for ingredient widget
This commit is contained in:
parent
3af6cc5bc6
commit
4ad9db0fdf
4 changed files with 28 additions and 10 deletions
|
@ -9,11 +9,12 @@ class Ingredient {
|
|||
|
||||
Ingredient(this.name, this.unit, this.value);
|
||||
|
||||
Widget getIngredientWidget(int weight){
|
||||
return Row(
|
||||
TableRow getIngredientWidget(int pizzaCount, int doughBallSize){
|
||||
return TableRow(
|
||||
children: <Widget>[
|
||||
Text("${this.name.capitalize()}: "),
|
||||
Text("${this.getAbsolute(weight)}$unit")
|
||||
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"))),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,10 +7,27 @@ class Ingredients {
|
|||
|
||||
Ingredients(this.ingredients, this.method);
|
||||
|
||||
Widget getIngredientsWidget(int weight) {
|
||||
Widget getIngredientsWidget(int pizzaCount, int doughBallSize) {
|
||||
return Container(
|
||||
child: Column(
|
||||
children: ingredients.values.map((ingredient) => ingredient.getIngredientWidget(weight)).toList()
|
||||
child: Table(
|
||||
border: TableBorder.all(),
|
||||
columnWidths: const <int, TableColumnWidth>{
|
||||
0: FlexColumnWidth(2),
|
||||
1: FlexColumnWidth(2),
|
||||
2: FlexColumnWidth(2),
|
||||
},
|
||||
children:
|
||||
<TableRow>[
|
||||
TableRow(
|
||||
children: <TableCell>[
|
||||
TableCell(child: Center(child: Text("Ingredient"))),
|
||||
TableCell(child: Center(child: Text("Single Ball"))),
|
||||
TableCell(child: Center(child: Text("Total"))),
|
||||
]
|
||||
)
|
||||
|
||||
] +
|
||||
ingredients.values.map((ingredient) => ingredient.getIngredientWidget(pizzaCount, doughBallSize)).toList()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ class PizzaRecipe {
|
|||
|
||||
PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps);
|
||||
|
||||
Widget getIngredientsWidget(int weight){
|
||||
return ingredients.getIngredientsWidget(weight);
|
||||
Widget getIngredientsWidget(int pizzaCount, int doughBallSize){
|
||||
return ingredients.getIngredientsWidget(pizzaCount, doughBallSize);
|
||||
}
|
||||
|
||||
static Future<PizzaRecipe> fromYaml(yamlPath) async{
|
||||
|
|
|
@ -156,7 +156,7 @@ class AddPizzaEventPageState extends State<AddPizzaEventPage> {
|
|||
]
|
||||
),
|
||||
Divider(),
|
||||
this.initialized ? this.pizzaRecipe.getIngredientsWidget(this.doughBallSize * this.pizzaCount) : Container(),
|
||||
this.initialized ? this.pizzaRecipe.getIngredientsWidget(this.pizzaCount, this.doughBallSize) : Container(),
|
||||
Spacer(),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
|
|
Loading…
Add table
Reference in a new issue