added optional images to pizza recipes, that are displayed in the pizza recipe widget
This commit is contained in:
parent
2504c1632b
commit
bff604b09d
3 changed files with 22 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
recipe:
|
||||
name: "Neapolitan Cold Rise"
|
||||
image: https://mypizzacorner.com/wp-content/uploads/2020/12/neapolitan-pizza-authentic.jpg?ezimgfmt=ng:webp/ngcb45
|
||||
description: >
|
||||
A Neapolitan Style pizza with a multi day cold rise, giving a light and fluffy dough.
|
||||
|
||||
|
|
|
@ -31,7 +31,12 @@ class PizzaRecipe extends HiveObject {
|
|||
@HiveField(4)
|
||||
bool deleted = false;
|
||||
|
||||
PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps);
|
||||
@HiveField(5)
|
||||
String? imgUrl;
|
||||
|
||||
PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps, {String? image}){
|
||||
imgUrl = image;
|
||||
}
|
||||
|
||||
String getShortDescriptionString(){
|
||||
if (description.length < 150) { // TODO 150?
|
||||
|
@ -89,6 +94,7 @@ class PizzaRecipe extends HiveObject {
|
|||
final YamlMap recipe = yaml["recipe"] as YamlMap;
|
||||
|
||||
final String name = recipe["name"] as String;
|
||||
final String? image = recipe.containsKey("image") ? recipe["image"] as String : null;
|
||||
final String description = recipe["description"] as String;
|
||||
|
||||
final YamlList ingredients = recipe["ingredients"] as YamlList;
|
||||
|
@ -143,7 +149,8 @@ class PizzaRecipe extends HiveObject {
|
|||
name,
|
||||
description,
|
||||
newIngredients,
|
||||
newRecipeSteps
|
||||
newRecipeSteps,
|
||||
image: image
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -153,6 +160,11 @@ class PizzaRecipe extends HiveObject {
|
|||
// Name
|
||||
yaml.writeln(indent(1, 'name: "$name"'));
|
||||
|
||||
// image url
|
||||
if (imgUrl != null){
|
||||
yaml.writeln(indent(1, 'image: "$imgUrl"'));
|
||||
}
|
||||
|
||||
// Description
|
||||
yaml.writeln(indent(1, 'description: >'));
|
||||
for (final line in description.split("\n")){
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||
import 'package:pizzaplanner/entities/PizzaRecipe/pizza_recipe.dart';
|
||||
|
||||
class PizzaRecipeWidget extends StatelessWidget {
|
||||
|
@ -9,26 +10,22 @@ class PizzaRecipeWidget extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 120,
|
||||
color: Colors.blueAccent,
|
||||
//height: 120,
|
||||
//color: Colors.blueAccent,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
if (pizzaRecipe.imgUrl != null)
|
||||
Image.network(pizzaRecipe.imgUrl!)
|
||||
else
|
||||
const Icon(FontAwesome5.pizza_slice, size: 100,),
|
||||
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