feat(album): album view sort order (#14648)

* feat(mobile): album view sort order

* feat: add error message

* refactor(mobile): album page (#14659)

* refactor album page

* update lint rule

* const record

* fix: updating sort order when pull to refresh

---------

Co-authored-by: Alex <alex.tran1502@gmail.com>

* Move sort toggle button to bottom sheet menu

* chore: revert multiselectgrid loading status

* chore: revert multiselectgrid loading status

---------

Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
This commit is contained in:
Alex
2024-12-16 10:11:48 -06:00
committed by GitHub
parent 364b717fde
commit 9503bf479b
32 changed files with 711 additions and 336 deletions
+22 -3
View File
@@ -1,6 +1,7 @@
import 'dart:async';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/constants/enums.dart';
import 'package:immich_mobile/entities/user.entity.dart';
import 'package:immich_mobile/models/albums/album_search.model.dart';
import 'package:immich_mobile/services/album.service.dart';
@@ -106,6 +107,13 @@ class AlbumNotifier extends StateNotifier<List<Album>> {
return _albumService.setActivityStatus(album, enabled);
}
Future<Album?> toggleSortOrder(Album album) {
final order =
album.sortOrder == SortOrder.asc ? SortOrder.desc : SortOrder.asc;
return _albumService.updateSortOrder(album, order);
}
@override
void dispose() {
_streamSub.cancel();
@@ -135,11 +143,22 @@ final albumWatcher =
final albumRenderlistProvider =
StreamProvider.autoDispose.family<RenderList, int>((ref, albumId) {
final album = ref.watch(albumWatcher(albumId)).value;
if (album != null) {
final query =
album.assets.filter().isTrashedEqualTo(false).sortByFileCreatedAtDesc();
return renderListGeneratorWithGroupBy(query, GroupAssetsBy.none);
final query = album.assets.filter().isTrashedEqualTo(false);
if (album.sortOrder == SortOrder.asc) {
return renderListGeneratorWithGroupBy(
query.sortByFileCreatedAt(),
GroupAssetsBy.none,
);
} else if (album.sortOrder == SortOrder.desc) {
return renderListGeneratorWithGroupBy(
query.sortByFileCreatedAtDesc(),
GroupAssetsBy.none,
);
}
}
return const Stream.empty();
});
@@ -0,0 +1,20 @@
import 'package:hooks_riverpod/hooks_riverpod.dart';
enum RenderListStatusEnum { complete, empty, error, loading }
final renderListStatusProvider =
StateNotifierProvider<RenderListStatus, RenderListStatusEnum>((ref) {
return RenderListStatus(ref);
});
class RenderListStatus extends StateNotifier<RenderListStatusEnum> {
RenderListStatus(this.ref) : super(RenderListStatusEnum.complete);
final Ref ref;
RenderListStatusEnum get status => state;
set status(RenderListStatusEnum value) {
state = value;
}
}
@@ -7,7 +7,7 @@ part of 'backup_verification.provider.dart';
// **************************************************************************
String _$backupVerificationHash() =>
r'021dfdf65e1903c932e4a1c14967b786dd3516fb';
r'b204e43ab575d5fa5b2ee663297f32bcee9074f5';
/// See also [BackupVerification].
@ProviderFor(BackupVerification)