diff --git a/lib/main.dart b/lib/main.dart index df15fb4..9ef4610 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,7 +14,7 @@ import 'package:pizzaplanner/pages/PizzaEventsPage.dart'; import 'package:hive/hive.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:pizzaplanner/pages/PizzaRecipePage.dart'; +import 'package:pizzaplanner/pages/PizzaEventRecipePage.dart'; import 'package:pizzaplanner/pages/RecipeStepInstructionPage.dart'; import 'package:pizzaplanner/recipes/NeapolitanCold.dart'; import 'package:pizzaplanner/util.dart'; @@ -138,7 +138,7 @@ class RouteGenerator { return MaterialPageRoute(builder: (context) => PizzaEventPage(settings.arguments as PizzaEvent)); } case "/event/recipe": { - return MaterialPageRoute(builder: (context) => PizzaRecipePage(settings.arguments as PizzaEvent)); + return MaterialPageRoute(builder: (context) => PizzaEventRecipePage(settings.arguments as PizzaEvent)); } case "/event/notification": { if (selectedNotificationPayload != null) { diff --git a/lib/pages/PizzaEventRecipePage.dart b/lib/pages/PizzaEventRecipePage.dart new file mode 100644 index 0000000..622d277 --- /dev/null +++ b/lib/pages/PizzaEventRecipePage.dart @@ -0,0 +1,89 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_markdown/flutter_markdown.dart'; +import 'package:pizzaplanner/entities/PizzaEvent.dart'; +import 'package:pizzaplanner/entities/PizzaRecipe/RecipeStep.dart'; +import 'package:url_launcher/url_launcher.dart'; + +class PizzaEventRecipePage extends StatefulWidget { + final PizzaEvent pizzaEvent; + PizzaEventRecipePage(this.pizzaEvent); + + @override + PizzaEventRecipePageState createState() => PizzaEventRecipePageState(); +} + +class PizzaEventRecipePageState extends State { + @override + Widget build(BuildContext context){ + return Scaffold( + appBar: AppBar( + title: Text("Pizza Event Recipe"), + ), + resizeToAvoidBottomInset: false, + body: Container( + padding: EdgeInsets.fromLTRB(40, 10, 40, 10), + child: Column( + children: [ + Text(this.widget.pizzaEvent.name) + ], + ) + ) + ); + } + + Widget buildRecipeStep(RecipeStep recipeStep) { + var subSteps = recipeStep.subSteps.length == 0 ? 1 : recipeStep.subSteps.length; + + var currentSubStep = recipeStep.subSteps.indexWhere((subStep) => subStep.completed); + if (currentSubStep == -1){ + currentSubStep = 0; + } + + var completedSubSteps = recipeStep.completed ? 1 : 0; + if (recipeStep.subSteps.length > 0){ + completedSubSteps = currentSubStep + 1; + } + + return Column( + children: [ + Expanded( + flex: 10, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text(recipeStep.name), + Text("$completedSubSteps/$subSteps") + ], + ), + ), + Expanded( + flex: 80, + child: ListView( + children: [ + MarkdownBody( + data: recipeStep.description, + onTapLink: (text, url, title) { + launch(url!); + }, + ), + ] + ), + ), + Expanded( + flex: 10, + child: Container( + width: double.infinity, + padding: EdgeInsets.all(10), + color: Colors.blue, + child: TextButton( + child: Text("Start", style: TextStyle(color: Colors.white)), + onPressed: () { + Navigator.pushNamed(context, "/event/recipe", arguments: this.widget.pizzaEvent); + }, + ) + ) + ), + ], + ); + } +} \ No newline at end of file