Watch
1
0
Fork
You've already forked nexus
0
forked from Nexus/nexus

Add support for downloading media

Fixes #85
This commit is contained in:
Henry Hiles 2026-10-16 17:05:26 -04:00
commit 0ad85f24d5
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
15 changed files with 285 additions and 24 deletions

View file

@ -1,6 +1,7 @@
import "package:material_ui/material_ui.dart";
import "package:hooks_riverpod/hooks_riverpod.dart";
import "package:m3e_buttons/m3e_buttons.dart";
import "package:nexus/helpers/extensions/save_attachment.dart";
import "package:nexus/helpers/mxc_image.dart";
import "package:nexus/models/requests/download_media.dart";
import "package:nexus/widgets/error_dialog.dart";
@ -8,6 +9,9 @@ import "package:nexus/widgets/error_dialog.dart";
final class const ExpandableImage(
final DownloadMediaRequest? request, {
required final Widget child,
/// If set, a download button is shown, suggesting this filename
final String? downloadFilename,
super.key,
}) extends ConsumerWidget {
@override
@ -38,9 +42,25 @@ final class const ExpandableImage(
alignment: .topRight,
child: Padding(
padding: .all(32),
child: M3EButton(
onPressed: Navigator.of(context).pop,
child: Icon(Icons.close),
child: Row(
mainAxisSize: .min,
spacing: 8,
children: [
if (downloadFilename != null)
M3EButton(
onPressed: () => context.saveAttachment(
ref,
request!.mxc,
encrypted: request!.encrypted,
filename: downloadFilename,
),
child: Icon(Icons.download),
),
M3EButton(
onPressed: Navigator.of(context).pop,
child: Icon(Icons.close),
),
],
),
),
),