diff --git a/packages/neon/neon_files/lib/utils/download_task.dart b/packages/neon/neon_files/lib/utils/download_task.dart index 424fc04a..dced89b5 100644 --- a/packages/neon/neon_files/lib/utils/download_task.dart +++ b/packages/neon/neon_files/lib/utils/download_task.dart @@ -7,7 +7,9 @@ class DownloadTask { final List path; - final _streamController = StreamController(); + final _streamController = StreamController(); + + /// Upload progress in percent [0, 1]. late final progress = _streamController.stream.asBroadcastStream(); Future execute(final NextcloudClient client, final IOSink sink) async { @@ -20,7 +22,7 @@ class DownloadTask { sink.add(chunk); downloaded += chunk.length; - _streamController.add((downloaded / response.contentLength * 100).toInt()); + _streamController.add(downloaded / response.contentLength); if (downloaded >= response.contentLength) { completer.complete(); diff --git a/packages/neon/neon_files/lib/utils/upload_task.dart b/packages/neon/neon_files/lib/utils/upload_task.dart index 905f9caf..5559abc9 100644 --- a/packages/neon/neon_files/lib/utils/upload_task.dart +++ b/packages/neon/neon_files/lib/utils/upload_task.dart @@ -11,7 +11,9 @@ class UploadTask { final int size; final DateTime lastModified; - final _streamController = StreamController(); + final _streamController = StreamController(); + + /// Upload progress in percent [0, 1]. late final progress = _streamController.stream.asBroadcastStream(); Future execute(final NextcloudClient client, final Stream> stream) async { @@ -19,7 +21,7 @@ class UploadTask { await client.webdav.putStream( stream.map((final chunk) { uploaded += chunk.length; - _streamController.add((uploaded / size * 100).toInt()); + _streamController.add(uploaded / size); return Uint8List.fromList(chunk); }), diff --git a/packages/neon/neon_files/lib/widgets/browser_view.dart b/packages/neon/neon_files/lib/widgets/browser_view.dart index 58ccf39d..56973863 100644 --- a/packages/neon/neon_files/lib/widgets/browser_view.dart +++ b/packages/neon/neon_files/lib/widgets/browser_view.dart @@ -68,7 +68,7 @@ class _FilesBrowserViewState extends State { (final task) => sorted.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, )) ...[ - StreamBuilder( + StreamBuilder( stream: uploadTask.progress, builder: (final context, final uploadTaskProgressSnapshot) => !uploadTaskProgressSnapshot.hasData @@ -95,11 +95,11 @@ class _FilesBrowserViewState extends State { final matchingDownloadTasks = downloadTasksSnapshot.requireData .where((final task) => _pathMatchesFile(task.path, file.name)); - return StreamBuilder( + return StreamBuilder( stream: matchingUploadTasks.isNotEmpty ? matchingUploadTasks.first.progress : null, builder: (final context, final uploadTaskProgressSnapshot) => - StreamBuilder( + StreamBuilder( stream: matchingDownloadTasks.isNotEmpty ? matchingDownloadTasks.first.progress : null, 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 b46e8900..c29dea8e 100644 --- a/packages/neon/neon_files/lib/widgets/file_list_tile.dart +++ b/packages/neon/neon_files/lib/widgets/file_list_tile.dart @@ -19,8 +19,8 @@ class FileListTile extends StatelessWidget { final BuildContext context; final FileDetails details; - final int? uploadProgress; - final int? downloadProgress; + final double? uploadProgress; + final double? downloadProgress; final bool enableFileActions; final Function(FileDetails)? onPickFile; @@ -33,7 +33,7 @@ class FileListTile extends StatelessWidget { return null; } - return (uploadProgress ?? downloadProgress)! / 100; + return (uploadProgress ?? downloadProgress)!; } @override