pr suggestions

pull/341/head
Erick Zanardo 3 years ago
parent fe6e59b527
commit 4b940e4f8a

@ -1,7 +1,6 @@
import 'package:flame/components.dart';
import 'package:flutter/material.dart';
import 'package:pinball/game/game.dart';
import 'package:pinball/l10n/l10n.dart';
import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_ui/pinball_ui.dart';
@ -18,9 +17,7 @@ final _bodyTextPaint = TextPaint(
/// {@endtemplate}
class LoadingDisplay extends TextComponent with HasGameRef<PinballGame> {
/// {@template loading_display}
LoadingDisplay({AppLocalizations? l10n}) : _l10n = l10n;
final AppLocalizations? _l10n;
LoadingDisplay();
late final String _label;
@ -30,7 +27,7 @@ class LoadingDisplay extends TextComponent with HasGameRef<PinballGame> {
position = Vector2(0, -10);
anchor = Anchor.center;
text = _label = (_l10n ?? gameRef.l10n).loading;
text = _label = gameRef.l10n.loading;
textRenderer = _bodyTextPaint;
await add(

@ -16,10 +16,14 @@ class _MockAppLocalizations extends Mock implements AppLocalizations {
void main() {
group('LoadingDisplay', () {
final flameTester = FlameTester(EmptyKeyboardPinballTestGame.new);
final flameTester = FlameTester(
() => EmptyPinballTestGame(
l10n: _MockAppLocalizations(),
),
);
flameTester.test('renders correctly', (game) async {
await game.ensureAdd(LoadingDisplay(l10n: _MockAppLocalizations()));
await game.ensureAdd(LoadingDisplay());
final component = game.firstChild<TextComponent>();
expect(component, isNotNull);
@ -27,7 +31,7 @@ void main() {
});
flameTester.test('use ellipses as animation', (game) async {
await game.ensureAdd(LoadingDisplay(l10n: _MockAppLocalizations()));
await game.ensureAdd(LoadingDisplay());
final component = game.firstChild<TextComponent>();
expect(component?.text, equals('Loading'));

Loading…
Cancel
Save