multistore
Razmig Sarkissian 2 years ago
parent a7f8b1bafd
commit 437d408c6f
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 2
      PadelClub/Data/Match.swift
  3. 11
      PadelClub/Data/Round.swift
  4. 22
      PadelClub/Views/Tournament/Screen/BroadcastView.swift
  5. 1
      PadelClub/Views/Tournament/Screen/Screen.swift
  6. 16
      PadelClub/Views/Tournament/TournamentView.swift

@ -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 = "<group>"; };
FF5DA19A2BB9662200A33061 /* TournamentSeedEditing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentSeedEditing.swift; sourceTree = "<group>"; };
FF6087E92BE25EF1004E1E47 /* TournamentStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentStatusView.swift; sourceTree = "<group>"; };
FF6087EB2BE26A2F004E1E47 /* BroadcastView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BroadcastView.swift; sourceTree = "<group>"; };
FF663FBD2BE019EC0031AE83 /* TournamentFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentFilterView.swift; sourceTree = "<group>"; };
FF6EC8F62B94773100EA7F5A /* RowButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RowButtonView.swift; sourceTree = "<group>"; };
FF6EC8FA2B94788600EA7F5A /* TournamentButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentButtonView.swift; sourceTree = "<group>"; };
@ -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 */,

@ -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) {

@ -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 {

@ -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()
}

@ -17,4 +17,5 @@ enum Screen: String, Codable {
case cashier
case call
case rankings
case broadcast
}

@ -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()

Loading…
Cancel
Save