refactor: move options to mapconfig

This commit is contained in:
Yaros
2026-05-13 18:48:50 +02:00
parent d65226e325
commit 2382427488
3 changed files with 17 additions and 7 deletions
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:immich_mobile/utils/option.dart';
class MapConfig { class MapConfig {
final int relativeDays; final int relativeDays;
@@ -6,6 +7,8 @@ class MapConfig {
final bool includeArchived; final bool includeArchived;
final ThemeMode themeMode; final ThemeMode themeMode;
final bool withPartners; final bool withPartners;
final Option<DateTime> customFrom;
final Option<DateTime> customTo;
const MapConfig({ const MapConfig({
this.relativeDays = 0, this.relativeDays = 0,
@@ -13,6 +16,8 @@ class MapConfig {
this.includeArchived = false, this.includeArchived = false,
this.themeMode = ThemeMode.system, this.themeMode = ThemeMode.system,
this.withPartners = false, this.withPartners = false,
this.customFrom = const Option.none(),
this.customTo = const Option.none(),
}); });
MapConfig copyWith({ MapConfig copyWith({
@@ -21,12 +26,16 @@ class MapConfig {
bool? includeArchived, bool? includeArchived,
ThemeMode? themeMode, ThemeMode? themeMode,
bool? withPartners, bool? withPartners,
Option<DateTime>? customFrom,
Option<DateTime>? customTo,
}) => MapConfig( }) => MapConfig(
relativeDays: relativeDays ?? this.relativeDays, relativeDays: relativeDays ?? this.relativeDays,
favoritesOnly: favoritesOnly ?? this.favoritesOnly, favoritesOnly: favoritesOnly ?? this.favoritesOnly,
includeArchived: includeArchived ?? this.includeArchived, includeArchived: includeArchived ?? this.includeArchived,
themeMode: themeMode ?? this.themeMode, themeMode: themeMode ?? this.themeMode,
withPartners: withPartners ?? this.withPartners, withPartners: withPartners ?? this.withPartners,
customFrom: customFrom ?? this.customFrom,
customTo: customTo ?? this.customTo,
); );
@override @override
@@ -37,12 +46,15 @@ class MapConfig {
other.favoritesOnly == favoritesOnly && other.favoritesOnly == favoritesOnly &&
other.includeArchived == includeArchived && other.includeArchived == includeArchived &&
other.themeMode == themeMode && other.themeMode == themeMode &&
other.withPartners == withPartners); other.withPartners == withPartners &&
other.customFrom == customFrom &&
other.customTo == customTo);
@override @override
int get hashCode => Object.hash(relativeDays, favoritesOnly, includeArchived, themeMode, withPartners); int get hashCode =>
Object.hash(relativeDays, favoritesOnly, includeArchived, themeMode, withPartners, customFrom, customTo);
@override @override
String toString() => String toString() =>
'MapConfig(relativeDays: $relativeDays, favoritesOnly: $favoritesOnly, includeArchived: $includeArchived, themeMode: $themeMode, withPartners: $withPartners)'; 'MapConfig(relativeDays: $relativeDays, favoritesOnly: $favoritesOnly, includeArchived: $includeArchived, themeMode: $themeMode, withPartners: $withPartners, customFrom: $customFrom, customTo: $customTo)';
} }
@@ -50,6 +50,8 @@ enum MetadataKey<T extends Object> {
// Map // Map
mapShowFavoriteOnly<bool>(.appConfig, 'map.showFavoriteOnly', false), mapShowFavoriteOnly<bool>(.appConfig, 'map.showFavoriteOnly', false),
mapRelativeDate<int>(.appConfig, 'map.relativeDate', 0), mapRelativeDate<int>(.appConfig, 'map.relativeDate', 0),
mapCustomFrom<String>(.appConfig, 'map.customFrom', ''),
mapCustomTo<String>(.appConfig, 'map.customTo', ''),
mapIncludeArchived<bool>(.appConfig, 'map.includeArchived', false), mapIncludeArchived<bool>(.appConfig, 'map.includeArchived', false),
mapThemeMode<ThemeMode>(.appConfig, 'map.themeMode', .system, _EnumCodec(ThemeMode.values)), mapThemeMode<ThemeMode>(.appConfig, 'map.themeMode', .system, _EnumCodec(ThemeMode.values)),
mapWithPartners<bool>(.appConfig, 'map.withPartners', false), mapWithPartners<bool>(.appConfig, 'map.withPartners', false),
@@ -40,10 +40,6 @@ enum StoreKey<T> {
albumGridView<bool>._(140), albumGridView<bool>._(140),
loadOriginal<bool>._(101), loadOriginal<bool>._(101),
// Map custom time range settings
mapCustomFrom<String>._(142),
mapCustomTo<String>._(143),
// Experimental stuff // Experimental stuff
enableBackup<bool>._(1003), enableBackup<bool>._(1003),
useWifiForUploadVideos<bool>._(1004), useWifiForUploadVideos<bool>._(1004),