From f7bc15d18ae4542759d6d41c16651c024d1b723d Mon Sep 17 00:00:00 2001 From: broodjeaap89 Date: Tue, 14 Sep 2021 21:28:04 +0200 Subject: [PATCH] a button is shown on the pizza event page when a recipe step is due and not yet completed --- lib/pages/pizza_event_page.dart | 33 +++++++++++++++++++++++++++++++++ todo.md | 1 - 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/pages/pizza_event_page.dart b/lib/pages/pizza_event_page.dart index c7c66df..0598794 100644 --- a/lib/pages/pizza_event_page.dart +++ b/lib/pages/pizza_event_page.dart @@ -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_substep.dart'; import 'package:pizzaplanner/main.dart'; +import 'package:pizzaplanner/pages/recipe_step_instruction_page.dart'; import 'package:pizzaplanner/pages/scaffold.dart'; import 'package:pizzaplanner/util.dart'; import 'package:pizzaplanner/widgets/pizza_recipe_widget.dart'; @@ -27,6 +28,21 @@ class PizzaEventPageState extends State { Widget build(BuildContext context) { final recipeStepCount = widget.pizzaEvent.recipe.recipeSteps.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( title: Text(widget.pizzaEvent.name), body: Column( @@ -90,6 +106,23 @@ class PizzaEventPageState extends State { ] + widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) => buildRecipeStepWhenWidget(recipeStep)).toList() ), 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() ] ) ), diff --git a/todo.md b/todo.md index 3c2433b..1ae68c0 100644 --- a/todo.md +++ b/todo.md @@ -14,6 +14,5 @@ - also do this with hive box names ## 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 - user should only be able to archive a pizza event that has taken place (dateTime>now) \ No newline at end of file