Skip to content

Commit 14817ec

Browse files
authored
close singerdmx#149 underline strike through color according to text color (singerdmx#150)
1 parent 63c2ef9 commit 14817ec

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/widgets/text_line.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ class TextLine extends StatelessWidget {
119119
final textNode = node as leaf.Text;
120120
final style = textNode.style;
121121
var res = const TextStyle();
122+
final color = textNode.style.attributes[Attribute.color.key];
122123

123124
<String, TextStyle?>{
124125
Attribute.bold.key: defaultStyles.bold,
@@ -128,7 +129,16 @@ class TextLine extends StatelessWidget {
128129
Attribute.strikeThrough.key: defaultStyles.strikeThrough,
129130
}.forEach((k, s) {
130131
if (style.values.any((v) => v.key == k)) {
131-
res = _merge(res, s!);
132+
if (k == Attribute.underline.key || k == Attribute.strikeThrough.key) {
133+
var textColor = defaultStyles.color;
134+
if (color?.value is String) {
135+
textColor = stringToColor(color?.value);
136+
}
137+
res = _merge(res.copyWith(decorationColor: textColor),
138+
s!.copyWith(decorationColor: textColor));
139+
} else {
140+
res = _merge(res, s!);
141+
}
132142
}
133143
});
134144

@@ -159,7 +169,6 @@ class TextLine extends StatelessWidget {
159169
}
160170
}
161171

162-
final color = textNode.style.attributes[Attribute.color.key];
163172
if (color != null && color.value != null) {
164173
var textColor = defaultStyles.color;
165174
if (color.value is String) {

0 commit comments

Comments
 (0)