|
|
|
@ -20,10 +20,6 @@ struct GroupStageView: View { |
|
|
|
@State private var confirmResetMatch: Bool = false |
|
|
|
@State private var confirmResetMatch: Bool = false |
|
|
|
let playedMatches: [Match] |
|
|
|
let playedMatches: [Match] |
|
|
|
|
|
|
|
|
|
|
|
@State private var runningMatches: [Match]? |
|
|
|
|
|
|
|
@State private var readyMatches: [Match]? |
|
|
|
|
|
|
|
@State private var availableToStart: [Match]? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init(groupStage: GroupStage) { |
|
|
|
init(groupStage: GroupStage) { |
|
|
|
self.groupStage = groupStage |
|
|
|
self.groupStage = groupStage |
|
|
|
self.playedMatches = groupStage.playedMatches() |
|
|
|
self.playedMatches = groupStage.playedMatches() |
|
|
|
@ -55,16 +51,14 @@ struct GroupStageView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
.headerProminence(.increased) |
|
|
|
.headerProminence(.increased) |
|
|
|
|
|
|
|
|
|
|
|
MatchListView(section: "en cours", matches: runningMatches, hideWhenEmpty: true) |
|
|
|
let runningMatches = groupStage.runningMatches(playedMatches: playedMatches) |
|
|
|
|
|
|
|
MatchListView(section: "en cours", matches: groupStage.runningMatches(playedMatches: playedMatches), hideWhenEmpty: true) |
|
|
|
|
|
|
|
let availableToStart = groupStage.availableToStart(playedMatches: playedMatches, in: runningMatches) |
|
|
|
MatchListView(section: "prêt à démarrer", matches: availableToStart, hideWhenEmpty: true) |
|
|
|
MatchListView(section: "prêt à démarrer", matches: availableToStart, hideWhenEmpty: true) |
|
|
|
MatchListView(section: "à lancer", matches: self.readyMatches, hideWhenEmpty: true) |
|
|
|
.listRowView(isActive: availableToStart.isEmpty == false, color: .green, hideColorVariation: true) |
|
|
|
|
|
|
|
MatchListView(section: "à lancer", matches: groupStage.readyMatches(playedMatches: playedMatches), hideWhenEmpty: true) |
|
|
|
MatchListView(section: "terminés", matches: groupStage.finishedMatches(playedMatches: playedMatches), isExpanded: false) |
|
|
|
MatchListView(section: "terminés", matches: groupStage.finishedMatches(playedMatches: playedMatches), isExpanded: false) |
|
|
|
} |
|
|
|
} |
|
|
|
.task { |
|
|
|
|
|
|
|
self.runningMatches = await groupStage.asyncRunningMatches(playedMatches: playedMatches) |
|
|
|
|
|
|
|
self.readyMatches = await groupStage.readyMatches(playedMatches: playedMatches) |
|
|
|
|
|
|
|
self.availableToStart = await groupStage.availableToStart(playedMatches: playedMatches, in: runningMatches ?? []) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.toolbar { |
|
|
|
.toolbar { |
|
|
|
ToolbarItem(placement: .topBarTrailing) { |
|
|
|
ToolbarItem(placement: .topBarTrailing) { |
|
|
|
_groupStageMenuView() |
|
|
|
_groupStageMenuView() |
|
|
|
@ -148,6 +142,11 @@ struct GroupStageView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
ForEach(team.players()) { player in |
|
|
|
ForEach(team.players()) { player in |
|
|
|
Text(player.playerLabel()).lineLimit(1) |
|
|
|
Text(player.playerLabel()).lineLimit(1) |
|
|
|
|
|
|
|
.overlay { |
|
|
|
|
|
|
|
if player.hasArrived && team.isHere() == false { |
|
|
|
|
|
|
|
Color.logoYellow.opacity(0.6) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Spacer() |
|
|
|
Spacer() |
|
|
|
@ -175,12 +174,43 @@ struct GroupStageView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.contextMenu { |
|
|
|
.contextMenu { |
|
|
|
Button("équipe présente") { |
|
|
|
let teamHasArrived = team.isHere() |
|
|
|
team.hasArrived() |
|
|
|
Button { |
|
|
|
|
|
|
|
team.hasArrived(isHere: teamHasArrived) |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
if teamHasArrived { |
|
|
|
|
|
|
|
Label("équipe présente", systemImage: "checkmark").foregroundStyle(.green) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Text("équipe présente") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Divider() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
|
|
|
ForEach(team.players()) { player in |
|
|
|
|
|
|
|
Button { |
|
|
|
|
|
|
|
player.hasArrived.toggle() |
|
|
|
|
|
|
|
do { |
|
|
|
|
|
|
|
try self.tournamentStore.playerRegistrations.addOrUpdate(instance: player) |
|
|
|
|
|
|
|
} catch { |
|
|
|
|
|
|
|
Logger.error(error) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
if player.hasArrived { |
|
|
|
|
|
|
|
Label("\(player.playerLabel())", systemImage: "checkmark") |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Text("\(player.playerLabel())") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} header: { |
|
|
|
|
|
|
|
Text("Joueur présent") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.listRowView(isActive: team.qualified, color: .master) |
|
|
|
.listRowView(isActive: team.qualified, color: .master) |
|
|
|
|
|
|
|
.listRowView(isActive: team.isHere(), color: .green, hideColorVariation: true) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
VStack(alignment: .leading, spacing: 0) { |
|
|
|
VStack(alignment: .leading, spacing: 0) { |
|
|
|
Text("#\(index + 1)") |
|
|
|
Text("#\(index + 1)") |
|
|
|
|