Fix text alpha updates during fade
This commit is contained in:
@@ -138,6 +138,51 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('updates text alpha style without rebuilding text component', () {
|
||||
final component = RuntimeComponent(
|
||||
node: const RuntimeNode(
|
||||
id: 'text',
|
||||
type: RuntimeNodeType.text,
|
||||
text: 'Fade me',
|
||||
alpha: 0,
|
||||
color: Color(0xffffffff),
|
||||
),
|
||||
resources: GameResourceManager(),
|
||||
onNodeTap: (_, __) {},
|
||||
);
|
||||
|
||||
final text = component.children.whereType<TextComponent>().single;
|
||||
expect(((text.textRenderer as TextPaint).style.color!).a, 0);
|
||||
|
||||
component.setRuntimeAlpha(1);
|
||||
|
||||
final updatedText = component.children.whereType<TextComponent>().single;
|
||||
expect(identical(updatedText, text), isTrue);
|
||||
expect(((updatedText.textRenderer as TextPaint).style.color!).a, 1);
|
||||
});
|
||||
|
||||
test('updates button text alpha style without rebuilding text component', () {
|
||||
final component = RuntimeComponent(
|
||||
node: const RuntimeNode(
|
||||
id: 'button',
|
||||
type: RuntimeNodeType.button,
|
||||
text: 'Fade me',
|
||||
alpha: 0,
|
||||
),
|
||||
resources: GameResourceManager(),
|
||||
onNodeTap: (_, __) {},
|
||||
);
|
||||
|
||||
final text = component.children.whereType<TextComponent>().single;
|
||||
expect(((text.textRenderer as TextPaint).style.color!).a, 0);
|
||||
|
||||
component.setRuntimeAlpha(1);
|
||||
|
||||
final updatedText = component.children.whereType<TextComponent>().single;
|
||||
expect(identical(updatedText, text), isTrue);
|
||||
expect(((updatedText.textRenderer as TextPaint).style.color!).a, 1);
|
||||
});
|
||||
|
||||
test('applies text shadow style', () {
|
||||
final component = RuntimeComponent(
|
||||
node: const RuntimeNode(
|
||||
|
||||
Reference in New Issue
Block a user