import SwiftUI /// Compact R-H-E display for game cards struct MiniLinescoreView: View { let linescore: StatsLinescore let awayCode: String let homeCode: String var body: some View { HStack(spacing: 0) { // Team abbreviations column VStack(alignment: .leading, spacing: 2) { Text(awayCode).foregroundStyle(TeamAssets.color(for: awayCode)) Text(homeCode).foregroundStyle(TeamAssets.color(for: homeCode)) } .font(statFont.weight(.bold)) .frame(width: teamColWidth, alignment: .leading) // R column statColumn("R", away: linescore.teams?.away?.runs, home: linescore.teams?.home?.runs, bold: true) // H column statColumn("H", away: linescore.teams?.away?.hits, home: linescore.teams?.home?.hits, bold: false) // E column statColumn("E", away: linescore.teams?.away?.errors, home: linescore.teams?.home?.errors, bold: false) } } @ViewBuilder private func statColumn(_ label: String, away: Int?, home: Int?, bold: Bool) -> some View { VStack(spacing: 2) { Text(label) .dataLabelStyle() Text(away.map { "\($0)" } ?? "-") .font(statFont.weight(bold ? .bold : .medium).monospacedDigit()) .foregroundStyle(bold ? DS.Colors.textPrimary : DS.Colors.textSecondary) Text(home.map { "\($0)" } ?? "-") .font(statFont.weight(bold ? .bold : .medium).monospacedDigit()) .foregroundStyle(bold ? DS.Colors.textPrimary : DS.Colors.textSecondary) } .frame(width: statColWidth) } #if os(tvOS) private var statFont: Font { .system(size: 17, design: .rounded) } private var teamColWidth: CGFloat { 50 } private var statColWidth: CGFloat { 36 } #else private var statFont: Font { .system(size: 13, design: .rounded) } private var teamColWidth: CGFloat { 36 } private var statColWidth: CGFloat { 28 } #endif }