|
|
|
|
@ -41,14 +41,6 @@ struct CallView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct TeamView: View { |
|
|
|
|
let team: TeamRegistration |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
TeamRowView(team: team, displayCallDate: true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@EnvironmentObject var dataStore: DataStore |
|
|
|
|
|
|
|
|
|
@EnvironmentObject var networkMonitor: NetworkMonitor |
|
|
|
|
@ -58,6 +50,7 @@ struct CallView: View { |
|
|
|
|
let callDate: Date |
|
|
|
|
let matchFormat: MatchFormat |
|
|
|
|
let roundLabel: String |
|
|
|
|
let displayContext: SummoningDisplayContext |
|
|
|
|
|
|
|
|
|
@State private var contactType: ContactType? = nil |
|
|
|
|
@State private var sentError: ContactManagerError? = nil |
|
|
|
|
@ -76,6 +69,7 @@ struct CallView: View { |
|
|
|
|
self.matchFormat = matchFormat |
|
|
|
|
self.roundLabel = roundLabel |
|
|
|
|
self.simpleMode = false |
|
|
|
|
self.displayContext = .footer |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init(teams: [TeamRegistration]) { |
|
|
|
|
@ -84,6 +78,30 @@ struct CallView: View { |
|
|
|
|
self.matchFormat = MatchFormat.nineGames |
|
|
|
|
self.roundLabel = "" |
|
|
|
|
self.simpleMode = true |
|
|
|
|
self.displayContext = .footer |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init(team: TeamRegistration, displayContext: SummoningDisplayContext) { |
|
|
|
|
self.teams = [team] |
|
|
|
|
let expectedSummonDate = team.expectedSummonDate() |
|
|
|
|
self.displayContext = displayContext |
|
|
|
|
|
|
|
|
|
if let expectedSummonDate, let initialMatch = team.initialMatch() { |
|
|
|
|
self.callDate = expectedSummonDate |
|
|
|
|
self.matchFormat = initialMatch.matchFormat |
|
|
|
|
self.roundLabel = initialMatch.roundTitle() ?? "tableau" |
|
|
|
|
self.simpleMode = false |
|
|
|
|
} else if let expectedSummonDate, let initialGroupStage = team.groupStageObject() { |
|
|
|
|
self.callDate = expectedSummonDate |
|
|
|
|
self.matchFormat = initialGroupStage.matchFormat |
|
|
|
|
self.roundLabel = "poule" |
|
|
|
|
self.simpleMode = false |
|
|
|
|
} else { |
|
|
|
|
self.callDate = Date() |
|
|
|
|
self.matchFormat = MatchFormat.nineGames |
|
|
|
|
self.roundLabel = "" |
|
|
|
|
self.simpleMode = true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
|
@ -107,6 +125,9 @@ struct CallView: View { |
|
|
|
|
if success { |
|
|
|
|
calledTeams.forEach { team in |
|
|
|
|
team.callDate = callDate |
|
|
|
|
if reSummon { |
|
|
|
|
team.confirmationDate = nil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
do { |
|
|
|
|
try self.tournamentStore.teamRegistrations.addOrUpdate(contentOfs: calledTeams) |
|
|
|
|
@ -141,28 +162,14 @@ struct CallView: View { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
let callWord : String = (reSummon ? "Reconvoquer" : mainWord) |
|
|
|
|
HStack { |
|
|
|
|
if self.teams.count == 1 { |
|
|
|
|
if simpleMode { |
|
|
|
|
Text("\(callWord) cette paire par") |
|
|
|
|
} else { |
|
|
|
|
if let previousCallDate = teams.first?.callDate, Calendar.current.compare(previousCallDate, to: callDate, toGranularity: .minute) != .orderedSame { |
|
|
|
|
Text("Reconvoquer \(self.callDate.localizedDate()) par") |
|
|
|
|
} else { |
|
|
|
|
Text("\(callWord) cette paire par") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Text("\(callWord) ces \(self.teams.count) paires par") |
|
|
|
|
Group { |
|
|
|
|
switch displayContext { |
|
|
|
|
case .footer: |
|
|
|
|
_footerStyleView() |
|
|
|
|
case .menu: |
|
|
|
|
_menuStyleView() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
self._summonMenu(byMessage: true) |
|
|
|
|
Text("ou") |
|
|
|
|
self._summonMenu(byMessage: false) |
|
|
|
|
} |
|
|
|
|
.font(.subheadline) |
|
|
|
|
.buttonStyle(.borderless) |
|
|
|
|
.alert("Un problème est survenu", isPresented: messageSentFailed) { |
|
|
|
|
Button("OK") { |
|
|
|
|
} |
|
|
|
|
@ -259,6 +266,54 @@ struct CallView: View { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _footerStyleView() -> some View { |
|
|
|
|
HStack { |
|
|
|
|
let callWord : String = (reSummon ? "Reconvoquer" : mainWord) |
|
|
|
|
if self.teams.count == 1 { |
|
|
|
|
if simpleMode { |
|
|
|
|
Text("\(callWord) cette paire par") |
|
|
|
|
} else { |
|
|
|
|
if let previousCallDate = teams.first?.callDate, Calendar.current.compare(previousCallDate, to: callDate, toGranularity: .minute) != .orderedSame { |
|
|
|
|
Text("Reconvoquer \(self.callDate.localizedDate()) par") |
|
|
|
|
} else { |
|
|
|
|
Text("\(callWord) cette paire par") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Text("\(callWord) ces \(self.teams.count) paires par") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
self._summonMenu(byMessage: true) |
|
|
|
|
Text("ou") |
|
|
|
|
self._summonMenu(byMessage: false) |
|
|
|
|
} |
|
|
|
|
.font(.subheadline) |
|
|
|
|
.buttonStyle(.borderless) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _menuStyleView() -> some View { |
|
|
|
|
Menu { |
|
|
|
|
self._summonMenu(byMessage: true) |
|
|
|
|
self._summonMenu(byMessage: false) |
|
|
|
|
} label: { |
|
|
|
|
let callWord : String = (reSummon ? "Reconvoquer" : mainWord) |
|
|
|
|
if self.teams.count == 1 { |
|
|
|
|
if simpleMode { |
|
|
|
|
Text("\(callWord) cette paire") |
|
|
|
|
} else { |
|
|
|
|
if let previousCallDate = teams.first?.callDate, Calendar.current.compare(previousCallDate, to: callDate, toGranularity: .minute) != .orderedSame { |
|
|
|
|
Text("Reconvoquer \(self.callDate.localizedDate())") |
|
|
|
|
} else { |
|
|
|
|
Text("\(callWord) cette paire") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Text("\(callWord) ces \(self.teams.count) paires") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
private func _summonMenu(byMessage: Bool) -> some View { |
|
|
|
|
if self.reSummon { |
|
|
|
|
@ -334,3 +389,20 @@ struct CallView: View { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct TeamCallView: View { |
|
|
|
|
@Environment(Tournament.self) var tournament: Tournament |
|
|
|
|
let team: TeamRegistration |
|
|
|
|
var action: (() -> Void)? |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
NavigationLink { |
|
|
|
|
CallMenuOptionsView(team: team, action: action) |
|
|
|
|
.environment(tournament) |
|
|
|
|
} label: { |
|
|
|
|
TeamRowView(team: team, displayCallDate: true) |
|
|
|
|
} |
|
|
|
|
.buttonStyle(.plain) |
|
|
|
|
.listRowView(isActive: team.confirmed(), color: .green, hideColorVariation: true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|