a button is shown on the pizza event page when a recipe step is due and not yet completed
This commit is contained in:
parent
453926e6d3
commit
f7bc15d18a
2 changed files with 33 additions and 1 deletions
|
@ -7,6 +7,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/ingredient.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_substep.dart';
|
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_substep.dart';
|
||||||
import 'package:pizzaplanner/main.dart';
|
import 'package:pizzaplanner/main.dart';
|
||||||
|
import 'package:pizzaplanner/pages/recipe_step_instruction_page.dart';
|
||||||
import 'package:pizzaplanner/pages/scaffold.dart';
|
import 'package:pizzaplanner/pages/scaffold.dart';
|
||||||
import 'package:pizzaplanner/util.dart';
|
import 'package:pizzaplanner/util.dart';
|
||||||
import 'package:pizzaplanner/widgets/pizza_recipe_widget.dart';
|
import 'package:pizzaplanner/widgets/pizza_recipe_widget.dart';
|
||||||
|
@ -27,6 +28,21 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final recipeStepCount = widget.pizzaEvent.recipe.recipeSteps.length;
|
final recipeStepCount = widget.pizzaEvent.recipe.recipeSteps.length;
|
||||||
final completedRecipeStepCount = widget.pizzaEvent.recipe.recipeSteps.where((recipeStep) => recipeStep.completed).length;
|
final completedRecipeStepCount = widget.pizzaEvent.recipe.recipeSteps.where((recipeStep) => recipeStep.completed).length;
|
||||||
|
|
||||||
|
RecipeStep? firstStepDue;
|
||||||
|
for (final recipeStep in widget.pizzaEvent.recipe.recipeSteps){
|
||||||
|
if (recipeStep.completed){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (recipeStep.dateTime.isAfter(DateTime.now())){
|
||||||
|
print("step before now continue ${recipeStep.name}");
|
||||||
|
print("${recipeStep.dateTime} ${DateTime.now()}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
firstStepDue = recipeStep;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return PizzaPlannerScaffold(
|
return PizzaPlannerScaffold(
|
||||||
title: Text(widget.pizzaEvent.name),
|
title: Text(widget.pizzaEvent.name),
|
||||||
body: Column(
|
body: Column(
|
||||||
|
@ -90,6 +106,23 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
] + widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) => buildRecipeStepWhenWidget(recipeStep)).toList()
|
] + widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) => buildRecipeStepWhenWidget(recipeStep)).toList()
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
|
if (firstStepDue != null) Container(
|
||||||
|
color: Colors.blue,
|
||||||
|
width: double.infinity,
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.pushNamed(
|
||||||
|
context,
|
||||||
|
"/event/recipe_step",
|
||||||
|
arguments: RecipeStepInstructionPageArguments(
|
||||||
|
widget.pizzaEvent,
|
||||||
|
firstStepDue!
|
||||||
|
)
|
||||||
|
).then((_) => setState((){}));
|
||||||
|
},
|
||||||
|
child: Text("Start '${firstStepDue.name}' now!", style: const TextStyle(color: Colors.white))
|
||||||
|
)
|
||||||
|
) else const SizedBox()
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
1
todo.md
1
todo.md
|
@ -14,6 +14,5 @@
|
||||||
- also do this with hive box names
|
- also do this with hive box names
|
||||||
|
|
||||||
## Bug
|
## Bug
|
||||||
- add option to start recipe step instruction after step datetime and not completed
|
|
||||||
- when deleting recipes, it deletes 2, but not when deleting the last one
|
- when deleting recipes, it deletes 2, but not when deleting the last one
|
||||||
- user should only be able to archive a pizza event that has taken place (dateTime>now)
|
- user should only be able to archive a pizza event that has taken place (dateTime>now)
|
Loading…
Add table
Reference in a new issue