68 lines
2.6 KiB
Swift
68 lines
2.6 KiB
Swift
import SwiftUI
|
|
|
|
struct ScoreOverlayView: View {
|
|
let game: Game
|
|
|
|
var body: some View {
|
|
// Don't show for non-game streams (e.g., MLB Network)
|
|
if game.id == "MLBN" {
|
|
EmptyView()
|
|
} else {
|
|
HStack(spacing: 10) {
|
|
// Away
|
|
HStack(spacing: 6) {
|
|
Circle()
|
|
.fill(TeamAssets.color(for: game.awayTeam.code))
|
|
.frame(width: 8, height: 8)
|
|
Text(game.awayTeam.code)
|
|
.font(.system(size: 15, weight: .bold, design: .rounded))
|
|
.foregroundStyle(.white)
|
|
|
|
if !game.status.isScheduled, let score = game.awayTeam.score {
|
|
Text("\(score)")
|
|
.font(.system(size: 17, weight: .bold, design: .rounded).monospacedDigit())
|
|
.foregroundStyle(.white)
|
|
}
|
|
}
|
|
|
|
Text("-")
|
|
.font(.system(size: 13, weight: .medium))
|
|
.foregroundStyle(.white.opacity(0.4))
|
|
|
|
// Home
|
|
HStack(spacing: 6) {
|
|
if !game.status.isScheduled, let score = game.homeTeam.score {
|
|
Text("\(score)")
|
|
.font(.system(size: 17, weight: .bold, design: .rounded).monospacedDigit())
|
|
.foregroundStyle(.white)
|
|
}
|
|
|
|
Text(game.homeTeam.code)
|
|
.font(.system(size: 15, weight: .bold, design: .rounded))
|
|
.foregroundStyle(.white)
|
|
Circle()
|
|
.fill(TeamAssets.color(for: game.homeTeam.code))
|
|
.frame(width: 8, height: 8)
|
|
}
|
|
|
|
// Inning/status
|
|
if game.isLive, let inning = game.currentInningDisplay {
|
|
Text(inning)
|
|
.font(.system(size: 12, weight: .semibold))
|
|
.foregroundStyle(.white.opacity(0.6))
|
|
.padding(.leading, 4)
|
|
} else if game.isFinal {
|
|
Text("F")
|
|
.font(.system(size: 12, weight: .bold))
|
|
.foregroundStyle(.white.opacity(0.5))
|
|
.padding(.leading, 4)
|
|
}
|
|
}
|
|
.padding(.horizontal, 12)
|
|
.padding(.vertical, 6)
|
|
.background(.black.opacity(0.7))
|
|
.clipShape(RoundedRectangle(cornerRadius: 8))
|
|
}
|
|
}
|
|
}
|