fix wc stuff display

sync
Raz 8 months ago
parent 1601b757b1
commit 51395b60a4
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 56
      PadelClub/Data/TeamRegistration.swift
  3. 14
      PadelClub/Views/GroupStage/GroupStageView.swift
  4. 51
      PadelClub/Views/Match/Components/PlayerBlockView.swift
  5. 12
      PadelClub/Views/Team/TeamPickerView.swift
  6. 27
      PadelClub/Views/Team/TeamRowView.swift
  7. 1
      PadelClub/Views/Tournament/Screen/TableStructureView.swift

@ -3344,7 +3344,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.1.23; MARKETING_VERSION = 1.1.24;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@ -3389,7 +3389,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.1.23; MARKETING_VERSION = 1.1.24;
PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";

@ -600,7 +600,7 @@ final class TeamRegistration: ModelObject, Storable {
func wildcardLabel() -> String? { func wildcardLabel() -> String? {
if isWildCard() { if isWildCard() {
let wildcardLabel: String = ["wildcard", (wildCardBracket ? "tableau" : "poule")].joined(separator: " ") let wildcardLabel: String = ["Wildcard", (wildCardBracket ? "Tableau" : "Poule")].joined(separator: " ")
return wildcardLabel return wildcardLabel
} else { } else {
return nil return nil
@ -647,22 +647,48 @@ final class TeamRegistration: ModelObject, Storable {
unsortedPlayers().count > 0 unsortedPlayers().count > 0
} }
func bracketMatchTitleAndQualifiedStatus() -> String? { func teamInitialPositionBracket() -> String? {
let v = groupStageObject()?.groupStageTitle() let round = initialMatch()?.roundAndMatchTitle()
var base = "Qualifié" if let round {
if qualified { return round
if let groupStageTitle = groupStageObject()?.groupStageTitle() {
base = base + " (\(groupStageTitle))"
}
} }
return nil
let suffix = qualified ? nil : groupStageObject()?.groupStageTitle() }
let initalMatchTitle = initialMatch()?.roundAndMatchTitle() ?? suffix
let values = [qualified ? base : nil, initalMatchTitle].compactMap({ $0 }) func teamInitialPositionGroupStage() -> String? {
if values.isEmpty { let groupStage = self.groupStageObject()
return nil let group = groupStage?.groupStageTitle(.title)
var groupPositionLabel: String? = nil
if let finalPosition = groupStage?.finalPosition(ofTeam: self) {
groupPositionLabel = (finalPosition + 1).ordinalFormatted()
} else if let groupStagePosition {
groupPositionLabel = "\(groupStagePosition + 1)"
}
if let group {
if let groupPositionLabel {
return [group, "#\(groupPositionLabel)"].joined(separator: " ")
} else {
return group
}
}
return nil
}
func qualifiedStatus(hideBracketStatus: Bool = false) -> String? {
let teamInitialPositionBracket = teamInitialPositionBracket()
let groupStageTitle = teamInitialPositionGroupStage()
let base: String? = qualified ? "Qualifié" : nil
if let groupStageTitle, let teamInitialPositionBracket, hideBracketStatus == false {
return [base, groupStageTitle, ">", teamInitialPositionBracket].compactMap({ $0 }).joined(separator: " ")
} else if let groupStageTitle {
return [base, groupStageTitle].compactMap({ $0 }).joined(separator: " ")
} else if hideBracketStatus == false {
return teamInitialPositionBracket
} }
return values.joined(separator: " -> ")
return nil
} }
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {

@ -140,12 +140,16 @@ struct GroupStageView: View {
GroupStageTeamView(groupStage: groupStage, team: team) GroupStageTeamView(groupStage: groupStage, team: team)
.environment(self.tournament) .environment(self.tournament)
} label: { } label: {
let players = team.players()
VStack(alignment: .leading, spacing: 4.0) { VStack(alignment: .leading, spacing: 4.0) {
HStack(spacing: 6.0) { HStack(spacing: 6.0) {
Text("#\(groupStagePosition + 1)") Text("#\(groupStagePosition + 1)")
if groupStage.tournamentObject()?.hideWeight() == false { if players.isEmpty == false, groupStage.tournamentObject()?.hideWeight() == false {
Text("Poids \(team.weight)") Text("Poids \(team.weight)")
} }
if players.isEmpty == false, team.isWildCard() {
Text("wildcard").foregroundStyle(.logoRed).font(.caption).italic()
}
Spacer() Spacer()
if team.qualified { if team.qualified {
Text("qualifié") Text("qualifié")
@ -156,8 +160,14 @@ struct GroupStageView: View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
if let teamName = team.name, teamName.isEmpty == false { if let teamName = team.name, teamName.isEmpty == false {
Text(teamName).foregroundStyle(.secondary).font(.footnote) Text(teamName).foregroundStyle(.secondary).font(.footnote)
} else if players.isEmpty {
if team.isWildCard() {
Text("Place réservée wildcard")
} else {
Text("Place réservée")
}
} }
ForEach(team.players()) { player in ForEach(players) { player in
Text(player.playerLabel()).lineLimit(1) Text(player.playerLabel()).lineLimit(1)
.overlay { .overlay {
if player.hasArrived && team.isHere() == false { if player.hasArrived && team.isHere() == false {

@ -74,39 +74,48 @@ struct PlayerBlockView: View {
var body: some View { var body: some View {
HStack { HStack {
VStack(alignment: .leading) { VStack(alignment: .leading) {
if let team { ZStack(alignment: .leading) {
if let teamScore, teamScore.luckyLoser != nil, match.isLoserBracket == false { VStack {
Text("Repêchée").italic().font(.caption) if let teamName = team?.name {
Text(teamName).foregroundStyle(.secondary).font(.footnote)
}
Text("longLabelPlayerOne").lineLimit(1)
Text("longLabelPlayerTwo").lineLimit(1)
} }
.opacity(0)
if let teamName = team.name { if let team {
Text(teamName).foregroundStyle(.secondary).font(.footnote) if let teamScore, teamScore.luckyLoser != nil, match.isLoserBracket == false {
} Text("Repêchée").italic().font(.caption)
ForEach(team.players()) { player in }
Text(player.playerLabel()).lineLimit(1)
.italic(player.isHere() == false) if let teamName = team.name {
.foregroundStyle(player.isHere() == false ? .secondary : .primary) Text(teamName).foregroundStyle(.secondary).font(.footnote)
} } else if team.players().isEmpty {
} else { if team.isWildCard() {
ZStack(alignment: .leading) { Text("Place réservée wildcard")
VStack { } else {
if let teamName = team?.name { Text("Place réservée")
Text(teamName).foregroundStyle(.secondary).font(.footnote)
} }
Text("longLabelPlayerOne").lineLimit(1)
Text("longLabelPlayerTwo").lineLimit(1)
} }
.opacity(0) VStack(alignment: .leading) {
ForEach(team.players()) { player in
Text(player.playerLabel()).lineLimit(1)
.italic(player.isHere() == false)
.foregroundStyle(player.isHere() == false ? .secondary : .primary)
}
}
} else {
VStack(alignment: .leading) { VStack(alignment: .leading) {
ForEach(_defaultLabel(), id: \.self) { name in ForEach(_defaultLabel(), id: \.self) { name in
Text(name) Text(name)
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
.lineLimit(1) .lineLimit(1)
} }
} }
} }
} }
if displayRestingTime, let team { if displayRestingTime, let team {
TeamRowView.TeamRestingView(team: team) TeamRowView.TeamRestingView(team: team)
} }

@ -134,15 +134,9 @@ struct TeamPickerView: View {
// presentTeamPickerView = false // presentTeamPickerView = false
// } // }
} label: { } label: {
VStack(alignment: .leading) { TeamRowView(team: team)
if let roundAndMatchTitle = team.bracketMatchTitleAndQualifiedStatus() { .environment(\.isEditingTournamentSeed, .constant(false))
Text(roundAndMatchTitle) .contentShape(Rectangle())
.font(.headline)
.frame(maxWidth: .infinity, alignment: .leading)
}
TeamRowView(team: team)
}
.contentShape(Rectangle())
} }
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.buttonStyle(.plain) .buttonStyle(.plain)

@ -9,7 +9,6 @@ import SwiftUI
struct TeamRowView: View { struct TeamRowView: View {
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@Environment(\.isEditingTournamentSeed) private var isEditingTournamentSeed
var team: TeamRegistration var team: TeamRegistration
var teamPosition: TeamPosition? = nil var teamPosition: TeamPosition? = nil
@ -22,9 +21,7 @@ struct TeamRowView: View {
TeamWeightView(team: team, teamPosition: teamPosition, teamIndex: teamIndex) TeamWeightView(team: team, teamPosition: teamPosition, teamIndex: teamIndex)
} label: { } label: {
VStack(alignment: .leading) { VStack(alignment: .leading) {
if isEditingTournamentSeed.wrappedValue == false { TeamHeadlineView(team: team)
TeamHeadlineView(team: team)
}
TeamView(team: team) TeamView(team: team)
} }
if displayCallDate { if displayCallDate {
@ -78,23 +75,19 @@ struct TeamRowView: View {
} }
struct TeamHeadlineView: View { struct TeamHeadlineView: View {
@Environment(\.isEditingTournamentSeed) private var isEditingTournamentSeed
let team: TeamRegistration let team: TeamRegistration
var body: some View { var body: some View {
HStack { VStack(alignment: .leading) {
if let groupStage = team.groupStageObject() {
HStack {
Text(groupStage.groupStageTitle(.title))
if let finalPosition = groupStage.finalPosition(ofTeam: team) {
Text((finalPosition + 1).ordinalFormatted())
}
}
} else if let round = team.initialRound() {
Text(round.roundTitle(.wide))
}
if let wildcardLabel = team.wildcardLabel() { if let wildcardLabel = team.wildcardLabel() {
Text(wildcardLabel).italic().foregroundStyle(.red).font(.caption) Text(wildcardLabel).italic().foregroundStyle(.logoRed).font(.caption)
}
if let qualifiedStatus = team.qualifiedStatus(hideBracketStatus: isEditingTournamentSeed.wrappedValue == true) {
Text(qualifiedStatus)
.font(.caption)
.foregroundStyle(.secondary)
} }
} }
} }

@ -295,6 +295,7 @@ struct TableStructureView: View {
RowButtonView("Remise-à-zéro", role: .destructive) { RowButtonView("Remise-à-zéro", role: .destructive) {
tournament.deleteGroupStages() tournament.deleteGroupStages()
tournament.deleteStructure() tournament.deleteStructure()
structurePreset = PadelTournamentStructurePreset.manual
} }
} }
} }

Loading…
Cancel
Save