From 1ce594c5df11b947c7e75d9eafaf69f6ca78b220 Mon Sep 17 00:00:00 2001 From: broodjeaap89 Date: Mon, 9 Aug 2021 21:11:35 +0200 Subject: [PATCH] updated widget for recipe steps without substeps --- lib/pages/PizzaEventPage.dart | 61 +++++++++++++++++------------------ 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/lib/pages/PizzaEventPage.dart b/lib/pages/PizzaEventPage.dart index 969cc68..e044a5b 100644 --- a/lib/pages/PizzaEventPage.dart +++ b/lib/pages/PizzaEventPage.dart @@ -49,21 +49,21 @@ class PizzaEventPageState extends State { ], ), children: [ - Text(recipeStep.description), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(recipeStep.name), - Checkbox( - value: recipeStep.completedOn != null, - onChanged: (bool? newValue) async { - if (newValue == null){ - return; - } - setState(() {recipeStep.completedOn = newValue ? DateTime.now() : null;}); - }, - ) - ], + InkWell( + onLongPress: () { + setState(() { + recipeStep.completedOn = recipeStep.completed ? null : DateTime.now(); + }); + }, + child: Container( + width: double.infinity, + color: recipeStep.completed ? Colors.green : Colors.grey, + child: Column( + children: [ + Text(recipeStep.description) + ], + ), + ), ), Divider(), ] @@ -85,14 +85,17 @@ class PizzaEventPageState extends State { children: [ Text(recipeStep.description), Column( - children: recipeStep.subSteps.map((subStep) => getSubStepWidget(subStep)).toList() + children: recipeStep.subSteps.map( + (subStep) => getSubStepWidget(subStep) + ).expand((subStep) => [Divider(), subStep]).toList() ) ] ); } - + Widget getSubStepWidget(RecipeSubStep recipeSubStep){ return InkWell( + onLongPress: () async {}, onTap: () async { await showDialog( context: context, @@ -102,22 +105,16 @@ class PizzaEventPageState extends State { ); setState(() {}); }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - flex: 1, - child: SizedBox( - height: 50, - child: Container( - color: recipeSubStep.completed ? Colors.green : Colors.grey, - child: Center( - child: Text(recipeSubStep.name) - ), - ), + child: Container( + color: recipeSubStep.completed ? Colors.green : Colors.grey, + child: Column( + children: [ + Center( + child: Text(recipeSubStep.name), ), - ) - ], + Text(recipeSubStep.description) + ], + ), ), ); }