added pizza event recipe page
This commit is contained in:
parent
34d0eb8c08
commit
aed16832c2
2 changed files with 91 additions and 2 deletions
|
@ -14,7 +14,7 @@ import 'package:pizzaplanner/pages/PizzaEventsPage.dart';
|
||||||
|
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:hive_flutter/hive_flutter.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/pages/RecipeStepInstructionPage.dart';
|
||||||
import 'package:pizzaplanner/recipes/NeapolitanCold.dart';
|
import 'package:pizzaplanner/recipes/NeapolitanCold.dart';
|
||||||
import 'package:pizzaplanner/util.dart';
|
import 'package:pizzaplanner/util.dart';
|
||||||
|
@ -138,7 +138,7 @@ class RouteGenerator {
|
||||||
return MaterialPageRoute(builder: (context) => PizzaEventPage(settings.arguments as PizzaEvent));
|
return MaterialPageRoute(builder: (context) => PizzaEventPage(settings.arguments as PizzaEvent));
|
||||||
}
|
}
|
||||||
case "/event/recipe": {
|
case "/event/recipe": {
|
||||||
return MaterialPageRoute(builder: (context) => PizzaRecipePage(settings.arguments as PizzaEvent));
|
return MaterialPageRoute(builder: (context) => PizzaEventRecipePage(settings.arguments as PizzaEvent));
|
||||||
}
|
}
|
||||||
case "/event/notification": {
|
case "/event/notification": {
|
||||||
if (selectedNotificationPayload != null) {
|
if (selectedNotificationPayload != null) {
|
||||||
|
|
89
lib/pages/PizzaEventRecipePage.dart
Normal file
89
lib/pages/PizzaEventRecipePage.dart
Normal file
|
@ -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<PizzaEventRecipePage> {
|
||||||
|
@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: <Widget>[
|
||||||
|
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: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
flex: 10,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: <Widget>[
|
||||||
|
Text(recipeStep.name),
|
||||||
|
Text("$completedSubSteps/$subSteps")
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 80,
|
||||||
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
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);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue