From cca65a57180a9f9ff827c2a200292bc8d6d34bfe Mon Sep 17 00:00:00 2001 From: broodjeaap89 Date: Sun, 1 Aug 2021 13:48:55 +0200 Subject: [PATCH] updated layout of pizza event page --- lib/entities/PizzaEvent.dart | 2 +- lib/pages/PizzaEventPage.dart | 41 ++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/lib/entities/PizzaEvent.dart b/lib/entities/PizzaEvent.dart index c9bb190..932dfa4 100644 --- a/lib/entities/PizzaEvent.dart +++ b/lib/entities/PizzaEvent.dart @@ -5,7 +5,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/PizzaRecipe.dart'; part 'PizzaEvent.g.dart'; @HiveType(typeId: 4) -class PizzaEvent { +class PizzaEvent extends HiveObject{ @HiveField(0) String name; diff --git a/lib/pages/PizzaEventPage.dart b/lib/pages/PizzaEventPage.dart index 11e9307..a1447f7 100644 --- a/lib/pages/PizzaEventPage.dart +++ b/lib/pages/PizzaEventPage.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:fluttericon/font_awesome5_icons.dart'; import 'package:pizzaplanner/entities/PizzaEvent.dart'; class PizzaEventPage extends StatefulWidget { @@ -22,14 +23,44 @@ class PizzaEventPageState extends State { padding: EdgeInsets.all(10), child: ListView( children: this.widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) { + int recipeSubStepsCompleted = recipeStep.subSteps.where((subStep) => subStep.completed).length; + int recipeSubSteps = recipeStep.subSteps.length != 0 ? recipeStep.subSteps.length : 1; return ExpansionTile( title: Row( - children: [], + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Icon(FontAwesome5.sitemap), + Text(recipeStep.name), + Text("$recipeSubStepsCompleted/$recipeSubSteps") + ], ), - children: recipeStep.subSteps.map((recipeSubStep) { - return Text(recipeSubStep.name); - } - ).toList(), + children: [ + Text(recipeStep.description), + + ] + recipeStep.subSteps.map((subStep) { + return Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(subStep.name), + Checkbox( + value: subStep.completed, + onChanged: (bool? newValue) async { + if (newValue == null){ + return; + } + if (newValue){ + subStep.completedOn = DateTime.now(); + } else { + subStep.completedOn = null; + } + await this.widget.pizzaEvent.delete(); + await this.widget.pizzaEvent.save(); + setState(() {}); + }, + ) + ], + ); + }).toList(), ); }).toList(), )