Files
MLBApp/mlbIOS/Views/mlbIOSRootView.swift
Trey t b5daddefd3 Add UI redesign: design system, dashboard density, game intelligence, feed tab, league leaders
Phase 1 - Design System: DesignSystem.swift (typography, colors, spacing
constants) and DataPanel.swift (reusable panel container with 3 densities
and optional team accent bar).

Phase 2 - Dashboard Density: LiveSituationBar (compact strip of all live
games with scores/innings/outs), MiniLinescoreView (R-H-E footer for game
cards), DiamondView (visual baseball diamond with runners and count).
Dashboard shows live situation bar when games are active. Game cards now
display mini linescore for live/final games.

Phase 3 - Game Center Intelligence: WinProbabilityChartView (full-game
line chart using Swift Charts with area fills), PitchArsenalView (pitch
type distribution with velocity bars). GameCenterViewModel now stores
full WP history array instead of just latest values.

Phase 4 - Feed Tab: MLBWebDataService (fetches league leaders from Stats
API, news headlines, transactions), FeedViewModel, FeedView with
reverse-chronological feed items. FeedItemView with colored edge bars
by category. Added 5th "Feed" tab to both tvOS and iOS.

Phase 5 - Intel Tab: LeaderboardView (top-5 stat cards with headshots),
integrated into LeagueCenterView. Renamed tabs: Games->Today,
League->Intel. LeagueCenterViewModel now fetches league leaders.

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

115 lines
3.1 KiB
Swift

import SwiftUI
private enum mlbIOSSection: String, CaseIterable, Identifiable {
case games
case league
case multiView
case feed
case settings
var id: String { rawValue }
var title: String {
switch self {
case .games: "Today"
case .league: "Intel"
case .multiView: "Multi-View"
case .feed: "Feed"
case .settings: "Settings"
}
}
var systemImage: String {
switch self {
case .games: "sportscourt.fill"
case .league: "chart.bar.fill"
case .multiView: "rectangle.split.2x2.fill"
case .feed: "newspaper.fill"
case .settings: "gearshape.fill"
}
}
}
struct mlbIOSRootView: View {
@Environment(GamesViewModel.self) private var viewModel
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@State private var selectedSection: mlbIOSSection? = .games
private var usesCompactTabs: Bool {
horizontalSizeClass == .compact
}
private var multiViewTitle: String {
let count = viewModel.activeStreams.count
return count > 0 ? "Multi-View (\(count))" : "Multi-View"
}
var body: some View {
Group {
if usesCompactTabs {
compactTabs
} else {
splitView
}
}
.task {
if viewModel.games.isEmpty, !viewModel.isLoading {
await viewModel.loadGames()
}
}
}
private var compactTabs: some View {
TabView {
Tab("Today", systemImage: "sportscourt.fill") {
DashboardView()
}
Tab("Intel", systemImage: "chart.bar.fill") {
LeagueCenterView()
}
Tab(multiViewTitle, systemImage: "rectangle.split.2x2.fill") {
MultiStreamView()
}
Tab("Feed", systemImage: "newspaper.fill") {
FeedView()
}
Tab("Settings", systemImage: "gearshape.fill") {
SettingsView()
}
}
}
private var splitView: some View {
NavigationSplitView {
List(mlbIOSSection.allCases, selection: $selectedSection) { section in
Label(section.title, systemImage: section.systemImage)
.tag(section)
}
.navigationTitle("MLB")
} detail: {
NavigationStack {
detailView(for: selectedSection ?? .games)
.navigationTitle(selectedSection?.title ?? mlbIOSSection.games.title)
.navigationBarTitleDisplayMode(.inline)
}
}
.navigationSplitViewStyle(.balanced)
}
@ViewBuilder
private func detailView(for section: mlbIOSSection) -> some View {
switch section {
case .games:
DashboardView()
case .league:
LeagueCenterView()
case .multiView:
MultiStreamView()
case .feed:
FeedView()
case .settings:
SettingsView()
}
}
}