From 610e69f0d432b597e4db3687e1db4b71352287da Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 9 Jul 2024 16:24:17 +0200 Subject: [PATCH 1/3] fix stuff loser bracket / spin drawing --- PadelClub/Data/Round.swift | 2 +- .../Views/Components/FortuneWheelView.swift | 16 ++-- .../Views/Planning/PlanningSettingsView.swift | 8 +- PadelClub/Views/Round/LoserRoundView.swift | 14 +++ PadelClub/Views/Round/LoserRoundsView.swift | 2 - PadelClub/Views/Round/RoundSettingsView.swift | 9 +- PadelClub/Views/Round/RoundView.swift | 85 +++++++++++-------- 7 files changed, 85 insertions(+), 51 deletions(-) diff --git a/PadelClub/Data/Round.swift b/PadelClub/Data/Round.swift index 3305cb6..d74c31d 100644 --- a/PadelClub/Data/Round.swift +++ b/PadelClub/Data/Round.swift @@ -480,7 +480,7 @@ defer { if (previousRound.enabledMatches().isEmpty == false || initialMode) { return previousRound.seedInterval(initialMode: initialMode)?.chunks()?.first } else { - return previousRound.previousRound()?.seedInterval(initialMode: initialMode) + return previousRound.seedInterval(initialMode: initialMode) } } else if let parentRound { if parentRound.parent == nil { diff --git a/PadelClub/Views/Components/FortuneWheelView.swift b/PadelClub/Views/Components/FortuneWheelView.swift index f96f5f9..3005457 100644 --- a/PadelClub/Views/Components/FortuneWheelView.swift +++ b/PadelClub/Views/Components/FortuneWheelView.swift @@ -62,7 +62,7 @@ struct SpinDrawView: View { let drawees: [any SpinDrawable] @State var segments: [any SpinDrawable] var autoMode: Bool = false - let completion: ([DrawResult]) -> Void // Completion closure + let completion: ([DrawResult]) async -> Void // Completion closure @State private var drawCount: Int = 0 @State private var draws: [DrawResult] = [DrawResult]() @@ -82,7 +82,7 @@ struct SpinDrawView: View { _validationLabelView(drawee: drawCount, result: segments[draws.last!.drawIndex]) if autoMode == false || drawCount == drawees.count { RowButtonView("Valider le tirage") { - completion(draws) + await completion(draws) dismiss() } } @@ -173,10 +173,16 @@ struct SpinDrawView: View { ToolbarItem(placement: .topBarTrailing) { Button { validating = true - completion(draws) - dismiss() + Task { + await completion(draws) + dismiss() + } } label: { - Text("Tout valider") + if validating { + ProgressView() + } else { + Text("Tout valider") + } } } diff --git a/PadelClub/Views/Planning/PlanningSettingsView.swift b/PadelClub/Views/Planning/PlanningSettingsView.swift index dd2a326..53873bc 100644 --- a/PadelClub/Views/Planning/PlanningSettingsView.swift +++ b/PadelClub/Views/Planning/PlanningSettingsView.swift @@ -220,8 +220,12 @@ struct PlanningSettingsView: View { } label: { Text("Poules en parallèle") let value = tournament.getGroupStageChunkValue() - if parallelType == false, value > 1 { - Text("\(value.formatted()) poules commenceront en parallèle") + if parallelType == false { + if value > 1 { + Text("\(value.formatted()) poules commenceront en parallèle") + } else { + Text("une poule sera jouer à la fois") + } } } .onChange(of: parallelType) { diff --git a/PadelClub/Views/Round/LoserRoundView.swift b/PadelClub/Views/Round/LoserRoundView.swift index 19fc8bc..5a0f4c1 100644 --- a/PadelClub/Views/Round/LoserRoundView.swift +++ b/PadelClub/Views/Round/LoserRoundView.swift @@ -65,6 +65,20 @@ struct LoserRoundView: View { Spacer() Text(seedIntervalPointRange) .font(.caption) + } else { + if let previousRound = loserRound.previousRound() { + if let seedInterval = previousRound.seedInterval() { + Text(seedInterval.localizedLabel()) + } else { + Text("no previous round") + } + } else if let parentRound = loserRound.parentRound { + if let seedInterval = parentRound.seedInterval() { + Text(seedInterval.localizedLabel()) + } else { + Text("no parent round") + } + } } } } diff --git a/PadelClub/Views/Round/LoserRoundsView.swift b/PadelClub/Views/Round/LoserRoundsView.swift index 453dff3..b2c0fac 100644 --- a/PadelClub/Views/Round/LoserRoundsView.swift +++ b/PadelClub/Views/Round/LoserRoundsView.swift @@ -15,13 +15,11 @@ class UpperRound: Identifiable, Selectable { }() let title: String let playedMatches: [Match] - let correspondingLoserRoundTitle: String init(round: Round) { self.round = round self.title = round.roundTitle(.short) self.playedMatches = round.playedMatches() - self.correspondingLoserRoundTitle = round.correspondingLoserRoundTitle() } func loserMatches() -> [Match] { diff --git a/PadelClub/Views/Round/RoundSettingsView.swift b/PadelClub/Views/Round/RoundSettingsView.swift index c34b4bd..d5e79ce 100644 --- a/PadelClub/Views/Round/RoundSettingsView.swift +++ b/PadelClub/Views/Round/RoundSettingsView.swift @@ -99,14 +99,15 @@ struct RoundSettingsView: View { let nextRound = round.nextRound() var currentIndex = 0 let matches = (0.. Date: Tue, 9 Jul 2024 16:24:39 +0200 Subject: [PATCH 2/3] v90 --- PadelClub.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 0b6ee7c..41c09d0 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -1906,7 +1906,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -1950,7 +1950,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 89; + CURRENT_PROJECT_VERSION = 90; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; From 4c4c7b8489ef412840b58085797ff5e62f79ad9a Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 9 Jul 2024 16:39:22 +0200 Subject: [PATCH 3/3] fix default match format fix default tournament configuration view --- PadelClub/Data/Tournament.swift | 4 ++-- .../Views/Cashier/Event/TournamentConfiguratorView.swift | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 3fb6655..fc680c2 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -1827,8 +1827,8 @@ defer { func setupFederalSettings() { teamSorting = tournamentLevel.defaultTeamSortingType groupStageMatchFormat = groupStageSmartMatchFormat() - loserBracketMatchFormat = loserBracketSmartMatchFormat(1) - matchFormat = roundSmartMatchFormat(1) + loserBracketMatchFormat = loserBracketSmartMatchFormat(5) + matchFormat = roundSmartMatchFormat(5) } func roundSmartMatchFormat(_ roundIndex: Int) -> MatchFormat { diff --git a/PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift b/PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift index 1f36215..65ecfc3 100644 --- a/PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift +++ b/PadelClub/Views/Cashier/Event/TournamentConfiguratorView.swift @@ -29,6 +29,13 @@ struct TournamentConfigurationView: View { if tournament.federalLevelCategory == .unlisted { tournament.federalCategory = .unlisted tournament.federalAgeCategory = .unlisted + } else { + if tournament.federalCategory == .unlisted { + tournament.federalCategory = .men + } + if tournament.federalAgeCategory == .unlisted { + tournament.federalAgeCategory = .senior + } } } Picker(selection: $tournament.federalCategory, label: Text("Catégorie")) {