forked from Nexus/nexus
parent
1c2ba2971b
commit
0ad85f24d5
15 changed files with 285 additions and 24 deletions
|
|
@ -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),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue