Files
yattee/Yattee/Core/Settings/SettingsKey.swift
Arkadiusz Fal b632f11b2f Add separate light/dark mode accent colors
Adds an option in Appearance settings to use different accent colors
in light and dark mode, with a toggle to keep a single shared color
(the default, preserving existing behavior).

- New synced settings keys: accentColorDark, customAccentColorDark,
  useSeparateDarkAccentColor; dark values fall back to the light
  selection until explicitly set, so no migration is needed
- resolvedAccentColor returns a dynamic platform color (UIColor trait
  provider / NSColor appearance provider) when the toggle is on, so
  the root tint and all direct readers adapt to light/dark
  automatically without consumer changes
- Accent Color section shows two stacked preset+custom grids with
  Light/Dark headers when enabled, extracted into AccentColorGrid;
  CustomAccentColorButton now takes bindings so the macOS color panel
  edits whichever target was last opened
- New DarkAccentColorTests covering sync contract, default-off state,
  fallbacks, and toggle-off resolution

Claude-Session: https://claude.ai/code/session_0154KH8RAVAvm6iVanhmoW8o
2026-07-05 21:06:26 +02:00

187 lines
6.0 KiB
Swift

//
// SettingsKey.swift
// Yattee
//
// Keys used for storing settings in UserDefaults and iCloud.
//
import Foundation
/// Keys for storing settings values.
/// Used internally by SettingsManager for persistence.
enum SettingsKey: String, CaseIterable {
// General
case theme
case accentColor
case customAccentColor
case accentColorDark
case customAccentColorDark
case useSeparateDarkAccentColor
case showWatchedCheckmark
// Playback
case preferredQuality
case cellularQuality
case autoplay
case backgroundPlayback
case preferredAudioLanguage
case preferredSubtitlesLanguage
case resumeAction
case tvOSMenuButtonClosesVideo
case allowSoftwareDecodedFormats
// SponsorBlock
case sponsorBlockEnabled
case sponsorBlockCategories
case sponsorBlockAPIURL
// Return YouTube Dislike
case returnYouTubeDislikeEnabled
// DeArrow
case deArrowEnabled
case deArrowReplaceTitles
case deArrowReplaceThumbnails
case deArrowAPIURL
case deArrowThumbnailAPIURL
// Short link resolution
case resolveShortLinksEnabled
// Platform-specific
case macPlayerSeparateWindow
case macPlayerFloating
case macControlsBarOffsetX // Normalized X offset of macOS control bar from default position
case macControlsBarOffsetY // Normalized Y offset of macOS control bar from default position
case playerSheetAutoResize
case listStyle
// Feed
case feedCacheValidityMinutes
// Player
case keepPlayerPinned
case hapticFeedbackEnabled
case hapticFeedbackIntensity
case inAppOrientationLock
case rotateToMatchAspectRatio
case preferPortraitBrowsing
// Home
case homeShortcutOrder
case homeShortcutVisibility
case homeShortcutLayout
case homeShortcutCardStyle
case homeShortcutCardColor
case homeShortcutColorfulPalette
case homeShortcutCustomPaletteColors
case homeSectionOrder
case homeSectionVisibility
case homeSectionItemsLimit
case homeSectionLayout
// Top Shelf (tvOS)
case topShelfSections
// Tab Bar (compact size class)
case tabBarItemOrder
case tabBarItemVisibility
case tabBarStartupTab
// Sidebar
case sidebarMainItemOrder
case sidebarMainItemVisibility
case sidebarStartupTab
case sidebarSourcesEnabled
case sidebarSourceSort
case sidebarSourcesLimitEnabled
case sidebarMaxSources
case sidebarChannelsEnabled
case sidebarMaxChannels
case sidebarChannelSort
case sidebarChannelsLimitEnabled
case sidebarPlaylistsEnabled
case sidebarMaxPlaylists
case sidebarPlaylistSort
case sidebarPlaylistsLimitEnabled
// Remote Control
case remoteControlCustomDeviceName
case remoteControlHideWhenBackgrounded
// Advanced
case showAdvancedStreamDetails
case showPlayerAreaDebug
case showTVDebugButton
case verboseMPVLogging
case verboseRemoteControlLogging
case mpvBufferSeconds
case mpvUseEDLStreams
case zoomTransitionsEnabled
case tvMatchDisplayFrameRate
case tvMatchDisplayDynamicRange
case tvAudioDelayMs
case tvVideoSyncMode
// Details panel
case floatingDetailsPanelSide // Landscape only - which side the panel appears on
case floatingDetailsPanelWidth // Resizable panel width in wide layout
case landscapeDetailsPanelVisible
case landscapeDetailsPanelPinned
// Player Controls
case activeControlsPresetID
// Video Swipe Actions
case videoSwipeActionOrder
case videoSwipeActionVisibility
// Onboarding
case onboardingCompleted
/// Whether this key should have platform-specific prefixes.
/// Platform-specific keys are stored under a `iOS.` / `macOS.` / `tvOS.` prefix
/// in both UserDefaults and iCloud, so each platform family syncs independently.
var isPlatformSpecific: Bool {
switch self {
case .preferredQuality, .cellularQuality, .allowSoftwareDecodedFormats,
.macPlayerSeparateWindow, .macPlayerFloating, .listStyle,
.macControlsBarOffsetX, .macControlsBarOffsetY,
// Home layout different UI paradigms per platform
.homeShortcutOrder, .homeShortcutVisibility, .homeShortcutLayout, .homeShortcutCardStyle,
.homeShortcutCardColor, .homeShortcutColorfulPalette, .homeShortcutCustomPaletteColors,
.homeSectionOrder, .homeSectionVisibility, .homeSectionItemsLimit, .homeSectionLayout,
// Top Shelf tvOS only
.topShelfSections,
// Tab bar (compact size class) layout
.tabBarItemOrder, .tabBarItemVisibility, .tabBarStartupTab,
// Sidebar layout/selection
.sidebarMainItemOrder, .sidebarMainItemVisibility, .sidebarStartupTab,
.sidebarSourcesEnabled, .sidebarSourceSort, .sidebarSourcesLimitEnabled, .sidebarMaxSources,
.sidebarChannelsEnabled, .sidebarMaxChannels, .sidebarChannelSort, .sidebarChannelsLimitEnabled,
.sidebarPlaylistsEnabled, .sidebarMaxPlaylists, .sidebarPlaylistSort, .sidebarPlaylistsLimitEnabled,
// Player details panel iOS/iPadOS only, different on other platforms
.floatingDetailsPanelSide, .floatingDetailsPanelWidth,
.landscapeDetailsPanelVisible, .landscapeDetailsPanelPinned,
// Video swipe actions touch-gesture feature
.videoSwipeActionOrder, .videoSwipeActionVisibility:
return true
default:
return false
}
}
/// Whether this key should only be stored locally (not synced to iCloud).
/// Used for device-specific settings like custom device name for remote control.
var isLocalOnly: Bool {
switch self {
case .remoteControlCustomDeviceName, .remoteControlHideWhenBackgrounded,
.activeControlsPresetID, // Per-device preset selection
.onboardingCompleted: // Per-device onboarding state
return true
default:
return false
}
}
}