A framework for building convergent cross-platform Nextcloud clients using Flutter.
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.

84 lines
1.8 KiB

part of '../neon_files.dart';
3 years ago
@immutable
3 years ago
class FileDetails {
const FileDetails({
required this.uri,
3 years ago
required this.size,
required this.etag,
required this.mimeType,
required this.lastModified,
required this.hasPreview,
required this.isFavorite,
}) : task = null;
3 years ago
FileDetails.fromWebDav({
required final WebDavFile file,
}) : uri = file.path,
size = file.size,
etag = file.etag,
mimeType = file.mimeType,
lastModified = file.lastModified,
hasPreview = file.hasPreview,
isFavorite = file.favorite,
task = null;
FileDetails.fromUploadTask({
required FilesUploadTask this.task,
}) : uri = task.uri,
size = task.stat.size,
lastModified = task.stat.modified,
etag = null,
mimeType = null,
hasPreview = null,
isFavorite = null;
FileDetails.fromDownloadTask({
required FilesDownloadTask this.task,
required final WebDavFile file,
}) : uri = task.uri,
size = file.size,
etag = file.etag,
mimeType = file.mimeType,
lastModified = file.lastModified,
hasPreview = file.hasPreview,
isFavorite = file.favorite;
factory FileDetails.fromTask({
required final FilesTask task,
required final WebDavFile file,
}) {
switch (task) {
case FilesUploadTask():
return FileDetails.fromUploadTask(task: task);
case FilesDownloadTask():
return FileDetails.fromDownloadTask(
task: task,
file: file,
);
}
}
String get name => uri.name;
3 years ago
bool get isDirectory => uri.isDirectory;
3 years ago
final PathUri uri;
3 years ago
final int? size;
3 years ago
final String? etag;
final String? mimeType;
final DateTime? lastModified;
3 years ago
final bool? hasPreview;
final bool? isFavorite;
final FilesTask? task;
bool get hasTask => task != null;
3 years ago
}