-
-
Notifications
You must be signed in to change notification settings - Fork 933
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for strike-through text for flame_markdown
- Loading branch information
1 parent
3067da9
commit 8de288b
Showing
8 changed files
with
96 additions
and
4 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
packages/flame/lib/src/text/nodes/strikethrough_text_node.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:flame/src/text/nodes/inline_text_node.dart'; | ||
import 'package:flame/text.dart'; | ||
|
||
/// An [InlineTextNode] representing a text with a strikethrough line. | ||
/// | ||
/// The exact styling can be controlled | ||
class StrikethroughTextNode extends InlineTextNode { | ||
StrikethroughTextNode(this.child); | ||
|
||
StrikethroughTextNode.simple(String text) : child = PlainTextNode(text); | ||
|
||
StrikethroughTextNode.group(List<InlineTextNode> children) | ||
: child = GroupTextNode(children); | ||
|
||
final InlineTextNode child; | ||
|
||
static final defaultStyle = InlineTextStyle( | ||
decoration: TextDecoration.lineThrough, | ||
); | ||
|
||
@override | ||
void fillStyles(DocumentStyle stylesheet, InlineTextStyle parentTextStyle) { | ||
style = FlameTextStyle.merge( | ||
parentTextStyle, | ||
stylesheet.strikethroughText, | ||
)!; | ||
child.fillStyles(stylesheet, style); | ||
} | ||
|
||
@override | ||
TextNodeLayoutBuilder get layoutBuilder => child.layoutBuilder; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# Fire & Ice | ||
|
||
Some say the world will end in **fire**, | ||
Some say the world will ~~end~~ in **fire**, | ||
|
||
Some say in *ice*. | ||
|
||
From what I've tasted of >desire<, | ||
|
||
I hold with those who favor **fire**. | ||
I hold with those who favor **fire**. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters