diff --git a/analysis_options.yaml b/analysis_options.yaml index a3ce961..db42bd8 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -5,4 +5,3 @@ linter: unnecessary_this: false curly_braces_in_flow_control_structures: false unnecessary_brace_in_string_interps: false - control_flow_in_finally: false diff --git a/lib/backend/version.dart b/lib/backend/version.dart index 662eb93..b0b1ddc 100644 --- a/lib/backend/version.dart +++ b/lib/backend/version.dart @@ -31,7 +31,7 @@ class VersionChecker return version; } - static Future _getCurrentVersion() async + static Future getCurrentVersion() async { PackageInfo packageInfo = await PackageInfo.fromPlatform(); return packageInfo.version; @@ -40,7 +40,7 @@ class VersionChecker static Future shouldUpdate() async { try { - String currentVersion = await _getCurrentVersion(); + String currentVersion = await getCurrentVersion(); String lastVersion = await _getLastVersion(); return currentVersion != lastVersion; } catch (_) { @@ -126,8 +126,7 @@ class VersionChecker else throw Exception("Unsupported platform"); return true; - } finally { - return false; - } + } catch (_) {} + return false; } } \ No newline at end of file diff --git a/lib/views/home.dart b/lib/views/home.dart index abe7dc0..83decb0 100644 --- a/lib/views/home.dart +++ b/lib/views/home.dart @@ -17,11 +17,13 @@ class HomePage extends StatefulWidget { class _HomePageState extends State { - void _showInfo(BuildContext context) { + void _showInfo(BuildContext context) async { + String version = await VersionChecker.getCurrentVersion(); + // ignore: use_build_context_synchronously showDialog( context: context, builder: (context) => AlertDialog( - title: const Text("Crediti"), + title: Text("Stronzflix ${version}"), content: RichText( text: TextSpan( children: [ @@ -77,9 +79,14 @@ class _HomePageState extends State { ), TextButton( child: Text(action), - onPressed: () { - VersionChecker.update(); - Navigator.of(context).pop(); + onPressed: () async { + VersionChecker.update().then((updated) { + if(!updated) + return; + if(SPlatform.isMobile) + ScaffoldMessenger.of(context).showSnackBar(this._buildUpdateSnackBar()); + Navigator.of(context).pop(); + }); } ) ] @@ -87,6 +94,19 @@ class _HomePageState extends State { ); } + SnackBar _buildUpdateSnackBar() { + return const SnackBar( + content: Column( + children: [ + Text("Aggiornamento in corso..."), + Padding(padding: EdgeInsets.only(top: 8)), + LinearProgressIndicator() + ], + ), + duration: Duration(hours: 1) + ); + } + AppBar _buildSearchBar(BuildContext context) { return AppBar( title: const Text("Stronzflix"), diff --git a/lib/views/stronzflix.dart b/lib/views/stronzflix.dart index 76a19ea..17b9289 100644 --- a/lib/views/stronzflix.dart +++ b/lib/views/stronzflix.dart @@ -28,6 +28,18 @@ class Stronzflix extends StatelessWidget { ), appBarTheme: const AppBarTheme( centerTitle: true + ), + snackBarTheme: const SnackBarThemeData( + backgroundColor: Color(0xff121212), + behavior: SnackBarBehavior.floating, + showCloseIcon: true, + closeIconColor: Colors.white, + contentTextStyle: TextStyle( + color: Colors.white + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all(Radius.circular(20)) + ) ) ), home: const HomePage(), diff --git a/pubspec.yaml b/pubspec.yaml index c79169b..a8403ef 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: stronzflix description: "Streaming application." publish_to: 'none' -version: 0.1.1 +version: 0.1.2 environment: sdk: '>=3.2.0 <4.0.0'