From 9233bd66349988440c5fda58bad163142f3f726a Mon Sep 17 00:00:00 2001 From: Erick Date: Thu, 30 Nov 2023 10:30:37 -0300 Subject: [PATCH] feat: apps url links (#176) --- .gitignore | 1 - lib/constants/urls.dart | 9 +++- lib/game_intro/view/game_intro_page.dart | 58 ++++++++---------------- lib/l10n/arb/app_en.arb | 10 +++- 4 files changed, 36 insertions(+), 42 deletions(-) diff --git a/.gitignore b/.gitignore index 75606597..e2b7ea1b 100644 --- a/.gitignore +++ b/.gitignore @@ -104,7 +104,6 @@ coverage/ packages/**/pubspec.lock # Web related -lib/generated_plugin_registrant.dart # Symbolication related app.*.symbols diff --git a/lib/constants/urls.dart b/lib/constants/urls.dart index f455ae11..850c8d75 100644 --- a/lib/constants/urls.dart +++ b/lib/constants/urls.dart @@ -7,5 +7,12 @@ class Urls { static const String termsOfService = 'https://policies.google.com/terms'; - static const String howWeBuilt = 'https://medium.com/flutter/9c7aa2a5ad31'; + static const String howWeBuilt = + 'https://medium.com/flutter/how-we-built-the-new-super-dash-demo-in-flutter-and-flame-in-just-six-weeks-9c7aa2a5ad31'; + + static const appStoreLink = + 'https://apps.apple.com/app/super-dash-flutter-game/id6473050393'; + + static const playStoreLink = + 'https://play.google.com/store/apps/details?id=com.verygoodventures.super_dash'; } diff --git a/lib/game_intro/view/game_intro_page.dart b/lib/game_intro/view/game_intro_page.dart index dc1d06cb..2051b492 100644 --- a/lib/game_intro/view/game_intro_page.dart +++ b/lib/game_intro/view/game_intro_page.dart @@ -5,9 +5,8 @@ import 'package:dash_run/game_intro/game_intro.dart'; import 'package:dash_run/gen/assets.gen.dart'; import 'package:dash_run/l10n/l10n.dart'; import 'package:flutter/foundation.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:url_launcher/url_launcher_string.dart'; +import 'package:url_launcher/url_launcher.dart'; class GameIntroPage extends StatefulWidget { const GameIntroPage({super.key}); @@ -23,6 +22,11 @@ class _GameIntroPageState extends State { precacheImage(Assets.images.gameBackground.provider(), context); } + void _onDownload() { + final isAndroid = defaultTargetPlatform == TargetPlatform.android; + launchUrl(Uri.parse(isAndroid ? Urls.playStoreLink : Urls.appStoreLink)); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -36,7 +40,7 @@ class _GameIntroPageState extends State { ), ), child: isMobileWeb - ? const _MobileWebNotAvailableIntroPage() + ? _MobileWebNotAvailableIntroPage(onDownload: _onDownload) : const _IntroPage(), ), ); @@ -100,20 +104,17 @@ class _IntroPage extends StatelessWidget { } class _MobileWebNotAvailableIntroPage extends StatelessWidget { - const _MobileWebNotAvailableIntroPage(); + const _MobileWebNotAvailableIntroPage({ + required this.onDownload, + }); + + final VoidCallback onDownload; @override Widget build(BuildContext context) { final l10n = context.l10n; final theme = Theme.of(context); final textTheme = theme.textTheme; - final descriptionTextStyle = textTheme.headlineSmall?.copyWith( - color: Colors.white, - fontWeight: FontWeight.bold, - ); - final linkStyle = descriptionTextStyle?.copyWith( - decoration: TextDecoration.underline, - ); return Center( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 390), @@ -122,43 +123,22 @@ class _MobileWebNotAvailableIntroPage extends StatelessWidget { const Spacer(), Assets.images.gameLogo.image(width: 282), const Spacer(flex: 4), - Container( - decoration: const BoxDecoration( - shape: BoxShape.circle, - color: Color(0xFF0046ab), - ), - padding: const EdgeInsets.all(12), - child: const Icon( - Icons.mobile_off, - size: 24, - color: Colors.white, - ), - ), const SizedBox(height: 24), Text( - l10n.mobileAppsComingSoon, + l10n.downloadAppMessage, textAlign: TextAlign.center, style: textTheme.headlineSmall?.copyWith( color: Colors.white, - fontWeight: FontWeight.bold, ), ), const SizedBox(height: 24), - RichText( - textAlign: TextAlign.center, - text: TextSpan( - style: descriptionTextStyle, - children: [ - TextSpan(text: l10n.mobileAppsComingSoonGrabThe), - TextSpan( - text: l10n.mobileAppsComingSoonMobileSourceCode, - style: linkStyle, - recognizer: TapGestureRecognizer() - ..onTap = () => launchUrlString(Urls.githubRepo), - ), - TextSpan(text: l10n.mobileAppsComingSoonDescription), - ], + GameElevatedButton.icon( + label: l10n.downloadAppLabel, + icon: const Icon( + Icons.download, + color: Colors.white, ), + onPressed: onDownload, ), const Spacer(), const BottomBar(), diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arb index 3c4bcb50..3e4486c7 100644 --- a/lib/l10n/arb/app_en.arb +++ b/lib/l10n/arb/app_en.arb @@ -204,5 +204,13 @@ "tapToStart": "Tap/press Space to start", "@tapToStart": { "description": "Text shown in the game page" + }, + "downloadAppMessage": "Fly into Super Dash, avoid the bugs, collect points, and see how far you can go!", + "@downloadAppMessage": { + "description": "Text shown in the download mobile app page" + }, + "downloadAppLabel": "Download the app", + "@downloadAppLabel": { + "description": "Button lable for the app download" } -} \ No newline at end of file +}