From 6397441428298be2811ba07444abefe4a773dc3e Mon Sep 17 00:00:00 2001 From: RuiAlonso Date: Sat, 7 May 2022 11:57:17 +0200 Subject: [PATCH] feat: added open source url url launcher --- lib/game/components/backbox/backbox.dart | 3 +++ lib/game/components/backbox/bloc/backbox_bloc.dart | 5 +++-- lib/game/pinball_game.dart | 4 +++- packages/pinball_components/sandbox/pubspec.lock | 9 ++++++++- packages/share_repository/lib/src/share_repository.dart | 2 ++ pubspec.lock | 9 ++++++++- pubspec.yaml | 3 +++ 7 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/game/components/backbox/backbox.dart b/lib/game/components/backbox/backbox.dart index 35165ba9..5789f2bf 100644 --- a/lib/game/components/backbox/backbox.dart +++ b/lib/game/components/backbox/backbox.dart @@ -8,6 +8,8 @@ import 'package:pinball/game/components/backbox/displays/displays.dart'; import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_theme/pinball_theme.dart' hide Assets; +import 'package:pinball_ui/pinball_ui.dart'; +import 'package:share_repository/share_repository.dart'; /// {@template backbox} /// The [Backbox] of the pinball machine. @@ -85,6 +87,7 @@ class Backbox extends PositionComponent with ZIndex { ), ); }, + onNavigate: () => launchUrl(Uri.parse(ShareRepository.openSourceUrl)), ), ); } else if (state is InitialsFailureState) { diff --git a/lib/game/components/backbox/bloc/backbox_bloc.dart b/lib/game/components/backbox/bloc/backbox_bloc.dart index 6139b557..21ce1608 100644 --- a/lib/game/components/backbox/bloc/backbox_bloc.dart +++ b/lib/game/components/backbox/bloc/backbox_bloc.dart @@ -42,13 +42,14 @@ class BackboxBloc extends Bloc { ) async { try { emit(LoadingState()); - await _leaderboardRepository.addLeaderboardEntry( + /*await _leaderboardRepository.addLeaderboardEntry( LeaderboardEntryData( playerInitials: event.initials, score: event.score, character: event.character.toType, ), - ); + );*/ + await Future.delayed(Duration(seconds: 2)); emit( InitialsSuccessState( initials: event.initials, diff --git a/lib/game/pinball_game.dart b/lib/game/pinball_game.dart index 24f9d192..1ec7626c 100644 --- a/lib/game/pinball_game.dart +++ b/lib/game/pinball_game.dart @@ -92,7 +92,9 @@ class PinballGame extends PinballForge2DGame children: [ BoardBackgroundSpriteComponent(), Boundaries(), - Backbox(leaderboardRepository: leaderboardRepository), + Backbox( + leaderboardRepository: leaderboardRepository, + ), GoogleWord(position: Vector2(-4.45, 1.8)), Multipliers(), Multiballs(), diff --git a/packages/pinball_components/sandbox/pubspec.lock b/packages/pinball_components/sandbox/pubspec.lock index 616a7dd3..b5ac88b7 100644 --- a/packages/pinball_components/sandbox/pubspec.lock +++ b/packages/pinball_components/sandbox/pubspec.lock @@ -291,6 +291,13 @@ packages: relative: true source: path version: "1.0.0+1" + pinball_ui: + dependency: transitive + description: + path: "../../pinball_ui" + relative: true + source: path + version: "1.0.0+1" platform: dependency: transitive description: @@ -435,7 +442,7 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.20" + version: "6.1.0" url_launcher_android: dependency: transitive description: diff --git a/packages/share_repository/lib/src/share_repository.dart b/packages/share_repository/lib/src/share_repository.dart index 6e6679c2..a7c7dc7d 100644 --- a/packages/share_repository/lib/src/share_repository.dart +++ b/packages/share_repository/lib/src/share_repository.dart @@ -11,6 +11,8 @@ class ShareRepository { final String _appUrl; + static const openSourceUrl = 'https://github.com/VGVentures/pinball'; + /// Returns a url to share the [value] on the given [platform]. /// /// The returned url can be opened using the [url_launcher](https://pub.dev/packages/url_launcher) package. diff --git a/pubspec.lock b/pubspec.lock index 83de1390..7199435a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -576,6 +576,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" + share_repository: + dependency: "direct main" + description: + path: "packages/share_repository" + relative: true + source: path + version: "1.0.0+1" shelf: dependency: transitive description: @@ -694,7 +701,7 @@ packages: source: hosted version: "1.3.0" url_launcher: - dependency: transitive + dependency: "direct main" description: name: url_launcher url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index 1a025d4a..84554502 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,6 +44,9 @@ dependencies: path: packages/pinball_ui platform_helper: path: packages/platform_helper + share_repository: + path: packages/share_repository + url_launcher: ^6.1.0 dev_dependencies: bloc_test: ^9.0.2