refactored the way to get to the pizza recipe page
This commit is contained in:
parent
d5219256d1
commit
bfa5c2beba
4 changed files with 41 additions and 45 deletions
|
@ -14,7 +14,7 @@ import 'package:pizzaplanner/pages/pizza_events_page.dart';
|
|||
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:pizzaplanner/pages/pizza_event_recipe_page.dart';
|
||||
import 'package:pizzaplanner/pages/recipe_page.dart';
|
||||
import 'package:pizzaplanner/pages/recipe_step_instruction_page.dart';
|
||||
import 'package:pizzaplanner/recipes/neapolitan_cold.dart';
|
||||
import 'package:pizzaplanner/util.dart';
|
||||
|
@ -139,12 +139,12 @@ class RouteGenerator {
|
|||
}
|
||||
return MaterialPageRoute(builder: (context) => PizzaEventPage(pizzaEvent));
|
||||
}
|
||||
case "/event/recipe": {
|
||||
final pizzaEvent = settings.arguments as PizzaEvent?;
|
||||
if (pizzaEvent == null){
|
||||
case "/recipe/view": {
|
||||
final pizzaRecipe = settings.arguments as PizzaRecipe?;
|
||||
if (pizzaRecipe == null){
|
||||
break;
|
||||
}
|
||||
return MaterialPageRoute(builder: (context) => PizzaEventRecipePage(pizzaEvent));
|
||||
return MaterialPageRoute(builder: (context) => RecipePage(pizzaRecipe));
|
||||
}
|
||||
case "/event/notification": {
|
||||
if (selectedNotificationPayload != null) {
|
||||
|
|
|
@ -45,7 +45,7 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
|||
color: Colors.blue,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(context, "/event/recipe", arguments: widget.pizzaEvent);
|
||||
Navigator.pushNamed(context, "/recipe/view", arguments: widget.pizzaEvent.recipe);
|
||||
},
|
||||
child: Text(widget.pizzaEvent.recipe.name, style: const TextStyle(color: Colors.white)),
|
||||
)
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/pizza_recipe.dart';
|
||||
import 'package:pizzaplanner/entities/pizza_event.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class PizzaEventRecipePage extends StatefulWidget {
|
||||
final PizzaEvent pizzaEvent;
|
||||
const PizzaEventRecipePage(this.pizzaEvent);
|
||||
class RecipePage extends StatefulWidget {
|
||||
final PizzaRecipe pizzaRecipe;
|
||||
const RecipePage(this.pizzaRecipe);
|
||||
|
||||
@override
|
||||
PizzaEventRecipePageState createState() => PizzaEventRecipePageState();
|
||||
RecipePageState createState() => RecipePageState();
|
||||
}
|
||||
|
||||
class PizzaEventRecipePageState extends State<PizzaEventRecipePage> {
|
||||
class RecipePageState extends State<RecipePage> {
|
||||
final PageController controller = PageController();
|
||||
int page = 0;
|
||||
|
||||
PizzaEventRecipePageState(){
|
||||
RecipePageState(){
|
||||
page = controller.initialPage;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context){
|
||||
var recipeStepCount = widget.pizzaEvent.recipe.recipeSteps.length;
|
||||
var recipeStepCount = widget.pizzaRecipe.recipeSteps.length;
|
||||
recipeStepCount += 1; // because of first description page
|
||||
final List<Text> pageIndex = [];
|
||||
for (var i = 0;i < recipeStepCount;i++){
|
||||
|
@ -43,7 +44,7 @@ class PizzaEventRecipePageState extends State<PizzaEventRecipePage> {
|
|||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.pizzaEvent.recipe.name),
|
||||
title: Text(widget.pizzaRecipe.name),
|
||||
),
|
||||
resizeToAvoidBottomInset: false,
|
||||
body: Column(
|
||||
|
@ -55,12 +56,12 @@ class PizzaEventRecipePageState extends State<PizzaEventRecipePage> {
|
|||
controller: controller,
|
||||
children: <Widget>[
|
||||
Markdown(
|
||||
data: widget.pizzaEvent.recipe.description,
|
||||
data: widget.pizzaRecipe.description,
|
||||
onTapLink: (text, url, title) {
|
||||
launch(url!);
|
||||
},
|
||||
),
|
||||
] + widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) => buildRecipeStep(recipeStep)).toList()
|
||||
] + widget.pizzaRecipe.recipeSteps.map((recipeStep) => buildRecipeStep(recipeStep)).toList()
|
||||
)
|
||||
),
|
||||
Expanded(
|
|
@ -8,35 +8,30 @@ class PizzaRecipeWidget extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
Navigator.pushNamed(context, "/event/add", arguments: this.pizzaRecipe);
|
||||
},
|
||||
child: Container(
|
||||
height: 120,
|
||||
color: Colors.blueAccent,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(pizzaRecipe.name),
|
||||
]
|
||||
),
|
||||
Text(pizzaRecipe.getShortDescriptionString()),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("${pizzaRecipe.getMinDuration().inHours.round()} to ${pizzaRecipe.getMaxDuration().inHours.round()} hours")
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
),
|
||||
return Container(
|
||||
height: 120,
|
||||
color: Colors.blueAccent,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text(pizzaRecipe.name),
|
||||
]
|
||||
),
|
||||
Text(pizzaRecipe.getShortDescriptionString()),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Text("${pizzaRecipe.getMinDuration().inHours.round()} to ${pizzaRecipe.getMaxDuration().inHours.round()} hours")
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue