From 14817ec752f530cafcd12c10827bfb8142ea6bbe Mon Sep 17 00:00:00 2001 From: Thea Choem Date: Thu, 15 Apr 2021 21:55:42 +0700 Subject: [PATCH] close #149 underline strike through color according to text color (#150) --- lib/widgets/text_line.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/widgets/text_line.dart b/lib/widgets/text_line.dart index 3106a08d..ef80a024 100644 --- a/lib/widgets/text_line.dart +++ b/lib/widgets/text_line.dart @@ -119,6 +119,7 @@ class TextLine extends StatelessWidget { final textNode = node as leaf.Text; final style = textNode.style; var res = const TextStyle(); + final color = textNode.style.attributes[Attribute.color.key]; { Attribute.bold.key: defaultStyles.bold, @@ -128,7 +129,16 @@ class TextLine extends StatelessWidget { Attribute.strikeThrough.key: defaultStyles.strikeThrough, }.forEach((k, s) { if (style.values.any((v) => v.key == k)) { - res = _merge(res, s!); + if (k == Attribute.underline.key || k == Attribute.strikeThrough.key) { + var textColor = defaultStyles.color; + if (color?.value is String) { + textColor = stringToColor(color?.value); + } + res = _merge(res.copyWith(decorationColor: textColor), + s!.copyWith(decorationColor: textColor)); + } else { + res = _merge(res, s!); + } } }); @@ -159,7 +169,6 @@ class TextLine extends StatelessWidget { } } - final color = textNode.style.attributes[Attribute.color.key]; if (color != null && color.value != null) { var textColor = defaultStyles.color; if (color.value is String) {