paca_championship
Raz 1 year ago
parent 91c4c5b591
commit 7b2989d29b
  1. 8
      PadelClub.xcodeproj/project.pbxproj
  2. 4
      PadelClub/Data/MatchScheduler.swift
  3. 6
      PadelClub/Data/PlayerRegistration.swift
  4. 13
      PadelClub/Data/Round.swift
  5. 2
      PadelClub/Views/Calling/SeedsCallingView.swift
  6. 17
      PadelClub/Views/Cashier/CashierView.swift
  7. 2
      PadelClub/Views/Match/Components/MatchDateView.swift
  8. 8
      PadelClub/Views/Match/MatchDetailView.swift
  9. 4
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  10. 4
      PadelClub/Views/Score/EditScoreView.swift
  11. 16
      PadelClub/Views/Score/FollowUpMatchView.swift
  12. 123
      PadelClub/Views/Team/TeamRestingView.swift
  13. 31
      PadelClub/Views/Tournament/Screen/TournamentCashierView.swift
  14. 19
      PadelClub/Views/Tournament/TournamentRunningView.swift

@ -700,6 +700,9 @@
FF70FBC82C90584900129CC2 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = FF0CA5742BDA4AE10080E843 /* PrivacyInfo.xcprivacy */; }; FF70FBC82C90584900129CC2 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = FF0CA5742BDA4AE10080E843 /* PrivacyInfo.xcprivacy */; };
FF70FBC92C90584900129CC2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C425D4042B6D249E002A7B48 /* Assets.xcassets */; }; FF70FBC92C90584900129CC2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C425D4042B6D249E002A7B48 /* Assets.xcassets */; };
FF70FBCB2C90584900129CC2 /* LeStorage.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C49EF0372BDFF3000077B5AA /* LeStorage.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; FF70FBCB2C90584900129CC2 /* LeStorage.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C49EF0372BDFF3000077B5AA /* LeStorage.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
FF7DCD392CC330270041110C /* TeamRestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF7DCD382CC330260041110C /* TeamRestingView.swift */; };
FF7DCD3A2CC330270041110C /* TeamRestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF7DCD382CC330260041110C /* TeamRestingView.swift */; };
FF7DCD3B2CC330270041110C /* TeamRestingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF7DCD382CC330260041110C /* TeamRestingView.swift */; };
FF8044AC2C8F676D00A49A52 /* TournamentSubscriptionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF8044AB2C8F676D00A49A52 /* TournamentSubscriptionView.swift */; }; FF8044AC2C8F676D00A49A52 /* TournamentSubscriptionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF8044AB2C8F676D00A49A52 /* TournamentSubscriptionView.swift */; };
FF82CFC52B911F5B00B0CAF2 /* OrganizedTournamentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF82CFC42B911F5B00B0CAF2 /* OrganizedTournamentView.swift */; }; FF82CFC52B911F5B00B0CAF2 /* OrganizedTournamentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF82CFC42B911F5B00B0CAF2 /* OrganizedTournamentView.swift */; };
FF82CFC92B9132AF00B0CAF2 /* ActivityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF82CFC82B9132AF00B0CAF2 /* ActivityView.swift */; }; FF82CFC92B9132AF00B0CAF2 /* ActivityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF82CFC82B9132AF00B0CAF2 /* ActivityView.swift */; };
@ -1078,6 +1081,7 @@
FF70916B2B91005400AB08DA /* TournamentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentView.swift; sourceTree = "<group>"; }; FF70916B2B91005400AB08DA /* TournamentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentView.swift; sourceTree = "<group>"; };
FF70916D2B9108C600AB08DA /* InscriptionManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InscriptionManagerView.swift; sourceTree = "<group>"; }; FF70916D2B9108C600AB08DA /* InscriptionManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InscriptionManagerView.swift; sourceTree = "<group>"; };
FF70FBCF2C90584900129CC2 /* PadelClub TestFlight.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PadelClub TestFlight.app"; sourceTree = BUILT_PRODUCTS_DIR; }; FF70FBCF2C90584900129CC2 /* PadelClub TestFlight.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PadelClub TestFlight.app"; sourceTree = BUILT_PRODUCTS_DIR; };
FF7DCD382CC330260041110C /* TeamRestingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeamRestingView.swift; sourceTree = "<group>"; };
FF8044AB2C8F676D00A49A52 /* TournamentSubscriptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentSubscriptionView.swift; sourceTree = "<group>"; }; FF8044AB2C8F676D00A49A52 /* TournamentSubscriptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentSubscriptionView.swift; sourceTree = "<group>"; };
FF82CFC42B911F5B00B0CAF2 /* OrganizedTournamentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrganizedTournamentView.swift; sourceTree = "<group>"; }; FF82CFC42B911F5B00B0CAF2 /* OrganizedTournamentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrganizedTournamentView.swift; sourceTree = "<group>"; };
FF82CFC82B9132AF00B0CAF2 /* ActivityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityView.swift; sourceTree = "<group>"; }; FF82CFC82B9132AF00B0CAF2 /* ActivityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityView.swift; sourceTree = "<group>"; };
@ -1820,6 +1824,7 @@
FF089EB52BB00A3800F0AEC7 /* TeamRowView.swift */, FF089EB52BB00A3800F0AEC7 /* TeamRowView.swift */,
FF1162862BD004AD000C4809 /* EditingTeamView.swift */, FF1162862BD004AD000C4809 /* EditingTeamView.swift */,
FF17CA562CC02FEA003C7323 /* CoachListView.swift */, FF17CA562CC02FEA003C7323 /* CoachListView.swift */,
FF7DCD382CC330260041110C /* TeamRestingView.swift */,
FF025AD62BD0C0FB00A86CF8 /* Components */, FF025AD62BD0C0FB00A86CF8 /* Components */,
); );
path = Team; path = Team;
@ -2304,6 +2309,7 @@
FF5D30562BD95B1100F2B93D /* OngoingView.swift in Sources */, FF5D30562BD95B1100F2B93D /* OngoingView.swift in Sources */,
FF1DC5552BAB36DD00FD8220 /* CreateClubView.swift in Sources */, FF1DC5552BAB36DD00FD8220 /* CreateClubView.swift in Sources */,
C4607A7D2C04DDE2004CB781 /* APICallsListView.swift in Sources */, C4607A7D2C04DDE2004CB781 /* APICallsListView.swift in Sources */,
FF7DCD3B2CC330270041110C /* TeamRestingView.swift in Sources */,
FFC1E10A2BAC2A77008D6F59 /* NetworkFederalService.swift in Sources */, FFC1E10A2BAC2A77008D6F59 /* NetworkFederalService.swift in Sources */,
FF025AEF2BD1AE9400A86CF8 /* DurationSettingsView.swift in Sources */, FF025AEF2BD1AE9400A86CF8 /* DurationSettingsView.swift in Sources */,
FF025AED2BD1513700A86CF8 /* AppScreen.swift in Sources */, FF025AED2BD1513700A86CF8 /* AppScreen.swift in Sources */,
@ -2577,6 +2583,7 @@
FF4CBF802C996C0600151637 /* OngoingView.swift in Sources */, FF4CBF802C996C0600151637 /* OngoingView.swift in Sources */,
FF4CBF812C996C0600151637 /* CreateClubView.swift in Sources */, FF4CBF812C996C0600151637 /* CreateClubView.swift in Sources */,
FF4CBF822C996C0600151637 /* APICallsListView.swift in Sources */, FF4CBF822C996C0600151637 /* APICallsListView.swift in Sources */,
FF7DCD392CC330270041110C /* TeamRestingView.swift in Sources */,
FF4CBF832C996C0600151637 /* NetworkFederalService.swift in Sources */, FF4CBF832C996C0600151637 /* NetworkFederalService.swift in Sources */,
FF4CBF842C996C0600151637 /* DurationSettingsView.swift in Sources */, FF4CBF842C996C0600151637 /* DurationSettingsView.swift in Sources */,
FF4CBF852C996C0600151637 /* AppScreen.swift in Sources */, FF4CBF852C996C0600151637 /* AppScreen.swift in Sources */,
@ -2829,6 +2836,7 @@
FF70FAFF2C90584900129CC2 /* OngoingView.swift in Sources */, FF70FAFF2C90584900129CC2 /* OngoingView.swift in Sources */,
FF70FB002C90584900129CC2 /* CreateClubView.swift in Sources */, FF70FB002C90584900129CC2 /* CreateClubView.swift in Sources */,
FF70FB012C90584900129CC2 /* APICallsListView.swift in Sources */, FF70FB012C90584900129CC2 /* APICallsListView.swift in Sources */,
FF7DCD3A2CC330270041110C /* TeamRestingView.swift in Sources */,
FF70FB022C90584900129CC2 /* NetworkFederalService.swift in Sources */, FF70FB022C90584900129CC2 /* NetworkFederalService.swift in Sources */,
FF70FB032C90584900129CC2 /* DurationSettingsView.swift in Sources */, FF70FB032C90584900129CC2 /* DurationSettingsView.swift in Sources */,
FF70FB042C90584900129CC2 /* AppScreen.swift in Sources */, FF70FB042C90584900129CC2 /* AppScreen.swift in Sources */,

@ -660,7 +660,7 @@ final class MatchScheduler : ModelObject, Storable {
@discardableResult func updateBracketSchedule(tournament: Tournament, fromRoundId roundId: String?, fromMatchId matchId: String?, startDate: Date) -> Bool { @discardableResult func updateBracketSchedule(tournament: Tournament, fromRoundId roundId: String?, fromMatchId matchId: String?, startDate: Date) -> Bool {
let upperRounds: [Round] = tournament.rounds() let upperRounds: [Round] = tournament.rounds()
let allMatches: [Match] = tournament.allMatches() let allMatches: [Match] = tournament.allMatches().filter({ $0.hasEnded() == false })
var rounds = [Round]() var rounds = [Round]()
@ -681,7 +681,7 @@ final class MatchScheduler : ModelObject, Storable {
} }
let flattenedMatches = rounds.flatMap { round in let flattenedMatches = rounds.flatMap { round in
round._matches().filter({ $0.disabled == false }).sorted(by: \.index) round._matches().filter({ $0.disabled == false && $0.hasEnded() == false }).sorted(by: \.index)
} }
flattenedMatches.forEach({ flattenedMatches.forEach({

@ -155,12 +155,12 @@ final class PlayerRegistration: ModelObject, Storable {
} }
func contains(_ searchField: String) -> Bool { func contains(_ searchField: String) -> Bool {
firstName.localizedCaseInsensitiveContains(searchField) || lastName.localizedCaseInsensitiveContains(searchField) firstName.canonicalVersion.localizedCaseInsensitiveContains(searchField.canonicalVersion) || lastName.canonicalVersion.localizedCaseInsensitiveContains(searchField.canonicalVersion)
} }
func isSameAs(_ player: PlayerRegistration) -> Bool { func isSameAs(_ player: PlayerRegistration) -> Bool {
firstName.trimmedMultiline.localizedCaseInsensitiveCompare(player.firstName.trimmedMultiline) == .orderedSame && firstName.trimmedMultiline.canonicalVersion.localizedCaseInsensitiveCompare(player.firstName.trimmedMultiline.canonicalVersion) == .orderedSame &&
lastName.trimmedMultiline.localizedCaseInsensitiveCompare(player.lastName.trimmedMultiline) == .orderedSame lastName.trimmedMultiline.canonicalVersion.localizedCaseInsensitiveCompare(player.lastName.trimmedMultiline.canonicalVersion) == .orderedSame
} }
func tournament() -> Tournament? { func tournament() -> Tournament? {

@ -145,13 +145,22 @@ final class Round: ModelObject, Storable {
let initialMatchIndex = RoundRule.matchIndex(fromRoundIndex: index) let initialMatchIndex = RoundRule.matchIndex(fromRoundIndex: index)
let numberOfMatches = RoundRule.numberOfMatches(forRoundIndex: index) let numberOfMatches = RoundRule.numberOfMatches(forRoundIndex: index)
return self.tournamentStore.teamRegistrations.filter { return self.tournamentStore.teamRegistrations.filter {
$0.tournament == tournament $0.bracketPosition != nil
&& $0.bracketPosition != nil
&& ($0.bracketPosition! / 2) >= initialMatchIndex && ($0.bracketPosition! / 2) >= initialMatchIndex
&& ($0.bracketPosition! / 2) < initialMatchIndex + numberOfMatches && ($0.bracketPosition! / 2) < initialMatchIndex + numberOfMatches
} }
} }
func teamsOrSeeds() -> [TeamRegistration] {
let seeds = seeds()
if seeds.isEmpty {
return playedMatches().flatMap({ $0.teams() })
} else {
return seeds
}
}
func losers() -> [TeamRegistration] { func losers() -> [TeamRegistration] {
let teamIds: [String] = self._matches().compactMap { $0.losingTeamId } let teamIds: [String] = self._matches().compactMap { $0.losingTeamId }
return teamIds.compactMap { self.tournamentStore.teamRegistrations.findById($0) } return teamIds.compactMap { self.tournamentStore.teamRegistrations.findById($0) }

@ -28,7 +28,7 @@ struct SeedsCallingView: View {
PlayersWithoutContactView(players: tournament.seededTeams().flatMap({ $0.unsortedPlayers() }).sorted(by: \.computedRank)) PlayersWithoutContactView(players: tournament.seededTeams().flatMap({ $0.unsortedPlayers() }).sorted(by: \.computedRank))
ForEach(tournamentRounds) { round in ForEach(tournamentRounds) { round in
let seeds = round.seeds() let seeds = round.teamsOrSeeds()
let callSeeds = seeds.filter({ tournament.isStartDateIsDifferentThanCallDate($0) == false }) let callSeeds = seeds.filter({ tournament.isStartDateIsDifferentThanCallDate($0) == false })
if seeds.isEmpty == false { if seeds.isEmpty == false {
Section { Section {

@ -56,7 +56,7 @@ extension Array {
class CashierViewModel: ObservableObject { class CashierViewModel: ObservableObject {
let id: UUID = UUID() let id: UUID = UUID()
@Published var sortOption: SortOption = .callDate @Published var sortOption: SortOption = .callDate
@Published var filterOption: FilterOption = .all @Published var filterOption: FilterOption = .didNotPay
@Published var presenceFilterOption: PresenceFilterOption = .all @Published var presenceFilterOption: PresenceFilterOption = .all
@Published var sortOrder: SortOrder = .ascending @Published var sortOrder: SortOrder = .ascending
@Published var searchText: String = "" @Published var searchText: String = ""
@ -306,8 +306,7 @@ struct CashierView: View {
case .alphabeticalLastName, .alphabeticalFirstName, .playerRank, .age: case .alphabeticalLastName, .alphabeticalFirstName, .playerRank, .age:
PlayerCashierView(players: filteredPlayers, displayTournamentTitle: tournaments.count > 1, editingOptions: _editingOptions()) PlayerCashierView(players: filteredPlayers, displayTournamentTitle: tournaments.count > 1, editingOptions: _editingOptions())
case .callDate: case .callDate:
let _teams = teams.filter({ $0.callDate != nil }) TeamCallDateView(teams: teams, displayTournamentTitle: tournaments.count > 1, editingOptions: _editingOptions())
TeamCallDateView(teams: _teams, displayTournamentTitle: tournaments.count > 1, editingOptions: _editingOptions())
} }
} }
.onAppear { .onAppear {
@ -354,7 +353,7 @@ struct CashierView: View {
} }
} footer: { } footer: {
if let teamCallDate = player.team()?.callDate { if let teamCallDate = player.team()?.callDate {
Text("équipe convoqué") + Text(teamCallDate.localizedDate()) Text("équipe convoquée ") + Text(teamCallDate.localizedDate())
} }
} }
} }
@ -369,8 +368,8 @@ struct CashierView: View {
var body: some View { var body: some View {
ForEach(teams) { team in ForEach(teams) { team in
let players = team.players().filter({ cashierViewModel._shouldDisplayPlayer($0) }) let players = team.players()
if players.isEmpty == false { if players.isEmpty == false, cashierViewModel._shouldDisplayTeam(team) {
Section { Section {
ForEach(players) { player in ForEach(players) { player in
EditablePlayerView(player: player, editingOptions: editingOptions) EditablePlayerView(player: player, editingOptions: editingOptions)
@ -404,15 +403,15 @@ struct CashierView: View {
var body: some View { var body: some View {
let groupedTeams = Dictionary(grouping: teams) { team in let groupedTeams = Dictionary(grouping: teams) { team in
team.callDate team.callDate ?? .distantPast
} }
let keys = cashierViewModel.sortOrder == .ascending ? groupedTeams.keys.compactMap { $0 }.sorted() : groupedTeams.keys.compactMap { $0 }.sorted().reversed() let keys = cashierViewModel.sortOrder == .ascending ? groupedTeams.keys.compactMap { $0 }.sorted() : groupedTeams.keys.compactMap { $0 }.sorted().reversed()
ForEach(keys, id: \.self) { key in ForEach(keys, id: \.self) { key in
if let _teams = groupedTeams[key] { if let _teams = groupedTeams[key] {
ForEach(_teams) { team in ForEach(_teams) { team in
let players = team.players().filter({ cashierViewModel._shouldDisplayPlayer($0) }) let players = team.players()
if players.isEmpty == false { if players.isEmpty == false, cashierViewModel._shouldDisplayTeam(team) {
Section { Section {
ForEach(players) { player in ForEach(players) { player in
EditablePlayerView(player: player, editingOptions: editingOptions) EditablePlayerView(player: player, editingOptions: editingOptions)

@ -35,7 +35,7 @@ struct MatchDateView: View {
} else { } else {
Menu { Menu {
let estimatedDuration = match.getDuration() let estimatedDuration = match.getDuration()
if isReady && match.hasStarted() == false { if isReady {
Section { Section {
Button("Démarrer maintenant") { Button("Démarrer maintenant") {
if let updatedField { if let updatedField {

@ -437,9 +437,11 @@ struct MatchDetailView: View {
Text("Partage sur les réseaux sociaux") Text("Partage sur les réseaux sociaux")
} }
Section { if match.currentTournament()?.hasEnded() == false {
RowButtonView("Match à suivre") { Section {
presentFollowUpMatch = true RowButtonView("Match à suivre") {
presentFollowUpMatch = true
}
} }
} }
} }

@ -70,8 +70,8 @@ struct OngoingView: View {
.toolbar { .toolbar {
ToolbarItem(placement: .status) { ToolbarItem(placement: .status) {
Picker(selection: $sortByField) { Picker(selection: $sortByField) {
Text("tri par date").tag(true) Text("tri par date").tag(false)
Text("tri par terrain").tag(false) Text("tri par terrain").tag(true)
} label: { } label: {
} }

@ -102,6 +102,10 @@ struct EditScoreView: View {
} }
} }
.listRowView(isActive: teamTwoSetupIsActive, color: colorTeamTwo, hideColorVariation: false, alignment: .trailing) .listRowView(isActive: teamTwoSetupIsActive, color: colorTeamTwo, hideColorVariation: false, alignment: .trailing)
} header: {
if let roundTitle = matchDescriptor.match?.roundAndMatchTitle() {
Text(roundTitle)
}
} footer: { } footer: {
HStack { HStack {
Menu { Menu {

@ -65,6 +65,20 @@ struct FollowUpMatchView: View {
match.loser() match.loser()
} }
var sortingModeCases: [SortingMode] {
var sortingModes = [SortingMode]()
if let winningTeam {
sortingModes.append(.winner)
}
if let losingTeam {
sortingModes.append(.loser)
}
sortingModes.append(.index)
sortingModes.append(.restingTime)
sortingModes.append(.court)
return sortingModes
}
func contentUnavailableDescriptionLabel() -> String { func contentUnavailableDescriptionLabel() -> String {
switch sortingMode { switch sortingMode {
case .winner: case .winner:
@ -155,7 +169,7 @@ struct FollowUpMatchView: View {
} }
} header: { } header: {
Picker(selection: $sortingMode) { Picker(selection: $sortingMode) {
ForEach(SortingMode.allCases) { sortingMode in ForEach(sortingModeCases) { sortingMode in
Text(sortingMode.localizedSortingModeLabel()).tag(sortingMode) Text(sortingMode.localizedSortingModeLabel()).tag(sortingMode)
} }
} label: { } label: {

@ -0,0 +1,123 @@
//
// TeamRestingView.swift
// PadelClub
//
// Created by razmig on 19/10/2024.
//
import SwiftUI
struct TeamRestingView: View {
@Environment(Tournament.self) var tournament
let readyMatches: [Match]
let matchesLeft: [Match]
@State private var sortingMode: SortingMode = .restingTime
@State private var selectedCourt: Int?
enum SortingMode: Int, Identifiable, CaseIterable {
var id: Int { self.rawValue }
case index
case restingTime
case court
func localizedSortingModeLabel() -> String {
switch self {
case .index:
return "Ordre"
case .court:
return "Terrain"
case .restingTime:
return "Repos"
}
}
}
var sortingModeCases: [SortingMode] {
var sortingModes = [SortingMode]()
sortingModes.append(.index)
sortingModes.append(.restingTime)
sortingModes.append(.court)
return sortingModes
}
func contentUnavailableDescriptionLabel() -> String {
switch sortingMode {
case .index:
return "Ce tournoi n'a aucun match prêt à démarrer"
case .restingTime:
return "Ce tournoi n'a aucun match prêt à démarrer"
case .court:
return "Ce tournoi n'a aucun match prêt à démarrer"
}
}
var sortedMatches: [Match] {
switch sortingMode {
case .index:
return readyMatches
case .restingTime:
return readyMatches.sorted(by: \.restingTimeForSorting)
case .court:
return readyMatches.sorted(using: [.keyPath(\.courtIndexForSorting), .keyPath(\.restingTimeForSorting)], order: .ascending)
}
}
var body: some View {
NavigationStack {
List {
Section {
Picker(selection: $selectedCourt) {
Text("Aucun").tag(nil as Int?)
ForEach(0..<tournament.courtCount, id: \.self) { courtIndex in
Text(tournament.courtName(atIndex: courtIndex)).tag(courtIndex as Int?)
}
} label: {
Text("Sur le terrain")
}
//
// Toggle(isOn: $checkCanPlay) {
// if isFree {
// Text("Vérifier le paiement ou la présence")
// } else {
// Text("Vérifier la présence")
// }
// }
// } footer: {
// if isFree {
// Text("Masque les matchs où un ou plusieurs joueurs qui ne sont pas encore arrivé")
// } else {
// Text("Masque les matchs où un ou plusieurs joueurs n'ont pas encore réglé ou qui ne sont pas encore arrivé")
// }
}
Section {
if sortedMatches.isEmpty == false {
ForEach(sortedMatches) { match in
MatchRowView(match: match, matchViewStyle: .followUpStyle, updatedField: selectedCourt)
}
} else {
ContentUnavailableView("Aucun match à venir", systemImage: "xmark.circle", description: Text(contentUnavailableDescriptionLabel()))
}
} header: {
Picker(selection: $sortingMode) {
ForEach(sortingModeCases) { sortingMode in
Text(sortingMode.localizedSortingModeLabel()).tag(sortingMode)
}
} label: {
Text("Méthode de tri")
}
.labelsHidden()
.pickerStyle(.segmented)
.fixedSize()
}
.headerProminence(.increased)
.textCase(nil)
}
.toolbarBackground(.visible, for: .navigationBar)
.navigationTitle("Match à suivre")
.navigationBarTitleDisplayMode(.inline)
}
}
}

@ -118,21 +118,22 @@ struct TournamentCashierView: View {
self.allDestinations = allDestinations self.allDestinations = allDestinations
_selectedDestination = .init(wrappedValue: all)
if tournament.hasEnded() {
if tournament.players().anySatisfy({ $0.hasPaid() == false }) == false { // if tournament.hasEnded() {
_selectedDestination = .init(wrappedValue: .summary) // if tournament.players().anySatisfy({ $0.hasPaid() == false }) == false {
} else { // _selectedDestination = .init(wrappedValue: .summary)
_selectedDestination = .init(wrappedValue: all) // } else {
} // _selectedDestination = .init(wrappedValue: all)
} else { // }
let gs = tournament.getActiveGroupStage() // } else {
if let gs, let destination = allDestinations.first(where: { $0.id == gs.id }) { // let gs = tournament.getActiveGroupStage()
_selectedDestination = State(wrappedValue: destination) // if let gs, let destination = allDestinations.first(where: { $0.id == gs.id }) {
} else if let rs = tournament.getActiveRound(withSeeds: true), let destination = allDestinations.first(where: { $0.id == rs.id }) { // _selectedDestination = State(wrappedValue: destination)
_selectedDestination = State(wrappedValue: destination) // } else if let rs = tournament.getActiveRound(withSeeds: true), let destination = allDestinations.first(where: { $0.id == rs.id }) {
} // _selectedDestination = State(wrappedValue: destination)
} // }
// }
} }
var body: some View { var body: some View {

@ -18,9 +18,24 @@ struct TournamentRunningView: View {
@ViewBuilder @ViewBuilder
var body: some View { var body: some View {
MatchListView(section: "à venir", matches: tournament.readyMatches(allMatches), hideWhenEmpty: true, isExpanded: false)
MatchListView(section: "en cours", matches: tournament.runningMatches(allMatches), hideWhenEmpty: tournament.hasEnded()) let matchesLeft = tournament.matchesLeft(allMatches)
let runningMatches = tournament.runningMatches(allMatches)
let readyMatches = tournament.readyMatches(allMatches)
let availableToStart = tournament.availableToStart(readyMatches, in: runningMatches, checkCanPlay: false)
// if tournament.hasEnded() == false {
// NavigationLink {
// TeamRestingView(readyMatches: availableToStart, matchesLeft: matchesLeft)
// .environment(tournament)
// } label: {
// Text("Temps de repos")
// }
// }
MatchListView(section: "à venir", matches: readyMatches, hideWhenEmpty: true, isExpanded: false)
MatchListView(section: "en cours", matches: runningMatches, hideWhenEmpty: tournament.hasEnded())
// MatchListView(section: "disponible", matches: tournament.availableToStart(allMatches), isExpanded: false) // MatchListView(section: "disponible", matches: tournament.availableToStart(allMatches), isExpanded: false)
let finishedMatches = tournament.finishedMatches(allMatches, limit: tournament.courtCount) let finishedMatches = tournament.finishedMatches(allMatches, limit: tournament.courtCount)
MatchListView(section: "Dernier\(finishedMatches.count.pluralSuffix) match\(finishedMatches.count.pluralSuffix) terminé\(finishedMatches.count.pluralSuffix)", matches: finishedMatches, isExpanded: tournament.hasEnded()) MatchListView(section: "Dernier\(finishedMatches.count.pluralSuffix) match\(finishedMatches.count.pluralSuffix) terminé\(finishedMatches.count.pluralSuffix)", matches: finishedMatches, isExpanded: tournament.hasEnded())

Loading…
Cancel
Save