From 9b55ee712780961a5514828e64f5ed634eceed57 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Thu, 16 Apr 2026 04:26:48 +0200 Subject: [PATCH] Add tvOS setting for video click behavior --- .../Settings/SettingsManager+General.swift | 20 +++++++++++++ Yattee/Core/SettingsManager.swift | 8 +++++ Yattee/Localizable.xcstrings | 10 +++++++ .../Components/TappableVideoModifier.swift | 11 +++++++ .../LayoutNavigationSettingsView.swift | 30 ++++++++++++++++++- 5 files changed, 78 insertions(+), 1 deletion(-) diff --git a/Yattee/Core/Settings/SettingsManager+General.swift b/Yattee/Core/Settings/SettingsManager+General.swift index 5e43d5a3..ea62c21c 100644 --- a/Yattee/Core/Settings/SettingsManager+General.swift +++ b/Yattee/Core/Settings/SettingsManager+General.swift @@ -506,6 +506,26 @@ extension SettingsManager { } #endif + // MARK: - Video Tap Action (tvOS only) + + #if os(tvOS) + /// Action to perform when clicking a video cell on tvOS. Default is openInfo. + var tvOSVideoTapAction: VideoTapAction { + get { + if let cached = _tvOSVideoTapAction { return cached } + guard let rawValue = localDefaults.string(forKey: "tvOSVideoTapAction"), + let action = VideoTapAction(rawValue: rawValue) else { + return .openInfo + } + return action + } + set { + _tvOSVideoTapAction = newValue + localDefaults.set(newValue.rawValue, forKey: "tvOSVideoTapAction") + } + } + #endif + // MARK: - Onboarding /// Whether onboarding has been completed on this device. diff --git a/Yattee/Core/SettingsManager.swift b/Yattee/Core/SettingsManager.swift index 93b22044..043f26d7 100644 --- a/Yattee/Core/SettingsManager.swift +++ b/Yattee/Core/SettingsManager.swift @@ -190,6 +190,11 @@ final class SettingsManager { var _textAreaTapAction: VideoTapAction? #endif + // Video tap action (tvOS only) + #if os(tvOS) + var _tvOSVideoTapAction: VideoTapAction? + #endif + // Player Controls settings (controlsButtonSize moved to preset) // Appearance settings @@ -500,6 +505,9 @@ final class SettingsManager { _thumbnailTapAction = nil _textAreaTapAction = nil #endif + #if os(tvOS) + _tvOSVideoTapAction = nil + #endif _listStyle = nil #if os(iOS) _appIcon = nil diff --git a/Yattee/Localizable.xcstrings b/Yattee/Localizable.xcstrings index b76474a2..116fe4de 100644 --- a/Yattee/Localizable.xcstrings +++ b/Yattee/Localizable.xcstrings @@ -10256,6 +10256,16 @@ } } }, + "settings.behavior.tvOSVideoTapAction" : { + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "On Click" + } + } + } + }, "settings.behavior.videoTap.none" : { "localizations" : { "en" : { diff --git a/Yattee/Views/Components/TappableVideoModifier.swift b/Yattee/Views/Components/TappableVideoModifier.swift index 45510701..32aaabbc 100644 --- a/Yattee/Views/Components/TappableVideoModifier.swift +++ b/Yattee/Views/Components/TappableVideoModifier.swift @@ -58,7 +58,18 @@ struct TappableVideoModifier: ViewModifier { func body(content: Content) -> some View { Button { dismissKeyboard() + #if os(tvOS) + let tapAction = appEnvironment?.settingsManager.tvOSVideoTapAction ?? .openInfo + if tapAction == .openInfo { + appEnvironment?.navigationCoordinator.navigate( + to: .video(.loaded(video), queueContext: queueContext) + ) + } else { + checkPasswordAndPlay() + } + #else checkPasswordAndPlay() + #endif } label: { content .contentShape(Rectangle()) diff --git a/Yattee/Views/Settings/LayoutNavigationSettingsView.swift b/Yattee/Views/Settings/LayoutNavigationSettingsView.swift index 88f728cd..64bf120b 100644 --- a/Yattee/Views/Settings/LayoutNavigationSettingsView.swift +++ b/Yattee/Views/Settings/LayoutNavigationSettingsView.swift @@ -17,7 +17,9 @@ struct LayoutNavigationSettingsView: View { #if os(iOS) HapticsSection(settings: settings) #endif - #if !os(tvOS) + #if os(tvOS) + TVVideoActionsSection(settings: settings) + #else VideoActionsSection(settings: settings) LinkActionSection(settings: settings) ClipboardSection(settings: settings) @@ -190,6 +192,32 @@ private struct VideoActionsSection: View { } #endif +// MARK: - TV Video Actions Section + +#if os(tvOS) +private struct TVVideoActionsSection: View { + @Bindable var settings: SettingsManager + + var body: some View { + Section { + LabeledContent(String(localized: "settings.behavior.tvOSVideoTapAction")) { + Picker( + String(localized: "settings.behavior.tvOSVideoTapAction"), + selection: $settings.tvOSVideoTapAction + ) { + Text(VideoTapAction.openInfo.displayName).tag(VideoTapAction.openInfo) + Text(VideoTapAction.playVideo.displayName).tag(VideoTapAction.playVideo) + } + .pickerStyle(.menu) + .labelsHidden() + } + } header: { + Text(String(localized: "settings.videoActions.header")) + } + } +} +#endif + // MARK: - Mini Player Minimize Behavior Section (iOS 26+) #if os(iOS)