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>
81 lines
3.0 KiB
Swift
81 lines
3.0 KiB
Swift
import SwiftUI
|
|
|
|
/// Top-5 stat leaderboard card with player headshots
|
|
struct LeaderboardView: View {
|
|
let category: LeaderCategory
|
|
|
|
var body: some View {
|
|
DataPanel(.standard) {
|
|
VStack(alignment: .leading, spacing: 10) {
|
|
Text(category.name.uppercased())
|
|
.dataLabelStyle()
|
|
|
|
ForEach(category.leaders) { leader in
|
|
leaderRow(leader)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@ViewBuilder
|
|
private func leaderRow(_ leader: LeagueLeader) -> some View {
|
|
HStack(spacing: 10) {
|
|
Text("\(leader.rank)")
|
|
.font(rankFont)
|
|
.foregroundStyle(leader.rank <= 3 ? DS.Colors.textPrimary : DS.Colors.textTertiary)
|
|
.frame(width: rankWidth, alignment: .center)
|
|
|
|
// Player headshot
|
|
if let personId = leader.personId {
|
|
AsyncImage(url: URL(string: "https://img.mlbstatic.com/mlb-photos/image/upload/w_80,q_auto:best/v1/people/\(personId)/headshot/67/current")) { phase in
|
|
if let image = phase.image {
|
|
image.resizable().aspectRatio(contentMode: .fill)
|
|
} else {
|
|
Circle().fill(DS.Colors.panelFill)
|
|
}
|
|
}
|
|
.frame(width: headshotSize, height: headshotSize)
|
|
.clipShape(Circle())
|
|
}
|
|
|
|
VStack(alignment: .leading, spacing: 1) {
|
|
Text(leader.playerName)
|
|
.font(nameFont)
|
|
.foregroundStyle(DS.Colors.textPrimary)
|
|
.lineLimit(1)
|
|
|
|
if !leader.teamCode.isEmpty {
|
|
HStack(spacing: 3) {
|
|
RoundedRectangle(cornerRadius: 1)
|
|
.fill(TeamAssets.color(for: leader.teamCode))
|
|
.frame(width: 2, height: 10)
|
|
Text(leader.teamCode)
|
|
.font(DS.Fonts.caption)
|
|
.foregroundStyle(DS.Colors.textTertiary)
|
|
}
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
|
|
Text(leader.value)
|
|
.font(valueFont)
|
|
.foregroundStyle(leader.rank == 1 ? DS.Colors.interactive : DS.Colors.textPrimary)
|
|
}
|
|
}
|
|
|
|
#if os(tvOS)
|
|
private var rankWidth: CGFloat { 28 }
|
|
private var headshotSize: CGFloat { 36 }
|
|
private var rankFont: Font { .system(size: 16, weight: .bold, design: .rounded).monospacedDigit() }
|
|
private var nameFont: Font { .system(size: 17, weight: .semibold) }
|
|
private var valueFont: Font { DS.Fonts.tvDataValue }
|
|
#else
|
|
private var rankWidth: CGFloat { 22 }
|
|
private var headshotSize: CGFloat { 28 }
|
|
private var rankFont: Font { .system(size: 13, weight: .bold, design: .rounded).monospacedDigit() }
|
|
private var nameFont: Font { .system(size: 14, weight: .semibold) }
|
|
private var valueFont: Font { DS.Fonts.dataValue }
|
|
#endif
|
|
}
|