Skip to content

Commit

Permalink
added snackbar for loading process
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonfra04 committed Jan 16, 2024
1 parent b6183e8 commit 6938f19
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 4 additions & 5 deletions lib/backend/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class VersionChecker
return version;
}

static Future<String> _getCurrentVersion() async
static Future<String> getCurrentVersion() async
{
PackageInfo packageInfo = await PackageInfo.fromPlatform();
return packageInfo.version;
Expand All @@ -40,7 +40,7 @@ class VersionChecker
static Future<bool> shouldUpdate() async
{
try {
String currentVersion = await _getCurrentVersion();
String currentVersion = await getCurrentVersion();
String lastVersion = await _getLastVersion();
return currentVersion != lastVersion;
} catch (_) {
Expand Down Expand Up @@ -126,8 +126,7 @@ class VersionChecker
else
throw Exception("Unsupported platform");
return true;
} finally {
return false;
}
} catch (_) {}
return false;
}
}
30 changes: 25 additions & 5 deletions lib/views/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ class HomePage extends StatefulWidget {

class _HomePageState extends State<HomePage> {

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: [
Expand Down Expand Up @@ -77,16 +79,34 @@ class _HomePageState extends State<HomePage> {
),
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();
});
}
)
]
)
);
}

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"),
Expand Down
12 changes: 12 additions & 0 deletions lib/views/stronzflix.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 6938f19

Please sign in to comment.