From c2c5b8cbb38f9045adbd17b484952c9283524fbd Mon Sep 17 00:00:00 2001 From: olorin99 Date: Tue, 5 May 2026 10:58:00 +1000 Subject: [PATCH] Show snackbar to notify on successful image download. --- lib/l10n/app_en.arb | 10 +++++++++- lib/src/utils/share.dart | 12 +++++++++++- lib/src/widgets/image.dart | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 2a7d5a0c..08141232 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -887,5 +887,13 @@ "modlog_communityAdded": "Community added", "modlog_communityRemoved": "Community removed", "modlog_postLocked": "Post locked", - "modlog_postUnlocked": "Post unlocked" + "modlog_postUnlocked": "Post unlocked", + "downloaded_file": "Downloaded {file}.", + "@downloaded_file": { + "placeholders": { + "file": { + "type": "String" + } + } + } } diff --git a/lib/src/utils/share.dart b/lib/src/utils/share.dart index 63f41523..9f2e71be 100644 --- a/lib/src/utils/share.dart +++ b/lib/src/utils/share.dart @@ -1,6 +1,8 @@ import 'dart:io'; +import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; +import 'package:interstellar/src/utils/globals.dart'; import 'package:interstellar/src/utils/platform/platform.dart'; import 'package:interstellar/src/utils/utils.dart'; import 'package:path/path.dart'; @@ -30,9 +32,17 @@ Future shareFile(Uri uri, String filename) async { } Future downloadFile( + BuildContext context, Uri uri, String filename, { Directory? defaultDir, }) async { - downloadFromUri(uri, filename, defaultDir: defaultDir); + await downloadFromUri(uri, filename, defaultDir: defaultDir); + if (!context.mounted) return; + scaffoldMessengerKey.currentState?.showSnackBar( + SnackBar( + content: Text(l(context).downloaded_file(filename)), + showCloseIcon: true, + ), + ); } diff --git a/lib/src/widgets/image.dart b/lib/src/widgets/image.dart index 9925befa..c4192a7c 100644 --- a/lib/src/widgets/image.dart +++ b/lib/src/widgets/image.dart @@ -162,6 +162,7 @@ class _AdvancedImagePageState extends State { LoadingIconButton( onPressed: () async { await downloadFile( + context, Uri.parse(widget.image.src), widget.image.src.split('/').last, defaultDir: context.read().defaultDownloadDir, @@ -169,6 +170,7 @@ class _AdvancedImagePageState extends State { }, onLongPress: () async { await downloadFile( + context, Uri.parse(widget.image.src), widget.image.src.split('/').last, );