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>
This commit is contained in:
112
mlbTVOS/Views/Components/FeedItemView.swift
Normal file
112
mlbTVOS/Views/Components/FeedItemView.swift
Normal file
@@ -0,0 +1,112 @@
|
||||
import SwiftUI
|
||||
|
||||
struct FeedItemView: View {
|
||||
let item: FeedItem
|
||||
|
||||
private var accentColor: Color {
|
||||
switch item.type {
|
||||
case .news: DS.Colors.interactive
|
||||
case .transaction: DS.Colors.positive
|
||||
case .scoring: DS.Colors.live
|
||||
}
|
||||
}
|
||||
|
||||
private var iconName: String {
|
||||
switch item.type {
|
||||
case .news: "newspaper.fill"
|
||||
case .transaction: "arrow.left.arrow.right"
|
||||
case .scoring: "sportscourt.fill"
|
||||
}
|
||||
}
|
||||
|
||||
private var typeLabel: String {
|
||||
switch item.type {
|
||||
case .news: "NEWS"
|
||||
case .transaction: "TRANSACTION"
|
||||
case .scoring: "SCORING"
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
// Colored edge bar
|
||||
RoundedRectangle(cornerRadius: 1.5)
|
||||
.fill(accentColor)
|
||||
.frame(width: 3)
|
||||
.padding(.vertical, 8)
|
||||
|
||||
HStack(spacing: 12) {
|
||||
Image(systemName: iconName)
|
||||
.font(.system(size: iconSize, weight: .semibold))
|
||||
.foregroundStyle(accentColor)
|
||||
.frame(width: iconFrame, height: iconFrame)
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
HStack(spacing: 8) {
|
||||
Text(typeLabel)
|
||||
.font(DS.Fonts.caption)
|
||||
.foregroundStyle(accentColor)
|
||||
.kerning(1)
|
||||
|
||||
if let code = item.teamCode {
|
||||
HStack(spacing: 4) {
|
||||
RoundedRectangle(cornerRadius: 1)
|
||||
.fill(TeamAssets.color(for: code))
|
||||
.frame(width: 2, height: 10)
|
||||
Text(code)
|
||||
.font(DS.Fonts.caption)
|
||||
.foregroundStyle(DS.Colors.textTertiary)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
Text(timeAgo(item.timestamp))
|
||||
.font(DS.Fonts.caption)
|
||||
.foregroundStyle(DS.Colors.textQuaternary)
|
||||
}
|
||||
|
||||
Text(item.title)
|
||||
.font(titleFont)
|
||||
.foregroundStyle(DS.Colors.textPrimary)
|
||||
.lineLimit(2)
|
||||
|
||||
if !item.subtitle.isEmpty {
|
||||
Text(item.subtitle)
|
||||
.font(subtitleFont)
|
||||
.foregroundStyle(DS.Colors.textTertiary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 14)
|
||||
.padding(.vertical, 12)
|
||||
}
|
||||
.background(DS.Colors.panelFill)
|
||||
.clipShape(RoundedRectangle(cornerRadius: DS.Radii.compact))
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: DS.Radii.compact)
|
||||
.strokeBorder(DS.Colors.panelStroke, lineWidth: 0.5)
|
||||
)
|
||||
}
|
||||
|
||||
private func timeAgo(_ date: Date) -> String {
|
||||
let interval = Date().timeIntervalSince(date)
|
||||
if interval < 60 { return "Just now" }
|
||||
if interval < 3600 { return "\(Int(interval / 60))m ago" }
|
||||
if interval < 86400 { return "\(Int(interval / 3600))h ago" }
|
||||
return "\(Int(interval / 86400))d ago"
|
||||
}
|
||||
|
||||
#if os(tvOS)
|
||||
private var iconSize: CGFloat { 18 }
|
||||
private var iconFrame: CGFloat { 36 }
|
||||
private var titleFont: Font { .system(size: 18, weight: .semibold) }
|
||||
private var subtitleFont: Font { DS.Fonts.bodySmall }
|
||||
#else
|
||||
private var iconSize: CGFloat { 14 }
|
||||
private var iconFrame: CGFloat { 28 }
|
||||
private var titleFont: Font { .system(size: 15, weight: .semibold) }
|
||||
private var subtitleFont: Font { .system(size: 12, weight: .medium) }
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user