diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 864564a..0bff72b 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -154,6 +154,7 @@ FF5DA1952BB927E800A33061 /* GenericDestinationPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF5DA1942BB927E800A33061 /* GenericDestinationPickerView.swift */; }; FF5DA19B2BB9662200A33061 /* TournamentSeedEditing.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF5DA19A2BB9662200A33061 /* TournamentSeedEditing.swift */; }; FF6087EA2BE25EF1004E1E47 /* TournamentStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF6087E92BE25EF1004E1E47 /* TournamentStatusView.swift */; }; + FF6087EC2BE26A2F004E1E47 /* BroadcastView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF6087EB2BE26A2F004E1E47 /* BroadcastView.swift */; }; FF663FBE2BE019EC0031AE83 /* TournamentFilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF663FBD2BE019EC0031AE83 /* TournamentFilterView.swift */; }; FF6EC8F72B94773200EA7F5A /* RowButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF6EC8F62B94773100EA7F5A /* RowButtonView.swift */; }; FF6EC8FB2B94788600EA7F5A /* TournamentButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF6EC8FA2B94788600EA7F5A /* TournamentButtonView.swift */; }; @@ -446,6 +447,7 @@ FF5DA1942BB927E800A33061 /* GenericDestinationPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GenericDestinationPickerView.swift; sourceTree = ""; }; FF5DA19A2BB9662200A33061 /* TournamentSeedEditing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentSeedEditing.swift; sourceTree = ""; }; FF6087E92BE25EF1004E1E47 /* TournamentStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentStatusView.swift; sourceTree = ""; }; + FF6087EB2BE26A2F004E1E47 /* BroadcastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BroadcastView.swift; sourceTree = ""; }; FF663FBD2BE019EC0031AE83 /* TournamentFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentFilterView.swift; sourceTree = ""; }; FF6EC8F62B94773100EA7F5A /* RowButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RowButtonView.swift; sourceTree = ""; }; FF6EC8FA2B94788600EA7F5A /* TournamentButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentButtonView.swift; sourceTree = ""; }; @@ -933,6 +935,7 @@ FF9268062BCE94D90080F940 /* TournamentCallView.swift */, FF1162802BCF945C000C4809 /* TournamentCashierView.swift */, FF5BAF712BE19274008B4B7E /* TournamentRankView.swift */, + FF6087EB2BE26A2F004E1E47 /* BroadcastView.swift */, FF8F26522BAE0E4E00650388 /* Components */, ); path = Screen; @@ -1450,6 +1453,7 @@ FF2EFBF02BDE295E0049CE3B /* SendToAllView.swift in Sources */, FF8F263B2BAD528600650388 /* EventCreationView.swift in Sources */, FFC1E1082BAC29FC008D6F59 /* LocationManager.swift in Sources */, + FF6087EC2BE26A2F004E1E47 /* BroadcastView.swift in Sources */, FFF964552BC266CF00EEF017 /* SchedulerView.swift in Sources */, FFA1B1292BB71773006CE248 /* PadelClubButtonView.swift in Sources */, FF5DA19B2BB9662200A33061 /* TournamentSeedEditing.swift in Sources */, diff --git a/PadelClub/Data/Match.swift b/PadelClub/Data/Match.swift index 4496dfc..de0a683 100644 --- a/PadelClub/Data/Match.swift +++ b/PadelClub/Data/Match.swift @@ -349,6 +349,7 @@ class Match: ModelObject, Storable { winningTeamId = teamScoreWinning.teamRegistration losingTeamId = teamScoreWalkout.teamRegistration groupStageObject?.updateGroupStageState() + roundObject?.updateTournamentState() } func setScore(fromMatchDescriptor matchDescriptor: MatchDescriptor) { @@ -359,6 +360,7 @@ class Match: ModelObject, Storable { winningTeamId = team(matchDescriptor.winner)?.id losingTeamId = team(matchDescriptor.winner.otherTeam)?.id groupStageObject?.updateGroupStageState() + roundObject?.updateTournamentState() } func updateScore(fromMatchDescriptor matchDescriptor: MatchDescriptor) { diff --git a/PadelClub/Data/Round.swift b/PadelClub/Data/Round.swift index 82b829e..a5851fc 100644 --- a/PadelClub/Data/Round.swift +++ b/PadelClub/Data/Round.swift @@ -370,6 +370,17 @@ class Round: ModelObject, Storable { } return RoundRule.roundName(fromRoundIndex: index) } + + func updateTournamentState() { + if let tournamentObject = tournamentObject(), index == 0, isUpperBracket(), hasEnded() { + tournamentObject.endDate = Date() + do { + try DataStore.shared.tournaments.addOrUpdate(instance: tournamentObject) + } catch { + Logger.error(error) + } + } + } func roundStatus() -> String { if hasStarted() && hasEnded() == false { diff --git a/PadelClub/Views/Tournament/Screen/BroadcastView.swift b/PadelClub/Views/Tournament/Screen/BroadcastView.swift new file mode 100644 index 0000000..2d6ace4 --- /dev/null +++ b/PadelClub/Views/Tournament/Screen/BroadcastView.swift @@ -0,0 +1,22 @@ +// +// BroadcastView.swift +// PadelClub +// +// Created by Razmig Sarkissian on 01/05/2024. +// + +import SwiftUI + +struct BroadcastView: View { + var body: some View { + List { + } + .navigationTitle("Diffusion") + .navigationBarTitleDisplayMode(.inline) + .toolbarBackground(.visible, for: .navigationBar) + } +} + +#Preview { + BroadcastView() +} diff --git a/PadelClub/Views/Tournament/Screen/Screen.swift b/PadelClub/Views/Tournament/Screen/Screen.swift index 57c0a67..05ee93b 100644 --- a/PadelClub/Views/Tournament/Screen/Screen.swift +++ b/PadelClub/Views/Tournament/Screen/Screen.swift @@ -17,4 +17,5 @@ enum Screen: String, Codable { case cashier case call case rankings + case broadcast } diff --git a/PadelClub/Views/Tournament/TournamentView.swift b/PadelClub/Views/Tournament/TournamentView.swift index e13f048..ac9806a 100644 --- a/PadelClub/Views/Tournament/TournamentView.swift +++ b/PadelClub/Views/Tournament/TournamentView.swift @@ -60,8 +60,19 @@ struct TournamentView: View { switch tournament.state() { case .initial: TournamentInitView() + + NavigationLink(value: Screen.broadcast) { + Text("Diffusion") + } + case .build: TournamentRunningView(tournament: tournament) + + if tournament.hasEnded() { + NavigationLink(value: Screen.rankings) { + Text("Classement") + } + } } } } @@ -87,6 +98,8 @@ struct TournamentView: View { TournamentCallView(tournament: tournament) case .rankings: TournamentRankView() + case .broadcast: + BroadcastView() } } .environment(tournament) @@ -123,6 +136,9 @@ struct TournamentView: View { NavigationLink(value: Screen.rankings) { Text("Classement") } + NavigationLink(value: Screen.broadcast) { + Text("Diffusion") + } } } label: { LabelOptions()