|
|
|
@ -17,49 +17,38 @@ struct RoundView: View { |
|
|
|
@Environment(NavigationViewModel.self) private var navigation: NavigationViewModel |
|
|
|
@Environment(NavigationViewModel.self) private var navigation: NavigationViewModel |
|
|
|
|
|
|
|
|
|
|
|
@State private var selectedSeedGroup: SeedInterval? |
|
|
|
@State private var selectedSeedGroup: SeedInterval? |
|
|
|
@State private var spaceLeft: [Match] = [] |
|
|
|
|
|
|
|
@State private var seedSpaceLeft: [Match] = [] |
|
|
|
|
|
|
|
@State private var availableSeedGroup: SeedInterval? |
|
|
|
|
|
|
|
@State private var showPrintScreen: Bool = false |
|
|
|
@State private var showPrintScreen: Bool = false |
|
|
|
|
|
|
|
|
|
|
|
var upperRound: UpperRound |
|
|
|
var upperRound: UpperRound |
|
|
|
|
|
|
|
|
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
init(upperRound: UpperRound) { |
|
|
|
return self.tournament.tournamentStore |
|
|
|
self.upperRound = upperRound |
|
|
|
|
|
|
|
let seeds = upperRound.round.seeds() |
|
|
|
|
|
|
|
SlideToDeleteSeedTip.seeds = seeds.count |
|
|
|
|
|
|
|
PrintTip.seeds = seeds.count |
|
|
|
|
|
|
|
BracketEditTip.matchesHidden = upperRound.round.getDisabledMatches().count |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func _getAvailableSeedGroup() { |
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
#if DEBUG_TIME //DEBUGING TIME |
|
|
|
return self.tournament.tournamentStore |
|
|
|
let start = Date() |
|
|
|
|
|
|
|
defer { |
|
|
|
|
|
|
|
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) |
|
|
|
|
|
|
|
print("func _getAvailableSeedGroup of: ", duration.formatted(.units(allowed: [.seconds, .milliseconds]))) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
availableSeedGroup = tournament.seedGroupAvailable(atRoundIndex: upperRound.round.index) |
|
|
|
private var spaceLeft: [Match] { |
|
|
|
|
|
|
|
let displayableMatches: [Match] = self.upperRound.round.displayableMatches() |
|
|
|
|
|
|
|
return displayableMatches.filter { match in |
|
|
|
|
|
|
|
match.teamScores.count == 1 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func _getSpaceLeft() { |
|
|
|
|
|
|
|
#if DEBUG_TIME //DEBUGING TIME |
|
|
|
|
|
|
|
let start = Date() |
|
|
|
|
|
|
|
defer { |
|
|
|
|
|
|
|
let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) |
|
|
|
|
|
|
|
print("func _getSpaceLeft of: ", duration.formatted(.units(allowed: [.seconds, .milliseconds]))) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.spaceLeft.removeAll() |
|
|
|
private var seedSpaceLeft: [Match] { |
|
|
|
self.seedSpaceLeft.removeAll() |
|
|
|
|
|
|
|
let displayableMatches: [Match] = self.upperRound.round.displayableMatches() |
|
|
|
let displayableMatches: [Match] = self.upperRound.round.displayableMatches() |
|
|
|
displayableMatches.forEach { match in |
|
|
|
return displayableMatches.filter { match in |
|
|
|
let count: Int = match.teamScores.count |
|
|
|
match.teamScores.count == 0 |
|
|
|
if count == 0 { |
|
|
|
|
|
|
|
seedSpaceLeft.append(match) |
|
|
|
|
|
|
|
} else if count == 1 { |
|
|
|
|
|
|
|
spaceLeft.append(match) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var availableSeedGroup: SeedInterval? { |
|
|
|
|
|
|
|
tournament.seedGroupAvailable(atRoundIndex: upperRound.round.index) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var showVisualDrawView: Binding<Bool> { Binding( |
|
|
|
var showVisualDrawView: Binding<Bool> { Binding( |
|
|
|
@ -133,10 +122,6 @@ struct RoundView: View { |
|
|
|
Task { |
|
|
|
Task { |
|
|
|
tournament.setSeeds(inRoundIndex: upperRound.round.index, inSeedGroup: availableSeedGroup) |
|
|
|
tournament.setSeeds(inRoundIndex: upperRound.round.index, inSeedGroup: availableSeedGroup) |
|
|
|
_save() |
|
|
|
_save() |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_prepareRound() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} footer: { |
|
|
|
} footer: { |
|
|
|
@ -175,10 +160,6 @@ struct RoundView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
_save() |
|
|
|
_save() |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_prepareRound() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
@ -206,10 +187,6 @@ struct RoundView: View { |
|
|
|
team.setSeedPosition(inSpot: seedSpaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: false) |
|
|
|
team.setSeedPosition(inSpot: seedSpaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: false) |
|
|
|
} |
|
|
|
} |
|
|
|
_save() |
|
|
|
_save() |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_prepareRound() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
@ -233,10 +210,6 @@ struct RoundView: View { |
|
|
|
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true) |
|
|
|
team.setSeedPosition(inSpot: spaceLeft[drawResult.drawIndex], slot: nil, opposingSeeding: true) |
|
|
|
} |
|
|
|
} |
|
|
|
_save() |
|
|
|
_save() |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_prepareRound() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
@ -288,13 +261,6 @@ struct RoundView: View { |
|
|
|
.navigationDestination(isPresented: $showPrintScreen) { |
|
|
|
.navigationDestination(isPresented: $showPrintScreen) { |
|
|
|
PrintSettingsView(tournament: tournament) |
|
|
|
PrintSettingsView(tournament: tournament) |
|
|
|
} |
|
|
|
} |
|
|
|
.onAppear { |
|
|
|
|
|
|
|
_prepareRound() |
|
|
|
|
|
|
|
let seeds = upperRound.round.seeds() |
|
|
|
|
|
|
|
SlideToDeleteSeedTip.seeds = seeds.count |
|
|
|
|
|
|
|
PrintTip.seeds = seeds.count |
|
|
|
|
|
|
|
BracketEditTip.matchesHidden = upperRound.round.getDisabledMatches().count |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
.fullScreenCover(isPresented: showVisualDrawView) { |
|
|
|
.fullScreenCover(isPresented: showVisualDrawView) { |
|
|
|
if let availableSeedGroup = selectedSeedGroup { |
|
|
|
if let availableSeedGroup = selectedSeedGroup { |
|
|
|
let seeds = tournament.seeds(inSeedGroup: availableSeedGroup) |
|
|
|
let seeds = tournament.seeds(inSeedGroup: availableSeedGroup) |
|
|
|
@ -308,11 +274,6 @@ struct RoundView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_save() |
|
|
|
_save() |
|
|
|
_prepareRound() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
|
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -352,11 +313,10 @@ struct RoundView: View { |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
Logger.error(error) |
|
|
|
Logger.error(error) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func _prepareRound() { |
|
|
|
if tournament.availableSeeds().isEmpty && tournament.availableQualifiedTeams().isEmpty { |
|
|
|
_getSpaceLeft() |
|
|
|
self.isEditingTournamentSeed.wrappedValue = false |
|
|
|
_getAvailableSeedGroup() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|