Merge branch 'main' of https://stax.alwaysdata.net/gitea/staxriver/PadelClub
commit
2127f089f7
@ -0,0 +1,60 @@ |
||||
// |
||||
// WaitingListView.swift |
||||
// PadelClub |
||||
// |
||||
// Created by razmig on 26/02/2025. |
||||
// |
||||
|
||||
import SwiftUI |
||||
|
||||
struct WaitingListView: View { |
||||
@Environment(Tournament.self) var tournament: Tournament |
||||
let teamCount: Int |
||||
|
||||
@ViewBuilder |
||||
var body: some View { |
||||
Text("Attention, l'inscription en ligne est activée et vous avez des équipes inscrites en ligne, en modifiant la structure ces équipes seront intégrées ou retirées de votre sélection d'équipes. Pour l'instant Padel Club ne saura pas les prévenir automatiquement, vous devrez les contacter via l'écran de gestion des inscriptions.") |
||||
.foregroundStyle(.logoRed) |
||||
let selection = tournament.selectedSortedTeams() |
||||
if teamCount > tournament.teamCount { |
||||
Section { |
||||
let teams = tournament.waitingListSortedTeams(selectedSortedTeams: selection) |
||||
.prefix(teamCount - tournament.teamCount) |
||||
.filter { $0.hasRegisteredOnline() } |
||||
|
||||
ForEach(teams) { team in |
||||
NavigationLink { |
||||
EditingTeamView(team: team) |
||||
.environment(tournament) |
||||
} label: { |
||||
TeamRowView(team: team) |
||||
} |
||||
} |
||||
} header: { |
||||
Text("Équipes entrantes dans la sélection") |
||||
} footer: { |
||||
Text("Équipes inscrites en ligne à prévenir rentrant dans votre liste") |
||||
} |
||||
} |
||||
|
||||
if teamCount < tournament.teamCount { |
||||
Section { |
||||
let teams = selection.suffix(tournament.teamCount - teamCount) |
||||
.filter { $0.hasRegisteredOnline() } |
||||
|
||||
ForEach(teams) { team in |
||||
NavigationLink { |
||||
EditingTeamView(team: team) |
||||
.environment(tournament) |
||||
} label: { |
||||
TeamRowView(team: team) |
||||
} |
||||
} |
||||
} header: { |
||||
Text("Équipes sortantes de la sélection") |
||||
} footer: { |
||||
Text("Équipes inscrites en ligne à prévenir retirées de votre liste") |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,72 @@ |
||||
// |
||||
// MatchFormatGuideView.swift |
||||
// PadelClub |
||||
// |
||||
// Created by razmig on 20/02/2025. |
||||
// |
||||
|
||||
import SwiftUI |
||||
|
||||
struct MatchFormatGuideView: View { |
||||
let matchCounts = Array(2...7) |
||||
let formats: [MatchFormat] = [ |
||||
.twoSets, .twoSetsDecisivePoint, |
||||
.twoSetsSuperTie, .twoSetsDecisivePointSuperTie, |
||||
.twoSetsOfFourGames, .twoSetsOfFourGamesDecisivePoint, |
||||
.nineGames, .nineGamesDecisivePoint, |
||||
.superTie |
||||
] |
||||
|
||||
func getFormatDescription(for matchCount: Int) -> String { |
||||
var description = "" |
||||
|
||||
// Group formats by their behavior |
||||
let formatGroups = Dictionary(grouping: formats) { format in |
||||
format.maximumMatchPerDay(for: matchCount) |
||||
} |
||||
|
||||
// Sort by maximum matches allowed (descending) |
||||
let sortedMaxMatches = formatGroups.keys.sorted(by: >) |
||||
|
||||
for maxMatches in sortedMaxMatches { |
||||
if let formatsForMax = formatGroups[maxMatches] { |
||||
let formatStrings = formatsForMax.map { $0.format }.joined(separator: "/") |
||||
if maxMatches > 0 && maxMatches <= matchCount { |
||||
description += "Maximum \(maxMatches) matchs en format \(formatStrings)\n" |
||||
} else if maxMatches == 0 { |
||||
description += "Aucun match au format \(formatStrings)\n" |
||||
} |
||||
} |
||||
} |
||||
|
||||
if matchCount >= 7 { |
||||
description += "Format \(MatchFormat.superTie.format) principalement" |
||||
} |
||||
|
||||
return description.isEmpty ? "Aucun match possible" : description |
||||
} |
||||
|
||||
var body: some View { |
||||
List { |
||||
Section { |
||||
ForEach(matchCounts, id: \.self) { count in |
||||
VStack { |
||||
Text("\(count) matchs par jour") |
||||
.font(.headline) |
||||
Text(getFormatDescription(for: count)) |
||||
} |
||||
} |
||||
|
||||
// Special case for 7+ matches |
||||
VStack { |
||||
Text("7+ matchs par jour") |
||||
.font(.headline) |
||||
Text("Tournois P 25 uniquement (soirée/demi-journée/journée)") |
||||
} |
||||
} |
||||
} |
||||
.navigationTitle("Guide des Formats de Match") |
||||
.navigationBarTitleDisplayMode(.inline) |
||||
.toolbarBackground(.visible, for: .navigationBar) |
||||
} |
||||
} |
||||
Loading…
Reference in new issue