From ce7955dccdad2490e768767e2ab06cb22be2e2c1 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Fri, 25 Aug 2023 17:39:16 +0200 Subject: [PATCH] feat(neon_files): sort folders first in FilesBrowserView Signed-off-by: Nikolas Rimikis --- packages/neon/neon_files/lib/sort/files.dart | 1 + packages/neon/neon_files/lib/widgets/browser_view.dart | 3 +++ 2 files changed, 4 insertions(+) diff --git a/packages/neon/neon_files/lib/sort/files.dart b/packages/neon/neon_files/lib/sort/files.dart index d0d7d96e..b46bc14a 100644 --- a/packages/neon/neon_files/lib/sort/files.dart +++ b/packages/neon/neon_files/lib/sort/files.dart @@ -5,6 +5,7 @@ final filesSortBox = SortBox( FilesSortProperty.name: (final file) => file.name.toLowerCase(), FilesSortProperty.modifiedDate: (final file) => file.lastModified?.millisecondsSinceEpoch ?? 0, FilesSortProperty.size: (final file) => file.size ?? 0, + FilesSortProperty.isFolder: (final file) => file.isDirectory ? 0 : 1, }, { FilesSortProperty.modifiedDate: { diff --git a/packages/neon/neon_files/lib/widgets/browser_view.dart b/packages/neon/neon_files/lib/widgets/browser_view.dart index 7f066028..e05298a7 100644 --- a/packages/neon/neon_files/lib/widgets/browser_view.dart +++ b/packages/neon/neon_files/lib/widgets/browser_view.dart @@ -62,6 +62,9 @@ class _FilesBrowserViewState extends State { sortBox: filesSortBox, sortPropertyOption: widget.bloc.options.filesSortPropertyOption, sortBoxOrderOption: widget.bloc.options.filesSortBoxOrderOption, + presort: const { + (FilesSortProperty.isFolder, SortBoxOrder.ascending), + }, input: files.data, builder: (final context, final sorted) => NeonListView( scrollKey: 'files-${pathSnapshot.requireData.join('/')}',