mirror of
https://github.com/yattee/yattee.git
synced 2026-05-13 10:55:03 +00:00
Surfaces Continue Watching, Recent Feed, and Recent Bookmarks in the
Apple TV Home top shelf when Yattee is focused. Tapping a tile opens
the video via the existing yattee://video/{id} deep link.
- New YatteeTopShelf app extension target (tvOS only). LD_ENTRY_POINT is
overridden to _NSExtensionMain; the tv-app-extension product type
defaults to _TVExtensionMain which is for the pre-tvOS-13 legacy API
and crashes modern TVTopShelfContentProvider subclasses at launch.
- Main app writes per-section JSON snapshots (capped at 10 items each)
to a shared App Group UserDefaults suite after bookmark, watch-history,
and feed-cache changes, plus an initial write on launch.
- Enabled-sections list is mirrored to the same App Group so the
extension can respect the user's selection without touching SwiftData.
- Settings → Top Shelf (tvOS only) lets the user toggle sections.
- Deep link playback shows a loading toast while video details are
fetched, and an error toast if no source is configured.
53 lines
1.8 KiB
Swift
53 lines
1.8 KiB
Swift
//
|
|
// TopShelfSettingsView.swift
|
|
// Yattee
|
|
//
|
|
// tvOS-only Top Shelf configuration.
|
|
//
|
|
|
|
#if os(tvOS)
|
|
import SwiftUI
|
|
|
|
struct TopShelfSettingsView: View {
|
|
@Environment(\.appEnvironment) private var appEnvironment
|
|
|
|
var body: some View {
|
|
Form {
|
|
if let settings = appEnvironment?.settingsManager {
|
|
Section {
|
|
ForEach(TopShelfSection.allCases) { section in
|
|
Toggle(section.localizedTitle, isOn: binding(for: section, settings: settings))
|
|
}
|
|
} header: {
|
|
Text(String(localized: "settings.topShelf.sections.header", defaultValue: "Sections"))
|
|
} footer: {
|
|
Text(String(
|
|
localized: "settings.topShelf.sections.footer",
|
|
defaultValue: "Enabled sections appear in the Apple TV Home top shelf when Yattee is focused."
|
|
))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private func binding(for section: TopShelfSection, settings: SettingsManager) -> Binding<Bool> {
|
|
Binding(
|
|
get: { settings.topShelfSections.contains(section) },
|
|
set: { enabled in
|
|
var sections = settings.topShelfSections
|
|
if enabled {
|
|
if !sections.contains(section) {
|
|
let defaultIndex = TopShelfSection.defaultOrder.firstIndex(of: section) ?? sections.endIndex
|
|
let insertAt = min(defaultIndex, sections.count)
|
|
sections.insert(section, at: insertAt)
|
|
}
|
|
} else {
|
|
sections.removeAll { $0 == section }
|
|
}
|
|
settings.topShelfSections = sections
|
|
}
|
|
)
|
|
}
|
|
}
|
|
#endif
|