diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 96b966c..fdcffe6 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -150,9 +150,9 @@ class Tournament : ModelObject, Storable { } func state() -> Tournament.State { - if currentCanceled == true { - return .canceled - } +// if currentCanceled == true { +// return .canceled +// } if (groupStageCount > 0 && groupStages().isEmpty == false) || rounds().isEmpty == false { return .build @@ -377,7 +377,7 @@ class Tournament : ModelObject, Storable { } func selectedSortedTeams() -> [TeamRegistration] { - let start = Date() + //let start = Date() var _sortedTeams : [TeamRegistration] = [] let _teams = unsortedTeams().filter({ $0.walkOut == false }) diff --git a/PadelClub/Extensions/Locale+Extensions.swift b/PadelClub/Extensions/Locale+Extensions.swift index e1d91ba..5e6534b 100644 --- a/PadelClub/Extensions/Locale+Extensions.swift +++ b/PadelClub/Extensions/Locale+Extensions.swift @@ -12,8 +12,8 @@ extension Locale { static func countries() -> [String] { var countries: [String] = [] - for countryCode in Locale.isoRegionCodes { - if let countryName = Locale.current.localizedString(forRegionCode: countryCode) { + for countryCode in Locale.Region.isoRegions { + if let countryName = Locale.current.localizedString(forRegionCode: countryCode.identifier) { countries.append(countryName) } } diff --git a/PadelClub/Utils/CloudConvert.swift b/PadelClub/Utils/CloudConvert.swift index 11962cb..6a5a28f 100644 --- a/PadelClub/Utils/CloudConvert.swift +++ b/PadelClub/Utils/CloudConvert.swift @@ -60,7 +60,7 @@ class CloudConvert { request.httpBody = postData let task = try await URLSession.shared.data(for: request) - print("tried: \(request.url)") + //print("tried: \(request.url)") if let errorResponse = try? JSONDecoder().decode(ErrorResponse.self, from: task.0) { print("errorResponse.error", errorResponse.error) throw CloudConvertionError.serviceError(errorResponse) @@ -77,7 +77,7 @@ class CloudConvert { uploadRequest.httpMethod = "PUT" let uploadTask = try await URLSession.shared.upload(for: uploadRequest, fromFile: url) - print("tried: \(uploadRequest.url)") + //print("tried: \(uploadRequest.url)") if let errorResponse = try? JSONDecoder().decode(ErrorResponse.self, from: uploadTask.0) { print("errorResponse.error", errorResponse.error) throw CloudConvertionError.serviceError(errorResponse) @@ -94,7 +94,7 @@ class CloudConvert { request.httpMethod = "GET" let task = try await URLSession.shared.data(for: request) - print("tried: \(request.url)") + //print("tried: \(request.url)") if let errorResponse = try? JSONDecoder().decode(ErrorResponse.self, from: task.0) { print("errorResponse.error", errorResponse.error) throw CloudConvertionError.serviceError(errorResponse) @@ -117,7 +117,7 @@ class CloudConvert { throw CloudConvertionError.serviceError(errorResponse) } - print("tried: \(downloadRequest.url)") + //print("tried: \(downloadRequest.url)") let dataResponse = try JSONDecoder().decode(DataResponse.self, from: downloadTask.0) if let decodedData = Data(base64Encoded: dataResponse.data.content), let string = String(data: decodedData, encoding: .utf8) { return string diff --git a/PadelClub/Utils/ContactManager.swift b/PadelClub/Utils/ContactManager.swift index 005e736..56cb08f 100644 --- a/PadelClub/Utils/ContactManager.swift +++ b/PadelClub/Utils/ContactManager.swift @@ -57,7 +57,7 @@ extension ContactType { static func callingGroupStageMessage(tournament: Tournament?, startDate: Date?, roundLabel: String, matchFormat: MatchFormat?) -> String { - let useFullCustomMessage = DataStore.shared.appSettings.callUseFullCustomMessage ?? false + let useFullCustomMessage = DataStore.shared.appSettings.callUseFullCustomMessage if useFullCustomMessage { return callingGroupStageCustomMessage(tournament: tournament, startDate: startDate, roundLabel: roundLabel) @@ -72,11 +72,11 @@ extension ContactType { let localizedCalled = "convoqué" + (tournament?.tournamentCategory == .women ? "e" : "") + "s" var formatMessage: String? { - (DataStore.shared.appSettings.callDisplayFormat ?? false) ? matchFormat?.computedLongLabel.appending(".") : nil + (DataStore.shared.appSettings.callDisplayFormat) ? matchFormat?.computedLongLabel.appending(".") : nil } var entryFeeMessage: String? { - (DataStore.shared.appSettings.callDisplayEntryFee ?? false) ? tournament?.entryFeeMessage : nil + (DataStore.shared.appSettings.callDisplayEntryFee) ? tournament?.entryFeeMessage : nil } var computedMessage: String { diff --git a/PadelClub/ViewModel/MatchScheduler.swift b/PadelClub/ViewModel/MatchScheduler.swift index 65cb618..6c4708d 100644 --- a/PadelClub/ViewModel/MatchScheduler.swift +++ b/PadelClub/ViewModel/MatchScheduler.swift @@ -502,7 +502,6 @@ class MatchScheduler { } func updateBracketSchedule(tournament: Tournament, fromRoundId roundId: String?, fromMatchId matchId: String?, startDate: Date) { - let numberOfCourtsAvailablePerRotation: Int = tournament.courtCount courtsUnavailability = tournament.eventObject?.courtsUnavailability let upperRounds = tournament.rounds() @@ -522,7 +521,7 @@ class MatchScheduler { } } - var flattenedMatches = rounds.flatMap { round in + let flattenedMatches = rounds.flatMap { round in round._matches().filter({ $0.disabled == false }).sorted(by: \.index) } @@ -575,7 +574,7 @@ class MatchScheduler { let courts : [Int]? = initialCourts.isEmpty ? nil : initialCourts - print("initial available courts at beginning: \(courts)") + print("initial available courts at beginning: \(courts ?? [])") let roundDispatch = self.roundDispatcher(numberOfCourtsAvailablePerRotation: tournament.courtCount, flattenedMatches: flattenedMatches, dispatcherStartDate: startDate, initialCourts: courts) @@ -608,7 +607,6 @@ class MatchScheduler { } func updateSchedule(tournament: Tournament) { - let numberOfCourtsAvailablePerRotation: Int = tournament.courtCount courtsUnavailability = tournament.eventObject?.courtsUnavailability let lastDate = updateGroupStageSchedule(tournament: tournament) updateBracketSchedule(tournament: tournament, fromRoundId: nil, fromMatchId: nil, startDate: lastDate) diff --git a/PadelClub/Views/Cashier/CashierView.swift b/PadelClub/Views/Cashier/CashierView.swift index a20c4fe..9236a46 100644 --- a/PadelClub/Views/Cashier/CashierView.swift +++ b/PadelClub/Views/Cashier/CashierView.swift @@ -21,7 +21,7 @@ struct CashierView: View { init(tournament: Tournament, teams: [TeamRegistration]) { self.tournaments = [tournament] self.teams = teams - if teams.filter { $0.callDate != nil }.isEmpty { + if teams.filter({ $0.callDate != nil }).isEmpty { _sortOption = .init(wrappedValue: .teamRank) } else { _sortOption = .init(wrappedValue: .callDate) diff --git a/PadelClub/Views/Components/FortuneWheelView.swift b/PadelClub/Views/Components/FortuneWheelView.swift index ac3a688..c31a452 100644 --- a/PadelClub/Views/Components/FortuneWheelView.swift +++ b/PadelClub/Views/Components/FortuneWheelView.swift @@ -74,7 +74,7 @@ struct SpinDrawView: View { Text(time, style: .timer) } - if let selectedIndex { + if selectedIndex != nil { Section { Text(validationLabel(drawee: drawCount, result: segments[draws.last!.drawIndex])) if autoMode == false || drawCount == drawees.count { diff --git a/PadelClub/Views/Match/MatchDetailView.swift b/PadelClub/Views/Match/MatchDetailView.swift index a392a05..5f61db8 100644 --- a/PadelClub/Views/Match/MatchDetailView.swift +++ b/PadelClub/Views/Match/MatchDetailView.swift @@ -406,7 +406,7 @@ struct MatchDetailView: View { } label: { Text("Horaire") } - .onChange(of: startDateSetup, perform: { value in + .onChange(of: startDateSetup) { switch startDateSetup { case .customDate: break @@ -415,7 +415,7 @@ struct MatchDetailView: View { case .inMinutes(let minutes): startDate = Date().addingTimeInterval(Double(minutes) * 60) } - }) + } } if match.startDate != nil || startDateSetup == .customDate { diff --git a/PadelClub/Views/Navigation/MainView.swift b/PadelClub/Views/Navigation/MainView.swift index 2395e2c..94768e7 100644 --- a/PadelClub/Views/Navigation/MainView.swift +++ b/PadelClub/Views/Navigation/MainView.swift @@ -91,7 +91,7 @@ struct MainView: View { } private func _checkSourceFileAvailability() async { - print(dataStore.appSettings.lastDataSource) + print("dataStore.appSettings.lastDataSource :", dataStore.appSettings.lastDataSource ?? "none") print("check internet") print("check files on internet") print("check if any files on internet are more recent than here") diff --git a/PadelClub/Views/Round/RoundView.swift b/PadelClub/Views/Round/RoundView.swift index f00ea1f..4fba924 100644 --- a/PadelClub/Views/Round/RoundView.swift +++ b/PadelClub/Views/Round/RoundView.swift @@ -21,7 +21,7 @@ struct RoundView: View { if isEditingTournamentSeed.wrappedValue == false { //(where: { $0.isDisabled() == false || isEditingTournamentSeed.wrappedValue }) - if loserRounds.isEmpty == false, let first = loserRounds.first { + if loserRounds.isEmpty == false { let correspondingLoserRoundTitle = round.correspondingLoserRoundTitle() Section { NavigationLink { diff --git a/PadelClub/Views/Score/EditScoreView.swift b/PadelClub/Views/Score/EditScoreView.swift index 58d93a7..3c71dbd 100644 --- a/PadelClub/Views/Score/EditScoreView.swift +++ b/PadelClub/Views/Score/EditScoreView.swift @@ -47,7 +47,7 @@ struct EditScoreView: View { Spacer() MatchTypeSmallSelectionView(selectedFormat: $matchDescriptor.matchFormat, format: "Format") - .onChange(of: matchDescriptor.matchFormat) { newValue in + .onChange(of: matchDescriptor.matchFormat) { matchDescriptor.setDescriptors.removeAll() matchDescriptor.addNewSet() } @@ -55,8 +55,8 @@ struct EditScoreView: View { } ForEach($matchDescriptor.setDescriptors) { $setDescriptor in SetInputView(setDescriptor: $setDescriptor) - .onChange(of: setDescriptor.hasEnded) { hasEnded in - if hasEnded { + .onChange(of: setDescriptor.hasEnded) { + if setDescriptor.hasEnded { if matchDescriptor.hasEnded == false { matchDescriptor.addNewSet() } diff --git a/PadelClub/Views/Score/SetInputView.swift b/PadelClub/Views/Score/SetInputView.swift index d69919b..3e4c787 100644 --- a/PadelClub/Views/Score/SetInputView.swift +++ b/PadelClub/Views/Score/SetInputView.swift @@ -137,8 +137,8 @@ struct SetInputView: View { } } } - .onChange(of: setDescriptor.valueTeamOne, perform: { newValue in - if let newValue { + .onChange(of: setDescriptor.valueTeamOne) { + if let newValue = setDescriptor.valueTeamOne { if newValue == setFormat.scoreToWin - 1 && setFormat.tieBreak == 8 { setDescriptor.valueTeamTwo = setFormat.scoreToWin } else if newValue == setFormat.scoreToWin - 2 && setFormat.tieBreak == 8 { @@ -154,14 +154,14 @@ struct SetInputView: View { } } - }) - .onChange(of: setDescriptor.valueTeamTwo, perform: { newValue in + } + .onChange(of: setDescriptor.valueTeamTwo) { if setDescriptor.valueTeamOne != nil && setDescriptor.valueTeamTwo != nil { showSetInputView = false } - }) - .onChange(of: setDescriptor.tieBreakValueTeamOne, perform: { newValue in - if let newValue, setDescriptor.tieBreakValueTeamTwo == nil { + } + .onChange(of: setDescriptor.tieBreakValueTeamOne) { + if let newValue = setDescriptor.tieBreakValueTeamOne, setDescriptor.tieBreakValueTeamTwo == nil { if newValue > 7 { setDescriptor.tieBreakValueTeamTwo = newValue - 2 } @@ -172,7 +172,7 @@ struct SetInputView: View { setDescriptor.tieBreakValueTeamTwo = 7 } } - else if let newValue, let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo { + else if let newValue = setDescriptor.tieBreakValueTeamOne, let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo { if newValue > 6 && tieBreakValueTeamTwo < newValue { setDescriptor.tieBreakValueTeamTwo = newValue - 2 } @@ -187,31 +187,28 @@ struct SetInputView: View { showTieBreakInputView = false } } - }) - .onChange(of: setDescriptor.tieBreakValueTeamTwo, perform: { newValue in + } + .onChange(of: setDescriptor.tieBreakValueTeamTwo) { if let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne, tieBreakValueTeamOne <= 5 { showTieBreakInputView = false } else { if let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo { - if let newValue { - if newValue > 6 && tieBreakValueTeamTwo > setDescriptor.tieBreakValueTeamOne ?? 0 { - setDescriptor.tieBreakValueTeamOne = newValue - 2 - } - if newValue > 4 && tieBreakValueTeamTwo < setDescriptor.tieBreakValueTeamOne ?? 0 { - setDescriptor.tieBreakValueTeamOne = newValue + 2 - } + if tieBreakValueTeamTwo > 6 && tieBreakValueTeamTwo > setDescriptor.tieBreakValueTeamOne ?? 0 { + setDescriptor.tieBreakValueTeamOne = tieBreakValueTeamTwo - 2 + } + if tieBreakValueTeamTwo > 4 && tieBreakValueTeamTwo < setDescriptor.tieBreakValueTeamOne ?? 0 { + setDescriptor.tieBreakValueTeamOne = tieBreakValueTeamTwo + 2 } } - if let newValue, let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne { - if newValue < 6 && tieBreakValueTeamOne == 7 { + if let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo, let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne { + if tieBreakValueTeamTwo < 6 && tieBreakValueTeamOne == 7 { showTieBreakInputView = false } } } - }) - + } .listRowSeparator(.hidden) } } diff --git a/PadelClub/Views/Score/SetLabelView.swift b/PadelClub/Views/Score/SetLabelView.swift index 7071bc3..abe6c28 100644 --- a/PadelClub/Views/Score/SetLabelView.swift +++ b/PadelClub/Views/Score/SetLabelView.swift @@ -42,10 +42,10 @@ struct SetLabelView: View { .scaleEffect(0.7) } } - .onChange(of: initialValueLeft) { newValue in + .onChange(of: initialValueLeft) { valueLeft = initialValueLeft ?? 0 } - .onChange(of: initialValueRight) { newValue in + .onChange(of: initialValueRight) { valueRight = initialValueRight ?? 0 } .onAppear { diff --git a/PadelClub/Views/Tournament/FileImportView.swift b/PadelClub/Views/Tournament/FileImportView.swift index 9feacf1..23e79a1 100644 --- a/PadelClub/Views/Tournament/FileImportView.swift +++ b/PadelClub/Views/Tournament/FileImportView.swift @@ -225,9 +225,9 @@ struct FileImportView: View { ToolbarItem(placement: .topBarTrailing) { ButtonValidateView { - if false { //selectedOptions.contains(.deleteBeforeImport) - try? dataStore.teamRegistrations.delete(contentOfs: tournament.unsortedTeams()) - } +// if false { //selectedOptions.contains(.deleteBeforeImport) +// try? dataStore.teamRegistrations.delete(contentOfs: tournament.unsortedTeams()) +// } if true { //selectedOptions.contains(.notFoundAreWalkOut) let previousTeams = filteredTeams.compactMap({ $0.previousTeam })