Support for persisting sort settings on device
This commit is contained in:
parent
31a9aca08e
commit
77721ca3b3
1 changed files with 31 additions and 0 deletions
31
lib/utils/local_settings.dart
Normal file
31
lib/utils/local_settings.dart
Normal file
|
@ -0,0 +1,31 @@
|
|||
import 'package:logging/logging.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
enum AlbumSortKey {
|
||||
albumName,
|
||||
lastModified,
|
||||
createdAt,
|
||||
}
|
||||
|
||||
class LocalSettings {
|
||||
LocalSettings._privateConstructor();
|
||||
|
||||
static final LocalSettings instance = LocalSettings._privateConstructor();
|
||||
static const kCollectionSortPref = "collection_sort_pref";
|
||||
|
||||
final _logger = Logger("FeatureFlagService");
|
||||
SharedPreferences _prefs;
|
||||
|
||||
Future<void> init() async {
|
||||
_prefs = await SharedPreferences.getInstance();
|
||||
}
|
||||
|
||||
AlbumSortKey albumSortKey() {
|
||||
return AlbumSortKey.values[_prefs.getInt(kCollectionSortPref)]
|
||||
}
|
||||
|
||||
void setAlbumSortKey(AlbumSortKey key) {
|
||||
_prefs.setInt(kCollectionSortPref, key.index);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue