Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Show download status messages in the app's toast style

Barnabasa0dbf7a139f7
diff --git a/lib/providers/_lp_absorbing.dart b/lib/providers/_lp_absorbing.dart
index 80f8ad34..842801d3 100644
--- a/lib/providers/_lp_absorbing.dart
+++ b/lib/providers/_lp_absorbing.dart
@@ -470,7 +470,8 @@ mixin _AbsorbingMixin on ChangeNotifier, _StateMixin, _CoreMixin {
PlayerSettings.getRollingDownloadDeleteFinished().then((delete) {
if (!delete) return;
DownloadService().deleteDownload(itemId, skipStopCheck: true);
- _showRollingSnackBar(_l()?.lpDeletedFinishedDownload ?? 'Deleted finished download');
+ _showRollingSnackBar(_l()?.lpDeletedFinishedDownload ?? 'Deleted finished download',
+ icon: Icons.delete_outline_rounded);
});
}
diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dart
index 4002f3ab..7672de30 100644
--- a/lib/providers/_lp_core.dart
+++ b/lib/providers/_lp_core.dart
@@ -2238,7 +2238,8 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
final l = _l();
_showRollingSnackBar(
l?.lpQueueDownloadingItems(newDownloads)
- ?? 'Queue: downloading $newDownloads item${newDownloads == 1 ? '' : 's'}');
+ ?? 'Queue: downloading $newDownloads item${newDownloads == 1 ? '' : 's'}',
+ icon: Icons.download_rounded);
}
}
@@ -2368,7 +2369,8 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
final l = _l();
_showRollingSnackBar(
l?.lpDownloadingBooks(newDownloads)
- ?? 'Downloading $newDownloads book${newDownloads == 1 ? '' : 's'}');
+ ?? 'Downloading $newDownloads book${newDownloads == 1 ? '' : 's'}',
+ icon: Icons.download_rounded);
}
}
@@ -2446,7 +2448,8 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
final l = _l();
_showRollingSnackBar(
l?.lpDownloadingEpisodes(newDownloads)
- ?? 'Downloading $newDownloads episode${newDownloads == 1 ? '' : 's'}');
+ ?? 'Downloading $newDownloads episode${newDownloads == 1 ? '' : 's'}',
+ icon: Icons.download_rounded);
}
}
diff --git a/lib/providers/_lp_state.dart b/lib/providers/_lp_state.dart
index 4e97c0e3..50d1ab7f 100644
--- a/lib/providers/_lp_state.dart
+++ b/lib/providers/_lp_state.dart
@@ -329,13 +329,9 @@ mixin _StateMixin on ChangeNotifier {
return cached;
}
- void _showRollingSnackBar(String message) {
- scaffoldMessengerKey.currentState
- ?..clearSnackBars()
- ..showSnackBar(SnackBar(
- content: Text(message),
- duration: const Duration(seconds: 3),
- ));
+ void _showRollingSnackBar(String message, {IconData? icon}) {
+ final ctx = rootNavigatorKey.currentContext;
+ if (ctx != null) showOverlayToast(ctx, message, icon: icon);
}
/// Look up [AppLocalizations] via the root navigator. Returns null if no