diff --git a/Yattee/Views/Components/TVSidebarDetailContainer.swift b/Yattee/Views/Components/TVSidebarDetailContainer.swift new file mode 100644 index 00000000..7c2b94d6 --- /dev/null +++ b/Yattee/Views/Components/TVSidebarDetailContainer.swift @@ -0,0 +1,51 @@ +// +// TVSidebarDetailContainer.swift +// Yattee +// +// Decorates a tvOS detail screen with a fixed 400pt left sidebar showing +// a large SF Symbol and a title, matching the look of tvOS settings. +// + +#if os(tvOS) +import SwiftUI + +struct TVSidebarDetailContainer: View { + let content: Content + var systemImage: String? + var title: String? + + init(systemImage: String? = nil, title: String? = nil, @ViewBuilder content: () -> Content) { + self.content = content() + self.systemImage = systemImage + self.title = title + } + + var body: some View { + content + .safeAreaInset(edge: .leading) { + if let systemImage { + VStack(spacing: 16) { + Spacer() + Image(systemName: systemImage) + .font(.system(size: 80)) + .foregroundStyle(.secondary) + if let title { + Text(title) + .font(.title3) + .fontWeight(.semibold) + .foregroundStyle(.secondary) + .multilineTextAlignment(.center) + } + Spacer() + } + .frame(width: 400) + .allowsHitTesting(false) + } else { + Spacer() + .frame(width: 400) + .allowsHitTesting(false) + } + } + } +} +#endif diff --git a/Yattee/Views/Settings/SettingsView.swift b/Yattee/Views/Settings/SettingsView.swift index 1dd2a8bd..1aec8bb7 100644 --- a/Yattee/Views/Settings/SettingsView.swift +++ b/Yattee/Views/Settings/SettingsView.swift @@ -384,50 +384,6 @@ enum SettingsSection: String, CaseIterable, Identifiable { } } -// MARK: - tvOS Sidebar Detail Container - -#if os(tvOS) -struct TVSidebarDetailContainer: View { - let content: Content - var systemImage: String? - var title: String? - - init(systemImage: String? = nil, title: String? = nil, @ViewBuilder content: () -> Content) { - self.content = content() - self.systemImage = systemImage - self.title = title - } - - var body: some View { - content - .safeAreaInset(edge: .leading) { - if let systemImage { - VStack(spacing: 16) { - Spacer() - Image(systemName: systemImage) - .font(.system(size: 80)) - .foregroundStyle(.secondary) - if let title { - Text(title) - .font(.title3) - .fontWeight(.semibold) - .foregroundStyle(.secondary) - .multilineTextAlignment(.center) - } - Spacer() - } - .frame(width: 400) - .allowsHitTesting(false) - } else { - Spacer() - .frame(width: 400) - .allowsHitTesting(false) - } - } - } -} -#endif - #Preview { SettingsView() .appEnvironment(.preview)