fix: remove duplicated PinballButton

pull/252/head
arturplaczek 3 years ago
parent 048372e9df
commit ae8d3f02f8

Binary file not shown.

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 'bonus_animation.dart';
export 'game_hud.dart'; export 'game_hud.dart';
export 'pinball_button.dart';
export 'play_button_overlay.dart'; export 'play_button_overlay.dart';
export 'round_count_display.dart'; export 'round_count_display.dart';
export 'score_view.dart'; export 'score_view.dart';

@ -70,10 +70,6 @@ class $AssetsImagesScoreGen {
class $AssetsImagesSelectCharacterGen { class $AssetsImagesSelectCharacterGen {
const $AssetsImagesSelectCharacterGen(); const $AssetsImagesSelectCharacterGen();
/// File path: assets/images/select_character/pinball_button.png
AssetGenImage get pinballButton =>
const AssetGenImage('assets/images/select_character/pinball_button.png');
/// File path: assets/images/select_character/star_a.png /// File path: assets/images/select_character/star_a.png
AssetGenImage get starA => AssetGenImage get starA =>
const AssetGenImage('assets/images/select_character/star_a.png'); const AssetGenImage('assets/images/select_character/star_a.png');

@ -3,9 +3,9 @@ import 'package:flame/sprite.dart';
import 'package:flutter/material.dart' hide Image; import 'package:flutter/material.dart' hide Image;
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pinball/select_character/select_character.dart'; import 'package:pinball/select_character/select_character.dart';
import 'package:pinball/theme/theme.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
import 'package:pinball_theme/pinball_theme.dart'; import 'package:pinball_theme/pinball_theme.dart';
import 'package:pinball_ui/pinball_ui.dart';
/// {@template selected_character} /// {@template selected_character}
/// Widget to display the selected character based on the [CharacterThemeCubit] /// Widget to display the selected character based on the [CharacterThemeCubit]
@ -91,8 +91,8 @@ class _SelectedCharacterState extends State<SelectedCharacter>
children: [ children: [
Text( Text(
currentCharacter.name, currentCharacter.name,
style: AppTextStyle.headline2.copyWith( style: PinballTextStyle.headline2.copyWith(
color: AppColors.white, color: PinballColors.white,
), ),
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),

@ -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…
Cancel
Save