|
|
|
@ -11,25 +11,46 @@ import LeStorage |
|
|
|
struct TeamsCallingView: View { |
|
|
|
struct TeamsCallingView: View { |
|
|
|
@Environment(Tournament.self) var tournament: Tournament |
|
|
|
@Environment(Tournament.self) var tournament: Tournament |
|
|
|
let teams : [TeamRegistration] |
|
|
|
let teams : [TeamRegistration] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var filteredTeams: [TeamRegistration] { |
|
|
|
|
|
|
|
teams.filter({ searchText.isEmpty || $0.contains(searchText) }) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@State private var searchText: String = "" |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
var body: some View { |
|
|
|
List { |
|
|
|
List { |
|
|
|
PlayersWithoutContactView(players: teams.flatMap({ $0.unsortedPlayers() }).sorted(by: \.computedRank)) |
|
|
|
PlayersWithoutContactView(players: teams.flatMap({ $0.unsortedPlayers() }).sorted(by: \.computedRank)) |
|
|
|
|
|
|
|
|
|
|
|
let called = teams.filter { tournament.isStartDateIsDifferentThanCallDate($0) == false } |
|
|
|
let called = teams.filter { tournament.isStartDateIsDifferentThanCallDate($0) == false } |
|
|
|
|
|
|
|
let confirmed = teams.filter { $0.confirmed() } |
|
|
|
let justCalled = teams.filter { $0.called() } |
|
|
|
let justCalled = teams.filter { $0.called() } |
|
|
|
|
|
|
|
|
|
|
|
let label = "\(justCalled.count.formatted()) / \(teams.count.formatted()) convoquées (dont \(called.count.formatted()) au bon horaire)" |
|
|
|
let label = "\(justCalled.count.formatted()) / \(teams.count.formatted())" |
|
|
|
|
|
|
|
let subtitle = "dont \(called.count.formatted()) au bon horaire" |
|
|
|
if teams.isEmpty == false { |
|
|
|
let confirmedLabel = "\(confirmed.count.formatted()) / \(teams.count.formatted())" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if teams.isEmpty == false, searchText.isEmpty { |
|
|
|
Section { |
|
|
|
Section { |
|
|
|
Text(label) |
|
|
|
LabeledContent { |
|
|
|
|
|
|
|
Text(label).font(.title3) |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Text("Paire\(justCalled.count.pluralSuffix) convoquée\(justCalled.count.pluralSuffix)") |
|
|
|
|
|
|
|
Text(subtitle) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
LabeledContent { |
|
|
|
|
|
|
|
Text(confirmedLabel).font(.title3) |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Text("Paire\(confirmed.count.pluralSuffix) confirmée\(confirmed.count.pluralSuffix)") |
|
|
|
|
|
|
|
} |
|
|
|
} footer: { |
|
|
|
} footer: { |
|
|
|
Text("Vous pouvez indiquer si une équipe vous a confirmé sa convocation en appuyant sur ") + Text(Image(systemName: "ellipsis.circle")) |
|
|
|
Text("Vous pouvez indiquer si une équipe vous a confirmé sa convocation en appuyant sur ") + Text(Image(systemName: "ellipsis.circle")) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if teams.isEmpty == false { |
|
|
|
Section { |
|
|
|
Section { |
|
|
|
ForEach(teams) { team in |
|
|
|
ForEach(filteredTeams) { team in |
|
|
|
Menu { |
|
|
|
Menu { |
|
|
|
_menuOptions(team: team) |
|
|
|
_menuOptions(team: team) |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
@ -51,6 +72,7 @@ struct TeamsCallingView: View { |
|
|
|
ContentUnavailableView("Aucune équipe", systemImage: "person.2.slash") |
|
|
|
ContentUnavailableView("Aucune équipe", systemImage: "person.2.slash") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
.searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always)) |
|
|
|
.headerProminence(.increased) |
|
|
|
.headerProminence(.increased) |
|
|
|
.navigationTitle("Statut des équipes") |
|
|
|
.navigationTitle("Statut des équipes") |
|
|
|
.navigationBarTitleDisplayMode(.inline) |
|
|
|
.navigationBarTitleDisplayMode(.inline) |
|
|
|
@ -66,6 +88,7 @@ struct TeamsCallingView: View { |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
Logger.error(error) |
|
|
|
Logger.error(error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
searchText = "" |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
if team.confirmed() { |
|
|
|
if team.confirmed() { |
|
|
|
Label("Confirmation reçue", systemImage: "checkmark.circle.fill").foregroundStyle(.green) |
|
|
|
Label("Confirmation reçue", systemImage: "checkmark.circle.fill").foregroundStyle(.green) |
|
|
|
@ -73,6 +96,16 @@ struct TeamsCallingView: View { |
|
|
|
Label("Confirmation reçue", systemImage: "circle").foregroundStyle(.logoRed) |
|
|
|
Label("Confirmation reçue", systemImage: "circle").foregroundStyle(.logoRed) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Divider() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NavigationLink { |
|
|
|
|
|
|
|
EditingTeamView(team: team) |
|
|
|
|
|
|
|
.environment(tournament) |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Text("Détails de l'équipe") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Divider() |
|
|
|
Divider() |
|
|
|
|
|
|
|
|
|
|
|
Button(role: .destructive) { |
|
|
|
Button(role: .destructive) { |
|
|
|
@ -82,6 +115,7 @@ struct TeamsCallingView: View { |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
Logger.error(error) |
|
|
|
Logger.error(error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
searchText = "" |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
Text("Effacer la date de convocation") |
|
|
|
Text("Effacer la date de convocation") |
|
|
|
} |
|
|
|
} |
|
|
|
@ -96,6 +130,7 @@ struct TeamsCallingView: View { |
|
|
|
} catch { |
|
|
|
} catch { |
|
|
|
Logger.error(error) |
|
|
|
Logger.error(error) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
searchText = "" |
|
|
|
} label: { |
|
|
|
} label: { |
|
|
|
Text("Indiquer comme convoquée") |
|
|
|
Text("Indiquer comme convoquée") |
|
|
|
} |
|
|
|
} |
|
|
|
|