import SwiftUI struct PitchSequenceView: View { let pitches: [LiveFeedPlayEvent] var body: some View { VStack(alignment: .leading, spacing: 8) { Text("PITCH SEQUENCE") .font(.system(size: 12, weight: .bold, design: .rounded)) .foregroundStyle(.white.opacity(0.5)) .kerning(1.2) ForEach(Array(pitches.enumerated()), id: \.offset) { index, pitch in HStack(spacing: 10) { Text("#\(pitch.pitchNumber ?? (index + 1))") .font(.system(size: 13, weight: .bold, design: .rounded)) .foregroundStyle(.white.opacity(0.5)) .frame(width: 28, alignment: .leading) Text(pitch.pitchTypeDescription) .font(.system(size: 14, weight: .semibold, design: .rounded)) .foregroundStyle(.white) .lineLimit(1) Spacer() if let speed = pitch.speedMPH { Text("\(speed, specifier: "%.1f") mph") .font(.system(size: 13, weight: .medium).monospacedDigit()) .foregroundStyle(.white.opacity(0.7)) } pitchResultPill(code: pitch.callCode, description: pitch.callDescription) } .padding(.vertical, 4) .padding(.horizontal, 8) .background( index == pitches.count - 1 ? RoundedRectangle(cornerRadius: 8, style: .continuous).fill(.white.opacity(0.06)) : RoundedRectangle(cornerRadius: 8, style: .continuous).fill(.clear) ) } } } private func pitchResultPill(code: String, description: String) -> some View { let color = pitchCallColor(code) let label: String switch code { case "B": label = "Ball" case "C": label = "Called Strike" case "S": label = "Swinging Strike" case "F": label = "Foul" case "X": label = "In Play" case "D": label = "In Play (Out)" case "E": label = "In Play (Error)" default: label = description } return Text(label) .font(.system(size: 11, weight: .bold, design: .rounded)) .foregroundStyle(color) .padding(.horizontal, 8) .padding(.vertical, 4) .background(color.opacity(0.15)) .clipShape(Capsule()) } }