Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions score-ios/Models/GraphQL/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -84,6 +85,7 @@ type YoutubeVideoType {
url: String!
publishedAt: String!
duration: String
sportsType: String
}

"""
Expand Down
108 changes: 42 additions & 66 deletions score-ios/Models/Sport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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"
}
}
}
Expand Down
30 changes: 16 additions & 14 deletions score-ios/ViewModels/PastGameViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,36 @@ 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
}
}

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
}
}

Expand Down
19 changes: 10 additions & 9 deletions score-ios/Views/ListViews/UpcomingGamesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down