mirror of https://github.com/flutter/pinball.git
feat: include game files (#2)
* feat: included flame and flame_forge2d dependency * feat: included initial LandingPage with PinballGame * feat: included test * feat: included navigation test * fix: landing page test * feat: used l10n string for "Play" Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>pull/5/head
parent
5ab34687a0
commit
ab77ebec67
@ -0,0 +1,2 @@
|
||||
export 'pinball_game.dart';
|
||||
export 'view/pinball_game_page.dart';
|
@ -0,0 +1,3 @@
|
||||
import 'package:flame_forge2d/forge2d_game.dart';
|
||||
|
||||
class PinballGame extends Forge2DGame {}
|
@ -0,0 +1,16 @@
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball/game/game.dart';
|
||||
|
||||
class PinballGamePage extends StatelessWidget {
|
||||
const PinballGamePage({Key? key}) : super(key: key);
|
||||
|
||||
static Route route() {
|
||||
return MaterialPageRoute<void>(builder: (_) => const PinballGamePage());
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GameWidget(game: PinballGame());
|
||||
}
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
{
|
||||
"@@locale": "en",
|
||||
"counterAppBarTitle": "Counter",
|
||||
"@counterAppBarTitle": {
|
||||
"description": "Text shown in the AppBar of the Counter Page"
|
||||
}
|
||||
"play": "Play"
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
{
|
||||
"@@locale": "es",
|
||||
"counterAppBarTitle": "Contador",
|
||||
"@counterAppBarTitle": {
|
||||
"description": "Texto mostrado en la AppBar de la página del contador"
|
||||
}
|
||||
"play": "Jugar"
|
||||
}
|
@ -0,0 +1 @@
|
||||
export 'view/landing_page.dart';
|
@ -0,0 +1,21 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball/game/game.dart';
|
||||
import 'package:pinball/l10n/l10n.dart';
|
||||
|
||||
class LandingPage extends StatelessWidget {
|
||||
const LandingPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = context.l10n;
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: TextButton(
|
||||
onPressed: () =>
|
||||
Navigator.of(context).push<void>(PinballGamePage.route()),
|
||||
child: Text(l10n.play),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
import 'package:flame/game.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pinball/game/game.dart';
|
||||
|
||||
import '../../helpers/helpers.dart';
|
||||
|
||||
void main() {
|
||||
group('PinballGamePage', () {
|
||||
testWidgets('renders single GameWidget with PinballGame', (tester) async {
|
||||
await tester.pumpApp(const PinballGamePage());
|
||||
expect(find.byType(GameWidget<PinballGame>), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mockingjay/mockingjay.dart';
|
||||
import 'package:pinball/landing/landing.dart';
|
||||
|
||||
import '../../helpers/helpers.dart';
|
||||
|
||||
void main() {
|
||||
group('LandingPage', () {
|
||||
testWidgets('renders TextButton', (tester) async {
|
||||
await tester.pumpApp(const LandingPage());
|
||||
expect(find.byType(TextButton), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('tapping on TextButton navigates to PinballGamePage',
|
||||
(tester) async {
|
||||
final navigator = MockNavigator();
|
||||
when(() => navigator.push<void>(any())).thenAnswer((_) async {});
|
||||
|
||||
await tester.pumpApp(
|
||||
const LandingPage(),
|
||||
navigator: navigator,
|
||||
);
|
||||
await tester.tap(
|
||||
find.byType(
|
||||
TextButton,
|
||||
),
|
||||
);
|
||||
|
||||
verify(() => navigator.push<void>(any())).called(1);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in new issue