Files
MLBApp/mlbTVOS/Views/Components/LiveIndicator.swift
2026-03-26 15:37:31 -05:00

67 lines
1.9 KiB
Swift

import SwiftUI
struct LiveIndicator: View {
@State private var isPulsing = false
var body: some View {
HStack(spacing: 6) {
Circle()
.fill(.red)
.frame(width: 12, height: 12)
.scaleEffect(isPulsing ? 1.4 : 1.0)
.opacity(isPulsing ? 0.6 : 1.0)
.animation(
.easeInOut(duration: 0.8).repeatForever(autoreverses: true),
value: isPulsing
)
Text("LIVE")
.font(.subheadline.weight(.black))
.foregroundStyle(.red)
}
.onAppear { isPulsing = true }
}
}
struct StatusBadge: View {
let status: GameStatus
var body: some View {
switch status {
case .live(let inning):
HStack(spacing: 8) {
LiveIndicator()
if let inning {
Text(inning)
.font(.subheadline.weight(.semibold))
.foregroundStyle(.primary)
}
}
.padding(.horizontal, 16)
.padding(.vertical, 8)
.background(.red.opacity(0.15))
.clipShape(Capsule())
case .scheduled(let time):
Text(time)
.font(.body.weight(.bold))
.foregroundStyle(.green)
.padding(.horizontal, 16)
.padding(.vertical, 8)
.background(.green.opacity(0.12))
.clipShape(Capsule())
case .final_:
Text("FINAL")
.font(.subheadline.weight(.bold))
.foregroundStyle(.secondary)
.padding(.horizontal, 16)
.padding(.vertical, 8)
.background(.secondary.opacity(0.12))
.clipShape(Capsule())
case .unknown:
EmptyView()
}
}
}