|
|
|
|
@ -34,14 +34,14 @@ struct RoundView: View { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private var spaceLeft: [Match] { |
|
|
|
|
let displayableMatches: [Match] = self.upperRound.round.displayableMatches() |
|
|
|
|
let displayableMatches: [Match] = self.upperRound.round.playedMatches() |
|
|
|
|
return displayableMatches.filter { match in |
|
|
|
|
match.teamScores.count == 1 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private var seedSpaceLeft: [Match] { |
|
|
|
|
let displayableMatches: [Match] = self.upperRound.round.displayableMatches() |
|
|
|
|
let displayableMatches: [Match] = self.upperRound.round.playedMatches() |
|
|
|
|
return displayableMatches.filter { match in |
|
|
|
|
match.teamScores.count == 0 |
|
|
|
|
} |
|
|
|
|
@ -62,12 +62,31 @@ struct RoundView: View { |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
List { |
|
|
|
|
let displayableMatches = upperRound.round.displayableMatches().sorted(by: \.index) |
|
|
|
|
let displayableMatches = upperRound.round.playedMatches().sorted(by: \.index) |
|
|
|
|
if displayableMatches.isEmpty { |
|
|
|
|
Section { |
|
|
|
|
ContentUnavailableView("Aucun match dans cette manche", systemImage: "tennisball") |
|
|
|
|
} |
|
|
|
|
} else if isEditingTournamentSeed.wrappedValue == false { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let disabledMatchesCount = BracketEditTip.matchesHidden |
|
|
|
|
if disabledMatchesCount > 0 { |
|
|
|
|
let bracketTip = BracketEditTip(nextRoundName: upperRound.round.nextRound()?.roundTitle()) |
|
|
|
|
TipView(bracketTip).tipStyle(tint: .green, asSection: true) |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
let leftToPlay = (RoundRule.numberOfMatches(forRoundIndex: upperRound.round.index) - disabledMatchesCount) |
|
|
|
|
LabeledContent { |
|
|
|
|
Text(leftToPlay.formatted()) |
|
|
|
|
} label: { |
|
|
|
|
Text("Match\(leftToPlay.pluralSuffix) à jouer \(upperRound.title)") |
|
|
|
|
} |
|
|
|
|
} footer: { |
|
|
|
|
Text("\(disabledMatchesCount) match\(disabledMatchesCount.pluralSuffix) désactivé\(disabledMatchesCount.pluralSuffix) automatiquement") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if isEditingTournamentSeed.wrappedValue == false { |
|
|
|
|
//(where: { $0.isDisabled() == false || isEditingTournamentSeed.wrappedValue }) |
|
|
|
|
let printTip = PrintTip() |
|
|
|
|
TipView(printTip) { actions in |
|
|
|
|
@ -75,7 +94,7 @@ struct RoundView: View { |
|
|
|
|
} |
|
|
|
|
.tipStyle(tint: .master, asSection: true) |
|
|
|
|
|
|
|
|
|
if upperRound.loserRounds.isEmpty == false { |
|
|
|
|
if upperRound.round.index > 0 { |
|
|
|
|
let correspondingLoserRoundTitle = upperRound.round.correspondingLoserRoundTitle() |
|
|
|
|
Section { |
|
|
|
|
NavigationLink { |
|
|
|
|
@ -94,25 +113,11 @@ struct RoundView: View { |
|
|
|
|
Text(correspondingLoserRoundTitle) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} header: { |
|
|
|
|
Text("Match de classement") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
let disabledMatchesCount = BracketEditTip.matchesHidden |
|
|
|
|
if disabledMatchesCount > 0 { |
|
|
|
|
let bracketTip = BracketEditTip(nextRoundName: upperRound.round.nextRound()?.roundTitle()) |
|
|
|
|
TipView(bracketTip).tipStyle(tint: .green, asSection: true) |
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
|
let leftToPlay = (RoundRule.numberOfMatches(forRoundIndex: upperRound.round.index) - disabledMatchesCount) |
|
|
|
|
LabeledContent { |
|
|
|
|
Text(leftToPlay.formatted()).font(.largeTitle) |
|
|
|
|
} label: { |
|
|
|
|
Text("Match\(leftToPlay.pluralSuffix) à jouer \(upperRound.title)") |
|
|
|
|
Text("\(disabledMatchesCount) match\(disabledMatchesCount.pluralSuffix) désactivé\(disabledMatchesCount.pluralSuffix) automatiquement") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let availableSeeds = tournament.availableSeeds() |
|
|
|
|
let availableQualifiedTeams = tournament.availableQualifiedTeams() |
|
|
|
|
|
|
|
|
|
@ -255,6 +260,17 @@ struct RoundView: View { |
|
|
|
|
Text(match.teamScores.count.formatted()) |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} footer: { |
|
|
|
|
if isEditingTournamentSeed.wrappedValue == true && match.followingMatch()?.disabled == true { |
|
|
|
|
FooterButtonView("Désactiver", role: .destructive) { |
|
|
|
|
match.disableMatch() |
|
|
|
|
do { |
|
|
|
|
try tournamentStore.matches.addOrUpdate(instance: match) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -285,8 +301,10 @@ struct RoundView: View { |
|
|
|
|
Button(isEditingTournamentSeed.wrappedValue == true ? "Valider" : "Modifier") { |
|
|
|
|
if isEditingTournamentSeed.wrappedValue == true { |
|
|
|
|
_save() |
|
|
|
|
isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
} else { |
|
|
|
|
isEditingTournamentSeed.wrappedValue = true |
|
|
|
|
} |
|
|
|
|
isEditingTournamentSeed.wrappedValue.toggle() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|