|
|
|
|
@ -68,6 +68,24 @@ struct CallView: View { |
|
|
|
|
@State var summonParamByMessage: Bool = false |
|
|
|
|
@State var summonParamReSummon: Bool = false |
|
|
|
|
|
|
|
|
|
let simpleMode : Bool |
|
|
|
|
|
|
|
|
|
init(teams: [TeamRegistration], callDate: Date, matchFormat: MatchFormat, roundLabel: String) { |
|
|
|
|
self.teams = teams |
|
|
|
|
self.callDate = callDate |
|
|
|
|
self.matchFormat = matchFormat |
|
|
|
|
self.roundLabel = roundLabel |
|
|
|
|
self.simpleMode = false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init(teams: [TeamRegistration]) { |
|
|
|
|
self.teams = teams |
|
|
|
|
self.callDate = Date() |
|
|
|
|
self.matchFormat = MatchFormat.nineGames |
|
|
|
|
self.roundLabel = "" |
|
|
|
|
self.simpleMode = true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var tournamentStore: TournamentStore { |
|
|
|
|
return self.tournament.tournamentStore |
|
|
|
|
} |
|
|
|
|
@ -83,6 +101,9 @@ struct CallView: View { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private func _called(_ calledTeams: [TeamRegistration], _ success: Bool) { |
|
|
|
|
if simpleMode { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
if success { |
|
|
|
|
calledTeams.forEach { team in |
|
|
|
|
team.callDate = callDate |
|
|
|
|
@ -96,22 +117,42 @@ struct CallView: View { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func finalMessage(reSummon: Bool) -> String { |
|
|
|
|
ContactType.callingMessage(tournament: tournament, startDate: callDate, roundLabel: roundLabel, matchFormat: matchFormat, reSummon: reSummon) |
|
|
|
|
if simpleMode { |
|
|
|
|
let signature = dataStore.user.summonsMessageSignature ?? dataStore.user.defaultSignature() |
|
|
|
|
return "\n\n\n\n" + signature |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ContactType.callingMessage(tournament: tournament, startDate: callDate, roundLabel: roundLabel, matchFormat: matchFormat, reSummon: reSummon) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var reSummon: Bool { |
|
|
|
|
if simpleMode { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
return self.teams.allSatisfy({ $0.called() }) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var mainWord: String { |
|
|
|
|
if simpleMode { |
|
|
|
|
return "Contacter" |
|
|
|
|
} else { |
|
|
|
|
return "Convoquer" |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
let callWord : String = (reSummon ? "Reconvoquer" : "Convoquer") |
|
|
|
|
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") |
|
|
|
|
} |
|
|
|
|
@ -222,7 +263,7 @@ struct CallView: View { |
|
|
|
|
private func _summonMenu(byMessage: Bool) -> some View { |
|
|
|
|
if self.reSummon { |
|
|
|
|
Menu { |
|
|
|
|
Button("Convoquer") { |
|
|
|
|
Button(mainWord) { |
|
|
|
|
self._summon(byMessage: byMessage, reSummon: false) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|