diff --git a/packages/neon/neon_files/lib/models/file_details.dart b/packages/neon/neon_files/lib/models/file_details.dart index dec33ff5..19e8620b 100644 --- a/packages/neon/neon_files/lib/models/file_details.dart +++ b/packages/neon/neon_files/lib/models/file_details.dart @@ -13,6 +13,29 @@ class FileDetails { required this.isFavorite, }); + FileDetails.fromWebDav({ + required final WebDavFile file, + required final List path, + }) : path = List.from(path)..add(file.name), + isDirectory = file.isDirectory, + size = file.size, + etag = file.etag, + mimeType = file.mimeType, + lastModified = file.lastModified, + hasPreview = file.hasPreview, + isFavorite = file.favorite; + + FileDetails.fromUploadTask({ + required final UploadTask task, + }) : path = task.path, + size = task.size, + lastModified = task.lastModified, + isDirectory = false, + etag = null, + mimeType = null, + hasPreview = null, + isFavorite = null; + String get name => path.last; final List path; diff --git a/packages/neon/neon_files/lib/widgets/browser_view.dart b/packages/neon/neon_files/lib/widgets/browser_view.dart index 4540d8de..58ccf39d 100644 --- a/packages/neon/neon_files/lib/widgets/browser_view.dart +++ b/packages/neon/neon_files/lib/widgets/browser_view.dart @@ -75,15 +75,8 @@ class _FilesBrowserViewState extends State { ? const SizedBox() : FileListTile( context: context, - details: FileDetails( - path: uploadTask.path, - isDirectory: false, - size: uploadTask.size, - etag: null, - mimeType: null, - lastModified: uploadTask.lastModified, - hasPreview: null, - isFavorite: null, + details: FileDetails.fromUploadTask( + task: uploadTask, ), uploadProgress: uploadTaskProgressSnapshot.data, downloadProgress: null, @@ -110,27 +103,26 @@ class _FilesBrowserViewState extends State { stream: matchingDownloadTasks.isNotEmpty ? matchingDownloadTasks.first.progress : null, - builder: (final context, final downloadTaskProgressSnapshot) => FileListTile( - context: context, - details: FileDetails( - path: [...widget.bloc.path.value, file.name], - isDirectory: matchingUploadTasks.isEmpty && file.isDirectory, - size: matchingUploadTasks.isNotEmpty - ? matchingUploadTasks.first.size - : file.size, - etag: matchingUploadTasks.isNotEmpty ? null : file.etag, - mimeType: matchingUploadTasks.isNotEmpty ? null : file.mimeType, - lastModified: matchingUploadTasks.isNotEmpty - ? matchingUploadTasks.first.lastModified - : file.lastModified, - hasPreview: matchingUploadTasks.isNotEmpty ? null : file.hasPreview, - isFavorite: matchingUploadTasks.isNotEmpty ? null : file.favorite, - ), - uploadProgress: uploadTaskProgressSnapshot.data, - downloadProgress: downloadTaskProgressSnapshot.data, - enableFileActions: widget.enableFileActions, - onPickFile: widget.onPickFile, - ), + builder: (final context, final downloadTaskProgressSnapshot) { + final path = widget.bloc.path.value; + final details = matchingUploadTasks.isEmpty + ? FileDetails.fromWebDav( + file: file, + path: path, + ) + : FileDetails.fromUploadTask( + task: matchingUploadTasks.first, + ); + + return FileListTile( + context: context, + details: details, + uploadProgress: uploadTaskProgressSnapshot.data, + downloadProgress: downloadTaskProgressSnapshot.data, + enableFileActions: widget.enableFileActions, + onPickFile: widget.onPickFile, + ); + }, ), ); }, diff --git a/packages/neon/neon_files/lib/widgets/file_list_tile.dart b/packages/neon/neon_files/lib/widgets/file_list_tile.dart index 400dec28..b46e8900 100644 --- a/packages/neon/neon_files/lib/widgets/file_list_tile.dart +++ b/packages/neon/neon_files/lib/widgets/file_list_tile.dart @@ -84,7 +84,7 @@ class FileListTile extends StatelessWidget { progress: _progress, details: details, ), - trailing: _hasProgress && enableFileActions + trailing: !_hasProgress && enableFileActions ? FileActions(details: details) : const SizedBox.square( dimension: 48,