mirror of
https://github.com/yattee/yattee.git
synced 2026-06-04 13:54:19 +00:00
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.
71 lines
2.1 KiB
Swift
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
|