completed the pizza event page (for now)
This commit is contained in:
parent
59843328c2
commit
f8285159cf
1 changed files with 72 additions and 30 deletions
|
@ -3,9 +3,12 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
|||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaEvent.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/Ingredient.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/RecipeStep.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/RecipeSubStep.dart';
|
||||
import 'package:pizzaplanner/main.dart';
|
||||
import 'package:pizzaplanner/util.dart';
|
||||
import 'package:pizzaplanner/widgets/PizzaRecipeWidget.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class PizzaEventPage extends StatefulWidget {
|
||||
|
@ -33,11 +36,20 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
|||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
flex: 10,
|
||||
flex: 15,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text(this.widget.pizzaEvent.name),
|
||||
Text(getTimeRemainingString(this.widget.pizzaEvent.dateTime))
|
||||
Text(getTimeRemainingString(this.widget.pizzaEvent.dateTime)),
|
||||
Container(
|
||||
color: Colors.blue,
|
||||
child: TextButton(
|
||||
child: Text(this.widget.pizzaEvent.recipe.name, style: TextStyle(color: Colors.white)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, "/event/recipe", arguments: this.widget.pizzaEvent);
|
||||
},
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -46,45 +58,75 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
|||
flex: 80,
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
MarkdownBody(
|
||||
data: this.widget.pizzaEvent.recipe.description,
|
||||
onTapLink: (text, url, title) {
|
||||
launch(url!);
|
||||
Center(
|
||||
child: Text("Ingredients")
|
||||
),
|
||||
Table(
|
||||
columnWidths: const <int, TableColumnWidth>{
|
||||
0: FlexColumnWidth(5),
|
||||
1: FlexColumnWidth(5),
|
||||
3: FlexColumnWidth(1),
|
||||
},
|
||||
children: <TableRow>[
|
||||
TableRow(
|
||||
children: <TableCell>[
|
||||
TableCell(child: Text("Ingredient")),
|
||||
TableCell(child: Text("Total")),
|
||||
TableCell(child: Center(child: Text("0/4")))
|
||||
]
|
||||
)
|
||||
] + this.widget.pizzaEvent.recipe.ingredients.map((ingredient) => buildIngredientWidget(ingredient)).toList(),
|
||||
),
|
||||
Table(
|
||||
columnWidths: const <int, TableColumnWidth>{
|
||||
0: FlexColumnWidth(5),
|
||||
1: FlexColumnWidth(5),
|
||||
2: FlexColumnWidth(1),
|
||||
},
|
||||
children: <TableRow>[
|
||||
TableRow(
|
||||
children: <TableCell>[
|
||||
TableCell(child: Text("Recipe Step")),
|
||||
TableCell(child: Text("When")),
|
||||
TableCell(child: Text("$completedRecipeStepCount/$recipeStepCount")),
|
||||
]
|
||||
)
|
||||
] + this.widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) => buildRecipeStepWhenWidget(recipeStep)).toList()
|
||||
),
|
||||
Divider(),
|
||||
this.widget.pizzaEvent.recipe.getIngredientsTable(this.widget.pizzaEvent.pizzaCount, this.widget.pizzaEvent.doughBallSize),
|
||||
] + this.widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) => buildRecipeStepWhenWidget(recipeStep)).toList()
|
||||
]
|
||||
)
|
||||
),
|
||||
Expanded(
|
||||
flex: 10,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(10),
|
||||
color: Colors.blue,
|
||||
child: TextButton(
|
||||
child: Text("Start", style: TextStyle(color: Colors.white)),
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, "/event/recipe", arguments: this.widget.pizzaEvent);
|
||||
},
|
||||
)
|
||||
)
|
||||
),
|
||||
],
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildRecipeStepWhenWidget(RecipeStep recipeStep){
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(recipeStep.name),
|
||||
// TODO add when todo/when completed
|
||||
Icon(recipeStep.completed ? FontAwesome5.check : FontAwesome5.clock)
|
||||
],
|
||||
TableRow buildIngredientWidget(Ingredient ingredient){
|
||||
int totalWeight = this.widget.pizzaEvent.pizzaCount * this.widget.pizzaEvent.doughBallSize;
|
||||
return TableRow(
|
||||
children: <TableCell>[
|
||||
TableCell(child: Text(ingredient.name)),
|
||||
TableCell(child: Text("${ingredient.getAbsolute(totalWeight)}")),
|
||||
TableCell(child: Center(child: Checkbox(
|
||||
value: ingredient.bought,
|
||||
onChanged: (bool? newValue) {
|
||||
setState((){ingredient.bought = newValue!;});
|
||||
this.widget.pizzaEvent.save();
|
||||
},
|
||||
))),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
TableRow buildRecipeStepWhenWidget(RecipeStep recipeStep){
|
||||
return TableRow(
|
||||
children: <TableCell>[
|
||||
TableCell(child: Text(recipeStep.name)),
|
||||
TableCell(child: Text(getDateFormat().format(recipeStep.dateTime))),
|
||||
TableCell(child: Center(child: Icon(recipeStep.completed ? FontAwesome5.check : FontAwesome5.clock))),
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue