From ace91d2b7389a7e15827f7e1a11d604659acabfc Mon Sep 17 00:00:00 2001 From: davidpkj Date: Sun, 5 Mar 2023 15:03:31 +0100 Subject: Update markdown viewer style --- lib/constants.dart | 1 + lib/views/recipe_view.dart | 4 ++- lib/views/shoplist_view.dart | 2 +- lib/widgets/custom_markdown_style.dart | 42 +++++++++++++++++--------------- lib/widgets/utility_icon_row_widget.dart | 19 +-------------- 5 files changed, 29 insertions(+), 39 deletions(-) diff --git a/lib/constants.dart b/lib/constants.dart index e7816cf..2ff32bf 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -85,6 +85,7 @@ const cRecipeSubtitleStyle = TextStyle( ); const cRecipeDescriptionStyle = TextStyle( + backgroundColor: Colors.transparent, fontFamily: "RobotoSlab", color: Colors.black54, fontSize: 14.0, diff --git a/lib/views/recipe_view.dart b/lib/views/recipe_view.dart index faaa0ca..c22ea2b 100644 --- a/lib/views/recipe_view.dart +++ b/lib/views/recipe_view.dart @@ -6,6 +6,7 @@ import 'package:kulinar_app/constants.dart'; import 'package:kulinar_app/views/image_view.dart'; import 'package:kulinar_app/models/recipe_class.dart'; import 'package:kulinar_app/widgets/toastbar_widget.dart'; +import 'package:kulinar_app/widgets/custom_markdown_style.dart'; import 'package:kulinar_app/models/data/recipe_data_class.dart'; import 'package:kulinar_app/widgets/page_route_transitions.dart'; import 'package:kulinar_app/widgets/utility_icon_row_widget.dart'; @@ -130,7 +131,7 @@ class RecipeViewState extends State { setState(() {}); } - // TODO: FIXME: This might introduce bugs later (sanitize); maybe use FileHandler? + // TODO: This might introduce bugs later (sanitize); maybe use FileHandler? void downloadRecipe(BuildContext context, Recipe recipe) async { RecipeData.recipeList.add(recipe); ToastBar.showToastBar(context, AppLocalizations.of(context)!.downloadSuccess); @@ -274,6 +275,7 @@ class RecipeViewState extends State { MarkdownBody _buildMarkdownDescription() { return MarkdownBody( + styleSheet: CustomMarkdownStyle.sheet(), data: _controller2.text, selectable: true, onTapLink: (text, href, title) => {}, diff --git a/lib/views/shoplist_view.dart b/lib/views/shoplist_view.dart index e13ef21..35332bc 100644 --- a/lib/views/shoplist_view.dart +++ b/lib/views/shoplist_view.dart @@ -52,7 +52,7 @@ class ShoplistViewState extends State { ); } - // TODO: FIXME: Sometimes exception "cant call insertItem of null" is thrown when first item is added or last is removed + // TODO: Sometimes exception "cant call insertItem of null" is thrown when first item is added or last is removed Widget _buildAnimatedList() { if (ShoplistData.shoplist.isEmpty) return const NoContentError(); diff --git a/lib/widgets/custom_markdown_style.dart b/lib/widgets/custom_markdown_style.dart index 41173f5..b00e047 100644 --- a/lib/widgets/custom_markdown_style.dart +++ b/lib/widgets/custom_markdown_style.dart @@ -5,23 +5,27 @@ import 'package:kulinar_app/constants.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; class CustomMarkdownStyle extends MarkdownStyleSheet { - markdownStyleSheet({ - tableBody = cRecipeDescriptionStyle, - a = cRecipeDescriptionStyle, - p = cRecipeDescriptionStyle, - h1 = cRecipeSubtitleStyle, - h2 = cRecipeSubtitleStyle, - h3 = cRecipeSubtitleStyle, - h4 = cRecipeSubtitleStyle, - h5 = cRecipeSubtitleStyle, - h6 = cRecipeSubtitleStyle, -/* TODO: remove code and quote block - blockquoteDecoration: BoxDecoration(color: Color.fromARGB(255, 255, 13, 13)), - code: cDetailsTextStyle, -*/ - listIndent = 15.0, - listBullet = cRecipeDescriptionStyle, - listBulletPadding = const EdgeInsets.only(right: 10.0), - // horizontalRuleDecoration: BoxDecoration(border: Border.all(color: Colors.grey, width: 0.5)), - }) {} + static sheet() { + return MarkdownStyleSheet( + tableBody: cRecipeDescriptionStyle, + a: cRecipeDescriptionStyle, + p: cRecipeDescriptionStyle, + h1: cRecipeSubtitleStyle.copyWith(color: Colors.black87), + h2: cRecipeSubtitleStyle.copyWith(color: Colors.black87), + h3: cRecipeSubtitleStyle, + h4: cRecipeSubtitleStyle, + h5: cRecipeSubtitleStyle, + h6: cRecipeSubtitleStyle, + blockquote: cRecipeDescriptionStyle, + blockquotePadding: const EdgeInsets.only(left: 16.0, top: 4.0, bottom: 4.0), + blockquoteDecoration: const BoxDecoration(border: Border(left: BorderSide(color: cPrimaryColor, width: 2.0))), + code: cRecipeDescriptionStyle, + codeblockPadding: const EdgeInsets.only(left: 16.0, top: 4.0, bottom: 4.0), + codeblockDecoration: const BoxDecoration(border: Border(left: BorderSide(color: Colors.black45, width: 2.0))), + listIndent: 15.0, + listBullet: cRecipeDescriptionStyle, + listBulletPadding: const EdgeInsets.only(right: 10.0), + horizontalRuleDecoration: const BoxDecoration(border: Border(top: BorderSide(color: Colors.black12))), + ); + } } diff --git a/lib/widgets/utility_icon_row_widget.dart b/lib/widgets/utility_icon_row_widget.dart index 224823f..8270ab0 100644 --- a/lib/widgets/utility_icon_row_widget.dart +++ b/lib/widgets/utility_icon_row_widget.dart @@ -138,24 +138,7 @@ class UtilityIconRowState extends State { ); } - /* todo: IMPLEMENT RICH TEXT https://stackoverflow.com/questions/41557139/how-do-i-bold-or-format-a-piece-of-text-within-a-paragraph - // todo: Implement recalculations (portions, measurement system) - Widget _buildIconCalculate() { - return IconButton( - icon: Icon(Icons.calculate_rounded), - onPressed: null, - ); - } - */ - -/* Widget _buildIconShare() { - return IconButton( - icon: Icon(Icons.share), - onPressed: widget.readonly && !widget.remote ? _shareData : null, - ); - } */ - - /* + /* IF REMOTE: DOWNLOAD -- cgit v1.2.3