From 797b8580bbc32b21cd076b9bc7b9ebc3a6eeafe5 Mon Sep 17 00:00:00 2001 From: broodjeaap89 Date: Tue, 27 Jul 2021 22:14:15 +0200 Subject: [PATCH] added simple pizza event page, showing steps + substeps in an expanded list tile --- lib/main.dart | 4 ++ lib/pages/PizzaEventPage.dart | 39 +++++++++++++ lib/widgets/PizzaEventWidget.dart | 95 +++++++++++++++++-------------- 3 files changed, 96 insertions(+), 42 deletions(-) create mode 100644 lib/pages/PizzaEventPage.dart diff --git a/lib/main.dart b/lib/main.dart index 95a3bfd..e1a3093 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,6 +6,7 @@ import 'package:pizzaplanner/entities/PizzaRecipe/RecipeStep.dart'; import 'package:pizzaplanner/entities/PizzaRecipe/RecipeSubStep.dart'; import 'package:pizzaplanner/pages/AddPizzaEventPage.dart'; import 'package:pizzaplanner/pages/PickPizzaRecipePage.dart'; +import 'package:pizzaplanner/pages/PizzaEventPage.dart'; import 'package:pizzaplanner/pages/PizzaEventsPage.dart'; import 'package:hive/hive.dart'; @@ -57,6 +58,9 @@ class RouteGenerator { case "/event/add": { return MaterialPageRoute(builder: (context) => AddPizzaEventPage(settings.arguments as PizzaRecipe)); } + case "/event/view": { + return MaterialPageRoute(builder: (context) => PizzaEventPage(settings.arguments as PizzaEvent)); + } default: { return MaterialPageRoute(builder: (context) => PizzaEventsPage()); diff --git a/lib/pages/PizzaEventPage.dart b/lib/pages/PizzaEventPage.dart new file mode 100644 index 0000000..11e9307 --- /dev/null +++ b/lib/pages/PizzaEventPage.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:pizzaplanner/entities/PizzaEvent.dart'; + +class PizzaEventPage extends StatefulWidget { + PizzaEvent pizzaEvent; + + PizzaEventPage(this.pizzaEvent); + + @override + PizzaEventPageState createState() => PizzaEventPageState(); +} + +class PizzaEventPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text(this.widget.pizzaEvent.name), + ), + resizeToAvoidBottomInset: false, + body: Container( + padding: EdgeInsets.all(10), + child: ListView( + children: this.widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) { + return ExpansionTile( + title: Row( + children: [], + ), + children: recipeStep.subSteps.map((recipeSubStep) { + return Text(recipeSubStep.name); + } + ).toList(), + ); + }).toList(), + ) + ) + ); + } +} \ No newline at end of file diff --git a/lib/widgets/PizzaEventWidget.dart b/lib/widgets/PizzaEventWidget.dart index 8815294..36e1431 100644 --- a/lib/widgets/PizzaEventWidget.dart +++ b/lib/widgets/PizzaEventWidget.dart @@ -9,52 +9,63 @@ class PizzaEventWidget extends StatelessWidget { @override Widget build(BuildContext context){ - return Container( - height: 120, - color: Colors.blueAccent, - child: Container( - padding: const EdgeInsets.all(8), - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(pizzaEvent.name), - Text(this.getTimeRemainingString()) - ], - ), - Container( - padding: const EdgeInsets.all(10), - height: 72, - child: Row( + return InkWell( + child: Container( + height: 120, + color: Colors.blueAccent, + child: Container( + padding: const EdgeInsets.all(8), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded( - child: Slider( - min: 0.0, - max: pizzaEvent.recipe.recipeSteps.length.toDouble(), - divisions: pizzaEvent.recipe.recipeSteps.length, - value: pizzaEvent.recipe.getStepsCompleted().toDouble(), - onChanged: (d) {}, - activeColor: Colors.green, - inactiveColor: Colors.white, - ) - ), - ] + Text(pizzaEvent.name), + Text(this.getTimeRemainingString()) + ], + ), + Container( + padding: const EdgeInsets.all(10), + height: 72, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: IgnorePointer( + child: Slider( + min: 0.0, + max: pizzaEvent.recipe.recipeSteps.length.toDouble(), + divisions: pizzaEvent.recipe.recipeSteps.length, + value: pizzaEvent.recipe.getStepsCompleted().toDouble(), + onChanged: (d) {}, + activeColor: Colors.green, + inactiveColor: Colors.white, + ) + ) + ), + ] + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(getDateFormat().format(pizzaEvent.dateTime)), + Text(pizzaEvent.recipe.name) + ], ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text(getDateFormat().format(pizzaEvent.dateTime)), - Text(pizzaEvent.recipe.name) - ], - ), - ] - ) - ) + ] + ) + ) + ), + onTap: () { + Navigator.pushNamed( + context, + "/event/view", + arguments: this.pizzaEvent + ); + }, ); }