Add intro popup dialog
This commit is contained in:
parent
145471dcba
commit
8642eac9b2
2 changed files with 61 additions and 3 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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<Home> {
|
|||
|
||||
late final _homeStore = HomeStore(authStore: _authStore);
|
||||
|
||||
Future<void> _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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue