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/hive.dart';
|
||||||
import 'package:hive_flutter/hive_flutter.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/pages/recipe_step_instruction_page.dart';
|
||||||
import 'package:pizzaplanner/recipes/neapolitan_cold.dart';
|
import 'package:pizzaplanner/recipes/neapolitan_cold.dart';
|
||||||
import 'package:pizzaplanner/util.dart';
|
import 'package:pizzaplanner/util.dart';
|
||||||
|
@ -139,12 +139,12 @@ class RouteGenerator {
|
||||||
}
|
}
|
||||||
return MaterialPageRoute(builder: (context) => PizzaEventPage(pizzaEvent));
|
return MaterialPageRoute(builder: (context) => PizzaEventPage(pizzaEvent));
|
||||||
}
|
}
|
||||||
case "/event/recipe": {
|
case "/recipe/view": {
|
||||||
final pizzaEvent = settings.arguments as PizzaEvent?;
|
final pizzaRecipe = settings.arguments as PizzaRecipe?;
|
||||||
if (pizzaEvent == null){
|
if (pizzaRecipe == null){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return MaterialPageRoute(builder: (context) => PizzaEventRecipePage(pizzaEvent));
|
return MaterialPageRoute(builder: (context) => RecipePage(pizzaRecipe));
|
||||||
}
|
}
|
||||||
case "/event/notification": {
|
case "/event/notification": {
|
||||||
if (selectedNotificationPayload != null) {
|
if (selectedNotificationPayload != null) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ class PizzaEventPageState extends State<PizzaEventPage> {
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
onPressed: () {
|
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)),
|
child: Text(widget.pizzaEvent.recipe.name, style: const TextStyle(color: Colors.white)),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,28 +1,29 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_markdown/flutter_markdown.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/pizza_event.dart';
|
||||||
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
import 'package:pizzaplanner/entities/PizzaRecipe/recipe_step.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class PizzaEventRecipePage extends StatefulWidget {
|
class RecipePage extends StatefulWidget {
|
||||||
final PizzaEvent pizzaEvent;
|
final PizzaRecipe pizzaRecipe;
|
||||||
const PizzaEventRecipePage(this.pizzaEvent);
|
const RecipePage(this.pizzaRecipe);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PizzaEventRecipePageState createState() => PizzaEventRecipePageState();
|
RecipePageState createState() => RecipePageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class PizzaEventRecipePageState extends State<PizzaEventRecipePage> {
|
class RecipePageState extends State<RecipePage> {
|
||||||
final PageController controller = PageController();
|
final PageController controller = PageController();
|
||||||
int page = 0;
|
int page = 0;
|
||||||
|
|
||||||
PizzaEventRecipePageState(){
|
RecipePageState(){
|
||||||
page = controller.initialPage;
|
page = controller.initialPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context){
|
Widget build(BuildContext context){
|
||||||
var recipeStepCount = widget.pizzaEvent.recipe.recipeSteps.length;
|
var recipeStepCount = widget.pizzaRecipe.recipeSteps.length;
|
||||||
recipeStepCount += 1; // because of first description page
|
recipeStepCount += 1; // because of first description page
|
||||||
final List<Text> pageIndex = [];
|
final List<Text> pageIndex = [];
|
||||||
for (var i = 0;i < recipeStepCount;i++){
|
for (var i = 0;i < recipeStepCount;i++){
|
||||||
|
@ -43,7 +44,7 @@ class PizzaEventRecipePageState extends State<PizzaEventRecipePage> {
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(widget.pizzaEvent.recipe.name),
|
title: Text(widget.pizzaRecipe.name),
|
||||||
),
|
),
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
body: Column(
|
body: Column(
|
||||||
|
@ -55,12 +56,12 @@ class PizzaEventRecipePageState extends State<PizzaEventRecipePage> {
|
||||||
controller: controller,
|
controller: controller,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Markdown(
|
Markdown(
|
||||||
data: widget.pizzaEvent.recipe.description,
|
data: widget.pizzaRecipe.description,
|
||||||
onTapLink: (text, url, title) {
|
onTapLink: (text, url, title) {
|
||||||
launch(url!);
|
launch(url!);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
] + widget.pizzaEvent.recipe.recipeSteps.map((recipeStep) => buildRecipeStep(recipeStep)).toList()
|
] + widget.pizzaRecipe.recipeSteps.map((recipeStep) => buildRecipeStep(recipeStep)).toList()
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
|
@ -8,11 +8,7 @@ class PizzaRecipeWidget extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return InkWell(
|
return Container(
|
||||||
onTap: () {
|
|
||||||
Navigator.pushNamed(context, "/event/add", arguments: this.pizzaRecipe);
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
height: 120,
|
height: 120,
|
||||||
color: Colors.blueAccent,
|
color: Colors.blueAccent,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
@ -36,7 +32,6 @@ class PizzaRecipeWidget extends StatelessWidget {
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue