mirror of
https://github.com/yattee/yattee.git
synced 2026-05-12 18:35:05 +00:00
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:
51
Yattee/Views/Components/TVSidebarDetailContainer.swift
Normal file
51
Yattee/Views/Components/TVSidebarDetailContainer.swift
Normal 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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user