diff --git a/score-ios/Models/GraphQL/schema.graphqls b/score-ios/Models/GraphQL/schema.graphqls index 9bacad1..88988cb 100644 --- a/score-ios/Models/GraphQL/schema.graphqls +++ b/score-ios/Models/GraphQL/schema.graphqls @@ -74,6 +74,7 @@ Attributes: - url: The URL to the video. - published_at: The date and time the video was published. - duration: The duration of the video (optional). + - sportsType: The sport type extracted from the video title. """ type YoutubeVideoType { id: String @@ -84,6 +85,7 @@ type YoutubeVideoType { url: String! publishedAt: String! duration: String + sportsType: String } """ diff --git a/score-ios/Models/Sport.swift b/score-ios/Models/Sport.swift index 837a2fa..128c3cc 100644 --- a/score-ios/Models/Sport.swift +++ b/score-ios/Models/Sport.swift @@ -14,33 +14,33 @@ enum Sport : String, Identifiable, CaseIterable, CustomStringConvertible { case All // Both -// case Basketball -// case CrossCountry -// case IceHockey + case Basketball + // case CrossCountry + case IceHockey case Lacrosse case Soccer -// case Squash -// case SwimmingDiving -// case Tennis -// case TrackField + // case Squash + // case SwimmingDiving + // case Tennis + // case TrackField // Women -// case Fencing + // case Fencing case FieldHockey -// case Gymnastics -// case Rowing -// case Sailing -// case Softball -// case Volleyball + // case Gymnastics + // case Rowing + // case Sailing + // case Softball + // case Volleyball // Men case Baseball case Football -// case Golf -// case RowingHeavyweight -// case RowingLightweight -// case SprintFootball -// case Wrestling + // case Golf + // case RowingHeavyweight + // case RowingLightweight + // case SprintFootball + // case Wrestling // init from a string from backend (might include spaces) init?(normalizedValue: String) { @@ -58,54 +58,30 @@ enum Sport : String, Identifiable, CaseIterable, CustomStringConvertible { // Make a to string function var description: String { switch self { - case .All: - return "All" -// case .Basketball: -// return "Basketball" -// case .CrossCountry: -// return "Cross Country" -// case .IceHockey: -// return "Ice Hockey" - case .Lacrosse: - return "Lacrosse" - case .Soccer: - return "Soccer" -// case .Squash: -// return "Squash" -// case .SwimmingDiving: -// return "Swimming" -// case .Tennis: -// return "Tennis" -// case .TrackField: -// return "Track and Field" -// case .Fencing: -// return "Fencing" - case .FieldHockey: - return "Field Hockey" -// case .Gymnastics: -// return "Gymnastics" -// case .Rowing: -// return "Rowing" -// case .Sailing: -// return "Sailing" -// case .Softball: -// return "Softball" -// case .Volleyball: -// return "Volleyball" - case .Baseball: - return "Baseball" - case .Football: - return "Football" -// case .Golf: -// return "Golf" -// case .RowingHeavyweight: -// return "HW Rowing" -// case .RowingLightweight: -// return "LW Rowing" -// case .SprintFootball: -// return "Sprint Football" -// case .Wrestling: -// return "Wrestling" + case .All: return "All" + case .Basketball: return "Basketball" + // case .CrossCountry: return "Cross Country" + case .IceHockey: return "Ice Hockey" + case .Lacrosse: return "Lacrosse" + case .Soccer: return "Soccer" + // case .Squash: return "Squash" + // case .SwimmingDiving: return "Swimming" + // case .Tennis: return "Tennis" + // case .TrackField: return "Track and Field" + // case .Fencing: return "Fencing" + case .FieldHockey: return "Field Hockey" + // case .Gymnastics: return "Gymnastics" + // case .Rowing: return "Rowing" + // case .Sailing: return "Sailing" + // case .Softball: return "Softball" + // case .Volleyball: return "Volleyball" + case .Baseball: return "Baseball" + case .Football: return "Football" + // case .Golf: return "Golf" + // case .RowingHeavyweight: return "HW Rowing" + // case .RowingLightweight: return "LW Rowing" + // case .SprintFootball: return "Sprint Football" + // case .Wrestling: return "Wrestling" } } } diff --git a/score-ios/ViewModels/PastGameViewModel.swift b/score-ios/ViewModels/PastGameViewModel.swift index aeb8dcf..af36f61 100644 --- a/score-ios/ViewModels/PastGameViewModel.swift +++ b/score-ios/ViewModels/PastGameViewModel.swift @@ -13,22 +13,23 @@ class PastGameViewModel: ObservableObject { var numberOfRounds: Int { switch game.sport { - case .Baseball: return game.timeUpdates.count > 3 ? game.timeUpdates.count - 3 : 9 - // number of innings is not always 9 - case .Soccer: return 2 -// case .IceHockey: return 3 - case .FieldHockey, .Football, .Lacrosse: return 4 - default: return 1 + case .Baseball: game.timeUpdates.count > 3 ? game.timeUpdates.count - 3 : 9 + case .Basketball: game.sex == .Men ? 2 : 4 + case .Soccer: 2 + case .IceHockey: 3 + case .FieldHockey, .Football, .Lacrosse: 4 + default: 1 } } var numberOfColumns: Int { switch game.sport { case .Baseball: return game.timeUpdates.count > 3 ? game.timeUpdates.count - 2 : 10 - // the last three columns are total runs, hits, and errors - // if backend stores null for scoreBreakdown, display regular score box with 10 columns + case .Basketball: + let cols = game.sex == .Men ? 3 : 5 + return game.timeUpdates.count >= cols ? game.timeUpdates.count : cols case .Soccer: return game.timeUpdates.count >= 3 ? game.timeUpdates.count : 3 -// case .IceHockey: return game.timeUpdates.count + case .IceHockey: return game.timeUpdates.count >= 4 ? game.timeUpdates.count : 4 case .FieldHockey, .Football, .Lacrosse: return game.timeUpdates.count >= 5 ? game.timeUpdates.count : 5 default: return 1 } @@ -36,11 +37,12 @@ class PastGameViewModel: ObservableObject { var numberOfOvertimes: Int { switch game.sport { - case .Baseball: return -1 - case .Soccer: return game.timeUpdates.count - 3 -// case .IceHockey: return game.timeUpdates.count - 4 - case .FieldHockey, .Football, .Lacrosse: return game.timeUpdates.count - 5 - default: return -1 + case .Baseball: -1 + case .Basketball: game.sex == .Men ? game.timeUpdates.count - 3 : game.timeUpdates.count - 5 + case .Soccer: game.timeUpdates.count - 3 + case .IceHockey: game.timeUpdates.count - 4 + case .FieldHockey, .Football, .Lacrosse: game.timeUpdates.count - 5 + default: -1 } } diff --git a/score-ios/Views/ListViews/UpcomingGamesView.swift b/score-ios/Views/ListViews/UpcomingGamesView.swift index 2bc791f..01f3ea9 100644 --- a/score-ios/Views/ListViews/UpcomingGamesView.swift +++ b/score-ios/Views/ListViews/UpcomingGamesView.swift @@ -21,15 +21,16 @@ struct UpcomingGamesView: View { ScrollView (.vertical, showsIndicators: false) { ZStack { LazyVStack(spacing: 0, pinnedViews: [.sectionHeaders]) { - CarouselView(games: vm.topUpcomingGames, title: "Upcoming", - cardView: { game in - UpcomingGameCard(game: game) - }, - gameView: { game in - GameView(game: game, viewModel: PastGameViewModel(game: game)) - }) - .padding(.horizontal, paddingMain) - + if !vm.topUpcomingGames.isEmpty { + CarouselView(games: vm.topUpcomingGames, title: "Upcoming", + cardView: { game in + UpcomingGameCard(game: game) + }, + gameView: { game in + GameView(game: game, viewModel: PastGameViewModel(game: game)) + }) + .padding(.horizontal, paddingMain) + } Section(header: GameSectionHeaderView(headerTitle: "Game Schedule") .padding(.horizontal, paddingMain)) {