From 8de0282956798a02322fb08baac5d1c6542340e0 Mon Sep 17 00:00:00 2001 From: broodjeaap89 Date: Tue, 3 Aug 2021 21:38:09 +0200 Subject: [PATCH] very annoying, probably have to skip seperate stateful widgets and dump everything in the build() of the page widet.... --- lib/pages/PizzaEventPage.dart | 44 +++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/pages/PizzaEventPage.dart b/lib/pages/PizzaEventPage.dart index c493311..33b7a04 100644 --- a/lib/pages/PizzaEventPage.dart +++ b/lib/pages/PizzaEventPage.dart @@ -5,7 +5,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/RecipeStep.dart'; import 'package:pizzaplanner/entities/PizzaRecipe/RecipeSubStep.dart'; class PizzaEventPage extends StatefulWidget { - PizzaEvent pizzaEvent; + final PizzaEvent pizzaEvent; PizzaEventPage(this.pizzaEvent); @@ -63,8 +63,10 @@ class PizzaEventRecipeStepWidgetState extends State ), children: [ Text(this.widget.recipeStep.description), - - ] + this.widget.recipeStep.subSteps.map((subStep) => PizzaEventSubStepWidget(subStep)).toList() //subStep.buildPizzaEventSubStepWidget(context, pizzaEventPage)).toList() + Column( + children: this.widget.recipeStep.subSteps.map((subStep) => PizzaEventSubStepWidget(subStep, this)).toList() + ) + ] ); } @@ -90,12 +92,12 @@ class PizzaEventRecipeStepWidgetState extends State if (newValue == null){ return; } - this.widget.recipeStep.completedOn = newValue ? DateTime.now() : null; - setState(() {}); + setState(() {this.widget.recipeStep.completedOn = newValue ? DateTime.now() : null;}); }, ) ], - ) + ), + Divider(), ] ); } @@ -103,8 +105,9 @@ class PizzaEventRecipeStepWidgetState extends State class PizzaEventSubStepWidget extends StatefulWidget { final RecipeSubStep recipeSubStep; + final PizzaEventRecipeStepWidgetState parent; - PizzaEventSubStepWidget(this.recipeSubStep); + PizzaEventSubStepWidget(this.recipeSubStep, this.parent); PizzaEventSubStepWidgetState createState() => PizzaEventSubStepWidgetState(); } @@ -119,18 +122,25 @@ class PizzaEventSubStepWidgetState extends State { builder: (context) { return PizzaEventSubStepDialog(this.widget.recipeSubStep); } - ); - setState(() {}); + ).then((_) { + setState(() {}); + this.widget.parent.setState(() {}); + }); }, child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(this.widget.recipeSubStep.name), - IgnorePointer( - child: Checkbox( - value: this.widget.recipeSubStep.completed, - onChanged: (b) {}, - ) + Expanded( + flex: 1, + child: SizedBox( + height: 50, + child: Container( + color: this.widget.recipeSubStep.completed ? Colors.green : Colors.grey, + child: Center( + child: Text(this.widget.recipeSubStep.name) + ), + ), + ), ) ], ), @@ -164,7 +174,7 @@ class PizzaEventSubStepDialogState extends State { width: double.infinity, height: 70, child: Container( - color: this.widget.recipeSubStep.completed ? Colors.green : Colors.redAccent, + color: this.widget.recipeSubStep.completed ? Colors.green : Colors.grey, child: TextButton( child: Text(this.widget.recipeSubStep.completed ? "Complete" : "Todo", style: TextStyle(color: Colors.white)), onPressed: () {