refactor: url and text for share

pull/406/head
RuiAlonso 3 years ago
parent db6a5f2848
commit eef391f1a8

@ -6,6 +6,7 @@ import 'package:leaderboard_repository/leaderboard_repository.dart';
import 'package:pinball/game/components/backbox/bloc/backbox_bloc.dart'; import 'package:pinball/game/components/backbox/bloc/backbox_bloc.dart';
import 'package:pinball/game/components/backbox/displays/displays.dart'; import 'package:pinball/game/components/backbox/displays/displays.dart';
import 'package:pinball/game/game.dart'; import 'package:pinball/game/game.dart';
import 'package:pinball/l10n/l10n.dart';
import 'package:pinball_components/pinball_components.dart'; import 'package:pinball_components/pinball_components.dart';
import 'package:pinball_flame/pinball_flame.dart'; import 'package:pinball_flame/pinball_flame.dart';
import 'package:pinball_theme/pinball_theme.dart' hide Assets; import 'package:pinball_theme/pinball_theme.dart' hide Assets;
@ -107,8 +108,10 @@ class Backbox extends PositionComponent with ZIndex, HasGameRef {
_display.add( _display.add(
ShareDisplay( ShareDisplay(
onShare: (platform) { onShare: (platform) {
final message = readProvider<AppLocalizations>()
.iGotScoreAtPinball(state.score);
final url = _shareRepository.shareText( final url = _shareRepository.shareText(
value: state.score.toString(), value: message,
platform: platform, platform: platform,
); );
openLink(url); openLink(url);

@ -189,7 +189,7 @@
"description": "Text shown on the mobile controls enter button" "description": "Text shown on the mobile controls enter button"
}, },
"initialsErrorTitle": "Uh-oh... well, that didnt work", "initialsErrorTitle": "Uh-oh... well, that didnt work",
"@enter": { "@initialsErrorTitle": {
"description": "Title shown when the initials submission fails" "description": "Title shown when the initials submission fails"
}, },
"initialsErrorMessage": "Please try a different combination of letters", "initialsErrorMessage": "Please try a different combination of letters",
@ -212,5 +212,14 @@
"socialMediaAccount": "social media account!", "socialMediaAccount": "social media account!",
"@socialMediaAccount": { "@socialMediaAccount": {
"description": "Text displayed on share screen for description" "description": "Text displayed on share screen for description"
},
"iGotScoreAtPinball": "I got {score} at the #IOPinball machine, can you beat my score? See you at #GoogleIO!",
"@iGotScoreAtPinball": {
"description": "Text to share score on Social Network",
"placeholders": {
"score": {
"type": "int"
}
}
} }
} }

@ -12,7 +12,7 @@ void main() {
bootstrap((firestore, firebaseAuth) async { bootstrap((firestore, firebaseAuth) async {
final leaderboardRepository = LeaderboardRepository(firestore); final leaderboardRepository = LeaderboardRepository(firestore);
const shareRepository = const shareRepository =
ShareRepository(appUrl: ShareRepository.googleIOEvent); ShareRepository(appUrl: ShareRepository.pinballGameUrl);
final authenticationRepository = AuthenticationRepository(firebaseAuth); final authenticationRepository = AuthenticationRepository(firebaseAuth);
final pinballAudioPlayer = PinballAudioPlayer(); final pinballAudioPlayer = PinballAudioPlayer();
unawaited( unawaited(

@ -17,6 +17,9 @@ class ShareRepository {
/// Url to the Google IO Event. /// Url to the Google IO Event.
static const googleIOEvent = 'https://events.google.com/io/'; static const googleIOEvent = 'https://events.google.com/io/';
/// Url to the Pinball game.
static const pinballGameUrl = 'https://ashehwkdkdjruejdnensjsjdne.web.app/#/';
/// Returns a url to share the [value] on the given [platform]. /// 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. /// The returned url can be opened using the [url_launcher](https://pub.dev/packages/url_launcher) package.

@ -154,6 +154,9 @@ class _MockAppLocalizations extends Mock implements AppLocalizations {
@override @override
String get leaderboardErrorMessage => ''; String get leaderboardErrorMessage => '';
@override
String iGotScoreAtPinball(int _) => '';
} }
void main() { void main() {
@ -508,7 +511,7 @@ void main() {
verify( verify(
() => shareRepository.shareText( () => shareRepository.shareText(
value: state.score.toString(), value: any(named: 'value'),
platform: SharePlatform.facebook, platform: SharePlatform.facebook,
), ),
).called(1); ).called(1);
@ -562,7 +565,7 @@ void main() {
verify( verify(
() => shareRepository.shareText( () => shareRepository.shareText(
value: state.score.toString(), value: any(named: 'value'),
platform: SharePlatform.twitter, platform: SharePlatform.twitter,
), ),
).called(1); ).called(1);

Loading…
Cancel
Save