From 8642eac9b29697fa0d4e2d86746bd8bceeb5acb6 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Mon, 30 May 2022 20:32:10 -0400 Subject: [PATCH] Add intro popup dialog --- lib/main.dart | 4 +-- lib/screens/home/home.dart | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 575a10ef..631ab680 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -25,13 +25,11 @@ void main() async { // Workaround for clearing stored tokens on uninstall. // If first time running app, will clear all tokens in the secure storage. - if (prefs.getBool('first_run') ?? true) { + if (prefs.getBool('first_run') != false) { debugPrint('Clearing secure storage...'); const storage = FlutterSecureStorage(); await storage.deleteAll(); - - prefs.setBool('first_run', false); } // With the shared preferences instance, obtain the existing user settings if it exists. diff --git a/lib/screens/home/home.dart b/lib/screens/home/home.dart index db0eaf3f..060cf147 100644 --- a/lib/screens/home/home.dart +++ b/lib/screens/home/home.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:frosty/core/auth/auth_store.dart'; @@ -8,7 +10,9 @@ import 'package:frosty/screens/home/top/top_section.dart'; import 'package:frosty/screens/home/widgets/streams_list.dart'; import 'package:frosty/screens/settings/settings.dart'; import 'package:frosty/screens/settings/stores/settings_store.dart'; +import 'package:package_info_plus/package_info_plus.dart'; import 'package:provider/provider.dart'; +import 'package:shared_preferences/shared_preferences.dart'; class Home extends StatefulWidget { const Home({Key? key}) : super(key: key); @@ -22,6 +26,62 @@ class _HomeState extends State { late final _homeStore = HomeStore(authStore: _authStore); + Future _showStartDialog() async { + final packageInfo = await PackageInfo.fromPlatform(); + final prefs = await SharedPreferences.getInstance(); + + if (prefs.getBool('first_run') == false) return; + + return showDialog( + barrierDismissible: false, + context: context, + builder: (context) => AlertDialog( + scrollable: true, + title: Text( + 'Frosty v${packageInfo.version} (${packageInfo.buildNumber})', + style: const TextStyle( + fontWeight: FontWeight.bold, + ), + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Text( + 'Thank you so much for downloading and trying out Frosty! Hopefully it will make your mobile Twitch viewing experience a little more enjoyable.'), + const SizedBox(height: 20.0), + const Text( + 'You can see the full changelog on the app store listing or the "Releases" section on the GitHub repo (link on the top right of settings).'), + const SizedBox(height: 20.0), + const Text('You can also find the FAQ on the GitHub repo (link in Settings -> Other).'), + const SizedBox(height: 20.0), + const Text('If you have any issues or feature requests for the app, please open an issue on GitHub.'), + if (Platform.isAndroid) ...[ + const SizedBox(height: 20.0), + const Text('NOTE: Due to limitations with the Twitch web player, video streams may not work on Android versions below 7.1.1.'), + ] + ], + ), + actions: [ + TextButton( + onPressed: () { + prefs.setBool('first_run', false); + + Navigator.of(context).pop(); + }, + child: const Text('Close'), + ), + ], + ), + ); + } + + @override + void initState() { + super.initState(); + _showStartDialog(); + } + @override Widget build(BuildContext context) { return GestureDetector(