From a0b6c41c863879ca2bc7f81db4b4074caabbecd8 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Sat, 29 Jun 2024 18:26:47 +0200 Subject: [PATCH] fix stuff --- PadelClub.xcodeproj/project.pbxproj | 14 ++- PadelClub/Data/AppSettings.swift | 2 +- PadelClub/Data/Club.swift | 2 +- PadelClub/Data/Court.swift | 2 +- PadelClub/Data/DateInterval.swift | 2 +- PadelClub/Data/Event.swift | 2 +- PadelClub/Data/GroupStage.swift | 2 +- PadelClub/Data/Match.swift | 2 +- PadelClub/Data/MatchScheduler.swift | 2 +- PadelClub/Data/MonthData.swift | 2 +- PadelClub/Data/PlayerRegistration.swift | 2 +- PadelClub/Data/Round.swift | 2 +- PadelClub/Data/TeamRegistration.swift | 2 +- PadelClub/Data/TeamScore.swift | 2 +- PadelClub/Data/Tournament.swift | 4 +- PadelClub/ViewModel/SeedInterval.swift | 12 ++- .../Views/Calling/GroupStageCallingView.swift | 2 +- .../GroupStage/GroupStageSettingsView.swift | 6 ++ .../LoserGroupStageSettingsView.swift | 85 +++++++++++++++++++ 19 files changed, 127 insertions(+), 22 deletions(-) create mode 100644 PadelClub/Views/GroupStage/LoserGroupStageSettingsView.swift diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 7e3feab..af99cbc 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -76,6 +76,7 @@ FF1162872BD004AD000C4809 /* EditingTeamView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF1162862BD004AD000C4809 /* EditingTeamView.swift */; }; FF11628A2BD05247000C4809 /* DateUpdateManagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF1162892BD05247000C4809 /* DateUpdateManagerView.swift */; }; FF11628C2BD05267000C4809 /* LoserRoundStepScheduleEditorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF11628B2BD05267000C4809 /* LoserRoundStepScheduleEditorView.swift */; }; + FF135BF92C2FCB8300C9247A /* LoserGroupStageSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF135BF82C2FCB8300C9247A /* LoserGroupStageSettingsView.swift */; }; FF1CBC1B2BB53D1F0036DAAB /* FederalTournament.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF1CBC182BB53D1F0036DAAB /* FederalTournament.swift */; }; FF1CBC1D2BB53DC10036DAAB /* Calendar+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF1CBC1C2BB53DC10036DAAB /* Calendar+Extensions.swift */; }; FF1CBC1F2BB53E0C0036DAAB /* FederalTournamentSearchScope.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF1CBC1E2BB53E0C0036DAAB /* FederalTournamentSearchScope.swift */; }; @@ -405,6 +406,7 @@ FF1162862BD004AD000C4809 /* EditingTeamView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditingTeamView.swift; sourceTree = ""; }; FF1162892BD05247000C4809 /* DateUpdateManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateUpdateManagerView.swift; sourceTree = ""; }; FF11628B2BD05267000C4809 /* LoserRoundStepScheduleEditorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoserRoundStepScheduleEditorView.swift; sourceTree = ""; }; + FF135BF82C2FCB8300C9247A /* LoserGroupStageSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoserGroupStageSettingsView.swift; sourceTree = ""; }; FF1CBC182BB53D1F0036DAAB /* FederalTournament.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FederalTournament.swift; sourceTree = ""; }; FF1CBC1C2BB53DC10036DAAB /* Calendar+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Calendar+Extensions.swift"; sourceTree = ""; }; FF1CBC1E2BB53E0C0036DAAB /* FederalTournamentSearchScope.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FederalTournamentSearchScope.swift; sourceTree = ""; }; @@ -1143,6 +1145,7 @@ FF967CFA2BAEE13800A9A3BD /* GroupStageView.swift */, FF967CFB2BAEE13900A9A3BD /* GroupStagesView.swift */, FF5DA18E2BB9268800A33061 /* GroupStageSettingsView.swift */, + FF135BF82C2FCB8300C9247A /* LoserGroupStageSettingsView.swift */, FF9AC3932BE3625D00C2E883 /* Components */, FF9AC3922BE3625200C2E883 /* Shared */, ); @@ -1529,6 +1532,7 @@ FF6EC8F72B94773200EA7F5A /* RowButtonView.swift in Sources */, FF2EFBF02BDE295E0049CE3B /* SendToAllView.swift in Sources */, FF8F263B2BAD528600650388 /* EventCreationView.swift in Sources */, + FF135BF92C2FCB8300C9247A /* LoserGroupStageSettingsView.swift in Sources */, FFC1E1082BAC29FC008D6F59 /* LocationManager.swift in Sources */, FF6087EC2BE26A2F004E1E47 /* BroadcastView.swift in Sources */, FFF964552BC266CF00EEF017 /* SchedulerView.swift in Sources */, @@ -1882,13 +1886,14 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 76; + CURRENT_PROJECT_VERSION = 77; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; ENABLE_MODULE_VERIFIER = YES; ENABLE_PREVIEWS = YES; + GCC_OPTIMIZATION_LEVEL = fast; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = PadelClub/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Padel Club"; @@ -1906,10 +1911,12 @@ ); MARKETING_VERSION = 0.1; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20"; - OTHER_SWIFT_FLAGS = ""; + OTHER_SWIFT_FLAGS = "-Onone"; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -1922,7 +1929,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 76; + CURRENT_PROJECT_VERSION = 77; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; @@ -1948,6 +1955,7 @@ OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-function-bodies=5 -Xfrontend -warn-long-expression-type-checking=20 -Xfrontend -warn-long-function-bodies=50"; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/PadelClub/Data/AppSettings.swift b/PadelClub/Data/AppSettings.swift index 89a5763..6f08933 100644 --- a/PadelClub/Data/AppSettings.swift +++ b/PadelClub/Data/AppSettings.swift @@ -10,7 +10,7 @@ import LeStorage import SwiftUI @Observable -class AppSettings: MicroStorable { +final class AppSettings: MicroStorable { var lastDataSource: String? = nil var didCreateAccount: Bool = false diff --git a/PadelClub/Data/Club.swift b/PadelClub/Data/Club.swift index f18437c..eea0604 100644 --- a/PadelClub/Data/Club.swift +++ b/PadelClub/Data/Club.swift @@ -10,7 +10,7 @@ import SwiftUI import LeStorage @Observable -class Club : ModelObject, Storable, Hashable { +final class Club : ModelObject, Storable, Hashable { static func resourceName() -> String { return "clubs" } static func tokenExemptedMethods() -> [HTTPMethod] { return [.get] } diff --git a/PadelClub/Data/Court.swift b/PadelClub/Data/Court.swift index e68e50c..4ef3998 100644 --- a/PadelClub/Data/Court.swift +++ b/PadelClub/Data/Court.swift @@ -10,7 +10,7 @@ import SwiftUI import LeStorage @Observable -class Court : ModelObject, Storable, Hashable { +final class Court : ModelObject, Storable, Hashable { static func resourceName() -> String { return "courts" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/DateInterval.swift b/PadelClub/Data/DateInterval.swift index a82036f..5c2c5b6 100644 --- a/PadelClub/Data/DateInterval.swift +++ b/PadelClub/Data/DateInterval.swift @@ -10,7 +10,7 @@ import SwiftUI import LeStorage @Observable -class DateInterval: ModelObject, Storable { +final class DateInterval: ModelObject, Storable { static func resourceName() -> String { return "date-intervals" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/Event.swift b/PadelClub/Data/Event.swift index 2bf385c..50dc9c2 100644 --- a/PadelClub/Data/Event.swift +++ b/PadelClub/Data/Event.swift @@ -10,7 +10,7 @@ import LeStorage import SwiftUI @Observable -class Event: ModelObject, Storable { +final class Event: ModelObject, Storable { static func resourceName() -> String { return "events" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/GroupStage.swift b/PadelClub/Data/GroupStage.swift index af6175a..570e32b 100644 --- a/PadelClub/Data/GroupStage.swift +++ b/PadelClub/Data/GroupStage.swift @@ -11,7 +11,7 @@ import Algorithms import SwiftUI @Observable -class GroupStage: ModelObject, Storable { +final class GroupStage: ModelObject, Storable { static func resourceName() -> String { "group-stages" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/Match.swift b/PadelClub/Data/Match.swift index 26814b2..7af5681 100644 --- a/PadelClub/Data/Match.swift +++ b/PadelClub/Data/Match.swift @@ -9,7 +9,7 @@ import Foundation import LeStorage @Observable -class Match: ModelObject, Storable { +final class Match: ModelObject, Storable { static func resourceName() -> String { "matches" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/MatchScheduler.swift b/PadelClub/Data/MatchScheduler.swift index 9bda2a8..60606e8 100644 --- a/PadelClub/Data/MatchScheduler.swift +++ b/PadelClub/Data/MatchScheduler.swift @@ -10,7 +10,7 @@ import LeStorage import SwiftUI @Observable -class MatchScheduler : ModelObject, Storable { +final class MatchScheduler : ModelObject, Storable { static func resourceName() -> String { return "match-scheduler" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/MonthData.swift b/PadelClub/Data/MonthData.swift index 8ad05c8..2dea761 100644 --- a/PadelClub/Data/MonthData.swift +++ b/PadelClub/Data/MonthData.swift @@ -10,7 +10,7 @@ import SwiftUI import LeStorage @Observable -class MonthData : ModelObject, Storable { +final class MonthData : ModelObject, Storable { static func resourceName() -> String { return "month-data" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/PlayerRegistration.swift b/PadelClub/Data/PlayerRegistration.swift index 78f46d2..373292f 100644 --- a/PadelClub/Data/PlayerRegistration.swift +++ b/PadelClub/Data/PlayerRegistration.swift @@ -9,7 +9,7 @@ import Foundation import LeStorage @Observable -class PlayerRegistration: ModelObject, Storable { +final class PlayerRegistration: ModelObject, Storable { static func resourceName() -> String { "player-registrations" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/Round.swift b/PadelClub/Data/Round.swift index 60a137f..942fdd9 100644 --- a/PadelClub/Data/Round.swift +++ b/PadelClub/Data/Round.swift @@ -10,7 +10,7 @@ import LeStorage import SwiftUI @Observable -class Round: ModelObject, Storable { +final class Round: ModelObject, Storable { static func resourceName() -> String { "rounds" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/TeamRegistration.swift b/PadelClub/Data/TeamRegistration.swift index a57cd16..e571013 100644 --- a/PadelClub/Data/TeamRegistration.swift +++ b/PadelClub/Data/TeamRegistration.swift @@ -9,7 +9,7 @@ import Foundation import LeStorage @Observable -class TeamRegistration: ModelObject, Storable { +final class TeamRegistration: ModelObject, Storable { static func resourceName() -> String { "team-registrations" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/TeamScore.swift b/PadelClub/Data/TeamScore.swift index 8d4a33c..0859b7c 100644 --- a/PadelClub/Data/TeamScore.swift +++ b/PadelClub/Data/TeamScore.swift @@ -9,7 +9,7 @@ import Foundation import LeStorage @Observable -class TeamScore: ModelObject, Storable { +final class TeamScore: ModelObject, Storable { static func resourceName() -> String { "team-scores" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 07b9c72..b2bcbd5 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -9,7 +9,7 @@ import Foundation import LeStorage @Observable -class Tournament : ModelObject, Storable { +final class Tournament : ModelObject, Storable { static func resourceName() -> String { "tournaments" } static func tokenExemptedMethods() -> [HTTPMethod] { return [] } @@ -1865,7 +1865,7 @@ defer { let selected = selectedSortedTeams() let allTeams = unsortedTeams() let seedCount = max(selected.count - groupStageSpots(), 0) - let newGroup = selected.prefix(seedCount) + let newGroup = selected.prefix(seedCount) + selected.filter({ $0.qualified }) let currentGroup = allTeams.filter({ $0.bracketPosition != nil }) let selectedIds = newGroup.map { $0.id } let groupIds = currentGroup.map { $0.id } diff --git a/PadelClub/ViewModel/SeedInterval.swift b/PadelClub/ViewModel/SeedInterval.swift index 91adb31..525e14e 100644 --- a/PadelClub/ViewModel/SeedInterval.swift +++ b/PadelClub/ViewModel/SeedInterval.swift @@ -37,9 +37,15 @@ struct SeedInterval: Hashable, Comparable { func chunks() -> [SeedInterval]? { if dimension > 3 { let split = dimension / 2 - let firstHalf = SeedInterval(first: first, last: first + split - 1, reduce: reduce) - let secondHalf = SeedInterval(first: first + split, last: last, reduce: reduce) - return [firstHalf, secondHalf] + if split%2 == 0 { + let firstHalf = SeedInterval(first: first, last: first + split - 1, reduce: reduce) + let secondHalf = SeedInterval(first: first + split, last: last, reduce: reduce) + return [firstHalf, secondHalf] + } else { + let firstHalf = SeedInterval(first: first, last: first + split, reduce: reduce) + let secondHalf = SeedInterval(first: first + split + 1, last: last, reduce: reduce) + return [firstHalf, secondHalf] + } } else { return nil } diff --git a/PadelClub/Views/Calling/GroupStageCallingView.swift b/PadelClub/Views/Calling/GroupStageCallingView.swift index 03d333b..0b95b62 100644 --- a/PadelClub/Views/Calling/GroupStageCallingView.swift +++ b/PadelClub/Views/Calling/GroupStageCallingView.swift @@ -85,7 +85,7 @@ struct GroupStageCallingView: View { } } .overlay { - if groupStage.startDate == nil { + if groupStage.startDate == nil && groupStage._matches().filter({ $0.startDate != nil }).isEmpty { ContentUnavailableView { Label("Aucun horaire défini", systemImage: "clock.badge.questionmark") } description: { diff --git a/PadelClub/Views/GroupStage/GroupStageSettingsView.swift b/PadelClub/Views/GroupStage/GroupStageSettingsView.swift index a2feafc..b39d49b 100644 --- a/PadelClub/Views/GroupStage/GroupStageSettingsView.swift +++ b/PadelClub/Views/GroupStage/GroupStageSettingsView.swift @@ -77,6 +77,12 @@ struct GroupStageSettingsView: View { } #endif +// NavigationLink { +// LoserGroupStageSettingsView(tournament: tournament) +// } label: { +// Text("Match de perdant de poules") +// } + if tournament.unsortedTeams().filter({ $0.groupStagePosition != nil }).isEmpty == false { Section { menuBuildAllGroupStages diff --git a/PadelClub/Views/GroupStage/LoserGroupStageSettingsView.swift b/PadelClub/Views/GroupStage/LoserGroupStageSettingsView.swift new file mode 100644 index 0000000..78ccdd0 --- /dev/null +++ b/PadelClub/Views/GroupStage/LoserGroupStageSettingsView.swift @@ -0,0 +1,85 @@ +// +// LoserGroupStageSettingsView.swift +// PadelClub +// +// Created by Razmig Sarkissian on 29/06/2024. +// + +import SwiftUI + +extension Round { + var isGroupStageLoserBracket: Bool { + return false + } +} + +extension Tournament { + func groupStageLoserBrackets() -> [Round] { + [] + } + + func removeGroupStageLoserBrackets() { + + } +} + +struct LoserGroupStageSettingsView: View { + var tournament: Tournament + @State private var loserGroupStageBracketType: Int? = nil + @State private var losers : Set = Set() + @Environment(\.editMode) private var editMode + + var body: some View { + List(selection: $losers) { + if tournament.groupStageLoserBrackets().isEmpty == false { + //for each all rounds without parent and loserGroupStage, ability to delete them + Section { + RowButtonView("Effacer", role: .destructive) { + tournament.removeGroupStageLoserBrackets() + } + } + } + + if self.editMode?.wrappedValue == .active { + Section { + //rajouter + toolbar valider / cancel + ForEach(tournament.groupStageTeams().filter({ $0.qualified == false })) { team in + TeamRowView(team: team).tag(team) + } + } header: { + Text("Sélection des perdants de poules") + } + } else { + Section { + RowButtonView("Ajouter un match de perdant") { + self.editMode?.wrappedValue = .active + } + } footer: { + Text("Permet d'ajouter un match de perdant de poules.") + } + } + } + .toolbar { + if self.editMode?.wrappedValue == .active { + ToolbarItem(placement: .topBarLeading) { + Button("Annuler") { + self.editMode?.wrappedValue = .inactive + } + } + + ToolbarItem(placement: .topBarTrailing) { + Button("Valider") { + self.editMode?.wrappedValue = .inactive + //tournament.createGroupStageLoserBracket() + } + } + } + } + .navigationTitle("Match de perdant de poules") + .navigationBarBackButtonHidden(self.editMode?.wrappedValue == .active) + .navigationBarTitleDisplayMode(.inline) + .toolbar(.visible, for: .navigationBar) + .headerProminence(.increased) + .toolbarBackground(.visible, for: .navigationBar) + } +}