mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
better animation
This commit is contained in:
parent
382ce8c8f6
commit
848ba66e22
4 changed files with 266 additions and 111 deletions
|
|
@ -2,35 +2,45 @@ import 'package:collection/collection.dart';
|
|||
import 'package:immich_mobile/domain/models/album/album.model.dart';
|
||||
|
||||
typedef AlbumSortFn = List<RemoteAlbum> Function(
|
||||
List<RemoteAlbum> albums, bool isReverse);
|
||||
List<RemoteAlbum> albums,
|
||||
bool isReverse,
|
||||
);
|
||||
|
||||
class _RemoteAlbumSortHandlers {
|
||||
const _RemoteAlbumSortHandlers._();
|
||||
|
||||
static const AlbumSortFn created = _sortByCreated;
|
||||
static List<RemoteAlbum> _sortByCreated(
|
||||
List<RemoteAlbum> albums, bool isReverse) {
|
||||
List<RemoteAlbum> albums,
|
||||
bool isReverse,
|
||||
) {
|
||||
final sorted = albums.sortedBy((album) => album.createdAt);
|
||||
return (isReverse ? sorted.reversed : sorted).toList();
|
||||
}
|
||||
|
||||
static const AlbumSortFn title = _sortByTitle;
|
||||
static List<RemoteAlbum> _sortByTitle(
|
||||
List<RemoteAlbum> albums, bool isReverse) {
|
||||
List<RemoteAlbum> albums,
|
||||
bool isReverse,
|
||||
) {
|
||||
final sorted = albums.sortedBy((album) => album.name);
|
||||
return (isReverse ? sorted.reversed : sorted).toList();
|
||||
}
|
||||
|
||||
static const AlbumSortFn lastModified = _sortByLastModified;
|
||||
static List<RemoteAlbum> _sortByLastModified(
|
||||
List<RemoteAlbum> albums, bool isReverse) {
|
||||
List<RemoteAlbum> albums,
|
||||
bool isReverse,
|
||||
) {
|
||||
final sorted = albums.sortedBy((album) => album.updatedAt);
|
||||
return (isReverse ? sorted.reversed : sorted).toList();
|
||||
}
|
||||
|
||||
static const AlbumSortFn assetCount = _sortByAssetCount;
|
||||
static List<RemoteAlbum> _sortByAssetCount(
|
||||
List<RemoteAlbum> albums, bool isReverse) {
|
||||
List<RemoteAlbum> albums,
|
||||
bool isReverse,
|
||||
) {
|
||||
final sorted =
|
||||
albums.sorted((a, b) => a.assetCount.compareTo(b.assetCount));
|
||||
return (isReverse ? sorted.reversed : sorted).toList();
|
||||
|
|
@ -38,7 +48,9 @@ class _RemoteAlbumSortHandlers {
|
|||
|
||||
static const AlbumSortFn mostRecent = _sortByMostRecent;
|
||||
static List<RemoteAlbum> _sortByMostRecent(
|
||||
List<RemoteAlbum> albums, bool isReverse) {
|
||||
List<RemoteAlbum> albums,
|
||||
bool isReverse,
|
||||
) {
|
||||
final sorted = albums.sorted((a, b) {
|
||||
// For most recent, we sort by updatedAt in descending order
|
||||
return b.updatedAt.compareTo(a.updatedAt);
|
||||
|
|
@ -48,7 +60,9 @@ class _RemoteAlbumSortHandlers {
|
|||
|
||||
static const AlbumSortFn mostOldest = _sortByMostOldest;
|
||||
static List<RemoteAlbum> _sortByMostOldest(
|
||||
List<RemoteAlbum> albums, bool isReverse) {
|
||||
List<RemoteAlbum> albums,
|
||||
bool isReverse,
|
||||
) {
|
||||
final sorted = albums.sorted((a, b) {
|
||||
// For oldest, we sort by createdAt in ascending order
|
||||
return a.createdAt.compareTo(b.createdAt);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue