added method that shortens the description of the recipe for display in the recipe widget
This commit is contained in:
parent
696b987957
commit
e950bfb743
2 changed files with 13 additions and 2 deletions
|
@ -25,7 +25,18 @@ class PizzaRecipe extends HiveObject {
|
||||||
List<RecipeStep> recipeSteps;
|
List<RecipeStep> recipeSteps;
|
||||||
|
|
||||||
PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps);
|
PizzaRecipe(this.name, this.description, this.ingredients, this.recipeSteps);
|
||||||
|
|
||||||
|
String getShortDescriptionString(){
|
||||||
|
if (this.description.length < 150) { // TODO 150?
|
||||||
|
return this.description;
|
||||||
|
}
|
||||||
|
var endOfLineIndex = this.description.indexOf(RegExp("[.]|\$")) + 1;
|
||||||
|
if (endOfLineIndex >= 150){
|
||||||
|
var first150 = this.description.substring(0, 150);
|
||||||
|
return "$first150...";
|
||||||
|
}
|
||||||
|
return this.description.substring(0, endOfLineIndex);
|
||||||
|
}
|
||||||
Table getIngredientsTable(int pizzaCount, int doughBallSize) {
|
Table getIngredientsTable(int pizzaCount, int doughBallSize) {
|
||||||
return Table(
|
return Table(
|
||||||
border: TableBorder.all(),
|
border: TableBorder.all(),
|
||||||
|
|
|
@ -23,7 +23,7 @@ class PizzaRecipeWidget extends StatelessWidget {
|
||||||
Text(pizzaRecipe.name),
|
Text(pizzaRecipe.name),
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
Text(pizzaRecipe.description),
|
Text(pizzaRecipe.getShortDescriptionString()),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
|
Loading…
Add table
Reference in a new issue