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,4 +1,6 @@
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:material_ui/material_ui.dart";
import "package:nexus/helpers/extensions/save_attachment.dart";
import "package:nexus/helpers/extensions/size_to_string.dart";
import "package:nexus/models/info/file.dart";
@ -6,10 +8,11 @@ final class const FileCard(
final Uri uri,
final FileInfo? info, {
final String? filename,
final bool encrypted = false,
super.key,
}) extends StatelessWidget {
}) extends ConsumerWidget {
@override
Widget build(BuildContext context) => SizedBox(
Widget build(BuildContext context, WidgetRef ref) => SizedBox(
width: 320,
child: Card(
color: Theme.of(context).colorScheme.surfaceContainer,
@ -17,8 +20,15 @@ final class const FileCard(
leading: Icon(Icons.file_copy),
title: Text(filename ?? "file", maxLines: 1, overflow: .ellipsis),
subtitle: info?.size == null ? null : Text(info!.size!.sizeAsString),
// TODO: Downloading files
trailing: IconButton(onPressed: null, icon: Icon(Icons.download)),
trailing: IconButton(
onPressed: () => context.saveAttachment(
ref,
uri,
encrypted: encrypted,
filename: filename,
),
icon: Icon(Icons.download),
),
),
),
);