Extract TVSidebarDetailContainer to its own file

Now used by multiple tvOS tabs beyond Settings, so move it out of
SettingsView.swift into Views/Components/ where reusable view primitives
live.
This commit is contained in:
Arkadiusz Fal
2026-04-16 07:30:07 +02:00
parent 68ab994798
commit 65724ae201
2 changed files with 51 additions and 44 deletions

View File

@@ -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<Content: View>: 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

View File

@@ -384,50 +384,6 @@ enum SettingsSection: String, CaseIterable, Identifiable {
}
}
// MARK: - tvOS Sidebar Detail Container
#if os(tvOS)
struct TVSidebarDetailContainer<Content: View>: 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)