Files
yattee/Yattee/Views/Settings/YouTubeEnhancementsSettingsView.swift
Arkadiusz Fal 4b245ec176 Improve tvOS settings layout: use navigation instead of sheets, fix focus clipping
- Replace sheets with navigationDestination for Add/Edit Source on tvOS
  (tvOS sheets have fixed size that doesn't fit the content)
- Fix focused cell clipping by replacing TVSettingsContainer's frame-based
  layout with safeAreaInset, matching the main settings view pattern
- Use standard List with .listStyle(.grouped) for Sources on tvOS
- Add sidebar icons and titles to TVSettingsContainer for all settings
  subviews, utilizing the left column space
- Remove redundant large navigation titles on tvOS (shown in sidebar)
- Move Edit Source Save button from toolbar into form above Delete button
  for better tvOS focus navigation
2026-04-18 20:38:01 +02:00

111 lines
3.3 KiB
Swift

//
// YouTubeEnhancementsSettingsView.swift
// Yattee
//
// Settings view for YouTube-specific enhancements.
//
import SwiftUI
struct YouTubeEnhancementsSettingsView: View {
@Environment(\.appEnvironment) private var appEnvironment
var body: some View {
Form {
if let settings = appEnvironment?.settingsManager {
SponsorBlockSection(settings: settings)
ReturnYouTubeDislikeSection(settings: settings)
DeArrowSection(settings: settings)
}
}
#if !os(tvOS)
.navigationTitle(String(localized: "settings.youtubeEnhancements.title"))
#endif
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
}
}
// MARK: - SponsorBlock Section
private struct SponsorBlockSection: View {
@Bindable var settings: SettingsManager
var body: some View {
Section {
NavigationLink {
SponsorBlockSettingsView()
} label: {
HStack {
Label(String(localized: "settings.sponsorBlock.sectionTitle"), systemImage: "forward")
Spacer()
Text(settings.sponsorBlockEnabled
? String(localized: "common.enabled")
: String(localized: "common.disabled"))
.foregroundStyle(.secondary)
}
}
} footer: {
Text(String(localized: "settings.youtubeEnhancements.sponsorBlock.footer"))
}
}
}
// MARK: - Return YouTube Dislike Section
private struct ReturnYouTubeDislikeSection: View {
@Bindable var settings: SettingsManager
var body: some View {
Section {
NavigationLink {
ReturnYouTubeDislikeSettingsView()
} label: {
HStack {
Label(String(localized: "settings.returnYouTubeDislike.sectionTitle"), systemImage: "hand.thumbsdown")
Spacer()
Text(settings.returnYouTubeDislikeEnabled
? String(localized: "common.enabled")
: String(localized: "common.disabled"))
.foregroundStyle(.secondary)
}
}
} footer: {
Text(String(localized: "settings.youtubeEnhancements.returnYouTubeDislike.footer"))
}
}
}
// MARK: - DeArrow Section
private struct DeArrowSection: View {
@Bindable var settings: SettingsManager
var body: some View {
Section {
NavigationLink {
DeArrowSettingsView()
} label: {
HStack {
Label(String(localized: "settings.deArrow.sectionTitle"), systemImage: "textformat")
Spacer()
Text(settings.deArrowEnabled
? String(localized: "common.enabled")
: String(localized: "common.disabled"))
.foregroundStyle(.secondary)
}
}
} footer: {
Text(String(localized: "settings.youtubeEnhancements.deArrow.footer"))
}
}
}
#Preview {
NavigationStack {
YouTubeEnhancementsSettingsView()
}
.appEnvironment(.preview)
}