Browse Source

feat(neon_files): sort folders first in FilesBrowserView

Signed-off-by: Nikolas Rimikis <rimikis.nikolas@gmail.com>
pull/604/head
Nikolas Rimikis 1 year ago
parent
commit
ce7955dccd
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 1
      packages/neon/neon_files/lib/sort/files.dart
  2. 3
      packages/neon/neon_files/lib/widgets/browser_view.dart

1
packages/neon/neon_files/lib/sort/files.dart

@ -5,6 +5,7 @@ final filesSortBox = SortBox<FilesSortProperty, WebDavFile>(
FilesSortProperty.name: (final file) => file.name.toLowerCase(), FilesSortProperty.name: (final file) => file.name.toLowerCase(),
FilesSortProperty.modifiedDate: (final file) => file.lastModified?.millisecondsSinceEpoch ?? 0, FilesSortProperty.modifiedDate: (final file) => file.lastModified?.millisecondsSinceEpoch ?? 0,
FilesSortProperty.size: (final file) => file.size ?? 0, FilesSortProperty.size: (final file) => file.size ?? 0,
FilesSortProperty.isFolder: (final file) => file.isDirectory ? 0 : 1,
}, },
{ {
FilesSortProperty.modifiedDate: { FilesSortProperty.modifiedDate: {

3
packages/neon/neon_files/lib/widgets/browser_view.dart

@ -62,6 +62,9 @@ class _FilesBrowserViewState extends State<FilesBrowserView> {
sortBox: filesSortBox, sortBox: filesSortBox,
sortPropertyOption: widget.bloc.options.filesSortPropertyOption, sortPropertyOption: widget.bloc.options.filesSortPropertyOption,
sortBoxOrderOption: widget.bloc.options.filesSortBoxOrderOption, sortBoxOrderOption: widget.bloc.options.filesSortBoxOrderOption,
presort: const {
(FilesSortProperty.isFolder, SortBoxOrder.ascending),
},
input: files.data, input: files.data,
builder: (final context, final sorted) => NeonListView<Widget>( builder: (final context, final sorted) => NeonListView<Widget>(
scrollKey: 'files-${pathSnapshot.requireData.join('/')}', scrollKey: 'files-${pathSnapshot.requireData.join('/')}',

Loading…
Cancel
Save