Files
MLBApp/mlbTVOS/Views/ContentView.swift
Trey t 7568a3b9d3 Fix tvOS focus navigation: add focusSection to all major UI sections
Focus couldn't move from DashboardView controls up to the
CategoryPillBar, or between sections within screens. Added
.platformFocusSection() to:

- ContentView: pill bar and content area as separate focus sections
- DashboardView: header, overview strip, hero+control section
- LeagueCenterView: schedule, standings, leaders, teams sections

This lets the tvOS Focus Engine navigate vertically between all
sections with d-pad up/down.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 17:05:17 -05:00

63 lines
1.9 KiB
Swift

import SwiftUI
struct ContentView: View {
@Environment(GamesViewModel.self) private var viewModel
@State private var selectedSection: AppSection = .today
private var showsTicker: Bool {
selectedSection != .multiView && !viewModel.games.isEmpty
}
var body: some View {
ZStack {
BroadcastBackground()
.ignoresSafeArea()
VStack(spacing: shellSpacing) {
CategoryPillBar(
selected: $selectedSection,
streamCount: viewModel.activeStreams.count,
totalGames: viewModel.games.count,
liveGames: viewModel.liveGames.count
)
.padding(.horizontal, DS.Spacing.edgeInset)
.padding(.top, navPadTop)
.platformFocusSection()
if showsTicker {
ScoresTickerView()
.padding(.horizontal, DS.Spacing.edgeInset)
}
Group {
switch selectedSection {
case .today:
DashboardView()
case .intel:
LeagueCenterView()
case .highlights:
FeedView()
case .multiView:
MultiStreamView()
case .settings:
SettingsView()
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.platformFocusSection()
}
}
.task {
await viewModel.loadGames()
}
}
#if os(tvOS)
private var navPadTop: CGFloat { 26 }
private var shellSpacing: CGFloat { 18 }
#else
private var navPadTop: CGFloat { 14 }
private var shellSpacing: CGFloat { 14 }
#endif
}