-
-
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 2509490
Showing
9 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
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
35 changes: 35 additions & 0 deletions
35
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,35 @@ | ||
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 by the `strikethroughText` property | ||
/// on the document style. | ||
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
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