summaryrefslogtreecommitdiff
path: root/lib/model/settings
diff options
context:
space:
mode:
Diffstat (limited to 'lib/model/settings')
-rw-r--r--lib/model/settings/defaults.dart145
-rw-r--r--lib/model/settings/enums/accessibility_animations.dart32
-rw-r--r--lib/model/settings/enums/accessibility_timeout.dart26
-rw-r--r--lib/model/settings/enums/coordinate_format.dart95
-rw-r--r--lib/model/settings/enums/display_refresh_rate_mode.dart24
-rw-r--r--lib/model/settings/enums/entry_background.dart25
-rw-r--r--lib/model/settings/enums/screen_on.dart8
-rw-r--r--lib/model/settings/enums/subtitle_position.dart13
-rw-r--r--lib/model/settings/enums/theme_brightness.dart16
-rw-r--r--lib/model/settings/enums/viewer_transition.dart63
-rw-r--r--lib/model/settings/enums/widget_outline.dart33
-rw-r--r--lib/model/settings/enums/widget_shape.dart199
-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
-rw-r--r--lib/model/settings/settings.dart490
-rw-r--r--lib/model/settings/store_shared_pref.dart68
27 files changed, 1967 insertions, 0 deletions
diff --git a/lib/model/settings/defaults.dart b/lib/model/settings/defaults.dart
new file mode 100644
index 0000000..b758b99
--- /dev/null
+++ b/lib/model/settings/defaults.dart
@@ -0,0 +1,145 @@
+import 'package:aves/model/filters/favourite.dart';
+import 'package:aves/model/filters/mime.dart';
+import 'package:aves/model/filters/recent.dart';
+import 'package:aves/model/naming_pattern.dart';
+import 'package:aves/ref/mime_types.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/countries_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';
+
+class SettingsDefaults {
+ // app
+ static const hasAcceptedTerms = false;
+ static const canUseAnalysisService = true;
+ static const isInstalledAppAccessAllowed = false;
+ static const isErrorReportingAllowed = false;
+ static const tileLayout = TileLayout.grid;
+ static const entryRenamingPattern = '<${DateNamingProcessor.key}, yyyyMMdd-HHmmss> <${NameNamingProcessor.key}>';
+
+ // display
+ static const displayRefreshRateMode = DisplayRefreshRateMode.auto;
+ static const themeBrightness = AvesThemeBrightness.system;
+ static const themeColorMode = AvesThemeColorMode.polychrome;
+ static const enableDynamicColor = false;
+ static const enableBlurEffect = true; // `enableBlurEffect` has a contextual default value
+ static const maxBrightness = MaxBrightness.never;
+ static const forceTvLayout = false;
+
+ // navigation
+ static const mustBackTwiceToExit = true;
+ static const keepScreenOn = KeepScreenOn.viewerOnly;
+ static const homePage = HomePageSetting.collection;
+ static const confirm = true;
+ static const setMetadataDateBeforeFileOp = false;
+ static final drawerTypeBookmarks = [
+ null,
+ RecentlyAddedFilter.instance,
+ ];
+ static const drawerPageBookmarks = [
+ AlbumListPage.routeName,
+ CountryListPage.routeName,
+ TagListPage.routeName,
+ ExplorerPage.routeName,
+ ];
+ static final bottomNavigationActions = [
+ const AvesNavItem(route: CollectionPage.routeName),
+ AvesNavItem(route: CollectionPage.routeName, filters: {MimeFilter.video}),
+ AvesNavItem(route: CollectionPage.routeName, filters: {FavouriteFilter.instance}),
+ const AvesNavItem(route: AlbumListPage.routeName),
+ ];
+
+ // collection
+ static const collectionSectionFactor = EntrySectionFactor.month;
+ static const collectionSortFactor = EntrySortFactor.date;
+ static const collectionBrowsingQuickActions = [
+ EntrySetAction.searchCollection,
+ ];
+ static const collectionSelectionQuickActions = [
+ EntrySetAction.share,
+ EntrySetAction.delete,
+ ];
+ static const showThumbnailFavourite = true;
+ static const showThumbnailHdr = true;
+ static const thumbnailLocationIcon = ThumbnailOverlayLocationIcon.none;
+ static const thumbnailTagIcon = ThumbnailOverlayTagIcon.none;
+ static const showThumbnailMotionPhoto = true;
+ static const showThumbnailRating = true;
+ static const showThumbnailRaw = true;
+ static const showThumbnailVideoDuration = true;
+
+ // filter grids
+ static const albumGroupFactor = AlbumChipSectionFactor.importance;
+ static const chipListSortFactor = ChipSortFactor.name;
+
+ // viewer
+ static const viewerQuickActions = [
+ EntryAction.rotateScreen,
+ EntryAction.toggleFavourite,
+ EntryAction.share,
+ EntryAction.delete,
+ ];
+ static const showOverlayOnOpening = true;
+ static const showOverlayMinimap = false;
+ static const showOverlayZoomLevel = false;
+ static const overlayHistogramStyle = OverlayHistogramStyle.none;
+ static const showOverlayInfo = true;
+ static const showOverlayDescription = false;
+ static const showOverlayRatingTags = false;
+ static const showOverlayShootingDetails = false;
+ static const showOverlayThumbnailPreview = false;
+ static const viewerGestureSideTapNext = false;
+ static const viewerUseCutout = true;
+ static const enableMotionPhotoAutoPlay = false;
+
+ // info
+ static const infoMapZoom = 12.0;
+ static const coordinateFormat = CoordinateFormat.dms;
+ static const unitSystem = UnitSystem.metric;
+
+ // tag editor
+
+ static const tagEditorCurrentFilterSectionExpanded = true;
+
+ // converter
+
+ static const convertMimeType = MimeTypes.jpeg;
+ static const convertQuality = 95;
+ static const convertWriteMetadata = true;
+
+ // rendering
+ static const imageBackground = EntryBackground.white;
+
+ // search
+ static const saveSearchHistory = true;
+
+ // bin
+ static const enableBin = true;
+
+ // accessibility
+ static const showPinchGestureAlternatives = false;
+ static const accessibilityAnimations = AccessibilityAnimations.system;
+ static const timeToTakeAction = AccessibilityTimeout.s3;
+
+ // slideshow
+ static const slideshowRepeat = false;
+ static const slideshowShuffle = false;
+ static const slideshowFillScreen = false;
+ static const slideshowAnimatedZoomEffect = true;
+ static const slideshowTransition = ViewerTransition.fade;
+ static const slideshowVideoPlayback = SlideshowVideoPlayback.playMuted;
+ static const slideshowInterval = 5;
+
+ // widget
+ static const widgetOutline = false;
+ static const widgetShape = WidgetShape.rrect;
+ static const widgetOpenPage = WidgetOpenPage.viewer;
+ static const widgetDisplayedItem = WidgetDisplayedItem.random;
+
+ // platform settings
+ static const isRotationLocked = false;
+ static const areAnimationsRemoved = false;
+}
diff --git a/lib/model/settings/enums/accessibility_animations.dart b/lib/model/settings/enums/accessibility_animations.dart
new file mode 100644
index 0000000..25f9e0f
--- /dev/null
+++ b/lib/model/settings/enums/accessibility_animations.dart
@@ -0,0 +1,32 @@
+import 'package:aves/model/settings/settings.dart';
+import 'package:aves/theme/durations.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:flutter/widgets.dart';
+
+extension ExtraAccessibilityAnimations on AccessibilityAnimations {
+ bool get animate {
+ switch (this) {
+ case AccessibilityAnimations.system:
+ // as of Flutter v2.5.1, the check for `disableAnimations` is unreliable
+ // so we cannot use `window.accessibilityFeatures.disableAnimations` nor `MediaQuery.of(context).disableAnimations`
+ return !settings.areAnimationsRemoved;
+ case AccessibilityAnimations.disabled:
+ return false;
+ case AccessibilityAnimations.enabled:
+ return true;
+ }
+ }
+
+ Duration get popUpAnimationDuration => animate ? ADurations.popupMenuAnimation : Duration.zero;
+
+ Duration get popUpAnimationDelay => popUpAnimationDuration + const Duration(milliseconds: ADurations.transitionMarginMillis);
+
+ AnimationStyle get popUpAnimationStyle {
+ return animate
+ ? AnimationStyle(
+ curve: Curves.easeInOutCubic,
+ duration: popUpAnimationDuration,
+ )
+ : AnimationStyle.noAnimation;
+ }
+}
diff --git a/lib/model/settings/enums/accessibility_timeout.dart b/lib/model/settings/enums/accessibility_timeout.dart
new file mode 100644
index 0000000..dddd22b
--- /dev/null
+++ b/lib/model/settings/enums/accessibility_timeout.dart
@@ -0,0 +1,26 @@
+import 'package:aves/services/accessibility_service.dart';
+import 'package:aves/theme/durations.dart';
+import 'package:aves_model/aves_model.dart';
+
+extension ExtraAccessibilityTimeout on AccessibilityTimeout {
+ Future<Duration> getSnackBarDuration(bool hasAction) async {
+ switch (this) {
+ case AccessibilityTimeout.system:
+ if (hasAction) {
+ return Duration(milliseconds: await (AccessibilityService.getRecommendedTimeToTakeAction(ADurations.opToastActionDisplay)));
+ } else {
+ return Duration(milliseconds: await (AccessibilityService.getRecommendedTimeToRead(ADurations.opToastTextDisplay)));
+ }
+ case AccessibilityTimeout.s1:
+ return const Duration(seconds: 1);
+ case AccessibilityTimeout.s3:
+ return const Duration(seconds: 3);
+ case AccessibilityTimeout.s5:
+ return const Duration(seconds: 5);
+ case AccessibilityTimeout.s10:
+ return const Duration(seconds: 10);
+ case AccessibilityTimeout.s30:
+ return const Duration(seconds: 30);
+ }
+ }
+}
diff --git a/lib/model/settings/enums/coordinate_format.dart b/lib/model/settings/enums/coordinate_format.dart
new file mode 100644
index 0000000..2572bac
--- /dev/null
+++ b/lib/model/settings/enums/coordinate_format.dart
@@ -0,0 +1,95 @@
+import 'package:aves/l10n/l10n.dart';
+import 'package:aves/widgets/common/extensions/build_context.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:flutter/widgets.dart';
+import 'package:intl/intl.dart';
+import 'package:latlong2/latlong.dart';
+
+extension ExtraCoordinateFormat on CoordinateFormat {
+ static const _separator = ', ';
+
+ String format(BuildContext context, LatLng latLng, {bool minuteSecondPadding = false, int? dmsSecondDecimals}) {
+ final text = formatWithoutDirectionality(context.l10n, latLng, minuteSecondPadding: minuteSecondPadding, dmsSecondDecimals: dmsSecondDecimals);
+ return context.applyDirectionality(text);
+ }
+
+ String formatWithoutDirectionality(AppLocalizations l10n, LatLng latLng, {bool minuteSecondPadding = false, int? dmsSecondDecimals}) {
+ switch (this) {
+ case CoordinateFormat.dms:
+ return toDMS(l10n, latLng, minuteSecondPadding: minuteSecondPadding, secondDecimals: dmsSecondDecimals ?? 2).join(_separator);
+ case CoordinateFormat.ddm:
+ return toDDM(l10n, latLng, minutePadding: minuteSecondPadding, minuteDecimals: dmsSecondDecimals ?? 4).join(_separator);
+ case CoordinateFormat.decimal:
+ return _toDecimal(l10n, latLng).join(_separator);
+ }
+ }
+
+ // returns coordinates formatted as DMS, e.g. ['41° 24′ 12.2″ N', '2° 10′ 26.5″ E']
+ static List<String> toDMS(AppLocalizations l10n, LatLng latLng, {bool minuteSecondPadding = false, int secondDecimals = 2}) {
+ final locale = l10n.localeName;
+ final lat = latLng.latitude;
+ final lng = latLng.longitude;
+ final latSexa = _decimal2sexagesimal(lat, minuteSecondPadding, secondDecimals, locale);
+ final lngSexa = _decimal2sexagesimal(lng, minuteSecondPadding, secondDecimals, locale);
+ return [
+ l10n.coordinateDms(latSexa, lat < 0 ? l10n.coordinateDmsSouth : l10n.coordinateDmsNorth),
+ l10n.coordinateDms(lngSexa, lng < 0 ? l10n.coordinateDmsWest : l10n.coordinateDmsEast),
+ ];
+ }
+
+ // returns coordinates formatted as DDM, e.g. ['41° 24.2028′ N', '2° 10.4418′ E']
+ static List<String> toDDM(AppLocalizations l10n, LatLng latLng, {bool minutePadding = false, int minuteDecimals = 4}) {
+ final locale = l10n.localeName;
+ final lat = latLng.latitude;
+ final lng = latLng.longitude;
+ final latSexa = _decimal2ddm(lat, minutePadding, minuteDecimals, locale);
+ final lngSexa = _decimal2ddm(lng, minutePadding, minuteDecimals, locale);
+ return [
+ l10n.coordinateDms(latSexa, lat < 0 ? l10n.coordinateDmsSouth : l10n.coordinateDmsNorth),
+ l10n.coordinateDms(lngSexa, lng < 0 ? l10n.coordinateDmsWest : l10n.coordinateDmsEast),
+ ];
+ }
+
+ static String _decimal2sexagesimal(
+ double degDecimal,
+ bool minuteSecondPadding,
+ int secondDecimals,
+ String locale,
+ ) {
+ final degAbs = degDecimal.abs();
+ final deg = degAbs.toInt();
+ final minDecimal = (degAbs - deg) * 60;
+ final min = minDecimal.toInt();
+ final sec = (minDecimal - min) * 60;
+
+ final degText = NumberFormat('0', locale).format(deg);
+ final minText = NumberFormat('0' * (minuteSecondPadding ? 2 : 1), locale).format(min);
+ final secText = NumberFormat('${'0' * (minuteSecondPadding ? 2 : 1)}${secondDecimals > 0 ? '.${'0' * secondDecimals}' : ''}', locale).format(sec);
+
+ return '$degText° $minText′ $secText″';
+ }
+
+ static String _decimal2ddm(
+ double degDecimal,
+ bool minutePadding,
+ int minuteDecimals,
+ String locale,
+ ) {
+ final degAbs = degDecimal.abs();
+ final deg = degAbs.toInt();
+ final min = (degAbs - deg) * 60;
+
+ final degText = NumberFormat('0', locale).format(deg);
+ final minText = NumberFormat('${'0' * (minutePadding ? 2 : 1)}${minuteDecimals > 0 ? '.${'0' * minuteDecimals}' : ''}', locale).format(min);
+
+ return '$degText° $minText′';
+ }
+
+ static List<String> _toDecimal(AppLocalizations l10n, LatLng latLng) {
+ final coordinateFormatter = NumberFormat('0.000000°', l10n.localeName);
+ return [
+ coordinateFormatter.format(latLng.latitude),
+ coordinateFormatter.format(latLng.longitude),
+ ];
+ }
+}
diff --git a/lib/model/settings/enums/display_refresh_rate_mode.dart b/lib/model/settings/enums/display_refresh_rate_mode.dart
new file mode 100644
index 0000000..32d1cd2
--- /dev/null
+++ b/lib/model/settings/enums/display_refresh_rate_mode.dart
@@ -0,0 +1,24 @@
+import 'package:aves/services/common/services.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:device_info_plus/device_info_plus.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter_displaymode/flutter_displaymode.dart';
+
+extension ExtraDisplayRefreshRateMode on DisplayRefreshRateMode {
+ Future<void> apply() async {
+ if (!await windowService.isActivity()) return;
+
+ final androidInfo = await DeviceInfoPlugin().androidInfo;
+ if (androidInfo.version.sdkInt < 23) return;
+
+ debugPrint('Apply display refresh rate: $name');
+ switch (this) {
+ case DisplayRefreshRateMode.auto:
+ await FlutterDisplayMode.setPreferredMode(DisplayMode.auto);
+ case DisplayRefreshRateMode.highest:
+ await FlutterDisplayMode.setHighRefreshRate();
+ case DisplayRefreshRateMode.lowest:
+ await FlutterDisplayMode.setLowRefreshRate();
+ }
+ }
+}
diff --git a/lib/model/settings/enums/entry_background.dart b/lib/model/settings/enums/entry_background.dart
new file mode 100644
index 0000000..9661c4d
--- /dev/null
+++ b/lib/model/settings/enums/entry_background.dart
@@ -0,0 +1,25 @@
+import 'dart:ui';
+
+import 'package:aves_model/aves_model.dart';
+
+extension ExtraEntryBackground on EntryBackground {
+ bool get isColor {
+ switch (this) {
+ case EntryBackground.black:
+ case EntryBackground.white:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ Color get color {
+ switch (this) {
+ case EntryBackground.white:
+ return const Color(0xFFFFFFFF);
+ case EntryBackground.black:
+ default:
+ return const Color(0xFF000000);
+ }
+ }
+}
diff --git a/lib/model/settings/enums/screen_on.dart b/lib/model/settings/enums/screen_on.dart
new file mode 100644
index 0000000..2d6e63b
--- /dev/null
+++ b/lib/model/settings/enums/screen_on.dart
@@ -0,0 +1,8 @@
+import 'package:aves/services/common/services.dart';
+import 'package:aves_model/aves_model.dart';
+
+extension ExtraKeepScreenOn on KeepScreenOn {
+ void apply() {
+ windowService.keepScreenOn(this == KeepScreenOn.always);
+ }
+}
diff --git a/lib/model/settings/enums/subtitle_position.dart b/lib/model/settings/enums/subtitle_position.dart
new file mode 100644
index 0000000..a37ad72
--- /dev/null
+++ b/lib/model/settings/enums/subtitle_position.dart
@@ -0,0 +1,13 @@
+import 'package:aves_model/aves_model.dart';
+import 'package:flutter/painting.dart';
+
+extension ExtraSubtitlePosition on SubtitlePosition {
+ TextAlignVertical toTextAlignVertical() {
+ switch (this) {
+ case SubtitlePosition.top:
+ return TextAlignVertical.top;
+ case SubtitlePosition.bottom:
+ return TextAlignVertical.bottom;
+ }
+ }
+}
diff --git a/lib/model/settings/enums/theme_brightness.dart b/lib/model/settings/enums/theme_brightness.dart
new file mode 100644
index 0000000..5bcbd75
--- /dev/null
+++ b/lib/model/settings/enums/theme_brightness.dart
@@ -0,0 +1,16 @@
+import 'package:aves_model/aves_model.dart';
+import 'package:flutter/material.dart';
+
+extension ExtraAvesThemeBrightness on AvesThemeBrightness {
+ ThemeMode get appThemeMode {
+ switch (this) {
+ case AvesThemeBrightness.system:
+ return ThemeMode.system;
+ case AvesThemeBrightness.light:
+ return ThemeMode.light;
+ case AvesThemeBrightness.dark:
+ case AvesThemeBrightness.black:
+ return ThemeMode.dark;
+ }
+ }
+}
diff --git a/lib/model/settings/enums/viewer_transition.dart b/lib/model/settings/enums/viewer_transition.dart
new file mode 100644
index 0000000..b9c0cc0
--- /dev/null
+++ b/lib/model/settings/enums/viewer_transition.dart
@@ -0,0 +1,63 @@
+import 'dart:math';
+
+import 'package:aves/widgets/viewer/controls/transitions.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:collection/collection.dart';
+import 'package:flutter/widgets.dart';
+
+extension ExtraViewerTransition on ViewerTransition {
+ TransitionBuilder builder(PageController pageController, int index) {
+ switch (this) {
+ case ViewerTransition.slide:
+ return PageTransitionEffects.slide(pageController, index, parallax: false);
+ case ViewerTransition.parallax:
+ return PageTransitionEffects.slide(pageController, index, parallax: true);
+ case ViewerTransition.fade:
+ return PageTransitionEffects.fade(pageController, index, zoomIn: false);
+ case ViewerTransition.zoomIn:
+ return PageTransitionEffects.fade(pageController, index, zoomIn: true);
+ case ViewerTransition.none:
+ return PageTransitionEffects.none(pageController, index);
+ case ViewerTransition.random:
+ return _ViewerTransitionRandomizer.getBuilder(pageController, index);
+ }
+ }
+}
+
+class _ViewerTransitionRandomizer {
+ static const options = [
+ ViewerTransition.slide,
+ ViewerTransition.parallax,
+ ViewerTransition.fade,
+ ViewerTransition.zoomIn,
+ ];
+
+ static final List<(int, ViewerTransition)> _indexedTransitions = [];
+
+ static TransitionBuilder getBuilder(
+ PageController pageController,
+ int index,
+ ) =>
+ (context, child) {
+ final negative = pageController.hasClients && pageController.position.haveDimensions && (pageController.page! - index).isNegative;
+ final transition = _getTransition(negative ? index - 1 : index);
+ final builder = transition.builder(pageController, index);
+ return builder(context, child);
+ };
+
+ static ViewerTransition _getTransition(int transitionIndex) {
+ var indexedTransition = _indexedTransitions.firstWhereOrNull((v) => v.$1 == transitionIndex);
+ if (indexedTransition != null) {
+ _indexedTransitions.remove(indexedTransition);
+ } else {
+ indexedTransition = (transitionIndex, options[Random().nextInt(options.length)]);
+ }
+ _indexedTransitions.insert(0, indexedTransition);
+ while (_indexedTransitions.length > 3) {
+ _indexedTransitions.removeLast();
+ }
+
+ final (_, transition) = indexedTransition;
+ return transition;
+ }
+}
diff --git a/lib/model/settings/enums/widget_outline.dart b/lib/model/settings/enums/widget_outline.dart
new file mode 100644
index 0000000..660d66d
--- /dev/null
+++ b/lib/model/settings/enums/widget_outline.dart
@@ -0,0 +1,33 @@
+import 'package:aves_model/aves_model.dart';
+import 'package:dynamic_color/dynamic_color.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+
+extension ExtraWidgetOutline on WidgetOutline {
+ Future<Color?> color(Brightness brightness) async {
+ switch (this) {
+ case WidgetOutline.none:
+ return SynchronousFuture(null);
+ case WidgetOutline.black:
+ return SynchronousFuture(Colors.black);
+ case WidgetOutline.white:
+ return SynchronousFuture(Colors.white);
+ case WidgetOutline.systemBlackAndWhite:
+ return SynchronousFuture(brightness == Brightness.dark ? Colors.black : Colors.white);
+ case WidgetOutline.systemBlackAndWhiteHighContrast:
+ return SynchronousFuture(brightness == Brightness.dark ? Colors.white : Colors.black);
+ case WidgetOutline.systemDynamicLowContrast:
+ final color = await _getDynamicColor(brightness == Brightness.dark ? Brightness.light : Brightness.dark);
+ return color ?? await WidgetOutline.systemBlackAndWhite.color(brightness);
+ case WidgetOutline.systemDynamic:
+ final color = await _getDynamicColor(brightness);
+ return color ?? await WidgetOutline.systemBlackAndWhiteHighContrast.color(brightness);
+ }
+ }
+
+ Future<Color?> _getDynamicColor(Brightness brightness) async {
+ final corePalette = await DynamicColorPlugin.getCorePalette();
+ final scheme = corePalette?.toColorScheme(brightness: brightness);
+ return scheme?.primary;
+ }
+}
diff --git a/lib/model/settings/enums/widget_shape.dart b/lib/model/settings/enums/widget_shape.dart
new file mode 100644
index 0000000..5a7b88f
--- /dev/null
+++ b/lib/model/settings/enums/widget_shape.dart
@@ -0,0 +1,199 @@
+import 'dart:math';
+
+import 'package:aves/model/entry/entry.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:flutter/painting.dart';
+
+extension ExtraWidgetShape on WidgetShape {
+ static const double _defaultCornerRadius = 24;
+
+ Path path(Size widgetSize, double devicePixelRatio, {double? cornerRadiusPx}) {
+ final rect = Offset.zero & widgetSize;
+ switch (this) {
+ case WidgetShape.bumpyColumns:
+ return _buildBumpyColumnsPath(rect);
+ case WidgetShape.bumpyRows:
+ return _buildBumpyRowsPath(rect);
+ case WidgetShape.circle:
+ return Path()
+ ..addOval(Rect.fromCircle(
+ center: rect.center,
+ radius: rect.shortestSide / 2,
+ ));
+ case WidgetShape.concaveSquare:
+ return _buildConcaveSquarePath(rect);
+ case WidgetShape.heart:
+ return _buildHeartPath(rect);
+ case WidgetShape.rrect:
+ return Path()..addRRect(BorderRadius.circular(cornerRadiusPx ?? (_defaultCornerRadius * devicePixelRatio)).toRRect(rect));
+ case WidgetShape.tearRectLeft:
+ final radius = cornerRadiusPx ?? (_defaultCornerRadius * devicePixelRatio);
+ return _buildTearRectPath(rect, topLeftRadiusPx: radius, topRightRadiusPx: radius * 2);
+ case WidgetShape.tearRectRight:
+ final radius = cornerRadiusPx ?? (_defaultCornerRadius * devicePixelRatio);
+ return _buildTearRectPath(rect, topLeftRadiusPx: radius * 2, topRightRadiusPx: radius);
+ case WidgetShape.wavyCircle16:
+ return _buildWavyCirclePath(rect, 16, .5);
+ }
+ }
+
+ Path _buildBumpyColumnsPath(Rect rect) {
+ final radius = rect.width / 4;
+ final topY = radius;
+ final bottomY = rect.height - radius;
+ const angleUnit = pi / 6;
+ return Path()
+ ..moveTo(0, topY)
+ ..arcTo(Rect.fromCircle(center: Offset(radius, topY), radius: radius), -6 * angleUnit, 4 * angleUnit, false)
+ ..arcTo(Rect.fromCircle(center: Offset(radius * 2, topY), radius: radius), -4 * angleUnit, 2 * angleUnit, false)
+ ..arcTo(Rect.fromCircle(center: Offset(radius * 3, topY), radius: radius), -4 * angleUnit, 4 * angleUnit, false)
+ ..lineTo(rect.width, bottomY)
+ ..arcTo(Rect.fromCircle(center: Offset(radius * 3, bottomY), radius: radius), 0, 4 * angleUnit, false)
+ ..arcTo(Rect.fromCircle(center: Offset(radius * 2, bottomY), radius: radius), 2 * angleUnit, 2 * angleUnit, false)
+ ..arcTo(Rect.fromCircle(center: Offset(radius, bottomY), radius: radius), 2 * angleUnit, 4 * angleUnit, false)
+ ..lineTo(0, topY);
+ }
+
+ Path _buildBumpyRowsPath(Rect rect) {
+ final radius = rect.height / 4;
+ final leftX = radius;
+ final rightX = rect.width - radius;
+ const angleUnit = pi / 6;
+ return Path()
+ ..moveTo(leftX, 0)
+ ..lineTo(rightX, 0)
+ ..arcTo(Rect.fromCircle(center: Offset(rightX, radius), radius: radius), -3 * angleUnit, 4 * angleUnit, false)
+ ..arcTo(Rect.fromCircle(center: Offset(rightX, radius * 2), radius: radius), -angleUnit, 2 * angleUnit, false)
+ ..arcTo(Rect.fromCircle(center: Offset(rightX, radius * 3), radius: radius), -angleUnit, 4 * angleUnit, false)
+ ..lineTo(leftX, rect.height)
+ ..arcTo(Rect.fromCircle(center: Offset(leftX, radius * 3), radius: radius), 3 * angleUnit, 4 * angleUnit, false)
+ ..arcTo(Rect.fromCircle(center: Offset(leftX, radius * 2), radius: radius), 5 * angleUnit, 2 * angleUnit, false)
+ ..arcTo(Rect.fromCircle(center: Offset(leftX, radius), radius: radius), 5 * angleUnit, 4 * angleUnit, false);
+ }
+
+ Path _buildConcaveSquarePath(Rect rect) {
+ final center = rect.center;
+ final dim = rect.shortestSide;
+ final radius = dim / 4;
+
+ final tl = center + Offset(-radius, -radius);
+ final tr = center + Offset(radius, -radius);
+ final br = center + Offset(radius, radius);
+ final bl = center + Offset(-radius, radius);
+
+ final outsideDim = radius * (1 + sqrt(3));
+ final left = center + Offset(-outsideDim, 0);
+ final top = center + Offset(0, -outsideDim);
+ final right = center + Offset(outsideDim, 0);
+ final bottom = center + Offset(0, outsideDim);
+
+ final tlTop = (tl + top) / 2;
+ final topTr = (top + tr) / 2;
+ final trRight = (tr + right) / 2;
+ final rightBr = (right + br) / 2;
+ final brBottom = (br + bottom) / 2;
+ final bottomBl = (bottom + bl) / 2;
+ final blLeft = (bl + left) / 2;
+ final leftTl = (left + tl) / 2;
+
+ final r = Radius.circular(radius);
+ return Path()
+ ..moveTo(tlTop.dx, tlTop.dy)
+ ..arcToPoint(topTr, radius: r, clockwise: false)
+ ..arcToPoint(trRight, radius: r)
+ ..arcToPoint(rightBr, radius: r, clockwise: false)
+ ..arcToPoint(brBottom, radius: r)
+ ..arcToPoint(bottomBl, radius: r, clockwise: false)
+ ..arcToPoint(blLeft, radius: r)
+ ..arcToPoint(leftTl, radius: r, clockwise: false)
+ ..arcToPoint(tlTop, radius: r);
+ }
+
+ Path _buildHeartPath(Rect rect) {
+ final center = rect.center;
+ final dim = rect.shortestSide;
+ const p0dy = -.4;
+ const p1dx = .5;
+ const p1dy = -.4;
+ const p2dx = .8;
+ const p2dy = .5;
+ const p3dy = .5 - p0dy;
+ return Path()
+ ..moveTo(center.dx, center.dy)
+ ..relativeMoveTo(0, dim * p0dy)
+ ..relativeCubicTo(dim * -p1dx, dim * p1dy, dim * -p2dx, dim * p2dy, 0, dim * p3dy)
+ ..moveTo(center.dx, center.dy)
+ ..relativeMoveTo(0, dim * p0dy)
+ ..relativeCubicTo(dim * p1dx, dim * p1dy, dim * p2dx, dim * p2dy, 0, dim * p3dy);
+ }
+
+ Path _buildTearRectPath(Rect rect, {required double topLeftRadiusPx, required double topRightRadiusPx}) {
+ final topLeftRadius = Radius.circular(topLeftRadiusPx);
+ final topRightRadius = Radius.circular(topRightRadiusPx);
+ return Path()
+ ..addRRect(BorderRadius.only(
+ topLeft: topLeftRadius,
+ topRight: topRightRadius,
+ bottomLeft: topRightRadius,
+ bottomRight: topLeftRadius,
+ ).toRRect(rect));
+ }
+
+ Path _buildWavyCirclePath(Rect rect, int bumpCount, double amplitudeFactor, {double angleOffset = 0}) {
+ final center = rect.center;
+ final dim = rect.shortestSide;
+
+ final waveAmplitude = amplitudeFactor / bumpCount;
+ final circleRadius = (dim / 2) * (1 - waveAmplitude);
+
+ final pointCount = (dim * dim).round();
+ final angleIncrement = 2 * pi / pointCount;
+ final points = List.generate(pointCount, (i) {
+ final t = angleIncrement * i;
+ final r = cos((t + angleOffset) * bumpCount) * waveAmplitude + 1;
+ final dx = r * cos(t) * circleRadius;
+ final dy = r * sin(t) * circleRadius;
+ return Offset(center.dx + dx, center.dy + dy);
+ });
+ final origin = points.first;
+
+ final path = Path()..moveTo(origin.dx, origin.dy);
+ for (var i = 0; i <= pointCount; i++) {
+ final p = points[i % pointCount];
+ path.lineTo(p.dx, p.dy);
+ }
+ return path;
+ }
+
+ double extentPx(Size widgetSizePx, AvesEntry entry) {
+ switch (this) {
+ case WidgetShape.bumpyColumns:
+ case WidgetShape.bumpyRows:
+ case WidgetShape.rrect:
+ case WidgetShape.tearRectLeft:
+ case WidgetShape.tearRectRight:
+ final entryRatio = entry.displayAspectRatio;
+ final widgetRatio = widgetSizePx.width / widgetSizePx.height;
+ if (entryRatio > 1) {
+ // landscape entry, must return thumbnail height as extent
+ if (widgetRatio > entryRatio) {
+ return widgetSizePx.width / entryRatio;
+ } else {
+ return widgetSizePx.height;
+ }
+ } else {
+ // portrait entry, must return thumbnail width as extent
+ if (widgetRatio > entryRatio) {
+ return widgetSizePx.width;
+ } else {
+ return widgetSizePx.height * entryRatio;
+ }
+ }
+ case WidgetShape.circle:
+ case WidgetShape.heart:
+ case WidgetShape.wavyCircle16:
+ case WidgetShape.concaveSquare:
+ return widgetSizePx.shortestSide;
+ }
+ }
+}
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);
+}
diff --git a/lib/model/settings/settings.dart b/lib/model/settings/settings.dart
new file mode 100644
index 0000000..4e0bd1b
--- /dev/null
+++ b/lib/model/settings/settings.dart
@@ -0,0 +1,490 @@
+import 'dart:async';
+import 'dart:convert';
+import 'dart:math';
+
+import 'package:aves/app_flavor.dart';
+import 'package:aves/model/device.dart';
+import 'package:aves/model/dynamic_albums.dart';
+import 'package:aves/model/filters/favourite.dart';
+import 'package:aves/model/filters/mime.dart';
+import 'package:aves/model/grouping/common.dart';
+import 'package:aves/model/settings/defaults.dart';
+import 'package:aves/model/settings/enums/accessibility_animations.dart';
+import 'package:aves/model/settings/modules/app.dart';
+import 'package:aves/model/settings/modules/collection.dart';
+import 'package:aves/model/settings/modules/debug.dart';
+import 'package:aves/model/settings/modules/display.dart';
+import 'package:aves/model/settings/modules/filter_grids.dart';
+import 'package:aves/model/settings/modules/info.dart';
+import 'package:aves/model/settings/modules/navigation.dart';
+import 'package:aves/model/settings/modules/privacy.dart';
+import 'package:aves/model/settings/modules/screen_saver.dart';
+import 'package:aves/model/settings/modules/search.dart';
+import 'package:aves/model/settings/modules/slideshow.dart';
+import 'package:aves/model/settings/modules/viewer.dart';
+import 'package:aves/model/settings/modules/widget.dart';
+import 'package:aves/ref/bursts.dart';
+import 'package:aves/services/accessibility_service.dart';
+import 'package:aves/services/common/services.dart';
+import 'package:aves/widgets/common/search/page.dart';
+import 'package:aves/widgets/filter_grids/albums_page.dart';
+import 'package:aves/widgets/filter_grids/countries_page.dart';
+import 'package:aves/widgets/filter_grids/places_page.dart';
+import 'package:aves/widgets/filter_grids/tags_page.dart';
+import 'package:aves_map/aves_map.dart';
+import 'package:aves_model/aves_model.dart';
+import 'package:aves_utils/aves_utils.dart';
+import 'package:aves_video/aves_video.dart';
+import 'package:collection/collection.dart';
+import 'package:device_info_plus/device_info_plus.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/gestures.dart';
+import 'package:flutter/services.dart';
+import 'package:latlong2/latlong.dart';
+
+final Settings settings = Settings._private();
+
+class Settings with ChangeNotifier, SettingsAccess, SearchSettings, AppSettings, CollectionSettings, DebugSettings, DisplaySettings, FilterGridsSettings, InfoSettings, NavigationSettings, PrivacySettings, ScreenSaverSettings, SlideshowSettings, SubtitlesSettings, VideoSettings, ViewerSettings, WidgetSettings {
+ final Set<StreamSubscription> _subscriptions = {};
+ final EventChannel _platformSettingsChangeChannel = const OptionalEventChannel('deckers.thibault/aves/settings_change');
+ final StreamController<SettingsChangedEvent> _updateStreamController = StreamController.broadcast();
+ final StreamController<SettingsChangedEvent> _updateTileExtentStreamController = StreamController.broadcast();
+
+ @override
+ Stream<SettingsChangedEvent> get updateStream => _updateStreamController.stream;
+
+ Stream<SettingsChangedEvent> get updateTileExtentStream => _updateTileExtentStreamController.stream;
+
+ @override
+ bool get initialized => store.initialized;
+
+ @override
+ SettingsStore get store => settingsStore;
+
+ Settings._private() {
+ if (kFlutterMemoryAllocationsEnabled) ChangeNotifier.maybeDispatchObjectCreation(this);
+ }
+
+ Future<void> init({required bool monitorPlatformSettings}) async {
+ await store.init();
+ resetAppliedLocale();
+ _unregister();
+ _register(monitorPlatformSettings);
+ initAppSettings();
+ }
+
+ void _unregister() {
+ albumGrouping.removeListener(saveAlbumGroups);
+ tagGrouping.removeListener(saveTagGroups);
+ _subscriptions
+ ..forEach((sub) => sub.cancel())
+ ..clear();
+ }
+
+ void _register(bool monitorPlatformSettings) {
+ albumGrouping.addListener(saveAlbumGroups);
+ tagGrouping.addListener(saveTagGroups);
+ _subscriptions.add(dynamicAlbums.eventBus.on<DynamicAlbumChangedEvent>().listen((e) {
+ final changes = e.changes;
+ updateBookmarkedDynamicAlbums(changes);
+ updatePinnedDynamicAlbums(changes);
+ }));
+ _subscriptions.add(albumGrouping.eventBus.on<GroupUriChangedEvent>().listen(_onGroupingChange));
+ _subscriptions.add(tagGrouping.eventBus.on<GroupUriChangedEvent>().listen(_onGroupingChange));
+ if (monitorPlatformSettings) {
+ _subscriptions.add(_platformSettingsChangeChannel.receiveBroadcastStream().listen((event) => _onPlatformSettingsChanged(event as Map?)));
+ }
+ }
+
+ void _onGroupingChange(GroupUriChangedEvent event) {
+ final oldGroupUri = event.oldGroupUri;
+ final newGroupUri = event.newGroupUri;
+ updateBookmarkedGroup(oldGroupUri, newGroupUri);
+ updatePinnedGroup(oldGroupUri, newGroupUri);
+ }
+
+ Future<void> reload() => store.reload();
+
+ Future<void> reset({required bool includeInternalKeys}) async {
+ if (includeInternalKeys) {
+ await store.clear();
+ } else {
+ await Future.forEach<String>(store.getKeys().whereNot(SettingKeys.isInternalKey), store.remove);
+ }
+ }
+
+ Future<void> setContextualDefaults(AppFlavor flavor) async {
+ // performance
+ final performanceClass = await deviceService.getPerformanceClass();
+ enableBlurEffect = performanceClass >= 29;
+
+ final androidInfo = await DeviceInfoPlugin().androidInfo;
+ final manufacturer = androidInfo.manufacturer.toLowerCase();
+ final pattern = BurstPatterns.byManufacturer[manufacturer];
+ collectionBurstPatterns = pattern != null ? [pattern] : [];
+
+ // availability
+ if (flavor.hasMapStyleDefault) {
+ final defaultMapStyle = mobileServices.defaultMapStyle;
+ if (defaultMapStyle != null && mobileServices.mapStyles.contains(defaultMapStyle)) {
+ mapStyle = defaultMapStyle;
+ } else {
+ final styles = EntryMapStyles.baseStyles;
+ mapStyle = styles[Random().nextInt(styles.length)];
+ }
+ }
+
+ if (settings.useTvLayout) {
+ applyTvSettings();
+ }
+ }
+
+ void applyTvSettings() {
+ themeBrightness = AvesThemeBrightness.dark;
+ maxBrightness = MaxBrightness.never;
+ mustBackTwiceToExit = false;
+ // address `TV-BU` / `TV-BY` requirements from https://developer.android.com/docs/quality-guidelines/tv-app-quality
+ keepScreenOn = KeepScreenOn.videoPlayback;
+ drawerTypeBookmarks = [
+ null,
+ MimeFilter.video,
+ FavouriteFilter.instance,
+ ];
+ drawerPageBookmarks = [
+ AlbumListPage.routeName,
+ CountryListPage.routeName,
+ PlaceListPage.routeName,
+ TagListPage.routeName,
+ SearchPage.routeName,
+ ];
+ bottomNavigationActions = [];
+ showOverlayOnOpening = false;
+ showOverlayMinimap = false;
+ showOverlayZoomLevel = false;
+ showOverlayThumbnailPreview = false;
+ viewerGestureSideTapNext = false;
+ viewerUseCutout = true;
+ videoBackgroundMode = VideoBackgroundMode.disabled;
+ videoControlActions = [];
+ videoGestureDoubleTapTogglePlay = false;
+ videoGestureSideDoubleTapSeek = false;
+ enableBin = false;
+ showPinchGestureAlternatives = true;
+ resetShowTitleQuery();
+ }
+
+ Future<void> sanitize() async {
+ if (timeToTakeAction == AccessibilityTimeout.system && !await AccessibilityService.hasRecommendedTimeouts()) {
+ set(SettingKeys.timeToTakeActionKey, null);
+ }
+ if (viewerUseCutout != SettingsDefaults.viewerUseCutout && !await windowService.isCutoutAware()) {
+ set(SettingKeys.viewerUseCutoutKey, null);
+ }
+ if (videoBackgroundMode == VideoBackgroundMode.pip && !device.supportPictureInPicture) {
+ set(SettingKeys.videoBackgroundModeKey, null);
+ }
+ collectionBurstPatterns = collectionBurstPatterns.where(BurstPatterns.options.contains).toList();
+ }
+
+ // tag editor
+
+ bool get tagEditorCurrentFilterSectionExpanded => getBool(SettingKeys.tagEditorCurrentFilterSectionExpandedKey) ?? SettingsDefaults.tagEditorCurrentFilterSectionExpanded;
+
+ set tagEditorCurrentFilterSectionExpanded(bool newValue) => set(SettingKeys.tagEditorCurrentFilterSectionExpandedKey, newValue);
+
+ String? get tagEditorExpandedSection => getString(SettingKeys.tagEditorExpandedSectionKey);
+
+ set tagEditorExpandedSection(String? newValue) => set(SettingKeys.tagEditorExpandedSectionKey, newValue);
+
+ // converter
+
+ String get convertMimeType => getString(SettingKeys.convertMimeTypeKey) ?? SettingsDefaults.convertMimeType;
+
+ set convertMimeType(String newValue) => set(SettingKeys.convertMimeTypeKey, newValue);
+
+ int get convertQuality => getInt(SettingKeys.convertQualityKey) ?? SettingsDefaults.convertQuality;
+
+ set convertQuality(int newValue) => set(SettingKeys.convertQualityKey, newValue);
+
+ bool get convertWriteMetadata => getBool(SettingKeys.convertWriteMetadataKey) ?? SettingsDefaults.convertWriteMetadata;
+
+ set convertWriteMetadata(bool newValue) => set(SettingKeys.convertWriteMetadataKey, newValue);
+
+ // map
+
+ EntryMapStyle? get mapStyle {
+ var preferred = getString(SettingKeys.mapStyleKey);
+
+ // backward compatibility with definition as enum
+ const oldEnumPrefix = 'EntryMapStyle.';
+ if (preferred != null && preferred.startsWith(oldEnumPrefix)) {
+ preferred = preferred.substring(oldEnumPrefix.length);
+ if (preferred.isEmpty) preferred = null;
+ }
+
+ if (preferred == null) return null;
+
+ final styles = [...availability.mapStyles, ...customMapStyles];
+ return styles.firstWhereOrNull((v) => v.key == preferred) ?? styles.first;
+ }
+
+ set mapStyle(EntryMapStyle? newValue) => set(SettingKeys.mapStyleKey, newValue?.key);
+
+ LatLng? get mapDefaultCenter {
+ final json = getString(SettingKeys.mapDefaultCenterKey);
+ return json != null ? LatLng.fromJson(jsonDecode(json)) : null;
+ }
+
+ set mapDefaultCenter(LatLng? newValue) => set(SettingKeys.mapDefaultCenterKey, newValue != null ? jsonEncode(newValue.toJson()) : null);
+
+ Set<EntryMapStyle> get customMapStyles => (getStringList(SettingKeys.customMapStylesKey) ?? []).map(EntryMapStyle.fromJson).nonNulls.toSet();
+
+ set customMapStyles(Set<EntryMapStyle> newValue) => set(SettingKeys.customMapStylesKey, newValue.map((filter) => filter.toJson()).toList());
+
+ // bin
+
+ bool get enableBin => getBool(SettingKeys.enableBinKey) ?? SettingsDefaults.enableBin;
+
+ set enableBin(bool newValue) => set(SettingKeys.enableBinKey, newValue);
+
+ // accessibility
+
+ bool get showPinchGestureAlternatives => getBool(SettingKeys.showPinchGestureAlternativesKey) ?? SettingsDefaults.showPinchGestureAlternatives;
+
+ set showPinchGestureAlternatives(bool newValue) => set(SettingKeys.showPinchGestureAlternativesKey, newValue);
+
+ AccessibilityAnimations get accessibilityAnimations => getEnumOrDefault(SettingKeys.accessibilityAnimationsKey, SettingsDefaults.accessibilityAnimations, AccessibilityAnimations.values);
+
+ bool get animate => accessibilityAnimations.animate;
+
+ set accessibilityAnimations(AccessibilityAnimations newValue) => set(SettingKeys.accessibilityAnimationsKey, newValue.toString());
+
+ AccessibilityTimeout get timeToTakeAction => getEnumOrDefault(SettingKeys.timeToTakeActionKey, SettingsDefaults.timeToTakeAction, AccessibilityTimeout.values);
+
+ set timeToTakeAction(AccessibilityTimeout newValue) => set(SettingKeys.timeToTakeActionKey, newValue.toString());
+
+ // platform settings
+
+ void _onPlatformSettingsChanged(Map? fields) {
+ fields?.forEach((key, value) {
+ switch (key) {
+ case SettingKeys.platformAccelerometerRotationKey:
+ if (value is num) {
+ isRotationLocked = value == 0;
+ }
+ case SettingKeys.platformTransitionAnimationScaleKey:
+ if (value is num) {
+ areAnimationsRemoved = value == 0;
+ }
+ case SettingKeys.platformLongPressTimeoutMillisKey:
+ if (value is num) {
+ longPressTimeoutMillis = value.toInt();
+ }
+ }
+ });
+ }
+
+ bool get isRotationLocked => getBool(SettingKeys.platformAccelerometerRotationKey) ?? SettingsDefaults.isRotationLocked;
+
+ set isRotationLocked(bool newValue) => set(SettingKeys.platformAccelerometerRotationKey, newValue);
+
+ bool get areAnimationsRemoved => getBool(SettingKeys.platformTransitionAnimationScaleKey) ?? SettingsDefaults.areAnimationsRemoved;
+
+ set areAnimationsRemoved(bool newValue) => set(SettingKeys.platformTransitionAnimationScaleKey, newValue);
+
+ Duration get longPressTimeout => Duration(milliseconds: getInt(SettingKeys.platformLongPressTimeoutMillisKey) ?? kLongPressTimeout.inMilliseconds);
+
+ set longPressTimeoutMillis(int newValue) => set(SettingKeys.platformLongPressTimeoutMillisKey, newValue);
+
+ // import/export
+
+ Map<String, dynamic> export() => Map.fromEntries(
+ store.getKeys().whereNot(SettingKeys.isInternalKey).map((k) => MapEntry(k, store.get(k))),
+ );
+
+ Future<void> import(dynamic jsonMap) async {
+ if (jsonMap is Map<String, dynamic>) {
+ // clear to restore defaults
+ await reset(includeInternalKeys: false);
+
+ // apply user modifications
+ jsonMap.forEach((key, newValue) {
+ final oldValue = store.get(key);
+
+ if (newValue == null) {
+ store.remove(key);
+ } else if (key.startsWith(SettingKeys.tileExtentPrefixKey)) {
+ if (newValue is double) {
+ store.setDouble(key, newValue);
+ } else {
+ debugPrint('failed to import key=$key, value=$newValue is not a double');
+ }
+ } else if (key.startsWith(SettingKeys.tileLayoutPrefixKey)) {
+ if (newValue is String) {
+ store.setString(key, newValue);
+ } else {
+ debugPrint('failed to import key=$key, value=$newValue is not a string');
+ }
+ } else if (key.startsWith(SettingKeys.showTitleQueryPrefixKey)) {
+ if (newValue is bool) {
+ store.setBool(key, newValue);
+ } else {
+ debugPrint('failed to import key=$key, value=$newValue is not a bool');
+ }
+ } else {
+ switch (key) {
+ case SettingKeys.convertQualityKey:
+ case SettingKeys.screenSaverIntervalKey:
+ case SettingKeys.slideshowIntervalKey:
+ if (newValue is int) {
+ store.setInt(key, newValue);
+ } else {
+ debugPrint('failed to import key=$key, value=$newValue is not an int');
+ }
+ case SettingKeys.subtitleFontSizeKey:
+ case SettingKeys.infoMapZoomKey:
+ if (newValue is double) {
+ store.setDouble(key, newValue);
+ } else {
+ debugPrint('failed to import key=$key, value=$newValue is not a double');
+ }
+ case SettingKeys.isInstalledAppAccessAllowedKey:
+ case SettingKeys.isErrorReportingAllowedKey:
+ case SettingKeys.forceWesternArabicNumeralsKey:
+ case SettingKeys.enableDynamicColorKey:
+ case SettingKeys.enableBlurEffectKey:
+ case SettingKeys.mustBackTwiceToExitKey:
+ case SettingKeys.confirmCreateVaultKey:
+ case SettingKeys.confirmDeleteForeverKey:
+ case SettingKeys.confirmMoveToBinKey:
+ case SettingKeys.confirmMoveUndatedItemsKey:
+ case SettingKeys.confirmAfterMoveToBinKey:
+ case SettingKeys.setMetadataDateBeforeFileOpKey:
+ case SettingKeys.collectionSortReverseKey:
+ case SettingKeys.showThumbnailFavouriteKey:
+ case SettingKeys.showThumbnailHdrKey:
+ case SettingKeys.showThumbnailMotionPhotoKey:
+ case SettingKeys.showThumbnailRatingKey:
+ case SettingKeys.showThumbnailRawKey:
+ case SettingKeys.showThumbnailVideoDurationKey:
+ case SettingKeys.albumSortReverseKey:
+ case SettingKeys.countrySortReverseKey:
+ case SettingKeys.stateSortReverseKey:
+ case SettingKeys.placeSortReverseKey:
+ case SettingKeys.tagSortReverseKey:
+ case SettingKeys.showOverlayOnOpeningKey:
+ case SettingKeys.showOverlayMinimapKey:
+ case SettingKeys.showOverlayZoomLevelKey:
+ case SettingKeys.showOverlayInfoKey:
+ case SettingKeys.showOverlayDescriptionKey:
+ case SettingKeys.showOverlayRatingTagsKey:
+ case SettingKeys.showOverlayShootingDetailsKey:
+ case SettingKeys.showOverlayThumbnailPreviewKey:
+ case SettingKeys.viewerGestureSideTapNextKey:
+ case SettingKeys.viewerUseCutoutKey:
+ case SettingKeys.enableMotionPhotoAutoPlayKey:
+ case SettingKeys.enableVideoHardwareAccelerationKey:
+ case SettingKeys.videoGestureDoubleTapTogglePlayKey:
+ case SettingKeys.videoGestureSideDoubleTapSeekKey:
+ case SettingKeys.videoGestureVerticalDragBrightnessVolumeKey:
+ case SettingKeys.subtitleShowOutlineKey:
+ case SettingKeys.tagEditorCurrentFilterSectionExpandedKey:
+ case SettingKeys.convertWriteMetadataKey:
+ case SettingKeys.saveSearchHistoryKey:
+ case SettingKeys.showPinchGestureAlternativesKey:
+ case SettingKeys.screenSaverFillScreenKey:
+ case SettingKeys.screenSaverAnimatedZoomEffectKey:
+ case SettingKeys.slideshowRepeatKey:
+ case SettingKeys.slideshowShuffleKey:
+ case SettingKeys.slideshowFillScreenKey:
+ case SettingKeys.slideshowAnimatedZoomEffectKey:
+ if (newValue is bool) {
+ store.setBool(key, newValue);
+ } else {
+ debugPrint('failed to import key=$key, value=$newValue is not a bool');
+ }
+ case SettingKeys.localeKey:
+ case SettingKeys.displayRefreshRateModeKey:
+ case SettingKeys.themeBrightnessKey:
+ case SettingKeys.themeColorModeKey:
+ case SettingKeys.maxBrightnessKey:
+ case SettingKeys.keepScreenOnKey:
+ case SettingKeys.homePageKey:
+ case SettingKeys.homeCustomExplorerPathKey:
+ case SettingKeys.collectionGroupFactorKey:
+ case SettingKeys.collectionSortFactorKey:
+ case SettingKeys.thumbnailLocationIconKey:
+ case SettingKeys.thumbnailTagIconKey:
+ case SettingKeys.albumSectionFactorKey:
+ case SettingKeys.albumSortFactorKey:
+ case SettingKeys.countrySortFactorKey:
+ case SettingKeys.stateSortFactorKey:
+ case SettingKeys.placeSortFactorKey:
+ case SettingKeys.tagSortFactorKey:
+ case SettingKeys.albumGroupsKey:
+ case SettingKeys.tagGroupsKey:
+ case SettingKeys.imageBackgroundKey:
+ case SettingKeys.videoAutoPlayModeKey:
+ case SettingKeys.videoBackgroundModeKey:
+ case SettingKeys.videoLoopModeKey:
+ case SettingKeys.videoResumptionModeKey:
+ case SettingKeys.subtitleTextAlignmentKey:
+ case SettingKeys.subtitleTextPositionKey:
+ case SettingKeys.subtitleTextColorKey:
+ case SettingKeys.subtitleBackgroundColorKey:
+ case SettingKeys.tagEditorExpandedSectionKey:
+ case SettingKeys.convertMimeTypeKey:
+ case SettingKeys.mapStyleKey:
+ case SettingKeys.mapDefaultCenterKey:
+ case SettingKeys.coordinateFormatKey:
+ case SettingKeys.unitSystemKey:
+ case SettingKeys.accessibilityAnimationsKey:
+ case SettingKeys.timeToTakeActionKey:
+ case SettingKeys.screenSaverTransitionKey:
+ case SettingKeys.screenSaverVideoPlaybackKey:
+ case SettingKeys.slideshowTransitionKey:
+ case SettingKeys.slideshowVideoPlaybackKey:
+ if (newValue is String) {
+ store.setString(key, newValue);
+ } else {
+ debugPrint('failed to import key=$key, value=$newValue is not a string');
+ }
+ case SettingKeys.customMapStylesKey:
+ case SettingKeys.homeCustomCollectionKey:
+ case SettingKeys.drawerTypeBookmarksKey:
+ case SettingKeys.drawerAlbumBookmarksKey:
+ case SettingKeys.drawerPageBookmarksKey:
+ case SettingKeys.bottomNavigationActionsKey:
+ case SettingKeys.collectionBurstPatternsKey:
+ case SettingKeys.pinnedFiltersKey:
+ case SettingKeys.hiddenFiltersKey:
+ case SettingKeys.deactivatedHiddenFiltersKey:
+ case SettingKeys.collectionBrowsingQuickActionsKey:
+ case SettingKeys.collectionSelectionQuickActionsKey:
+ case SettingKeys.viewerQuickActionsKey:
+ case SettingKeys.videoControlActionsKey:
+ case SettingKeys.screenSaverCollectionFiltersKey:
+ if (newValue is List) {
+ store.setStringList(key, newValue.cast<String>());
+ } else {
+ debugPrint('failed to import key=$key, value=$newValue is not a list');
+ }
+ }
+ }
+ if (oldValue != newValue) {
+ notifyKeyChange(key, oldValue, newValue);
+ }
+ });
+ await sanitize();
+ notifyListeners();
+ }
+ }
+
+ @override
+ void notifyKeyChange(String key, dynamic oldValue, dynamic newValue) {
+ _updateStreamController.add(SettingsChangedEvent(key, oldValue, newValue));
+ if (key.startsWith(SettingKeys.tileExtentPrefixKey)) {
+ _updateTileExtentStreamController.add(SettingsChangedEvent(key, oldValue, newValue));
+ }
+ }
+}
diff --git a/lib/model/settings/store_shared_pref.dart b/lib/model/settings/store_shared_pref.dart
new file mode 100644
index 0000000..6547d8c
--- /dev/null
+++ b/lib/model/settings/store_shared_pref.dart
@@ -0,0 +1,68 @@
+import 'package:aves_model/aves_model.dart';
+import 'package:flutter/foundation.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+class SharedPrefSettingsStore implements SettingsStore {
+ static SharedPreferences? _prefs;
+
+ @override
+ bool get initialized => _prefs != null;
+
+ @override
+ Future<void> init() async {
+ try {
+ _prefs = await SharedPreferences.getInstance();
+ } catch (error, stack) {
+ debugPrint('$runtimeType init error=$error\n$stack');
+ }
+ }
+
+ @override
+ Future<void> reload() => _prefs!.reload();
+
+ @override
+ Future<bool> clear() => _prefs!.clear();
+
+ @override
+ Future<bool> remove(String key) => _prefs!.remove(key);
+
+ // get
+
+ @override
+ Set<String> getKeys() => _prefs!.getKeys();
+
+ @override
+ Object? get(String key) => _prefs!.get(key);
+
+ @override
+ bool? getBool(String key) => _prefs!.getBool(key);
+
+ @override
+ int? getInt(String key) => _prefs!.getInt(key);
+
+ @override
+ double? getDouble(String key) => _prefs!.getDouble(key);
+
+ @override
+ String? getString(String key) => _prefs!.getString(key);
+
+ @override
+ List<String>? getStringList(String key) => _prefs!.getStringList(key);
+
+ // set
+
+ @override
+ Future<bool> setBool(String key, bool value) => _prefs!.setBool(key, value);
+
+ @override
+ Future<bool> setInt(String key, int value) => _prefs!.setInt(key, value);
+
+ @override
+ Future<bool> setDouble(String key, double value) => _prefs!.setDouble(key, value);
+
+ @override
+ Future<bool> setString(String key, String value) => _prefs!.setString(key, value);
+
+ @override
+ Future<bool> setStringList(String key, List<String> value) => _prefs!.setStringList(key, value);
+}