diff --git a/lib/game/view/widgets/pinball_button.dart b/lib/game/view/widgets/pinball_button.dart index fc739696..db388ef1 100644 --- a/lib/game/view/widgets/pinball_button.dart +++ b/lib/game/view/widgets/pinball_button.dart @@ -1,6 +1,8 @@ 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} @@ -8,20 +10,19 @@ class PinballButton extends StatelessWidget { /// {@macro pinball_button} const PinballButton({ Key? key, - required this.child, - this.onPressed, - }) : super(key: key); - - /// Child displayed on button. - final Widget child; + required Widget child, + VoidCallback? onPressed, + }) : _child = child, + _onPressed = onPressed, + super(key: key); - /// On pressed callback used for user integration. - final VoidCallback? onPressed; + final Widget _child; + final VoidCallback? _onPressed; @override Widget build(BuildContext context) { return InkWell( - onTap: onPressed, + onTap: _onPressed, child: DecoratedBox( decoration: BoxDecoration( image: DecorationImage( @@ -36,7 +37,7 @@ class PinballButton extends StatelessWidget { horizontal: 32, vertical: 16, ), - child: child, + child: _child, ), ), ), diff --git a/lib/game/view/widgets/widgets.dart b/lib/game/view/widgets/widgets.dart index 5d1fccf8..2bc78c9b 100644 --- a/lib/game/view/widgets/widgets.dart +++ b/lib/game/view/widgets/widgets.dart @@ -1,5 +1,6 @@ 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'; diff --git a/lib/select_character/widgets/character_icon.dart b/lib/select_character/widgets/character_icon.dart index 1afb4c6a..aa697201 100644 --- a/lib/select_character/widgets/character_icon.dart +++ b/lib/select_character/widgets/character_icon.dart @@ -1,17 +1,23 @@ -// ignore_for_file: public_member_api_docs - import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:pinball/select_character/select_character.dart'; import 'package:pinball_theme/pinball_theme.dart' hide Assets; +/// {@template character_icon} +/// Widget for displaying character icon. +/// +/// On tap changes selected character in [CharacterThemeCubit]. +/// {@endtemplate} class CharacterIcon extends StatelessWidget { + /// {@macro character_icon} + const CharacterIcon( - this.characterTheme, { + CharacterTheme characterTheme, { Key? key, - }) : super(key: key); + }) : _characterTheme = characterTheme, + super(key: key); - final CharacterTheme characterTheme; + final CharacterTheme _characterTheme; @override Widget build(BuildContext context) { @@ -21,13 +27,14 @@ class CharacterIcon extends StatelessWidget { ); return GestureDetector( - onTap: () => - context.read().characterSelected(characterTheme), + onTap: () => context + .read() + .characterSelected(_characterTheme), child: Opacity( - opacity: currentCharacterTheme == characterTheme ? 1 : 0.5, + opacity: currentCharacterTheme == _characterTheme ? 1 : 0.5, child: Padding( padding: const EdgeInsets.all(8), - child: characterTheme.icon.image( + child: _characterTheme.icon.image( fit: BoxFit.contain, ), ), diff --git a/lib/select_character/widgets/selected_character.dart b/lib/select_character/widgets/selected_character.dart index 3b0fa9f2..0e9dd430 100644 --- a/lib/select_character/widgets/selected_character.dart +++ b/lib/select_character/widgets/selected_character.dart @@ -1,5 +1,3 @@ -// ignore_for_file: public_member_api_docs - import 'package:flame/flame.dart'; import 'package:flame/sprite.dart'; import 'package:flutter/material.dart' hide Image; @@ -9,7 +7,14 @@ import 'package:pinball/theme/theme.dart'; import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_theme/pinball_theme.dart'; +/// {@template selected_character} +/// Widget to display the selected character based on the [CharacterThemeCubit] +/// state. +/// +/// Displays a looped [SpriteAnimationWidget]. +/// {@endtemplate} class SelectedCharacter extends StatefulWidget { + /// {@macro selected_character} const SelectedCharacter({ Key? key, }) : super(key: key); @@ -17,6 +22,7 @@ class SelectedCharacter extends StatefulWidget { @override State createState() => _SelectedCharacterState(); + /// Returns a list of assets to be loaded static List loadAssets() { Flame.images.prefix = ''; diff --git a/lib/select_character/widgets/star_animation.dart b/lib/select_character/widgets/star_animation.dart index 0f23e336..662420fb 100644 --- a/lib/select_character/widgets/star_animation.dart +++ b/lib/select_character/widgets/star_animation.dart @@ -1,20 +1,28 @@ -// ignore_for_file: public_member_api_docs - import 'package:flame/flame.dart'; import 'package:flame/sprite.dart'; import 'package:flame/widgets.dart'; import 'package:flutter/material.dart' hide Image; import 'package:pinball/gen/gen.dart'; +/// {@template star_animation} +/// Widget to display a looped the star animation. +/// +/// For animation is using [SpriteAnimationWidget]. +/// {@endtemplate} class StarAnimation extends StatelessWidget { const StarAnimation._({ Key? key, - required this.imagePath, - required this.columns, - required this.rows, - required this.stepTime, - }) : super(key: key); + required String imagePath, + required int columns, + required int rows, + required double stepTime, + }) : _imagePath = imagePath, + _columns = columns, + _rows = rows, + _stepTime = stepTime, + super(key: key); + /// [Widget] that displays the star A animation. StarAnimation.starA({ Key? key, }) : this._( @@ -25,6 +33,7 @@ class StarAnimation extends StatelessWidget { stepTime: 1 / 18, ); + /// [Widget] that displays the star B animation. StarAnimation.starB({ Key? key, }) : this._( @@ -35,6 +44,7 @@ class StarAnimation extends StatelessWidget { stepTime: 1 / 36, ); + /// [Widget] that displays the star C animation. StarAnimation.starC({ Key? key, }) : this._( @@ -45,11 +55,12 @@ class StarAnimation extends StatelessWidget { stepTime: 1 / 24, ); - final String imagePath; - final int columns; - final int rows; - final double stepTime; + final String _imagePath; + final int _columns; + final int _rows; + final double _stepTime; + /// Returns a list of assets to be loaded static Future loadAssets() { Flame.images.prefix = ''; @@ -63,13 +74,13 @@ class StarAnimation extends StatelessWidget { @override Widget build(BuildContext context) { final spriteSheet = SpriteSheet.fromColumnsAndRows( - image: Flame.images.fromCache(imagePath), - columns: columns, - rows: rows, + image: Flame.images.fromCache(_imagePath), + columns: _columns, + rows: _rows, ); final animation = spriteSheet.createAnimation( row: 0, - stepTime: stepTime, + stepTime: _stepTime, to: spriteSheet.rows * spriteSheet.columns, );