From 1c4394d51d92924a196813de4e546dbe988d6105 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Tue, 17 Oct 2023 22:26:30 +0200 Subject: [PATCH 1/2] fix(neon_files): empty browser view Signed-off-by: Nikolas Rimikis --- .../neon_files/lib/widgets/browser_view.dart | 141 ++++++++++-------- 1 file changed, 76 insertions(+), 65 deletions(-) diff --git a/packages/neon/neon_files/lib/widgets/browser_view.dart b/packages/neon/neon_files/lib/widgets/browser_view.dart index 67cc8564..ab112e6d 100644 --- a/packages/neon/neon_files/lib/widgets/browser_view.dart +++ b/packages/neon/neon_files/lib/widgets/browser_view.dart @@ -43,13 +43,30 @@ class _FilesBrowserViewState extends State { @override Widget build(final BuildContext context) => ResultBuilder>.behaviorSubject( stream: widget.bloc.files, - builder: (final context, final files) => StreamBuilder>( + builder: (final context, final filesSnapshot) => StreamBuilder>( stream: widget.bloc.path, builder: (final context, final pathSnapshot) => StreamBuilder>( stream: widget.filesBloc.tasks, - builder: (final context, final tasksSnapshot) => !pathSnapshot.hasData || !tasksSnapshot.hasData - ? const SizedBox() - : BackButtonListener( + builder: (final context, final tasksSnapshot) { + if (!pathSnapshot.hasData || !tasksSnapshot.hasData) { + return const SizedBox(); + } + return ValueListenableBuilder( + valueListenable: widget.bloc.options.showHiddenFilesOption, + builder: (final context, final showHiddenFiles, final _) { + final files = filesSnapshot.data?.where((final file) { + var hideFile = false; + if (widget.mode == FilesBrowserMode.selectDirectory && !file.isDirectory) { + hideFile = true; + } + if (!showHiddenFiles && file.isHidden) { + hideFile = true; + } + + return !hideFile; + }).toList(); + + return BackButtonListener( onBackButtonPressed: () async { final path = pathSnapshot.requireData; if (path.isNotEmpty) { @@ -65,71 +82,65 @@ class _FilesBrowserViewState extends State { presort: const { (FilesSortProperty.isFolder, SortBoxOrder.ascending), }, - input: files.data, - builder: (final context, final sorted) => ValueListenableBuilder( - valueListenable: widget.bloc.options.showHiddenFilesOption, - builder: (final context, final showHiddenFiles, final _) { - final uploadingTasks = tasksSnapshot.requireData - .whereType() - .where( - (final task) => - sorted.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, - ) - .toList(); - - return NeonListView( - scrollKey: 'files-${pathSnapshot.requireData.join('/')}', - itemCount: uploadingTasks.length + sorted.length, - itemBuilder: (final context, final index) { - if (index < uploadingTasks.length) { - return FileListTile( - bloc: widget.filesBloc, - browserBloc: widget.bloc, - details: FileDetails.fromUploadTask( - task: uploadingTasks[index], - ), - ); - } + input: files, + builder: (final context, final sorted) { + final uploadingTasks = tasksSnapshot.requireData + .whereType() + .where( + (final task) => + sorted.where((final file) => _pathMatchesFile(task.path, file.name)).isEmpty, + ) + .toList(); - final file = sorted[index - uploadingTasks.length]; - if ((widget.mode != FilesBrowserMode.selectDirectory || file.isDirectory) && - (!file.isHidden || showHiddenFiles)) { - final matchingTask = tasksSnapshot.requireData - .firstWhereOrNull((final task) => _pathMatchesFile(task.path, file.name)); + return NeonListView( + scrollKey: 'files-${pathSnapshot.requireData.join('/')}', + itemCount: uploadingTasks.length + sorted.length, + itemBuilder: (final context, final index) { + if (index < uploadingTasks.length) { + return FileListTile( + bloc: widget.filesBloc, + browserBloc: widget.bloc, + details: FileDetails.fromUploadTask( + task: uploadingTasks[index], + ), + ); + } + final file = sorted[index - uploadingTasks.length]; + final matchingTask = tasksSnapshot.requireData + .firstWhereOrNull((final task) => _pathMatchesFile(task.path, file.name)); - final details = matchingTask != null - ? FileDetails.fromTask( - task: matchingTask, - file: file, - ) - : FileDetails.fromWebDav( - file: file, - path: widget.bloc.path.value, - ); + final details = matchingTask != null + ? FileDetails.fromTask( + task: matchingTask, + file: file, + ) + : FileDetails.fromWebDav( + file: file, + path: widget.bloc.path.value, + ); - return FileListTile( - bloc: widget.filesBloc, - browserBloc: widget.bloc, - details: details, - ); - } - - return null; - }, - isLoading: files.isLoading, - error: files.error, - onRefresh: widget.bloc.refresh, - topScrollingChildren: [ - FilesBrowserNavigator( - path: pathSnapshot.requireData, - bloc: widget.bloc, - ), - ], - ); - }, - ), + return FileListTile( + bloc: widget.filesBloc, + browserBloc: widget.bloc, + details: details, + ); + }, + isLoading: filesSnapshot.isLoading, + error: filesSnapshot.error, + onRefresh: widget.bloc.refresh, + topScrollingChildren: [ + FilesBrowserNavigator( + path: pathSnapshot.requireData, + bloc: widget.bloc, + ), + ], + ); + }, ), - ), + ); + }, + ); + }, ), ), ); From 58486708bddf30871f6d412001b17511e86f0d9f Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Thu, 19 Oct 2023 14:04:00 +0200 Subject: [PATCH 2/2] fix(neon_files): FileListTile don't show actions in selectDirectory mode Signed-off-by: Nikolas Rimikis --- packages/neon/neon_files/lib/widgets/browser_view.dart | 1 + packages/neon/neon_files/lib/widgets/file_list_tile.dart | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/neon/neon_files/lib/widgets/browser_view.dart b/packages/neon/neon_files/lib/widgets/browser_view.dart index ab112e6d..1104c27e 100644 --- a/packages/neon/neon_files/lib/widgets/browser_view.dart +++ b/packages/neon/neon_files/lib/widgets/browser_view.dart @@ -123,6 +123,7 @@ class _FilesBrowserViewState extends State { bloc: widget.filesBloc, browserBloc: widget.bloc, details: details, + mode: widget.mode, ); }, isLoading: filesSnapshot.isLoading, 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 cb609d55..85426f9f 100644 --- a/packages/neon/neon_files/lib/widgets/file_list_tile.dart +++ b/packages/neon/neon_files/lib/widgets/file_list_tile.dart @@ -73,7 +73,7 @@ class FileListTile extends StatelessWidget { details: details, bloc: bloc, ), - trailing: !details.hasTask && mode != FilesBrowserMode.noActions + trailing: !details.hasTask && mode == FilesBrowserMode.browser ? FileActions(details: details) : const SizedBox.square( dimension: largeIconSize,