From fe77786aee430d0f094fbf428d138fe1da79104e Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 30 Jul 2023 14:08:23 +0200 Subject: [PATCH] Add markdown support --- .../widgets/recipe_detail_tabbar_widget.dart | 15 +++++++++++++-- pubspec.lock | 16 ++++++++++++++++ pubspec.yaml | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/components/widgets/recipe_detail_tabbar_widget.dart b/lib/components/widgets/recipe_detail_tabbar_widget.dart index 6160c1a..27e3b96 100644 --- a/lib/components/widgets/recipe_detail_tabbar_widget.dart +++ b/lib/components/widgets/recipe_detail_tabbar_widget.dart @@ -7,6 +7,7 @@ import 'package:untare/extensions/double_extension.dart'; import 'package:flutter_gen/gen_l10n/app_locales.dart'; import 'package:collapsible/collapsible.dart'; import 'package:fraction/fraction.dart'; +import 'package:flutter_markdown/flutter_markdown.dart'; class RecipeDetailTabBarWidget extends StatefulWidget { final Recipe recipe; @@ -124,7 +125,12 @@ class RecipeDetailTabBarWidgetState extends State { stepList.addAll(recipe.steps[i].ingredients.map((item) => ingredientComponent(item, servings, newServings, true, context)).toList()); - stepList.add(Padding(padding: const EdgeInsets.fromLTRB(20, 12, 15, 10), child: Text(recipe.steps[i].instruction ?? '', style: const TextStyle(fontSize: 15)))); + stepList.add(Padding( + padding: const EdgeInsets.fromLTRB(20, 12, 15, 10), + child: MarkdownBody( + data: recipe.steps[i].instruction ?? '', + styleSheet: + MarkdownStyleSheet(p: const TextStyle(fontSize: 15))))); directionsSteps.add(directionStepLayout(context, Column(crossAxisAlignment: CrossAxisAlignment.start, children: stepList), i+1, recipe.steps[i].time, recipe.steps[i].name)); } @@ -149,7 +155,12 @@ class RecipeDetailTabBarWidgetState extends State { directionsSteps.add( directionStepLayout( context, - Padding(padding: const EdgeInsets.fromLTRB(20, 12, 15, 10), child: Text(splitInstruction, style: const TextStyle(fontSize: 15))), + Padding( + padding: const EdgeInsets.fromLTRB(20, 12, 15, 10), + child: MarkdownBody( + data: splitInstruction, + styleSheet: MarkdownStyleSheet( + p: const TextStyle(fontSize: 15)))), i+1, recipe.steps.first.time, recipe.steps.first.name diff --git a/pubspec.lock b/pubspec.lock index 63f7d0b..6d9470c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -436,6 +436,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_markdown: + dependency: "direct main" + description: + name: flutter_markdown + sha256: dc6d5258653f6857135b32896ccda7f7af0c54dcec832495ad6835154c6c77c0 + url: "https://pub.dev" + source: hosted + version: "0.6.15" flutter_phoenix: dependency: "direct main" description: @@ -726,6 +734,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + markdown: + dependency: transitive + description: + name: markdown + sha256: acf35edccc0463a9d7384e437c015a3535772e09714cf60e07eeef3a15870dcd + url: "https://pub.dev" + source: hosted + version: "7.1.1" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index a4075d1..5beb001 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -57,6 +57,7 @@ dependencies: collapsible: ^1.0.0 share_plus: ^6.3.1 fraction: ^4.1.4 + flutter_markdown: ^0.6.15 dependency_overrides: flutter_chips_input: