Fix text alpha updates during fade
This commit is contained in:
@@ -67,7 +67,12 @@ class RuntimeComponent extends PositionComponent
|
||||
double get renderAlpha => _runtimeAlpha ?? _node.alpha;
|
||||
|
||||
void setRuntimeAlpha(double value) {
|
||||
_runtimeAlpha = value.clamp(0, 1).toDouble();
|
||||
final next = value.clamp(0, 1).toDouble();
|
||||
if (_runtimeAlpha == next) {
|
||||
return;
|
||||
}
|
||||
_runtimeAlpha = next;
|
||||
_syncTextStyle(_node);
|
||||
}
|
||||
|
||||
void setParentScroll({
|
||||
@@ -961,21 +966,11 @@ class RuntimeComponent extends PositionComponent
|
||||
}
|
||||
|
||||
final text = label ?? '';
|
||||
final color = _textColor(node);
|
||||
final style = TextStyle(
|
||||
color: composeRuntimeColorAlpha(color, renderAlpha),
|
||||
fontSize: node.fontSize ?? 18,
|
||||
fontWeight: node.type == RuntimeNodeType.button
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
shadows: _textShadows(node),
|
||||
);
|
||||
|
||||
final component = _textComponent;
|
||||
if (component == null) {
|
||||
_textComponent = TextComponent(
|
||||
text: text,
|
||||
textRenderer: TextPaint(style: style),
|
||||
textRenderer: TextPaint(style: _textStyle(node)),
|
||||
anchor: _textAnchor(node),
|
||||
position: _textPosition(node),
|
||||
priority: priority + 1,
|
||||
@@ -986,10 +981,30 @@ class RuntimeComponent extends PositionComponent
|
||||
|
||||
component
|
||||
..text = text
|
||||
..textRenderer = TextPaint(style: style)
|
||||
..anchor = _textAnchor(node)
|
||||
..position = _textPosition(node)
|
||||
..priority = priority + 1;
|
||||
_syncTextStyle(node);
|
||||
}
|
||||
|
||||
void _syncTextStyle(RuntimeNode node) {
|
||||
final component = _textComponent;
|
||||
if (component == null) {
|
||||
return;
|
||||
}
|
||||
component.textRenderer = TextPaint(style: _textStyle(node));
|
||||
}
|
||||
|
||||
TextStyle _textStyle(RuntimeNode node) {
|
||||
final color = _textColor(node);
|
||||
return TextStyle(
|
||||
color: composeRuntimeColorAlpha(color, renderAlpha),
|
||||
fontSize: node.fontSize ?? 18,
|
||||
fontWeight: node.type == RuntimeNodeType.button
|
||||
? FontWeight.w600
|
||||
: FontWeight.normal,
|
||||
shadows: _textShadows(node),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user