|
|
|
@ -49,11 +49,15 @@ struct GroupStagesView: View { |
|
|
|
|
|
|
|
|
|
|
|
init(tournament: Tournament) { |
|
|
|
init(tournament: Tournament) { |
|
|
|
self.tournament = tournament |
|
|
|
self.tournament = tournament |
|
|
|
|
|
|
|
if tournament.unsortedTeams().filter({ $0.groupStagePosition != nil }).isEmpty { |
|
|
|
|
|
|
|
_selectedDestination = State(wrappedValue: nil) |
|
|
|
|
|
|
|
} else { |
|
|
|
let gs = tournament.getActiveGroupStage() |
|
|
|
let gs = tournament.getActiveGroupStage() |
|
|
|
if let gs { |
|
|
|
if let gs { |
|
|
|
_selectedDestination = State(wrappedValue: .groupStage(gs)) |
|
|
|
_selectedDestination = State(wrappedValue: .groupStage(gs)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func allDestinations() -> [GroupStageDestination] { |
|
|
|
func allDestinations() -> [GroupStageDestination] { |
|
|
|
var allDestinations : [GroupStageDestination] = [.all] |
|
|
|
var allDestinations : [GroupStageDestination] = [.all] |
|
|
|
@ -67,17 +71,23 @@ struct GroupStagesView: View { |
|
|
|
GenericDestinationPickerView(selectedDestination: $selectedDestination, destinations: allDestinations(), nilDestinationIsValid: true) |
|
|
|
GenericDestinationPickerView(selectedDestination: $selectedDestination, destinations: allDestinations(), nilDestinationIsValid: true) |
|
|
|
switch selectedDestination { |
|
|
|
switch selectedDestination { |
|
|
|
case .all: |
|
|
|
case .all: |
|
|
|
List { |
|
|
|
|
|
|
|
let allGroupStages = tournament.groupStages() |
|
|
|
let allGroupStages = tournament.groupStages() |
|
|
|
let availableToStart = allGroupStages.flatMap({ $0.availableToStart() }) |
|
|
|
let availableToStart = allGroupStages.flatMap({ $0.availableToStart() }) |
|
|
|
let runningMatches = allGroupStages.flatMap({ $0.runningMatches() }) |
|
|
|
let runningMatches = allGroupStages.flatMap({ $0.runningMatches() }) |
|
|
|
let readyMatches = allGroupStages.flatMap({ $0.readyMatches() }) |
|
|
|
let readyMatches = allGroupStages.flatMap({ $0.readyMatches() }) |
|
|
|
let finishedMatches = allGroupStages.flatMap({ $0.finishedMatches() }) |
|
|
|
let finishedMatches = allGroupStages.flatMap({ $0.finishedMatches() }) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List { |
|
|
|
MatchListView(section: "disponible", matches: availableToStart, matchViewStyle: .standardStyle, isExpanded: false) |
|
|
|
MatchListView(section: "disponible", matches: availableToStart, matchViewStyle: .standardStyle, isExpanded: false) |
|
|
|
MatchListView(section: "en cours", matches: runningMatches, matchViewStyle: .standardStyle, isExpanded: false) |
|
|
|
MatchListView(section: "en cours", matches: runningMatches, matchViewStyle: .standardStyle, isExpanded: false) |
|
|
|
MatchListView(section: "à lancer", matches: readyMatches, matchViewStyle: .standardStyle, isExpanded: false) |
|
|
|
MatchListView(section: "à lancer", matches: readyMatches, matchViewStyle: .standardStyle, isExpanded: false) |
|
|
|
MatchListView(section: "terminés", matches: finishedMatches, matchViewStyle: .standardStyle, isExpanded: false) |
|
|
|
MatchListView(section: "terminés", matches: finishedMatches, matchViewStyle: .standardStyle, isExpanded: false) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.overlay { |
|
|
|
|
|
|
|
if availableToStart.isEmpty && runningMatches.isEmpty && readyMatches.isEmpty && finishedMatches.isEmpty { |
|
|
|
|
|
|
|
ContentUnavailableView("Aucun match à afficher", systemImage: "tennisball") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
.navigationTitle("Toutes les poules") |
|
|
|
.navigationTitle("Toutes les poules") |
|
|
|
case .groupStage(let groupStage): |
|
|
|
case .groupStage(let groupStage): |
|
|
|
GroupStageView(groupStage: groupStage) |
|
|
|
GroupStageView(groupStage: groupStage) |
|
|
|
|