#1109 collection: sort by duration
This commit is contained in:
parent
374a85ed7d
commit
bf987d63bf
11 changed files with 28 additions and 1 deletions
|
@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- Viewer: display more items in tag/copy/move quick action choosers
|
- Viewer: display more items in tag/copy/move quick action choosers
|
||||||
|
- Collection: sort by duration
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -723,6 +723,7 @@
|
||||||
"sortBySize": "By size",
|
"sortBySize": "By size",
|
||||||
"sortByAlbumFileName": "By album & file name",
|
"sortByAlbumFileName": "By album & file name",
|
||||||
"sortByRating": "By rating",
|
"sortByRating": "By rating",
|
||||||
|
"sortByDuration": "By duration",
|
||||||
|
|
||||||
"sortOrderNewestFirst": "Newest first",
|
"sortOrderNewestFirst": "Newest first",
|
||||||
"sortOrderOldestFirst": "Oldest first",
|
"sortOrderOldestFirst": "Oldest first",
|
||||||
|
@ -732,6 +733,8 @@
|
||||||
"sortOrderLowestFirst": "Lowest first",
|
"sortOrderLowestFirst": "Lowest first",
|
||||||
"sortOrderLargestFirst": "Largest first",
|
"sortOrderLargestFirst": "Largest first",
|
||||||
"sortOrderSmallestFirst": "Smallest first",
|
"sortOrderSmallestFirst": "Smallest first",
|
||||||
|
"sortOrderShortestFirst": "Shortest first",
|
||||||
|
"sortOrderLongestFirst": "Longest first",
|
||||||
|
|
||||||
"albumGroupTier": "By tier",
|
"albumGroupTier": "By tier",
|
||||||
"albumGroupType": "By type",
|
"albumGroupType": "By type",
|
||||||
|
|
|
@ -35,4 +35,12 @@ class AvesEntrySort {
|
||||||
final c = (b.sizeBytes ?? 0).compareTo(a.sizeBytes ?? 0);
|
final c = (b.sizeBytes ?? 0).compareTo(a.sizeBytes ?? 0);
|
||||||
return c != 0 ? c : compareByDate(a, b);
|
return c != 0 ? c : compareByDate(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// compare by:
|
||||||
|
// 1) duration descending
|
||||||
|
// 2) date descending
|
||||||
|
static int compareByDuration(AvesEntry a, AvesEntry b) {
|
||||||
|
final c = (b.durationMillis ?? 0).compareTo(a.durationMillis ?? 0);
|
||||||
|
return c != 0 ? c : compareByDate(a, b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ class CollectionLens with ChangeNotifier {
|
||||||
case EntrySortFactor.rating:
|
case EntrySortFactor.rating:
|
||||||
return !filters.any((f) => f is RatingFilter);
|
return !filters.any((f) => f is RatingFilter);
|
||||||
case EntrySortFactor.size:
|
case EntrySortFactor.size:
|
||||||
|
case EntrySortFactor.duration:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,6 +262,8 @@ class CollectionLens with ChangeNotifier {
|
||||||
_filteredSortedEntries.sort(AvesEntrySort.compareByRating);
|
_filteredSortedEntries.sort(AvesEntrySort.compareByRating);
|
||||||
case EntrySortFactor.size:
|
case EntrySortFactor.size:
|
||||||
_filteredSortedEntries.sort(AvesEntrySort.compareBySize);
|
_filteredSortedEntries.sort(AvesEntrySort.compareBySize);
|
||||||
|
case EntrySortFactor.duration:
|
||||||
|
_filteredSortedEntries.sort(AvesEntrySort.compareByDuration);
|
||||||
}
|
}
|
||||||
if (sortReverse) {
|
if (sortReverse) {
|
||||||
_filteredSortedEntries = _filteredSortedEntries.reversed.toList();
|
_filteredSortedEntries = _filteredSortedEntries.reversed.toList();
|
||||||
|
@ -294,6 +297,7 @@ class CollectionLens with ChangeNotifier {
|
||||||
case EntrySortFactor.rating:
|
case EntrySortFactor.rating:
|
||||||
sections = groupBy<AvesEntry, EntryRatingSectionKey>(_filteredSortedEntries, (entry) => EntryRatingSectionKey(entry.rating));
|
sections = groupBy<AvesEntry, EntryRatingSectionKey>(_filteredSortedEntries, (entry) => EntryRatingSectionKey(entry.rating));
|
||||||
case EntrySortFactor.size:
|
case EntrySortFactor.size:
|
||||||
|
case EntrySortFactor.duration:
|
||||||
sections = Map.fromEntries([
|
sections = Map.fromEntries([
|
||||||
MapEntry(const SectionKey(), _filteredSortedEntries),
|
MapEntry(const SectionKey(), _filteredSortedEntries),
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -28,6 +28,7 @@ class AIcons {
|
||||||
static const descriptionUntitled = Icons.comments_disabled_outlined;
|
static const descriptionUntitled = Icons.comments_disabled_outlined;
|
||||||
static const disc = Icons.fiber_manual_record;
|
static const disc = Icons.fiber_manual_record;
|
||||||
static const display = Icons.light_mode_outlined;
|
static const display = Icons.light_mode_outlined;
|
||||||
|
static const duration = Icons.timelapse_outlined;
|
||||||
static const error = Icons.error_outline;
|
static const error = Icons.error_outline;
|
||||||
static const explorer = Icons.account_tree_outlined;
|
static const explorer = Icons.account_tree_outlined;
|
||||||
static const folder = Icons.folder_outlined;
|
static const folder = Icons.folder_outlined;
|
||||||
|
|
|
@ -11,6 +11,7 @@ extension ExtraEntrySortFactorView on EntrySortFactor {
|
||||||
EntrySortFactor.name => l10n.sortByAlbumFileName,
|
EntrySortFactor.name => l10n.sortByAlbumFileName,
|
||||||
EntrySortFactor.rating => l10n.sortByRating,
|
EntrySortFactor.rating => l10n.sortByRating,
|
||||||
EntrySortFactor.size => l10n.sortBySize,
|
EntrySortFactor.size => l10n.sortBySize,
|
||||||
|
EntrySortFactor.duration => l10n.sortByDuration,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ extension ExtraEntrySortFactorView on EntrySortFactor {
|
||||||
EntrySortFactor.name => AIcons.name,
|
EntrySortFactor.name => AIcons.name,
|
||||||
EntrySortFactor.rating => AIcons.rating,
|
EntrySortFactor.rating => AIcons.rating,
|
||||||
EntrySortFactor.size => AIcons.size,
|
EntrySortFactor.size => AIcons.size,
|
||||||
|
EntrySortFactor.duration => AIcons.duration,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +32,7 @@ extension ExtraEntrySortFactorView on EntrySortFactor {
|
||||||
EntrySortFactor.name => reverse ? l10n.sortOrderZtoA : l10n.sortOrderAtoZ,
|
EntrySortFactor.name => reverse ? l10n.sortOrderZtoA : l10n.sortOrderAtoZ,
|
||||||
EntrySortFactor.rating => reverse ? l10n.sortOrderLowestFirst : l10n.sortOrderHighestFirst,
|
EntrySortFactor.rating => reverse ? l10n.sortOrderLowestFirst : l10n.sortOrderHighestFirst,
|
||||||
EntrySortFactor.size => reverse ? l10n.sortOrderSmallestFirst : l10n.sortOrderLargestFirst,
|
EntrySortFactor.size => reverse ? l10n.sortOrderSmallestFirst : l10n.sortOrderLargestFirst,
|
||||||
|
EntrySortFactor.duration => reverse ? l10n.sortOrderShortestFirst : l10n.sortOrderLongestFirst,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
EntrySortFactor.size,
|
EntrySortFactor.size,
|
||||||
EntrySortFactor.name,
|
EntrySortFactor.name,
|
||||||
EntrySortFactor.rating,
|
EntrySortFactor.rating,
|
||||||
|
EntrySortFactor.duration,
|
||||||
];
|
];
|
||||||
|
|
||||||
static const _groupOptions = [
|
static const _groupOptions = [
|
||||||
|
|
|
@ -697,6 +697,7 @@ class _CollectionScrollViewState extends State<_CollectionScrollView> with Widge
|
||||||
addAlbums(collection, sectionLayouts, crumbs);
|
addAlbums(collection, sectionLayouts, crumbs);
|
||||||
case EntrySortFactor.rating:
|
case EntrySortFactor.rating:
|
||||||
case EntrySortFactor.size:
|
case EntrySortFactor.size:
|
||||||
|
case EntrySortFactor.duration:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return crumbs;
|
return crumbs;
|
||||||
|
|
|
@ -57,6 +57,10 @@ class CollectionDraggableThumbLabel extends StatelessWidget {
|
||||||
return [
|
return [
|
||||||
if (entry.sizeBytes != null) formatFileSize(context.locale, entry.sizeBytes!, round: 0),
|
if (entry.sizeBytes != null) formatFileSize(context.locale, entry.sizeBytes!, round: 0),
|
||||||
];
|
];
|
||||||
|
case EntrySortFactor.duration:
|
||||||
|
return [
|
||||||
|
if (entry.durationMillis != null) entry.durationText,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -66,6 +66,7 @@ class CollectionSectionHeader extends StatelessWidget {
|
||||||
selectable: selectable,
|
selectable: selectable,
|
||||||
);
|
);
|
||||||
case EntrySortFactor.size:
|
case EntrySortFactor.size:
|
||||||
|
case EntrySortFactor.duration:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -4,7 +4,7 @@ enum ChipSortFactor { date, name, count, size }
|
||||||
|
|
||||||
enum AlbumChipGroupFactor { none, importance, mimeType, volume }
|
enum AlbumChipGroupFactor { none, importance, mimeType, volume }
|
||||||
|
|
||||||
enum EntrySortFactor { date, name, rating, size }
|
enum EntrySortFactor { date, name, rating, size, duration }
|
||||||
|
|
||||||
enum EntryGroupFactor { none, album, month, day }
|
enum EntryGroupFactor { none, album, month, day }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue