|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:flame/components.dart';
|
|
|
|
|
import 'package:flame/input.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:pinball/game/game.dart';
|
|
|
|
|
import 'package:pinball/l10n/l10n.dart';
|
|
|
|
@ -8,9 +9,13 @@ import 'package:pinball_components/pinball_components.dart';
|
|
|
|
|
import 'package:pinball_flame/pinball_flame.dart';
|
|
|
|
|
import 'package:pinball_ui/pinball_ui.dart';
|
|
|
|
|
|
|
|
|
|
/// Signature for the callback called when the used has
|
|
|
|
|
/// shared score on the [InfoDisplay].
|
|
|
|
|
typedef ScoreOnShared = void Function();
|
|
|
|
|
/// Signature for the callback called when the used tries to share the score
|
|
|
|
|
/// on the [InfoDisplay].
|
|
|
|
|
typedef OnShareTap = void Function();
|
|
|
|
|
|
|
|
|
|
/// Signature for the callback called when the used tries to navigate to the
|
|
|
|
|
/// Google IO site on the [InfoDisplay].
|
|
|
|
|
typedef OnNavigateTap = void Function();
|
|
|
|
|
|
|
|
|
|
final _titleTextPaint = TextPaint(
|
|
|
|
|
style: const TextStyle(
|
|
|
|
@ -35,7 +40,6 @@ final _linkTextPaint = TextPaint(
|
|
|
|
|
color: PinballColors.orange,
|
|
|
|
|
fontFamily: PinballFonts.pixeloidSans,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
|
decorationThickness: 1,
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
@ -54,21 +58,17 @@ final _descriptionTextPaint = TextPaint(
|
|
|
|
|
class InfoDisplay extends Component with HasGameRef {
|
|
|
|
|
/// {@macro info_display}
|
|
|
|
|
InfoDisplay({
|
|
|
|
|
ScoreOnShared? onShared,
|
|
|
|
|
}) : _onShared = onShared,
|
|
|
|
|
super(
|
|
|
|
|
OnShareTap? onShare,
|
|
|
|
|
OnNavigateTap? onNavigate,
|
|
|
|
|
}) : super(
|
|
|
|
|
children: [
|
|
|
|
|
_InstructionsComponent(),
|
|
|
|
|
_InstructionsComponent(
|
|
|
|
|
onShare: onShare,
|
|
|
|
|
onNavigate: onNavigate,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final ScoreOnShared? _onShared;
|
|
|
|
|
|
|
|
|
|
bool _share() {
|
|
|
|
|
_onShared?.call();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
await super.onLoad();
|
|
|
|
@ -77,19 +77,24 @@ class InfoDisplay extends Component with HasGameRef {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _InstructionsComponent extends PositionComponent with HasGameRef {
|
|
|
|
|
_InstructionsComponent()
|
|
|
|
|
: super(
|
|
|
|
|
_InstructionsComponent({
|
|
|
|
|
OnShareTap? onShare,
|
|
|
|
|
OnNavigateTap? onNavigate,
|
|
|
|
|
}) : super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
|
position: Vector2(0, -25),
|
|
|
|
|
children: [
|
|
|
|
|
_TitleComponent(),
|
|
|
|
|
_LinksComponent(),
|
|
|
|
|
_LinksComponent(
|
|
|
|
|
onShare: onShare,
|
|
|
|
|
onNavigate: onNavigate,
|
|
|
|
|
),
|
|
|
|
|
_DescriptionComponent(),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _TitleComponent extends PositionComponent with HasGameRef<PinballGame> {
|
|
|
|
|
class _TitleComponent extends PositionComponent with HasGameRef {
|
|
|
|
|
_TitleComponent()
|
|
|
|
|
: super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
@ -102,8 +107,7 @@ class _TitleComponent extends PositionComponent with HasGameRef<PinballGame> {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ShareScoreTextComponent extends TextComponent
|
|
|
|
|
with HasGameRef<PinballGame> {
|
|
|
|
|
class _ShareScoreTextComponent extends TextComponent with HasGameRef {
|
|
|
|
|
_ShareScoreTextComponent()
|
|
|
|
|
: super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
@ -118,8 +122,7 @@ class _ShareScoreTextComponent extends TextComponent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ChallengeFriendsTextComponent extends TextComponent
|
|
|
|
|
with HasGameRef<PinballGame> {
|
|
|
|
|
class _ChallengeFriendsTextComponent extends TextComponent with HasGameRef {
|
|
|
|
|
_ChallengeFriendsTextComponent()
|
|
|
|
|
: super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
@ -152,26 +155,42 @@ class _TitleBackgroundSpriteComponent extends SpriteComponent with HasGameRef {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _LinksComponent extends PositionComponent with HasGameRef<PinballGame> {
|
|
|
|
|
_LinksComponent()
|
|
|
|
|
: super(
|
|
|
|
|
class _LinksComponent extends PositionComponent with HasGameRef {
|
|
|
|
|
_LinksComponent({
|
|
|
|
|
OnShareTap? onShare,
|
|
|
|
|
OnNavigateTap? onNavigate,
|
|
|
|
|
}) : super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
|
position: Vector2(0, 9.2),
|
|
|
|
|
children: [
|
|
|
|
|
_ShareLinkComponent(),
|
|
|
|
|
_GotoIOLinkComponent(),
|
|
|
|
|
ShareLinkComponent(onTap: onShare),
|
|
|
|
|
GotoIOLinkComponent(onTap: onNavigate),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ShareLinkComponent extends TextComponent with HasGameRef<PinballGame> {
|
|
|
|
|
_ShareLinkComponent()
|
|
|
|
|
: super(
|
|
|
|
|
/// {@template share_link_component}
|
|
|
|
|
/// Link button for navigate to sharing score screen.
|
|
|
|
|
/// {@endtemplate}
|
|
|
|
|
class ShareLinkComponent extends TextComponent with HasGameRef, Tappable {
|
|
|
|
|
/// {@macro share_link_component}
|
|
|
|
|
ShareLinkComponent({
|
|
|
|
|
OnShareTap? onTap,
|
|
|
|
|
}) : _onTap = onTap,
|
|
|
|
|
super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
|
position: Vector2(-7, 0),
|
|
|
|
|
textRenderer: _linkTextPaint,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final OnShareTap? _onTap;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool onTapDown(TapDownInfo info) {
|
|
|
|
|
_onTap?.call();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
await super.onLoad();
|
|
|
|
@ -179,14 +198,28 @@ class _ShareLinkComponent extends TextComponent with HasGameRef<PinballGame> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _GotoIOLinkComponent extends TextComponent with HasGameRef<PinballGame> {
|
|
|
|
|
_GotoIOLinkComponent()
|
|
|
|
|
: super(
|
|
|
|
|
/// {@template goto_io_link_component}
|
|
|
|
|
/// Link button for navigate to Google I/O site.
|
|
|
|
|
/// {@endtemplate}
|
|
|
|
|
class GotoIOLinkComponent extends TextComponent with HasGameRef, Tappable {
|
|
|
|
|
/// {@macro goto_io_link_component}
|
|
|
|
|
GotoIOLinkComponent({
|
|
|
|
|
OnNavigateTap? onTap,
|
|
|
|
|
}) : _onTap = onTap,
|
|
|
|
|
super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
|
position: Vector2(6, 0),
|
|
|
|
|
textRenderer: _linkTextPaint,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
final OnNavigateTap? _onTap;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool onTapDown(TapDownInfo info) {
|
|
|
|
|
_onTap?.call();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Future<void> onLoad() async {
|
|
|
|
|
await super.onLoad();
|
|
|
|
@ -194,8 +227,7 @@ class _GotoIOLinkComponent extends TextComponent with HasGameRef<PinballGame> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _DescriptionComponent extends PositionComponent
|
|
|
|
|
with HasGameRef<PinballGame> {
|
|
|
|
|
class _DescriptionComponent extends PositionComponent with HasGameRef {
|
|
|
|
|
_DescriptionComponent()
|
|
|
|
|
: super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
@ -207,8 +239,7 @@ class _DescriptionComponent extends PositionComponent
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _LearnMoreTextComponent extends TextComponent
|
|
|
|
|
with HasGameRef<PinballGame> {
|
|
|
|
|
class _LearnMoreTextComponent extends TextComponent with HasGameRef {
|
|
|
|
|
_LearnMoreTextComponent()
|
|
|
|
|
: super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
@ -223,8 +254,7 @@ class _LearnMoreTextComponent extends TextComponent
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _LearnMore2TextComponent extends TextComponent
|
|
|
|
|
with HasGameRef<PinballGame> {
|
|
|
|
|
class _LearnMore2TextComponent extends TextComponent with HasGameRef {
|
|
|
|
|
_LearnMore2TextComponent()
|
|
|
|
|
: super(
|
|
|
|
|
anchor: Anchor.center,
|
|
|
|
|