summaryrefslogtreecommitdiff
path: root/lib/model/settings/modules
diff options
context:
space:
mode:
authormirror <mirror@localhost>2026-11-22 08:41:00 +0900
committermirror <mirror@localhost>2026-11-22 08:41:00 +0900
commit449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch)
treec131c3528c4d517f56e19b854a7453fedb097d40 /lib/model/settings/modules
downloadaves-src-master.tar.gz
aves-src-master.zip
snapshot of aves v1.13.12 (secrets removed: android/app/google-services.json)HEADv1.13.12master
Diffstat (limited to 'lib/model/settings/modules')
-rw-r--r--lib/model/settings/modules/app.dart142
-rw-r--r--lib/model/settings/modules/collection.dart60
-rw-r--r--lib/model/settings/modules/debug.dart7
-rw-r--r--lib/model/settings/modules/display.dart37
-rw-r--r--lib/model/settings/modules/filter_grids.dart117
-rw-r--r--lib/model/settings/modules/info.dart16
-rw-r--r--lib/model/settings/modules/navigation.dart142
-rw-r--r--lib/model/settings/modules/privacy.dart46
-rw-r--r--lib/model/settings/modules/screen_saver.dart29
-rw-r--r--lib/model/settings/modules/search.dart13
-rw-r--r--lib/model/settings/modules/slideshow.dart32
-rw-r--r--lib/model/settings/modules/viewer.dart60
-rw-r--r--lib/model/settings/modules/widget.dart29
13 files changed, 730 insertions, 0 deletions
diff --git a/lib/model/settings/modules/app.dart b/lib/model/settings/modules/app.dart
new file mode 100644
index 0000000..53ea9c1
--- /dev/null
+++ b/lib/model/settings/modules/app.dart
@@ -0,0 +1,142 @@
+import 'package:aves/model/filters/covered/tag.dart';
+import 'package:aves/model/filters/filters.dart';
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves/model/source/collection_source.dart';
+import 'package:aves/model/vaults/vaults.dart';
+import 'package:aves/widgets/aves_app.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:flutter/widgets.dart';
+
+mixin AppSettings on SettingsAccess {
+ static const int recentFilterHistoryMax = 20;
+
+ void initAppSettings() {
+ vaults.addListener(_onVaultsChanged);
+ }
+
+ bool get hasAcceptedTerms => getBool(SettingKeys.hasAcceptedTermsKey) ?? SettingsDefaults.hasAcceptedTerms;
+
+ set hasAcceptedTerms(bool newValue) => set(SettingKeys.hasAcceptedTermsKey, newValue);
+
+ bool get canUseAnalysisService => getBool(SettingKeys.canUseAnalysisServiceKey) ?? SettingsDefaults.canUseAnalysisService;
+
+ set canUseAnalysisService(bool newValue) => set(SettingKeys.canUseAnalysisServiceKey, newValue);
+
+ bool get isInstalledAppAccessAllowed => getBool(SettingKeys.isInstalledAppAccessAllowedKey) ?? SettingsDefaults.isInstalledAppAccessAllowed;
+
+ set isInstalledAppAccessAllowed(bool newValue) => set(SettingKeys.isInstalledAppAccessAllowedKey, newValue);
+
+ bool get isErrorReportingAllowed => getBool(SettingKeys.isErrorReportingAllowedKey) ?? SettingsDefaults.isErrorReportingAllowed;
+
+ set isErrorReportingAllowed(bool newValue) => set(SettingKeys.isErrorReportingAllowedKey, newValue);
+
+ static const localeSeparator = '-';
+
+ Locale? get locale {
+ // exceptionally allow getting locale before settings are initialized
+ final tag = initialized ? getString(SettingKeys.localeKey) : null;
+ if (tag != null) {
+ final codes = tag.split(localeSeparator);
+ return Locale.fromSubtags(
+ languageCode: codes[0],
+ scriptCode: codes[1] == '' ? null : codes[1],
+ countryCode: codes[2] == '' ? null : codes[2],
+ );
+ }
+ return null;
+ }
+
+ set locale(Locale? newValue) {
+ String? tag;
+ if (newValue != null) {
+ tag = [
+ newValue.languageCode,
+ newValue.scriptCode ?? '',
+ newValue.countryCode ?? '',
+ ].join(localeSeparator);
+ }
+ set(SettingKeys.localeKey, tag);
+ resetAppliedLocale();
+ }
+
+ List<Locale> _systemLocalesFallback = [];
+
+ set systemLocalesFallback(List<Locale> locales) => _systemLocalesFallback = locales;
+
+ Locale? _appliedLocale;
+
+ void resetAppliedLocale() => _appliedLocale = null;
+
+ Locale get appliedLocale {
+ if (_appliedLocale == null) {
+ final _locale = locale;
+ final preferredLocales = <Locale>[];
+ if (_locale != null) {
+ preferredLocales.add(_locale);
+ } else {
+ preferredLocales.addAll(WidgetsBinding.instance.platformDispatcher.locales);
+ if (preferredLocales.isEmpty) {
+ // the `window` locales may be empty in a window-less service context
+ preferredLocales.addAll(_systemLocalesFallback);
+ }
+ }
+ _appliedLocale = basicLocaleListResolution(preferredLocales, AvesApp.supportedLocales);
+ }
+ return _appliedLocale!;
+ }
+
+ bool get forceWesternArabicNumerals => getBool(SettingKeys.forceWesternArabicNumeralsKey) ?? false;
+
+ set forceWesternArabicNumerals(bool newValue) => set(SettingKeys.forceWesternArabicNumeralsKey, newValue);
+
+ int get catalogTimeZoneOffsetMillis => getInt(SettingKeys.catalogTimeZoneOffsetMillisKey) ?? 0;
+
+ set catalogTimeZoneOffsetMillis(int newValue) => set(SettingKeys.catalogTimeZoneOffsetMillisKey, newValue);
+
+ double getTileExtent(String routeName) => getDouble(SettingKeys.tileExtentPrefixKey + routeName) ?? 0;
+
+ void setTileExtent(String routeName, double newValue) => set(SettingKeys.tileExtentPrefixKey + routeName, newValue);
+
+ TileLayout getTileLayout(String routeName) => getEnumOrDefault(SettingKeys.tileLayoutPrefixKey + routeName, SettingsDefaults.tileLayout, TileLayout.values);
+
+ void setTileLayout(String routeName, TileLayout newValue) => set(SettingKeys.tileLayoutPrefixKey + routeName, newValue.toString());
+
+ String get entryRenamingPattern => getString(SettingKeys.entryRenamingPatternKey) ?? SettingsDefaults.entryRenamingPattern;
+
+ set entryRenamingPattern(String newValue) => set(SettingKeys.entryRenamingPatternKey, newValue);
+
+ List<int>? get topEntryIds => getStringList(SettingKeys.topEntryIdsKey)?.map(int.tryParse).nonNulls.toList();
+
+ set topEntryIds(List<int>? newValue) => set(SettingKeys.topEntryIdsKey, newValue?.map((id) => id.toString()).nonNulls.toList());
+
+ List<String> get recentDestinationAlbums => getStringList(SettingKeys.recentDestinationAlbumsKey) ?? [];
+
+ set recentDestinationAlbums(List<String> newValue) => set(SettingKeys.recentDestinationAlbumsKey, newValue.take(recentFilterHistoryMax).toList());
+
+ // recent tags
+
+ List<CollectionFilter> get _recentTags => (getStringList(SettingKeys.recentTagsKey) ?? []).map(CollectionFilter.fromJson).nonNulls.toList();
+
+ set _recentTags(List<CollectionFilter> newValue) => set(SettingKeys.recentTagsKey, newValue.take(recentFilterHistoryMax).map((filter) => filter.toJson()).toList());
+
+ // when vaults are unlocked, recent tags are transient and not persisted
+ List<CollectionFilter>? _protectedRecentTags;
+
+ List<CollectionFilter> get recentTags => vaults.needProtection ? _protectedRecentTags ?? List.of(_recentTags) : _recentTags;
+
+ set recentTags(List<CollectionFilter> newValue) {
+ if (vaults.needProtection) {
+ _protectedRecentTags = newValue;
+ } else {
+ _recentTags = newValue;
+ }
+ }
+
+ void _onVaultsChanged() => _protectedRecentTags = null;
+
+ void removeObsoleteRecentTags(CollectionSource? source) {
+ if (source != null) {
+ recentTags = recentTags.where((v) => v is! TagFilter || source.sortedTags.contains(v.tag)).toList();
+ }
+ }
+}
diff --git a/lib/model/settings/modules/collection.dart b/lib/model/settings/modules/collection.dart
new file mode 100644
index 0000000..5ccd095
--- /dev/null
+++ b/lib/model/settings/modules/collection.dart
@@ -0,0 +1,60 @@
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves_model/aves_model.dart';
+
+mixin CollectionSettings on SettingsAccess {
+ List<String> get collectionBurstPatterns => getStringList(SettingKeys.collectionBurstPatternsKey) ?? [];
+
+ set collectionBurstPatterns(List<String> newValue) => set(SettingKeys.collectionBurstPatternsKey, newValue);
+
+ EntrySectionFactor get collectionSectionFactor => getEnumOrDefault(SettingKeys.collectionGroupFactorKey, SettingsDefaults.collectionSectionFactor, EntrySectionFactor.values);
+
+ set collectionSectionFactor(EntrySectionFactor newValue) => set(SettingKeys.collectionGroupFactorKey, newValue.toString());
+
+ EntrySortFactor get collectionSortFactor => getEnumOrDefault(SettingKeys.collectionSortFactorKey, SettingsDefaults.collectionSortFactor, EntrySortFactor.values);
+
+ set collectionSortFactor(EntrySortFactor newValue) => set(SettingKeys.collectionSortFactorKey, newValue.toString());
+
+ bool get collectionSortReverse => getBool(SettingKeys.collectionSortReverseKey) ?? false;
+
+ set collectionSortReverse(bool newValue) => set(SettingKeys.collectionSortReverseKey, newValue);
+
+ List<EntrySetAction> get collectionBrowsingQuickActions => getEnumListOrDefault(SettingKeys.collectionBrowsingQuickActionsKey, SettingsDefaults.collectionBrowsingQuickActions, EntrySetAction.values);
+
+ set collectionBrowsingQuickActions(List<EntrySetAction> newValue) => set(SettingKeys.collectionBrowsingQuickActionsKey, newValue.map((v) => v.toString()).toList());
+
+ List<EntrySetAction> get collectionSelectionQuickActions => getEnumListOrDefault(SettingKeys.collectionSelectionQuickActionsKey, SettingsDefaults.collectionSelectionQuickActions, EntrySetAction.values);
+
+ set collectionSelectionQuickActions(List<EntrySetAction> newValue) => set(SettingKeys.collectionSelectionQuickActionsKey, newValue.map((v) => v.toString()).toList());
+
+ bool get showThumbnailFavourite => getBool(SettingKeys.showThumbnailFavouriteKey) ?? SettingsDefaults.showThumbnailFavourite;
+
+ set showThumbnailFavourite(bool newValue) => set(SettingKeys.showThumbnailFavouriteKey, newValue);
+
+ bool get showThumbnailHdr => getBool(SettingKeys.showThumbnailHdrKey) ?? SettingsDefaults.showThumbnailHdr;
+
+ set showThumbnailHdr(bool newValue) => set(SettingKeys.showThumbnailHdrKey, newValue);
+
+ ThumbnailOverlayLocationIcon get thumbnailLocationIcon => getEnumOrDefault(SettingKeys.thumbnailLocationIconKey, SettingsDefaults.thumbnailLocationIcon, ThumbnailOverlayLocationIcon.values);
+
+ set thumbnailLocationIcon(ThumbnailOverlayLocationIcon newValue) => set(SettingKeys.thumbnailLocationIconKey, newValue.toString());
+
+ ThumbnailOverlayTagIcon get thumbnailTagIcon => getEnumOrDefault(SettingKeys.thumbnailTagIconKey, SettingsDefaults.thumbnailTagIcon, ThumbnailOverlayTagIcon.values);
+
+ set thumbnailTagIcon(ThumbnailOverlayTagIcon newValue) => set(SettingKeys.thumbnailTagIconKey, newValue.toString());
+
+ bool get showThumbnailMotionPhoto => getBool(SettingKeys.showThumbnailMotionPhotoKey) ?? SettingsDefaults.showThumbnailMotionPhoto;
+
+ set showThumbnailMotionPhoto(bool newValue) => set(SettingKeys.showThumbnailMotionPhotoKey, newValue);
+
+ bool get showThumbnailRating => getBool(SettingKeys.showThumbnailRatingKey) ?? SettingsDefaults.showThumbnailRating;
+
+ set showThumbnailRating(bool newValue) => set(SettingKeys.showThumbnailRatingKey, newValue);
+
+ bool get showThumbnailRaw => getBool(SettingKeys.showThumbnailRawKey) ?? SettingsDefaults.showThumbnailRaw;
+
+ set showThumbnailRaw(bool newValue) => set(SettingKeys.showThumbnailRawKey, newValue);
+
+ bool get showThumbnailVideoDuration => getBool(SettingKeys.showThumbnailVideoDurationKey) ?? SettingsDefaults.showThumbnailVideoDuration;
+
+ set showThumbnailVideoDuration(bool newValue) => set(SettingKeys.showThumbnailVideoDurationKey, newValue);
+}
diff --git a/lib/model/settings/modules/debug.dart b/lib/model/settings/modules/debug.dart
new file mode 100644
index 0000000..f740206
--- /dev/null
+++ b/lib/model/settings/modules/debug.dart
@@ -0,0 +1,7 @@
+import 'package:aves_model/aves_model.dart';
+
+mixin DebugSettings on SettingsAccess {
+ bool get debugShowViewerTiles => getBool(SettingKeys.debugShowViewerTilesKey) ?? false;
+
+ set debugShowViewerTiles(bool newValue) => set(SettingKeys.debugShowViewerTilesKey, newValue);
+}
diff --git a/lib/model/settings/modules/display.dart b/lib/model/settings/modules/display.dart
new file mode 100644
index 0000000..390dd87
--- /dev/null
+++ b/lib/model/settings/modules/display.dart
@@ -0,0 +1,37 @@
+import 'package:aves/model/device.dart';
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves_model/aves_model.dart';
+
+mixin DisplaySettings on SettingsAccess {
+ DisplayRefreshRateMode get displayRefreshRateMode => getEnumOrDefault(SettingKeys.displayRefreshRateModeKey, SettingsDefaults.displayRefreshRateMode, DisplayRefreshRateMode.values);
+
+ set displayRefreshRateMode(DisplayRefreshRateMode newValue) => set(SettingKeys.displayRefreshRateModeKey, newValue.toString());
+
+ AvesThemeBrightness get themeBrightness => getEnumOrDefault(SettingKeys.themeBrightnessKey, SettingsDefaults.themeBrightness, AvesThemeBrightness.values);
+
+ set themeBrightness(AvesThemeBrightness newValue) => set(SettingKeys.themeBrightnessKey, newValue.toString());
+
+ AvesThemeColorMode get themeColorMode => getEnumOrDefault(SettingKeys.themeColorModeKey, SettingsDefaults.themeColorMode, AvesThemeColorMode.values);
+
+ set themeColorMode(AvesThemeColorMode newValue) => set(SettingKeys.themeColorModeKey, newValue.toString());
+
+ bool get enableDynamicColor => getBool(SettingKeys.enableDynamicColorKey) ?? SettingsDefaults.enableDynamicColor;
+
+ set enableDynamicColor(bool newValue) => set(SettingKeys.enableDynamicColorKey, newValue);
+
+ bool get enableBlurEffect => getBool(SettingKeys.enableBlurEffectKey) ?? SettingsDefaults.enableBlurEffect;
+
+ set enableBlurEffect(bool newValue) => set(SettingKeys.enableBlurEffectKey, newValue);
+
+ MaxBrightness get maxBrightness => getEnumOrDefault(SettingKeys.maxBrightnessKey, SettingsDefaults.maxBrightness, MaxBrightness.values);
+
+ set maxBrightness(MaxBrightness newValue) => set(SettingKeys.maxBrightnessKey, newValue.toString());
+
+ bool get forceTvLayout => getBool(SettingKeys.forceTvLayoutKey) ?? SettingsDefaults.forceTvLayout;
+
+ set forceTvLayout(bool newValue) => set(SettingKeys.forceTvLayoutKey, newValue);
+
+ bool get useTvLayout => device.isTelevision || forceTvLayout;
+
+ bool get isReadOnly => useTvLayout;
+}
diff --git a/lib/model/settings/modules/filter_grids.dart b/lib/model/settings/modules/filter_grids.dart
new file mode 100644
index 0000000..1dcc772
--- /dev/null
+++ b/lib/model/settings/modules/filter_grids.dart
@@ -0,0 +1,117 @@
+import 'package:aves/model/filters/container/dynamic_album.dart';
+import 'package:aves/model/filters/filters.dart';
+import 'package:aves/model/grouping/common.dart';
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves/utils/collection_utils.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:synchronized/synchronized.dart';
+
+mixin FilterGridsSettings on SettingsAccess {
+ AlbumChipSectionFactor get albumSectionFactor => getEnumOrDefault(SettingKeys.albumSectionFactorKey, SettingsDefaults.albumGroupFactor, AlbumChipSectionFactor.values);
+
+ set albumSectionFactor(AlbumChipSectionFactor newValue) => set(SettingKeys.albumSectionFactorKey, newValue.toString());
+
+ ChipSortFactor get albumSortFactor => getEnumOrDefault(SettingKeys.albumSortFactorKey, SettingsDefaults.chipListSortFactor, ChipSortFactor.values);
+
+ set albumSortFactor(ChipSortFactor newValue) => set(SettingKeys.albumSortFactorKey, newValue.toString());
+
+ ChipSortFactor get countrySortFactor => getEnumOrDefault(SettingKeys.countrySortFactorKey, SettingsDefaults.chipListSortFactor, ChipSortFactor.values);
+
+ set countrySortFactor(ChipSortFactor newValue) => set(SettingKeys.countrySortFactorKey, newValue.toString());
+
+ ChipSortFactor get stateSortFactor => getEnumOrDefault(SettingKeys.stateSortFactorKey, SettingsDefaults.chipListSortFactor, ChipSortFactor.values);
+
+ set stateSortFactor(ChipSortFactor newValue) => set(SettingKeys.stateSortFactorKey, newValue.toString());
+
+ ChipSortFactor get placeSortFactor => getEnumOrDefault(SettingKeys.placeSortFactorKey, SettingsDefaults.chipListSortFactor, ChipSortFactor.values);
+
+ set placeSortFactor(ChipSortFactor newValue) => set(SettingKeys.placeSortFactorKey, newValue.toString());
+
+ ChipSortFactor get tagSortFactor => getEnumOrDefault(SettingKeys.tagSortFactorKey, SettingsDefaults.chipListSortFactor, ChipSortFactor.values);
+
+ set tagSortFactor(ChipSortFactor newValue) => set(SettingKeys.tagSortFactorKey, newValue.toString());
+
+ bool get albumSortReverse => getBool(SettingKeys.albumSortReverseKey) ?? false;
+
+ set albumSortReverse(bool newValue) => set(SettingKeys.albumSortReverseKey, newValue);
+
+ bool get countrySortReverse => getBool(SettingKeys.countrySortReverseKey) ?? false;
+
+ set countrySortReverse(bool newValue) => set(SettingKeys.countrySortReverseKey, newValue);
+
+ bool get stateSortReverse => getBool(SettingKeys.stateSortReverseKey) ?? false;
+
+ set stateSortReverse(bool newValue) => set(SettingKeys.stateSortReverseKey, newValue);
+
+ bool get placeSortReverse => getBool(SettingKeys.placeSortReverseKey) ?? false;
+
+ set placeSortReverse(bool newValue) => set(SettingKeys.placeSortReverseKey, newValue);
+
+ bool get tagSortReverse => getBool(SettingKeys.tagSortReverseKey) ?? false;
+
+ set tagSortReverse(bool newValue) => set(SettingKeys.tagSortReverseKey, newValue);
+
+ Set<CollectionFilter> get pinnedFilters => (getStringList(SettingKeys.pinnedFiltersKey) ?? []).map(CollectionFilter.fromJson).nonNulls.toSet();
+
+ set pinnedFilters(Set<CollectionFilter> newValue) => set(SettingKeys.pinnedFiltersKey, newValue.map((filter) => filter.toJson()).toList());
+
+ bool getShowTitleQuery(String routeName) => getBool(SettingKeys.showTitleQueryPrefixKey + routeName) ?? false;
+
+ void setShowTitleQuery(String routeName, bool newValue) => set(SettingKeys.showTitleQueryPrefixKey + routeName, newValue);
+
+ void resetShowTitleQuery() {
+ final configuredKeys = store.getKeys().where((v) => v.startsWith(SettingKeys.showTitleQueryPrefixKey)).toSet();
+ configuredKeys.forEach((key) => set(key, false));
+ }
+
+ Map<Uri, Set<Uri>> get albumGroups => FilterGrouping.fromJson(getString(SettingKeys.albumGroupsKey)) ?? {};
+
+ set albumGroups(Map<Uri, Set<Uri>> groups) => set(SettingKeys.albumGroupsKey, FilterGrouping.toJson(groups));
+
+ Map<Uri, Set<Uri>> get tagGroups => FilterGrouping.fromJson(getString(SettingKeys.tagGroupsKey)) ?? {};
+
+ set tagGroups(Map<Uri, Set<Uri>> groups) => set(SettingKeys.tagGroupsKey, FilterGrouping.toJson(groups));
+
+ // listening
+
+ final _lockForPins = Lock();
+
+ Future<void> updatePinnedDynamicAlbums(Map<DynamicAlbumFilter, DynamicAlbumFilter?> changes) async {
+ await _lockForPins.synchronized(() async {
+ final _pinnedFilters = pinnedFilters;
+ bool changed = false;
+ changes.forEach((oldFilter, newFilter) {
+ if (newFilter != null) {
+ changed |= _pinnedFilters.replace(oldFilter, newFilter);
+ } else {
+ changed |= _pinnedFilters.remove(oldFilter);
+ }
+ });
+ if (changed) {
+ pinnedFilters = _pinnedFilters;
+ }
+ });
+ }
+
+ Future<void> updatePinnedGroup(Uri oldGroupUri, Uri newGroupUri) async {
+ await _lockForPins.synchronized(() async {
+ final _pinnedFilters = pinnedFilters;
+ bool changed = false;
+ final grouping = FilterGrouping.forUri(oldGroupUri);
+ if (grouping != null) {
+ final oldFilter = grouping.uriToFilter(oldGroupUri);
+ final newFilter = grouping.uriToFilter(newGroupUri);
+ if (oldFilter != null && newFilter != null) {
+ changed |= _pinnedFilters.replace(oldFilter, newFilter);
+ }
+ }
+ if (changed) {
+ pinnedFilters = _pinnedFilters;
+ }
+ });
+ }
+
+ void saveAlbumGroups() => albumGroups = albumGrouping.allGroups;
+
+ void saveTagGroups() => tagGroups = tagGrouping.allGroups;
+}
diff --git a/lib/model/settings/modules/info.dart b/lib/model/settings/modules/info.dart
new file mode 100644
index 0000000..18e8094
--- /dev/null
+++ b/lib/model/settings/modules/info.dart
@@ -0,0 +1,16 @@
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves_model/aves_model.dart';
+
+mixin InfoSettings on SettingsAccess {
+ double get infoMapZoom => getDouble(SettingKeys.infoMapZoomKey) ?? SettingsDefaults.infoMapZoom;
+
+ set infoMapZoom(double newValue) => set(SettingKeys.infoMapZoomKey, newValue);
+
+ CoordinateFormat get coordinateFormat => getEnumOrDefault(SettingKeys.coordinateFormatKey, SettingsDefaults.coordinateFormat, CoordinateFormat.values);
+
+ set coordinateFormat(CoordinateFormat newValue) => set(SettingKeys.coordinateFormatKey, newValue.toString());
+
+ UnitSystem get unitSystem => getEnumOrDefault(SettingKeys.unitSystemKey, SettingsDefaults.unitSystem, UnitSystem.values);
+
+ set unitSystem(UnitSystem newValue) => set(SettingKeys.unitSystemKey, newValue.toString());
+}
diff --git a/lib/model/settings/modules/navigation.dart b/lib/model/settings/modules/navigation.dart
new file mode 100644
index 0000000..94d7634
--- /dev/null
+++ b/lib/model/settings/modules/navigation.dart
@@ -0,0 +1,142 @@
+import 'package:aves/model/filters/container/album_group.dart';
+import 'package:aves/model/filters/container/dynamic_album.dart';
+import 'package:aves/model/filters/filters.dart';
+import 'package:aves/model/grouping/common.dart';
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves/utils/collection_utils.dart';
+import 'package:aves/widgets/collection/collection_page.dart';
+import 'package:aves/widgets/explorer/explorer_page.dart';
+import 'package:aves/widgets/filter_grids/albums_page.dart';
+import 'package:aves/widgets/filter_grids/tags_page.dart';
+import 'package:aves/widgets/navigation/nav_item.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:synchronized/synchronized.dart';
+
+mixin NavigationSettings on SettingsAccess {
+ bool get mustBackTwiceToExit => getBool(SettingKeys.mustBackTwiceToExitKey) ?? SettingsDefaults.mustBackTwiceToExit;
+
+ set mustBackTwiceToExit(bool newValue) => set(SettingKeys.mustBackTwiceToExitKey, newValue);
+
+ KeepScreenOn get keepScreenOn => getEnumOrDefault(SettingKeys.keepScreenOnKey, SettingsDefaults.keepScreenOn, KeepScreenOn.values);
+
+ set keepScreenOn(KeepScreenOn newValue) => set(SettingKeys.keepScreenOnKey, newValue.toString());
+
+ HomePageSetting get homePage => getEnumOrDefault(SettingKeys.homePageKey, SettingsDefaults.homePage, HomePageSetting.values);
+
+ Set<CollectionFilter> get homeCustomCollection => (getStringList(SettingKeys.homeCustomCollectionKey) ?? []).map(CollectionFilter.fromJson).nonNulls.toSet();
+
+ String? get homeCustomExplorerPath => getString(SettingKeys.homeCustomExplorerPathKey);
+
+ AvesNavItem get homeNavItem {
+ switch (homePage) {
+ case HomePageSetting.collection:
+ return AvesNavItem(route: CollectionPage.routeName, filters: homeCustomCollection);
+ case HomePageSetting.albums:
+ return const AvesNavItem(route: AlbumListPage.routeName);
+ case HomePageSetting.tags:
+ return const AvesNavItem(route: TagListPage.routeName);
+ case HomePageSetting.explorer:
+ return AvesNavItem(route: ExplorerPage.routeName, path: homeCustomExplorerPath);
+ }
+ }
+
+ void setHome(
+ HomePageSetting homePage, {
+ Set<CollectionFilter> customCollection = const {},
+ String? customExplorerPath,
+ }) {
+ set(SettingKeys.homePageKey, homePage.toString());
+ set(SettingKeys.homeCustomCollectionKey, customCollection.map((filter) => filter.toJson()).toList());
+ set(SettingKeys.homeCustomExplorerPathKey, customExplorerPath);
+ }
+
+ bool get confirmCreateVault => getBool(SettingKeys.confirmCreateVaultKey) ?? SettingsDefaults.confirm;
+
+ set confirmCreateVault(bool newValue) => set(SettingKeys.confirmCreateVaultKey, newValue);
+
+ bool get confirmDeleteForever => getBool(SettingKeys.confirmDeleteForeverKey) ?? SettingsDefaults.confirm;
+
+ set confirmDeleteForever(bool newValue) => set(SettingKeys.confirmDeleteForeverKey, newValue);
+
+ bool get confirmMoveToBin => getBool(SettingKeys.confirmMoveToBinKey) ?? SettingsDefaults.confirm;
+
+ set confirmMoveToBin(bool newValue) => set(SettingKeys.confirmMoveToBinKey, newValue);
+
+ bool get confirmMoveUndatedItems => getBool(SettingKeys.confirmMoveUndatedItemsKey) ?? SettingsDefaults.confirm;
+
+ set confirmMoveUndatedItems(bool newValue) => set(SettingKeys.confirmMoveUndatedItemsKey, newValue);
+
+ bool get confirmAfterMoveToBin => getBool(SettingKeys.confirmAfterMoveToBinKey) ?? SettingsDefaults.confirm;
+
+ set confirmAfterMoveToBin(bool newValue) => set(SettingKeys.confirmAfterMoveToBinKey, newValue);
+
+ bool get setMetadataDateBeforeFileOp => getBool(SettingKeys.setMetadataDateBeforeFileOpKey) ?? SettingsDefaults.setMetadataDateBeforeFileOp;
+
+ set setMetadataDateBeforeFileOp(bool newValue) => set(SettingKeys.setMetadataDateBeforeFileOpKey, newValue);
+
+ List<CollectionFilter?> get drawerTypeBookmarks =>
+ getStringList(SettingKeys.drawerTypeBookmarksKey)?.map((v) {
+ if (v.isEmpty) return null;
+ return CollectionFilter.fromJson(v);
+ }).toList() ??
+ SettingsDefaults.drawerTypeBookmarks;
+
+ set drawerTypeBookmarks(List<CollectionFilter?> newValue) => set(SettingKeys.drawerTypeBookmarksKey, newValue.map((filter) => filter?.toJson() ?? '').toList());
+
+ List<AlbumBaseFilter>? get drawerAlbumBookmarks => getStringList(SettingKeys.drawerAlbumBookmarksKey)?.map(CollectionFilter.fromJson).whereType<AlbumBaseFilter>().toList();
+
+ set drawerAlbumBookmarks(List<AlbumBaseFilter>? newValue) => set(SettingKeys.drawerAlbumBookmarksKey, newValue?.map((filter) => filter.toJson()).toList());
+
+ List<String> get drawerPageBookmarks => getStringList(SettingKeys.drawerPageBookmarksKey) ?? SettingsDefaults.drawerPageBookmarks;
+
+ set drawerPageBookmarks(List<String> newValue) => set(SettingKeys.drawerPageBookmarksKey, newValue);
+
+ List<AvesNavItem> get bottomNavigationActions => getStringList(SettingKeys.bottomNavigationActionsKey)?.map(AvesNavItem.fromJson).nonNulls.toList() ?? SettingsDefaults.bottomNavigationActions;
+
+ set bottomNavigationActions(List<AvesNavItem>? newValue) => set(SettingKeys.bottomNavigationActionsKey, newValue?.map((v) => v.toJson()).toList());
+
+ bool get enableBottomNavigationBar => bottomNavigationActions.length >= 2;
+
+ // listening
+
+ final _lockForBookmarks = Lock();
+
+ Future<void> updateBookmarkedDynamicAlbums(Map<DynamicAlbumFilter, DynamicAlbumFilter?> changes) async {
+ await _lockForBookmarks.synchronized(() async {
+ final _bookmarks = drawerAlbumBookmarks;
+ bool changed = false;
+ if (_bookmarks != null) {
+ changes.forEach((oldFilter, newFilter) {
+ if (newFilter != null) {
+ changed |= _bookmarks.replace(oldFilter, newFilter);
+ } else {
+ changed |= _bookmarks.remove(oldFilter);
+ }
+ });
+ }
+ if (changed) {
+ drawerAlbumBookmarks = _bookmarks;
+ }
+ });
+ }
+
+ Future<void> updateBookmarkedGroup(Uri oldGroupUri, Uri newGroupUri) async {
+ await _lockForBookmarks.synchronized(() async {
+ final _bookmarks = drawerAlbumBookmarks;
+ bool changed = false;
+ if (_bookmarks != null) {
+ final grouping = FilterGrouping.forUri(oldGroupUri);
+ if (grouping != null) {
+ final oldFilter = grouping.uriToFilter(oldGroupUri);
+ final newFilter = grouping.uriToFilter(newGroupUri);
+ if (oldFilter is AlbumBaseFilter && newFilter is AlbumBaseFilter) {
+ changed |= _bookmarks.replace(oldFilter, newFilter);
+ }
+ }
+ }
+ if (changed) {
+ drawerAlbumBookmarks = _bookmarks;
+ }
+ });
+ }
+}
diff --git a/lib/model/settings/modules/privacy.dart b/lib/model/settings/modules/privacy.dart
new file mode 100644
index 0000000..a6408b8
--- /dev/null
+++ b/lib/model/settings/modules/privacy.dart
@@ -0,0 +1,46 @@
+import 'package:aves/model/filters/filters.dart';
+import 'package:aves/model/settings/modules/search.dart';
+import 'package:aves_model/aves_model.dart';
+
+mixin PrivacySettings on SettingsAccess, SearchSettings {
+ Set<CollectionFilter> get hiddenFilters => (getStringList(SettingKeys.hiddenFiltersKey) ?? []).map(CollectionFilter.fromJson).nonNulls.toSet();
+
+ set hiddenFilters(Set<CollectionFilter> newValue) => set(SettingKeys.hiddenFiltersKey, newValue.map((filter) => filter.toJson()).toList());
+
+ void changeFilterVisibility(Set<CollectionFilter> filters, bool visible) {
+ final _deactivatedHiddenFilters = deactivatedHiddenFilters;
+ final _hiddenFilters = hiddenFilters;
+
+ _deactivatedHiddenFilters.removeAll(filters);
+ if (visible) {
+ _hiddenFilters.removeAll(filters);
+ } else {
+ _hiddenFilters.addAll(filters);
+ searchHistory = searchHistory..removeWhere(filters.contains);
+ }
+
+ deactivatedHiddenFilters = _deactivatedHiddenFilters;
+ hiddenFilters = _hiddenFilters;
+ }
+
+ Set<CollectionFilter> get deactivatedHiddenFilters => (getStringList(SettingKeys.deactivatedHiddenFiltersKey) ?? []).map(CollectionFilter.fromJson).nonNulls.toSet();
+
+ set deactivatedHiddenFilters(Set<CollectionFilter> newValue) => set(SettingKeys.deactivatedHiddenFiltersKey, newValue.map((filter) => filter.toJson()).toList());
+
+ void activateHiddenFilter(CollectionFilter filter, bool active) {
+ final _deactivatedHiddenFilters = deactivatedHiddenFilters;
+ final _hiddenFilters = hiddenFilters;
+
+ if (active) {
+ _deactivatedHiddenFilters.remove(filter);
+ _hiddenFilters.add(filter);
+ searchHistory = searchHistory..remove(filter);
+ } else {
+ _deactivatedHiddenFilters.add(filter);
+ _hiddenFilters.remove(filter);
+ }
+
+ deactivatedHiddenFilters = _deactivatedHiddenFilters;
+ hiddenFilters = _hiddenFilters;
+ }
+}
diff --git a/lib/model/settings/modules/screen_saver.dart b/lib/model/settings/modules/screen_saver.dart
new file mode 100644
index 0000000..176bac4
--- /dev/null
+++ b/lib/model/settings/modules/screen_saver.dart
@@ -0,0 +1,29 @@
+import 'package:aves/model/filters/filters.dart';
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves_model/aves_model.dart';
+
+mixin ScreenSaverSettings on SettingsAccess {
+ bool get screenSaverFillScreen => getBool(SettingKeys.screenSaverFillScreenKey) ?? SettingsDefaults.slideshowFillScreen;
+
+ set screenSaverFillScreen(bool newValue) => set(SettingKeys.screenSaverFillScreenKey, newValue);
+
+ bool get screenSaverAnimatedZoomEffect => getBool(SettingKeys.screenSaverAnimatedZoomEffectKey) ?? SettingsDefaults.slideshowAnimatedZoomEffect;
+
+ set screenSaverAnimatedZoomEffect(bool newValue) => set(SettingKeys.screenSaverAnimatedZoomEffectKey, newValue);
+
+ ViewerTransition get screenSaverTransition => getEnumOrDefault(SettingKeys.screenSaverTransitionKey, SettingsDefaults.slideshowTransition, ViewerTransition.values);
+
+ set screenSaverTransition(ViewerTransition newValue) => set(SettingKeys.screenSaverTransitionKey, newValue.toString());
+
+ SlideshowVideoPlayback get screenSaverVideoPlayback => getEnumOrDefault(SettingKeys.screenSaverVideoPlaybackKey, SettingsDefaults.slideshowVideoPlayback, SlideshowVideoPlayback.values);
+
+ set screenSaverVideoPlayback(SlideshowVideoPlayback newValue) => set(SettingKeys.screenSaverVideoPlaybackKey, newValue.toString());
+
+ int get screenSaverInterval => getInt(SettingKeys.screenSaverIntervalKey) ?? SettingsDefaults.slideshowInterval;
+
+ set screenSaverInterval(int newValue) => set(SettingKeys.screenSaverIntervalKey, newValue);
+
+ Set<CollectionFilter> get screenSaverCollectionFilters => (getStringList(SettingKeys.screenSaverCollectionFiltersKey) ?? []).map(CollectionFilter.fromJson).nonNulls.toSet();
+
+ set screenSaverCollectionFilters(Set<CollectionFilter> newValue) => set(SettingKeys.screenSaverCollectionFiltersKey, newValue.map((filter) => filter.toJson()).toList());
+}
diff --git a/lib/model/settings/modules/search.dart b/lib/model/settings/modules/search.dart
new file mode 100644
index 0000000..3a5ff94
--- /dev/null
+++ b/lib/model/settings/modules/search.dart
@@ -0,0 +1,13 @@
+import 'package:aves/model/filters/filters.dart';
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves_model/aves_model.dart';
+
+mixin SearchSettings on SettingsAccess {
+ bool get saveSearchHistory => getBool(SettingKeys.saveSearchHistoryKey) ?? SettingsDefaults.saveSearchHistory;
+
+ set saveSearchHistory(bool newValue) => set(SettingKeys.saveSearchHistoryKey, newValue);
+
+ List<CollectionFilter> get searchHistory => (getStringList(SettingKeys.searchHistoryKey) ?? []).map(CollectionFilter.fromJson).nonNulls.toList();
+
+ set searchHistory(List<CollectionFilter> newValue) => set(SettingKeys.searchHistoryKey, newValue.map((filter) => filter.toJson()).toList());
+}
diff --git a/lib/model/settings/modules/slideshow.dart b/lib/model/settings/modules/slideshow.dart
new file mode 100644
index 0000000..50740e9
--- /dev/null
+++ b/lib/model/settings/modules/slideshow.dart
@@ -0,0 +1,32 @@
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves_model/aves_model.dart';
+
+mixin SlideshowSettings on SettingsAccess {
+ bool get slideshowRepeat => getBool(SettingKeys.slideshowRepeatKey) ?? SettingsDefaults.slideshowRepeat;
+
+ set slideshowRepeat(bool newValue) => set(SettingKeys.slideshowRepeatKey, newValue);
+
+ bool get slideshowShuffle => getBool(SettingKeys.slideshowShuffleKey) ?? SettingsDefaults.slideshowShuffle;
+
+ set slideshowShuffle(bool newValue) => set(SettingKeys.slideshowShuffleKey, newValue);
+
+ bool get slideshowFillScreen => getBool(SettingKeys.slideshowFillScreenKey) ?? SettingsDefaults.slideshowFillScreen;
+
+ set slideshowFillScreen(bool newValue) => set(SettingKeys.slideshowFillScreenKey, newValue);
+
+ bool get slideshowAnimatedZoomEffect => getBool(SettingKeys.slideshowAnimatedZoomEffectKey) ?? SettingsDefaults.slideshowAnimatedZoomEffect;
+
+ set slideshowAnimatedZoomEffect(bool newValue) => set(SettingKeys.slideshowAnimatedZoomEffectKey, newValue);
+
+ ViewerTransition get slideshowTransition => getEnumOrDefault(SettingKeys.slideshowTransitionKey, SettingsDefaults.slideshowTransition, ViewerTransition.values);
+
+ set slideshowTransition(ViewerTransition newValue) => set(SettingKeys.slideshowTransitionKey, newValue.toString());
+
+ SlideshowVideoPlayback get slideshowVideoPlayback => getEnumOrDefault(SettingKeys.slideshowVideoPlaybackKey, SettingsDefaults.slideshowVideoPlayback, SlideshowVideoPlayback.values);
+
+ set slideshowVideoPlayback(SlideshowVideoPlayback newValue) => set(SettingKeys.slideshowVideoPlaybackKey, newValue.toString());
+
+ int get slideshowInterval => getInt(SettingKeys.slideshowIntervalKey) ?? SettingsDefaults.slideshowInterval;
+
+ set slideshowInterval(int newValue) => set(SettingKeys.slideshowIntervalKey, newValue);
+}
diff --git a/lib/model/settings/modules/viewer.dart b/lib/model/settings/modules/viewer.dart
new file mode 100644
index 0000000..7d4f86f
--- /dev/null
+++ b/lib/model/settings/modules/viewer.dart
@@ -0,0 +1,60 @@
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves_model/aves_model.dart';
+
+mixin ViewerSettings on SettingsAccess {
+ List<EntryAction> get viewerQuickActions => getEnumListOrDefault(SettingKeys.viewerQuickActionsKey, SettingsDefaults.viewerQuickActions, EntryAction.values);
+
+ set viewerQuickActions(List<EntryAction> newValue) => set(SettingKeys.viewerQuickActionsKey, newValue.map((v) => v.toString()).toList());
+
+ bool get showOverlayOnOpening => getBool(SettingKeys.showOverlayOnOpeningKey) ?? SettingsDefaults.showOverlayOnOpening;
+
+ set showOverlayOnOpening(bool newValue) => set(SettingKeys.showOverlayOnOpeningKey, newValue);
+
+ bool get showOverlayMinimap => getBool(SettingKeys.showOverlayMinimapKey) ?? SettingsDefaults.showOverlayMinimap;
+
+ set showOverlayMinimap(bool newValue) => set(SettingKeys.showOverlayMinimapKey, newValue);
+
+ bool get showOverlayZoomLevel => getBool(SettingKeys.showOverlayZoomLevelKey) ?? SettingsDefaults.showOverlayZoomLevel;
+
+ set showOverlayZoomLevel(bool newValue) => set(SettingKeys.showOverlayZoomLevelKey, newValue);
+
+ OverlayHistogramStyle get overlayHistogramStyle => getEnumOrDefault(SettingKeys.overlayHistogramStyleKey, SettingsDefaults.overlayHistogramStyle, OverlayHistogramStyle.values);
+
+ set overlayHistogramStyle(OverlayHistogramStyle newValue) => set(SettingKeys.overlayHistogramStyleKey, newValue.toString());
+
+ bool get showOverlayInfo => getBool(SettingKeys.showOverlayInfoKey) ?? SettingsDefaults.showOverlayInfo;
+
+ set showOverlayInfo(bool newValue) => set(SettingKeys.showOverlayInfoKey, newValue);
+
+ bool get showOverlayDescription => getBool(SettingKeys.showOverlayDescriptionKey) ?? SettingsDefaults.showOverlayDescription;
+
+ set showOverlayDescription(bool newValue) => set(SettingKeys.showOverlayDescriptionKey, newValue);
+
+ bool get showOverlayRatingTags => getBool(SettingKeys.showOverlayRatingTagsKey) ?? SettingsDefaults.showOverlayRatingTags;
+
+ set showOverlayRatingTags(bool newValue) => set(SettingKeys.showOverlayRatingTagsKey, newValue);
+
+ bool get showOverlayShootingDetails => getBool(SettingKeys.showOverlayShootingDetailsKey) ?? SettingsDefaults.showOverlayShootingDetails;
+
+ set showOverlayShootingDetails(bool newValue) => set(SettingKeys.showOverlayShootingDetailsKey, newValue);
+
+ bool get showOverlayThumbnailPreview => getBool(SettingKeys.showOverlayThumbnailPreviewKey) ?? SettingsDefaults.showOverlayThumbnailPreview;
+
+ set showOverlayThumbnailPreview(bool newValue) => set(SettingKeys.showOverlayThumbnailPreviewKey, newValue);
+
+ bool get viewerGestureSideTapNext => getBool(SettingKeys.viewerGestureSideTapNextKey) ?? SettingsDefaults.viewerGestureSideTapNext;
+
+ set viewerGestureSideTapNext(bool newValue) => set(SettingKeys.viewerGestureSideTapNextKey, newValue);
+
+ bool get viewerUseCutout => getBool(SettingKeys.viewerUseCutoutKey) ?? SettingsDefaults.viewerUseCutout;
+
+ set viewerUseCutout(bool newValue) => set(SettingKeys.viewerUseCutoutKey, newValue);
+
+ bool get enableMotionPhotoAutoPlay => getBool(SettingKeys.enableMotionPhotoAutoPlayKey) ?? SettingsDefaults.enableMotionPhotoAutoPlay;
+
+ set enableMotionPhotoAutoPlay(bool newValue) => set(SettingKeys.enableMotionPhotoAutoPlayKey, newValue);
+
+ EntryBackground get imageBackground => getEnumOrDefault(SettingKeys.imageBackgroundKey, SettingsDefaults.imageBackground, EntryBackground.values);
+
+ set imageBackground(EntryBackground newValue) => set(SettingKeys.imageBackgroundKey, newValue.toString());
+}
diff --git a/lib/model/settings/modules/widget.dart b/lib/model/settings/modules/widget.dart
new file mode 100644
index 0000000..f1b3c91
--- /dev/null
+++ b/lib/model/settings/modules/widget.dart
@@ -0,0 +1,29 @@
+import 'package:aves/model/filters/filters.dart';
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves_model/aves_model.dart';
+
+mixin WidgetSettings on SettingsAccess {
+ WidgetOutline getWidgetOutline(int widgetId) => getEnumOrDefault('${SettingKeys.widgetOutlinePrefixKey}$widgetId', WidgetOutline.none, WidgetOutline.values);
+
+ void setWidgetOutline(int widgetId, WidgetOutline newValue) => set('${SettingKeys.widgetOutlinePrefixKey}$widgetId', newValue.toString());
+
+ WidgetShape getWidgetShape(int widgetId) => getEnumOrDefault('${SettingKeys.widgetShapePrefixKey}$widgetId', SettingsDefaults.widgetShape, WidgetShape.values);
+
+ void setWidgetShape(int widgetId, WidgetShape newValue) => set('${SettingKeys.widgetShapePrefixKey}$widgetId', newValue.toString());
+
+ Set<CollectionFilter> getWidgetCollectionFilters(int widgetId) => (getStringList('${SettingKeys.widgetCollectionFiltersPrefixKey}$widgetId') ?? []).map(CollectionFilter.fromJson).nonNulls.toSet();
+
+ void setWidgetCollectionFilters(int widgetId, Set<CollectionFilter> newValue) => set('${SettingKeys.widgetCollectionFiltersPrefixKey}$widgetId', newValue.map((filter) => filter.toJson()).toList());
+
+ WidgetOpenPage getWidgetOpenPage(int widgetId) => getEnumOrDefault('${SettingKeys.widgetOpenPagePrefixKey}$widgetId', SettingsDefaults.widgetOpenPage, WidgetOpenPage.values);
+
+ void setWidgetOpenPage(int widgetId, WidgetOpenPage newValue) => set('${SettingKeys.widgetOpenPagePrefixKey}$widgetId', newValue.toString());
+
+ WidgetDisplayedItem getWidgetDisplayedItem(int widgetId) => getEnumOrDefault('${SettingKeys.widgetDisplayedItemPrefixKey}$widgetId', SettingsDefaults.widgetDisplayedItem, WidgetDisplayedItem.values);
+
+ void setWidgetDisplayedItem(int widgetId, WidgetDisplayedItem newValue) => set('${SettingKeys.widgetDisplayedItemPrefixKey}$widgetId', newValue.toString());
+
+ String? getWidgetUri(int widgetId) => getString('${SettingKeys.widgetUriPrefixKey}$widgetId');
+
+ void setWidgetUri(int widgetId, String? newValue) => set('${SettingKeys.widgetUriPrefixKey}$widgetId', newValue);
+}