sort by path
This commit is contained in:
parent
32c5fcd41a
commit
0c0d3d3019
3 changed files with 55 additions and 28 deletions
|
@ -63,6 +63,9 @@ class ImageCollection with ChangeNotifier {
|
||||||
MapEntry(null, _rawEntries),
|
MapEntry(null, _rawEntries),
|
||||||
]));
|
]));
|
||||||
break;
|
break;
|
||||||
|
case SortFactor.name:
|
||||||
|
sections = Map.unmodifiable(groupBy(_rawEntries, (entry) => entry.directory));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
@ -75,6 +78,9 @@ class ImageCollection with ChangeNotifier {
|
||||||
case SortFactor.size:
|
case SortFactor.size:
|
||||||
_rawEntries.sort((a, b) => b.sizeBytes.compareTo(a.sizeBytes));
|
_rawEntries.sort((a, b) => b.sizeBytes.compareTo(a.sizeBytes));
|
||||||
break;
|
break;
|
||||||
|
case SortFactor.name:
|
||||||
|
_rawEntries.sort((a, b) => a.path.compareTo(b.path));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +200,6 @@ class ImageCollection with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SortFactor { date, size }
|
enum SortFactor { date, size, name }
|
||||||
|
|
||||||
enum GroupFactor { album, month, day }
|
enum GroupFactor { album, month, day }
|
||||||
|
|
|
@ -53,6 +53,10 @@ class _AllCollectionAppBar extends SliverAppBar {
|
||||||
value: AlbumAction.sortBySize,
|
value: AlbumAction.sortBySize,
|
||||||
child: MenuRow(text: 'Sort by size', checked: collection.sortFactor == SortFactor.size),
|
child: MenuRow(text: 'Sort by size', checked: collection.sortFactor == SortFactor.size),
|
||||||
),
|
),
|
||||||
|
PopupMenuItem(
|
||||||
|
value: AlbumAction.sortByName,
|
||||||
|
child: MenuRow(text: 'Sort by name', checked: collection.sortFactor == SortFactor.name),
|
||||||
|
),
|
||||||
const PopupMenuDivider(),
|
const PopupMenuDivider(),
|
||||||
if (collection.sortFactor == SortFactor.date) ...[
|
if (collection.sortFactor == SortFactor.date) ...[
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
|
@ -106,6 +110,10 @@ class _AllCollectionAppBar extends SliverAppBar {
|
||||||
settings.collectionSortFactor = SortFactor.size;
|
settings.collectionSortFactor = SortFactor.size;
|
||||||
collection.sort(SortFactor.size);
|
collection.sort(SortFactor.size);
|
||||||
break;
|
break;
|
||||||
|
case AlbumAction.sortByName:
|
||||||
|
settings.collectionSortFactor = SortFactor.name;
|
||||||
|
collection.sort(SortFactor.name);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,4 +129,4 @@ class _AllCollectionAppBar extends SliverAppBar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AlbumAction { debug, groupByAlbum, groupByMonth, groupByDay, sortByDate, sortBySize }
|
enum AlbumAction { debug, groupByAlbum, groupByMonth, groupByDay, sortByDate, sortBySize, sortByName }
|
||||||
|
|
|
@ -95,9 +95,34 @@ class SectionHeader extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Widget header = const SizedBox.shrink();
|
Widget header = const SizedBox.shrink();
|
||||||
|
switch (collection.sortFactor) {
|
||||||
|
case SortFactor.date:
|
||||||
if (collection.sortFactor == SortFactor.date) {
|
if (collection.sortFactor == SortFactor.date) {
|
||||||
switch (collection.groupFactor) {
|
switch (collection.groupFactor) {
|
||||||
case GroupFactor.album:
|
case GroupFactor.album:
|
||||||
|
header = _buildAlbumSectionHeader(context);
|
||||||
|
break;
|
||||||
|
case GroupFactor.month:
|
||||||
|
header = MonthSectionHeader(key: ValueKey(sectionKey), date: sectionKey as DateTime);
|
||||||
|
break;
|
||||||
|
case GroupFactor.day:
|
||||||
|
header = DaySectionHeader(key: ValueKey(sectionKey), date: sectionKey as DateTime);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SortFactor.size:
|
||||||
|
break;
|
||||||
|
case SortFactor.name:
|
||||||
|
header = _buildAlbumSectionHeader(context);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return IgnorePointer(
|
||||||
|
child: header,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildAlbumSectionHeader(BuildContext context) {
|
||||||
Widget albumIcon = IconUtils.getAlbumIcon(context, sectionKey as String);
|
Widget albumIcon = IconUtils.getAlbumIcon(context, sectionKey as String);
|
||||||
if (albumIcon != null) {
|
if (albumIcon != null) {
|
||||||
albumIcon = Material(
|
albumIcon = Material(
|
||||||
|
@ -109,22 +134,10 @@ class SectionHeader extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var title = collection.getUniqueAlbumName(sectionKey as String, sections.keys.cast<String>());
|
var title = collection.getUniqueAlbumName(sectionKey as String, sections.keys.cast<String>());
|
||||||
header = TitleSectionHeader(
|
return TitleSectionHeader(
|
||||||
key: ValueKey(title),
|
key: ValueKey(title),
|
||||||
leading: albumIcon,
|
leading: albumIcon,
|
||||||
title: title,
|
title: title,
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
case GroupFactor.month:
|
|
||||||
header = MonthSectionHeader(key: ValueKey(sectionKey), date: sectionKey as DateTime);
|
|
||||||
break;
|
|
||||||
case GroupFactor.day:
|
|
||||||
header = DaySectionHeader(key: ValueKey(sectionKey), date: sectionKey as DateTime);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return IgnorePointer(
|
|
||||||
child: header,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue