diff --git a/lib/entities/PizzaRecipe/PizzaRecipe.dart b/lib/entities/PizzaRecipe/PizzaRecipe.dart index 2e9b529..94540d1 100644 --- a/lib/entities/PizzaRecipe/PizzaRecipe.dart +++ b/lib/entities/PizzaRecipe/PizzaRecipe.dart @@ -61,9 +61,9 @@ class PizzaRecipe extends HiveObject { return stepCount; } - Widget getPizzaEventRecipeWidget(PizzaEventPageState pizzaEventPage) { + Widget getPizzaEventRecipeWidget(BuildContext context, PizzaEventPageState pizzaEventPage) { return ListView( - children: this.recipeSteps.map((recipeStep) => recipeStep.buildPizzaEventRecipeStepWidget(pizzaEventPage)).toList() + children: this.recipeSteps.map((recipeStep) => recipeStep.buildPizzaEventRecipeStepWidget(context, pizzaEventPage)).toList() ); } diff --git a/lib/entities/PizzaRecipe/RecipeStep.dart b/lib/entities/PizzaRecipe/RecipeStep.dart index 2429604..5a36ece 100644 --- a/lib/entities/PizzaRecipe/RecipeStep.dart +++ b/lib/entities/PizzaRecipe/RecipeStep.dart @@ -47,13 +47,13 @@ class RecipeStep extends HiveObject { completedOn != null; } - Widget buildPizzaEventRecipeStepWidget(PizzaEventPageState pizzaEventPage){ + Widget buildPizzaEventRecipeStepWidget(BuildContext context, PizzaEventPageState pizzaEventPage){ return this.subSteps.length > 0 ? - buildPizzaEventRecipeStepWidgetWithSubSteps(pizzaEventPage) : - buildPizzaEventRecipeStepWidgetWithoutSubSteps(pizzaEventPage); + buildPizzaEventRecipeStepWidgetWithSubSteps(context, pizzaEventPage) : + buildPizzaEventRecipeStepWidgetWithoutSubSteps(context, pizzaEventPage); } - Widget buildPizzaEventRecipeStepWidgetWithSubSteps(PizzaEventPageState pizzaEventPage) { + Widget buildPizzaEventRecipeStepWidgetWithSubSteps(BuildContext context, PizzaEventPageState pizzaEventPage) { int recipeSubStepsCompleted = this.subSteps.where((subStep) => subStep.completed).length; int recipeSubSteps = this.subSteps.length; return ExpansionTile( @@ -68,11 +68,11 @@ class RecipeStep extends HiveObject { children: [ Text(this.description), - ] + subSteps.map((subStep) => subStep.buildPizzaEventSubStepWidget(pizzaEventPage)).toList() + ] + subSteps.map((subStep) => subStep.buildTest(context, pizzaEventPage)).toList() //subStep.buildPizzaEventSubStepWidget(context, pizzaEventPage)).toList() ); } - Widget buildPizzaEventRecipeStepWidgetWithoutSubSteps(PizzaEventPageState pizzaEventPage) { + Widget buildPizzaEventRecipeStepWidgetWithoutSubSteps(BuildContext context, PizzaEventPageState pizzaEventPage) { return ExpansionTile( title: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/lib/entities/PizzaRecipe/RecipeSubStep.dart b/lib/entities/PizzaRecipe/RecipeSubStep.dart index 2375091..f36e3eb 100644 --- a/lib/entities/PizzaRecipe/RecipeSubStep.dart +++ b/lib/entities/PizzaRecipe/RecipeSubStep.dart @@ -20,7 +20,7 @@ class RecipeSubStep extends HiveObject { RecipeSubStep(this.name, this.description); - Widget buildPizzaEventSubStepWidget(PizzaEventPageState pizzaEventPage) { + Widget buildPizzaEventSubStepWidget(BuildContext context, PizzaEventPageState pizzaEventPage) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -43,4 +43,58 @@ class RecipeSubStep extends HiveObject { ], ); } + + Widget buildTest(BuildContext context, PizzaEventPageState pizzaEventPage){ + return InkWell( + onTap: () { + showDialog( + context: context, + builder: (context) { + return getDialog(context); + } + ); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(this.name), + Checkbox( + value: this.completed, + onChanged: (b) {}, + ) + ], + ), + ); + } + + Widget getDialog(BuildContext context){ + return Dialog( + insetPadding: EdgeInsets.all(10), + child: Container( + padding: EdgeInsets.all(10), + child: Column( + children: [ + Text(this.name), + Text(this.description), + Expanded( + child: Container() + ), + SizedBox( + width: double.infinity, + height: 70, + child: Container( + color: this.completed ? Colors.green : Colors.redAccent, + child: TextButton( + child: Text(this.completed ? "Complete" : "Todo", style: TextStyle(color: Colors.white)), + onPressed: () { + this.completedOn = this.completed ? null : DateTime.now(); + }, + ) + ) + ) + ] + ) + ) + ); + } } \ No newline at end of file diff --git a/lib/pages/PizzaEventPage.dart b/lib/pages/PizzaEventPage.dart index 2d619a3..55cce4d 100644 --- a/lib/pages/PizzaEventPage.dart +++ b/lib/pages/PizzaEventPage.dart @@ -21,7 +21,7 @@ class PizzaEventPageState extends State { resizeToAvoidBottomInset: false, body: Container( padding: EdgeInsets.all(10), - child: this.widget.pizzaEvent.recipe.getPizzaEventRecipeWidget(this) + child: this.widget.pizzaEvent.recipe.getPizzaEventRecipeWidget(context, this) ) ); }