63 lines
2.8 KiB
Swift
63 lines
2.8 KiB
Swift
import SwiftUI
|
|
|
|
enum TeamAssets {
|
|
// MLB team ID mapping for logo URLs
|
|
static let teamIds: [String: Int] = [
|
|
"ARI": 109, "AZ": 109, "ATL": 144, "BAL": 110, "BOS": 111,
|
|
"CHC": 112, "CWS": 145, "CIN": 113, "CLE": 114, "COL": 115,
|
|
"DET": 116, "HOU": 117, "KC": 118, "LAA": 108, "LAD": 119,
|
|
"MIA": 146, "MIL": 158, "MIN": 142, "NYM": 121, "NYY": 147,
|
|
"OAK": 133, "ATH": 133, "PHI": 143, "PIT": 134, "SD": 135,
|
|
"SF": 137, "SEA": 136, "STL": 138, "TB": 139, "TEX": 140,
|
|
"TOR": 141, "WSH": 120,
|
|
]
|
|
|
|
// Primary team colors
|
|
static let teamColors: [String: Color] = [
|
|
"ARI": Color(red: 0.65, green: 0.10, blue: 0.19),
|
|
"ATL": Color(red: 0.81, green: 0.07, blue: 0.26),
|
|
"BAL": Color(red: 0.87, green: 0.31, blue: 0.07),
|
|
"BOS": Color(red: 0.74, green: 0.09, blue: 0.13),
|
|
"CHC": Color(red: 0.00, green: 0.19, blue: 0.56),
|
|
"CWS": Color(red: 0.15, green: 0.15, blue: 0.15),
|
|
"CIN": Color(red: 0.77, green: 0.06, blue: 0.15),
|
|
"CLE": Color(red: 0.00, green: 0.17, blue: 0.38),
|
|
"COL": Color(red: 0.20, green: 0.11, blue: 0.35),
|
|
"DET": Color(red: 0.00, green: 0.18, blue: 0.42),
|
|
"HOU": Color(red: 0.00, green: 0.18, blue: 0.39),
|
|
"KC": Color(red: 0.00, green: 0.22, blue: 0.53),
|
|
"LAA": Color(red: 0.73, green: 0.07, blue: 0.15),
|
|
"LAD": Color(red: 0.00, green: 0.22, blue: 0.56),
|
|
"MIA": Color(red: 0.00, green: 0.63, blue: 0.79),
|
|
"MIL": Color(red: 0.07, green: 0.15, blue: 0.34),
|
|
"MIN": Color(red: 0.00, green: 0.17, blue: 0.38),
|
|
"NYM": Color(red: 0.00, green: 0.18, blue: 0.48),
|
|
"NYY": Color(red: 0.00, green: 0.14, blue: 0.30),
|
|
"OAK": Color(red: 0.00, green: 0.30, blue: 0.18),
|
|
"ATH": Color(red: 0.00, green: 0.30, blue: 0.18),
|
|
"PHI": Color(red: 0.76, green: 0.08, blue: 0.18),
|
|
"PIT": Color(red: 0.99, green: 0.73, blue: 0.01),
|
|
"SD": Color(red: 0.18, green: 0.12, blue: 0.07),
|
|
"SF": Color(red: 0.99, green: 0.31, blue: 0.07),
|
|
"SEA": Color(red: 0.00, green: 0.22, blue: 0.36),
|
|
"STL": Color(red: 0.76, green: 0.10, blue: 0.15),
|
|
"TB": Color(red: 0.00, green: 0.18, blue: 0.46),
|
|
"TEX": Color(red: 0.00, green: 0.21, blue: 0.52),
|
|
"TOR": Color(red: 0.08, green: 0.25, blue: 0.52),
|
|
"WSH": Color(red: 0.67, green: 0.09, blue: 0.19),
|
|
]
|
|
|
|
static func color(for code: String) -> Color {
|
|
teamColors[code.uppercased()] ?? .gray
|
|
}
|
|
|
|
static func logoURL(for code: String) -> URL? {
|
|
guard let id = teamIds[code.uppercased()] else { return nil }
|
|
return URL(string: "https://midfield.mlbstatic.com/v1/team/\(id)/spots/72")
|
|
}
|
|
|
|
static func logoURL(forId id: Int) -> URL {
|
|
URL(string: "https://midfield.mlbstatic.com/v1/team/\(id)/spots/72")!
|
|
}
|
|
}
|