mirror of https://github.com/flutter/pinball.git
parent
048372e9df
commit
ae8d3f02f8
Before Width: | Height: | Size: 1.6 KiB |
@ -1,46 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pinball/gen/gen.dart';
|
||||
|
||||
// TODO(arturplaczek): move PinballButton to pinball_ui
|
||||
|
||||
/// {@template pinball_button}
|
||||
/// Pinball button with onPressed [VoidCallback] and child [Widget].
|
||||
/// {@endtemplate}
|
||||
class PinballButton extends StatelessWidget {
|
||||
/// {@macro pinball_button}
|
||||
const PinballButton({
|
||||
Key? key,
|
||||
required Widget child,
|
||||
VoidCallback? onPressed,
|
||||
}) : _child = child,
|
||||
_onPressed = onPressed,
|
||||
super(key: key);
|
||||
|
||||
final Widget _child;
|
||||
final VoidCallback? _onPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage(
|
||||
Assets.images.selectCharacter.pinballButton.keyName,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Center(
|
||||
child: InkWell(
|
||||
onTap: _onPressed,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 32,
|
||||
vertical: 16,
|
||||
),
|
||||
child: _child,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
export 'bonus_animation.dart';
|
||||
export 'game_hud.dart';
|
||||
export 'pinball_button.dart';
|
||||
export 'play_button_overlay.dart';
|
||||
export 'round_count_display.dart';
|
||||
export 'score_view.dart';
|
||||
|
@ -1,39 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pinball/game/game.dart';
|
||||
|
||||
import '../../../helpers/helpers.dart';
|
||||
|
||||
void main() {
|
||||
const buttonText = 'this is the button text';
|
||||
|
||||
testWidgets('displays button', (tester) async {
|
||||
await tester.pumpApp(
|
||||
const Material(
|
||||
child: PinballButton(
|
||||
child: Text(buttonText),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text(buttonText), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('on tap calls onPressed callback', (tester) async {
|
||||
var isTapped = false;
|
||||
|
||||
await tester.pumpApp(
|
||||
Material(
|
||||
child: PinballButton(
|
||||
child: const Text(buttonText),
|
||||
onPressed: () {
|
||||
isTapped = true;
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.tap(find.text(buttonText));
|
||||
|
||||
expect(isTapped, isTrue);
|
||||
});
|
||||
}
|
Loading…
Reference in new issue