You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.4 KiB
95 lines
2.4 KiB
2 years ago
|
part of '../neon_files.dart';
|
||
|
|
||
|
class FilesFileTile extends StatelessWidget {
|
||
|
const FilesFileTile({
|
||
|
required this.filesBloc,
|
||
|
required this.details,
|
||
|
this.trailing,
|
||
|
this.onTap,
|
||
|
this.uploadProgress,
|
||
|
this.downloadProgress,
|
||
|
this.showFullPath = false,
|
||
|
super.key,
|
||
|
});
|
||
|
|
||
|
final FilesBloc filesBloc;
|
||
|
final FileDetails details;
|
||
|
final Widget? trailing;
|
||
|
final GestureTapCallback? onTap;
|
||
|
final int? uploadProgress;
|
||
|
final int? downloadProgress;
|
||
|
final bool showFullPath;
|
||
|
|
||
|
@override
|
||
|
Widget build(final BuildContext context) {
|
||
|
Widget icon = Center(
|
||
|
child: uploadProgress != null || downloadProgress != null
|
||
|
? Column(
|
||
|
children: [
|
||
|
Icon(
|
||
|
uploadProgress != null ? MdiIcons.upload : MdiIcons.download,
|
||
|
color: Theme.of(context).colorScheme.primary,
|
||
|
),
|
||
|
LinearProgressIndicator(
|
||
|
value: (uploadProgress ?? downloadProgress)! / 100,
|
||
|
),
|
||
|
],
|
||
|
)
|
||
|
: FilePreview(
|
||
|
bloc: filesBloc,
|
||
|
details: details,
|
||
|
withBackground: true,
|
||
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
||
|
),
|
||
|
);
|
||
|
if (details.isFavorite ?? false) {
|
||
|
icon = Stack(
|
||
|
children: [
|
||
|
icon,
|
||
|
const Align(
|
||
|
alignment: Alignment.bottomRight,
|
||
|
child: Icon(
|
||
|
Icons.star,
|
||
|
size: 14,
|
||
|
color: NcColors.starredColor,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
|
||
|
return ListTile(
|
||
|
onTap: onTap,
|
||
|
title: Text(
|
||
|
showFullPath ? details.uri.path : details.name,
|
||
|
overflow: TextOverflow.ellipsis,
|
||
|
),
|
||
|
subtitle: Row(
|
||
|
children: [
|
||
|
if (details.lastModified != null) ...[
|
||
|
RelativeTime(
|
||
|
date: details.lastModified!,
|
||
|
),
|
||
|
],
|
||
|
if (details.size != null && details.size! > 0) ...[
|
||
|
const SizedBox(
|
||
|
width: 10,
|
||
|
),
|
||
|
Text(
|
||
|
filesize(details.size, 1),
|
||
|
style: DefaultTextStyle.of(context).style.copyWith(
|
||
|
color: Colors.grey,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
],
|
||
|
),
|
||
|
leading: SizedBox.square(
|
||
|
dimension: 40,
|
||
|
child: icon,
|
||
|
),
|
||
|
trailing: trailing,
|
||
|
);
|
||
|
}
|
||
|
}
|