fix text stuff

multistore
Razmig Sarkissian 1 year ago
parent 89d62ae118
commit ea0159e3df
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 4
      PadelClub/Data/Round.swift
  3. 38
      PadelClub/Data/Tournament.swift
  4. 2
      PadelClub/Utils/PadelRule.swift
  5. 2
      PadelClub/Views/Calling/CallSettingsView.swift
  6. 40
      PadelClub/Views/Planning/SchedulerView.swift
  7. 2
      PadelClub/Views/Tournament/Screen/TournamentScheduleView.swift
  8. 78
      PadelClub/Views/Tournament/TournamentBuildView.swift
  9. 10
      PadelClub/Views/Tournament/TournamentInitView.swift

@ -1878,7 +1878,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 69; CURRENT_PROJECT_VERSION = 71;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -1918,7 +1918,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 69; CURRENT_PROJECT_VERSION = 71;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6; DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -36,7 +36,7 @@ class Round: ModelObject, Storable {
} }
func _matches() -> [Match] { func _matches() -> [Match] {
return DataStore.shared.matches.filter { $0.round == self.id } return DataStore.shared.matches.filter { $0.round == self.id }.sorted(by: \.index)
} }
func getDisabledMatches() -> [Match] { func getDisabledMatches() -> [Match] {
@ -249,7 +249,7 @@ defer {
} }
func enabledMatches() -> [Match] { func enabledMatches() -> [Match] {
return DataStore.shared.matches.filter { $0.round == self.id && $0.disabled == false } return DataStore.shared.matches.filter { $0.round == self.id && $0.disabled == false }.sorted(by: \.index)
} }
func displayableMatches() -> [Match] { func displayableMatches() -> [Match] {

@ -1394,20 +1394,28 @@ defer {
return TournamentStatus(label: label, completion: completionLabel) return TournamentStatus(label: label, completion: completionLabel)
} }
func bracketStatus() async -> (status: String, cut: TeamRegistration.TeamRange?) { func bracketStatus() async -> (status: String, description: String?, cut: TeamRegistration.TeamRange?) {
let availableSeeds = availableSeeds() let availableSeeds = availableSeeds()
let cut = TeamRegistration.TeamRange(availableSeeds.first, availableSeeds.last) var description: String? = nil
if availableSeeds.isEmpty == false { if availableSeeds.isEmpty == false {
return ("placer \(availableSeeds.count) tête\(availableSeeds.count.pluralSuffix) de série", cut) description = "placer \(availableSeeds.count) équipe\(availableSeeds.count.pluralSuffix)"
} }
let availableQualifiedTeams = availableQualifiedTeams() if description == nil {
if availableQualifiedTeams.isEmpty == false { let availableQualifiedTeams = availableQualifiedTeams()
return ("placer \(availableQualifiedTeams.count) qualifié" + availableQualifiedTeams.count.pluralSuffix, cut) if availableQualifiedTeams.isEmpty == false {
description = "placer \(availableQualifiedTeams.count) qualifié" + availableQualifiedTeams.count.pluralSuffix
}
}
var cut: TeamRegistration.TeamRange? = nil
if description == nil && isAnimation() == false {
cut = TeamRegistration.TeamRange(availableSeeds.first, availableSeeds.last)
} }
if let round = getActiveRound() { if let round = getActiveRound() {
return ([round.roundTitle(.short), round.roundStatus()].joined(separator: " "), cut) return ([round.roundTitle(.short), round.roundStatus()].joined(separator: " ").lowercased(), description, cut)
} else { } else {
return ("à construire", nil) return ("", description, nil)
} }
} }
@ -1415,10 +1423,10 @@ defer {
let groupStageTeams = groupStageTeams() let groupStageTeams = groupStageTeams()
let groupStageTeamsCount = groupStageTeams.count let groupStageTeamsCount = groupStageTeams.count
if groupStageTeamsCount == 0 || groupStageTeamsCount != groupStageSpots() { if groupStageTeamsCount == 0 || groupStageTeamsCount != groupStageSpots() {
return ("à faire", nil) return ("à compléter", nil)
} }
let cut = TeamRegistration.TeamRange(groupStageTeams.first, groupStageTeams.last) let cut : TeamRegistration.TeamRange? = isAnimation() ? nil : TeamRegistration.TeamRange(groupStageTeams.first, groupStageTeams.last)
let runningGroupStages = groupStages().filter({ $0.isRunning() }) let runningGroupStages = groupStages().filter({ $0.isRunning() })
if groupStagesAreOver() { return ("terminées", cut) } if groupStagesAreOver() { return ("terminées", cut) }
@ -1435,16 +1443,12 @@ defer {
} }
func settingsDescriptionLocalizedLabel() -> String { func settingsDescriptionLocalizedLabel() -> String {
[dayDuration.formatted() + " jour\(dayDuration.pluralSuffix)", courtCount.formatted() + " terrain\(courtCount.pluralSuffix)"].joined(separator: ", ") [courtCount.formatted() + " terrain\(courtCount.pluralSuffix)", entryFeeMessage].joined(separator: ", ")
} }
func structureDescriptionLocalizedLabel() -> String { func structureDescriptionLocalizedLabel() -> String {
if state() == .initial { let groupStageLabel: String? = groupStageCount > 0 ? groupStageCount.formatted() + " poule\(groupStageCount.pluralSuffix)" : nil
return "à valider" return [teamCount.formatted() + " équipes", groupStageLabel].compactMap({ $0 }).joined(separator: ", ")
} else {
let groupStageLabel: String? = groupStageCount > 0 ? groupStageCount.formatted() + " poule\(groupStageCount.pluralSuffix)" : nil
return [teamCount.formatted() + " équipes", groupStageLabel].compactMap({ $0 }).joined(separator: ", ")
}
} }
func deleteAndBuildEverything() { func deleteAndBuildEverything() {

@ -342,7 +342,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable {
return .twoSetsDecisivePointSuperTie return .twoSetsDecisivePointSuperTie
} }
default: default:
return .twoSetsDecisivePoint return .superTie
} }
} }

@ -46,7 +46,7 @@ struct CallSettingsView: View {
Logger.error(error) Logger.error(error)
} }
} label: { } label: {
Text(.init("Le tournoi n'est pas visible sur [Padel Club](\(URLs.main.rawValue)), ")).foregroundStyle(.logoRed) + Text("le rendre visible ?").underline().foregroundStyle(.master) Text(.init("Le tournoi est privée, le publier ?")).underline().foregroundStyle(.master)
} }
} }
} }

@ -50,13 +50,15 @@ struct SchedulerView: View {
} }
} footer: { } footer: {
if tournament.groupStageMatchFormat.weight > tournament.groupStageSmartMatchFormat().weight { if tournament.isAnimation() == false {
Button { if tournament.groupStageMatchFormat.weight > tournament.groupStageSmartMatchFormat().weight {
tournament.groupStageMatchFormat = tournament.groupStageSmartMatchFormat() Button {
} label: { tournament.groupStageMatchFormat = tournament.groupStageSmartMatchFormat()
Text("devrait être joué au moins en " + tournament.groupStageSmartMatchFormat().format + ", ") + Text("modifier ?").underline().foregroundStyle(.master) } label: {
Text("devrait être joué au moins en " + tournament.groupStageSmartMatchFormat().format + ", ") + Text("modifier ?").underline().foregroundStyle(.master)
}
.buttonStyle(.plain)
} }
.buttonStyle(.plain)
} }
} }
@ -117,19 +119,21 @@ struct SchedulerView: View {
} header: { } header: {
Text(round.titleLabel()) Text(round.titleLabel())
} footer: { } footer: {
let federalFormat = tournament.roundSmartMatchFormat(round.index) if tournament.isAnimation() == false {
if round.matchFormat.weight > federalFormat.weight { let federalFormat = tournament.roundSmartMatchFormat(round.index)
Button { if round.matchFormat.weight > federalFormat.weight {
round.updateMatchFormatAndAllMatches(federalFormat) Button {
do { round.updateMatchFormatAndAllMatches(federalFormat)
try dataStore.rounds.addOrUpdate(instance: round) do {
} catch { try dataStore.rounds.addOrUpdate(instance: round)
Logger.error(error) } catch {
Logger.error(error)
}
} label: {
Text("devrait être joué au moins en " + federalFormat.format + ", ") + Text("modifier ?").underline().foregroundStyle(.master)
} }
} label: { .buttonStyle(.plain)
Text("devrait être joué au moins en " + federalFormat.format + ", ") + Text("modifier ?").underline().foregroundStyle(.master)
} }
.buttonStyle(.plain)
} }
} }
@ -160,7 +164,7 @@ struct SchedulerView: View {
} header: { } header: {
Text("Match de classement \(round.roundTitle(.short))") Text("Match de classement \(round.roundTitle(.short))")
} footer: { } footer: {
if round.index == 1, let semi = round.loserRounds().first { if tournament.isAnimation() == false, round.index == 1, let semi = round.loserRounds().first {
let federalFormat = tournament.loserBracketSmartMatchFormat(1) let federalFormat = tournament.loserBracketSmartMatchFormat(1)
if semi.matchFormat.weight > federalFormat.weight { if semi.matchFormat.weight > federalFormat.weight {
Button { Button {

@ -92,7 +92,7 @@ struct TournamentScheduleView: View {
} }
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar)
.navigationTitle("Horaires") .navigationTitle("Horaires et formats")
} }
} }

@ -9,7 +9,7 @@ import SwiftUI
struct TournamentBuildView: View { struct TournamentBuildView: View {
var tournament: Tournament var tournament: Tournament
@State private var bracketStatus: (status: String, cut: TeamRegistration.TeamRange?)? @State private var bracketStatus: (status: String, description: String?, cut: TeamRegistration.TeamRange?)?
@State private var groupStageStatus: (String, TeamRegistration.TeamRange?)? @State private var groupStageStatus: (String, TeamRegistration.TeamRange?)?
@State private var callStatus: Tournament.TournamentStatus? @State private var callStatus: Tournament.TournamentStatus?
@State private var scheduleStatus: Tournament.TournamentStatus? @State private var scheduleStatus: Tournament.TournamentStatus?
@ -65,7 +65,9 @@ struct TournamentBuildView: View {
Text("Tableau") Text("Tableau")
if tournament.shouldVerifyBracket { if tournament.shouldVerifyBracket {
Text("Vérifier la tableau").foregroundStyle(.logoRed) Text("Vérifier la tableau").foregroundStyle(.logoRed)
} else if let range = bracketStatus?.1 { } else if let description = bracketStatus?.1 {
Text(description)
} else if let range = bracketStatus?.2 {
HStack { HStack {
if let left = range.left { if let left = range.left {
Text(left.weight.formatted()) Text(left.weight.formatted())
@ -98,48 +100,46 @@ struct TournamentBuildView: View {
TournamentBroadcastRowView(tournament: tournament) TournamentBroadcastRowView(tournament: tournament)
} }
if state != .finished { NavigationLink(value: Screen.schedule) {
NavigationLink(value: Screen.schedule) { let tournamentStatus = scheduleStatus
let tournamentStatus = scheduleStatus LabeledContent {
LabeledContent { if let tournamentStatus {
if let tournamentStatus { Text(tournamentStatus.completion)
Text(tournamentStatus.completion) } else {
} else { ProgressView()
ProgressView() }
} } label: {
} label: { Text("Horaires et formats")
Text("Horaires") if let tournamentStatus {
if let tournamentStatus { Text(tournamentStatus.label).lineLimit(1)
Text(tournamentStatus.label).lineLimit(1) } else {
} else { Text(" ")
Text(" ")
}
} }
} }
.task { }
scheduleStatus = await tournament.scheduleStatus() .task {
} scheduleStatus = await tournament.scheduleStatus()
}
NavigationLink(value: Screen.call) { NavigationLink(value: Screen.call) {
let tournamentStatus = callStatus let tournamentStatus = callStatus
LabeledContent { LabeledContent {
if let tournamentStatus { if let tournamentStatus {
Text(tournamentStatus.completion) Text(tournamentStatus.completion)
} else { } else {
ProgressView() ProgressView()
} }
} label: { } label: {
Text("Convocations") Text("Convocations")
if let tournamentStatus { if let tournamentStatus {
Text(tournamentStatus.label).lineLimit(1) Text(tournamentStatus.label).lineLimit(1)
} else { } else {
Text(" ") Text(" ")
}
} }
} }
.task { }
callStatus = await tournament.callStatus() .task {
} callStatus = await tournament.callStatus()
} }
NavigationLink(value: Screen.cashier) { NavigationLink(value: Screen.cashier) {

@ -28,17 +28,23 @@ struct TournamentInitView: View {
NavigationLink(value: Screen.structure) { NavigationLink(value: Screen.structure) {
LabeledContent { LabeledContent {
Text(tournament.structureDescriptionLocalizedLabel()) if tournament.state() == .initial {
Text("à valider")
} else {
Image(systemName: "checkmark").foregroundStyle(.green)
}
} label: { } label: {
LabelStructure() LabelStructure()
Text(tournament.structureDescriptionLocalizedLabel())
} }
} }
NavigationLink(value: Screen.settings) { NavigationLink(value: Screen.settings) {
LabeledContent { LabeledContent {
Text(tournament.settingsDescriptionLocalizedLabel()) Text(tournament.tournamentTitle(.short))
} label: { } label: {
LabelSettings() LabelSettings()
Text("Formats, statut, club, prix, etc.")
} }
} }

Loading…
Cancel
Save