feat(mobile): persist album sort order (#1997)
Co-authored-by: Atul Mehla <>
This commit is contained in:
parent
646b912da8
commit
719f074ccf
2 changed files with 7 additions and 2 deletions
|
@ -8,6 +8,8 @@ import 'package:immich_mobile/modules/album/providers/album.provider.dart';
|
||||||
import 'package:immich_mobile/modules/album/ui/album_thumbnail_card.dart';
|
import 'package:immich_mobile/modules/album/ui/album_thumbnail_card.dart';
|
||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
import 'package:immich_mobile/shared/models/album.dart';
|
import 'package:immich_mobile/shared/models/album.dart';
|
||||||
|
import 'package:immich_mobile/modules/settings/providers/app_settings.provider.dart';
|
||||||
|
import 'package:immich_mobile/modules/settings/services/app_settings.service.dart';
|
||||||
|
|
||||||
class LibraryPage extends HookConsumerWidget {
|
class LibraryPage extends HookConsumerWidget {
|
||||||
const LibraryPage({Key? key}) : super(key: key);
|
const LibraryPage({Key? key}) : super(key: key);
|
||||||
|
@ -16,6 +18,7 @@ class LibraryPage extends HookConsumerWidget {
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final albums = ref.watch(albumProvider);
|
final albums = ref.watch(albumProvider);
|
||||||
var isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
var isDarkMode = Theme.of(context).brightness == Brightness.dark;
|
||||||
|
var settings = ref.watch(appSettingsServiceProvider);
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() {
|
() {
|
||||||
|
@ -40,7 +43,7 @@ class LibraryPage extends HookConsumerWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final selectedAlbumSortOrder = useState(0);
|
final selectedAlbumSortOrder = useState(settings.getSetting(AppSettingsEnum.selectedAlbumSortOrder));
|
||||||
|
|
||||||
List<Album> sortedAlbums() {
|
List<Album> sortedAlbums() {
|
||||||
if (selectedAlbumSortOrder.value == 0) {
|
if (selectedAlbumSortOrder.value == 0) {
|
||||||
|
@ -91,6 +94,7 @@ class LibraryPage extends HookConsumerWidget {
|
||||||
},
|
},
|
||||||
onSelected: (int value) {
|
onSelected: (int value) {
|
||||||
selectedAlbumSortOrder.value = value;
|
selectedAlbumSortOrder.value = value;
|
||||||
|
settings.setSetting(AppSettingsEnum.selectedAlbumSortOrder, value);
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
|
|
@ -18,7 +18,8 @@ enum AppSettingsEnum<T> {
|
||||||
thumbnailCacheSize<int>("thumbnailCacheSize", 10000),
|
thumbnailCacheSize<int>("thumbnailCacheSize", 10000),
|
||||||
imageCacheSize<int>("imageCacheSize", 350),
|
imageCacheSize<int>("imageCacheSize", 350),
|
||||||
albumThumbnailCacheSize<int>("albumThumbnailCacheSize", 200),
|
albumThumbnailCacheSize<int>("albumThumbnailCacheSize", 200),
|
||||||
useExperimentalAssetGrid<bool>("useExperimentalAssetGrid", false);
|
useExperimentalAssetGrid<bool>("useExperimentalAssetGrid", false),
|
||||||
|
selectedAlbumSortOrder<int>("selectedAlbumSortOrder", 0);
|
||||||
|
|
||||||
const AppSettingsEnum(this.hiveKey, this.defaultValue);
|
const AppSettingsEnum(this.hiveKey, this.defaultValue);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue