Skip to content

Commit

Permalink
fix: vertex text style background not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
CorvusYe committed May 12, 2024
1 parent d052265 commit c644ae1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.4+1
- fix: vertex text style `background` not working.

## 1.0.4
- feat: support specifying vertex text style.

Expand Down
6 changes: 5 additions & 1 deletion lib/core/options/text/vertex_text_renderer_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class VertexTextRendererImpl extends VertexTextRenderer {
var paragraphFontSize = vertexTextStyle?.fontSize ?? 14;
var fontWeight = vertexTextStyle?.fontWeight ?? FontWeight.normal;
var fontColor = vertexTextStyle?.color;
var backgroundColor = vertexTextStyle?.backgroundColor;

/// 1.生成 ParagraphStyle,可设置文本的基本信息
final paragraphStyle = ui.ParagraphStyle(
Expand All @@ -39,6 +40,8 @@ class VertexTextRendererImpl extends VertexTextRenderer {
fontSize: fontSize,
foreground: fontColor != null ? (Paint()..color = fontColor) : paint,
fontWeight: fontWeight,
background:
backgroundColor == null ? null : (Paint()..color = backgroundColor),
);

/// 3.添加样式和文字
Expand All @@ -52,7 +55,8 @@ class VertexTextRendererImpl extends VertexTextRenderer {
TextPainter hpainter = TextPainter(
textDirection: TextDirection.ltr,
text: TextSpan(
style: const TextStyle(fontSize: 16),
style:
TextStyle(fontSize: paragraphFontSize + 2, fontWeight: fontWeight),
text: text,
),
)..layout();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_graph_view
description: Widgets for beautiful graphic data structures, such as force-oriented diagrams.
version: 1.0.4
version: 1.0.4+1
repository: https://github.com/dudu-ltd/flutter_graph_view
homepage: https://graph-cn.github.io/flutter_graph_view

Expand Down

0 comments on commit c644ae1

Please sign in to comment.