Files
yattee/Yattee/Views/Components/TVSidebarDetailContainer.swift
Arkadiusz Fal 39beb45cff Make tvOS detail dismiss button opt-in and unstick more views
TVSidebarDetailContainer now exposes a showsDismissButton flag instead of
always attaching a Done toolbar item. The button is only enabled where a
view can end up with no focusable element on its own — Device
Capabilities (informational rows) and the Import Playlists/Subscriptions
flows.

Wrap Contributors, Translators, Acknowledgements, and Device Capabilities
destinations in TVSidebarDetailContainer for the consistent sidebar look,
and make the Translators/Acknowledgements rows focusable on tvOS by
wrapping them in Buttons so the Menu remote button can pop the stack.
2026-05-06 22:41:46 +02:00

71 lines
2.1 KiB
Swift

//
// 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?
var showsDismissButton: Bool
@Environment(\.dismiss) private var dismiss
init(
systemImage: String? = nil,
title: String? = nil,
showsDismissButton: Bool = false,
@ViewBuilder content: () -> Content
) {
self.content = content()
self.systemImage = systemImage
self.title = title
self.showsDismissButton = showsDismissButton
}
var body: some View {
content
.focusSection()
.safeAreaInset(edge: .leading) {
if let systemImage {
VStack(spacing: 16) {
Image(systemName: systemImage)
.font(.system(size: 80))
.foregroundStyle(.secondary)
if let title {
Text(title)
.font(.title3)
.fontWeight(.semibold)
.foregroundStyle(.secondary)
.multilineTextAlignment(.center)
}
}
.allowsHitTesting(false)
.frame(width: 400)
} else {
Spacer()
.frame(width: 400)
.allowsHitTesting(false)
}
}
.toolbar {
if showsDismissButton {
ToolbarItem(placement: .cancellationAction) {
Button {
dismiss()
} label: {
Label(String(localized: "common.done"), systemImage: "chevron.backward")
}
}
}
}
}
}
#endif