fix some warnings

multistore
Razmig Sarkissian 2 years ago
parent 3a9a075035
commit fb1e503fbb
  1. 8
      PadelClub/Data/Tournament.swift
  2. 4
      PadelClub/Extensions/Locale+Extensions.swift
  3. 8
      PadelClub/Utils/CloudConvert.swift
  4. 6
      PadelClub/Utils/ContactManager.swift
  5. 6
      PadelClub/ViewModel/MatchScheduler.swift
  6. 2
      PadelClub/Views/Cashier/CashierView.swift
  7. 2
      PadelClub/Views/Components/FortuneWheelView.swift
  8. 4
      PadelClub/Views/Match/MatchDetailView.swift
  9. 2
      PadelClub/Views/Navigation/MainView.swift
  10. 2
      PadelClub/Views/Round/RoundView.swift
  11. 6
      PadelClub/Views/Score/EditScoreView.swift
  12. 37
      PadelClub/Views/Score/SetInputView.swift
  13. 4
      PadelClub/Views/Score/SetLabelView.swift
  14. 6
      PadelClub/Views/Tournament/FileImportView.swift

@ -150,9 +150,9 @@ class Tournament : ModelObject, Storable {
} }
func state() -> Tournament.State { func state() -> Tournament.State {
if currentCanceled == true { // if currentCanceled == true {
return .canceled // return .canceled
} // }
if (groupStageCount > 0 && groupStages().isEmpty == false) if (groupStageCount > 0 && groupStages().isEmpty == false)
|| rounds().isEmpty == false { || rounds().isEmpty == false {
return .build return .build
@ -377,7 +377,7 @@ class Tournament : ModelObject, Storable {
} }
func selectedSortedTeams() -> [TeamRegistration] { func selectedSortedTeams() -> [TeamRegistration] {
let start = Date() //let start = Date()
var _sortedTeams : [TeamRegistration] = [] var _sortedTeams : [TeamRegistration] = []
let _teams = unsortedTeams().filter({ $0.walkOut == false }) let _teams = unsortedTeams().filter({ $0.walkOut == false })

@ -12,8 +12,8 @@ extension Locale {
static func countries() -> [String] { static func countries() -> [String] {
var countries: [String] = [] var countries: [String] = []
for countryCode in Locale.isoRegionCodes { for countryCode in Locale.Region.isoRegions {
if let countryName = Locale.current.localizedString(forRegionCode: countryCode) { if let countryName = Locale.current.localizedString(forRegionCode: countryCode.identifier) {
countries.append(countryName) countries.append(countryName)
} }
} }

@ -60,7 +60,7 @@ class CloudConvert {
request.httpBody = postData request.httpBody = postData
let task = try await URLSession.shared.data(for: request) 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) { if let errorResponse = try? JSONDecoder().decode(ErrorResponse.self, from: task.0) {
print("errorResponse.error", errorResponse.error) print("errorResponse.error", errorResponse.error)
throw CloudConvertionError.serviceError(errorResponse) throw CloudConvertionError.serviceError(errorResponse)
@ -77,7 +77,7 @@ class CloudConvert {
uploadRequest.httpMethod = "PUT" uploadRequest.httpMethod = "PUT"
let uploadTask = try await URLSession.shared.upload(for: uploadRequest, fromFile: url) 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) { if let errorResponse = try? JSONDecoder().decode(ErrorResponse.self, from: uploadTask.0) {
print("errorResponse.error", errorResponse.error) print("errorResponse.error", errorResponse.error)
throw CloudConvertionError.serviceError(errorResponse) throw CloudConvertionError.serviceError(errorResponse)
@ -94,7 +94,7 @@ class CloudConvert {
request.httpMethod = "GET" request.httpMethod = "GET"
let task = try await URLSession.shared.data(for: request) 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) { if let errorResponse = try? JSONDecoder().decode(ErrorResponse.self, from: task.0) {
print("errorResponse.error", errorResponse.error) print("errorResponse.error", errorResponse.error)
throw CloudConvertionError.serviceError(errorResponse) throw CloudConvertionError.serviceError(errorResponse)
@ -117,7 +117,7 @@ class CloudConvert {
throw CloudConvertionError.serviceError(errorResponse) throw CloudConvertionError.serviceError(errorResponse)
} }
print("tried: \(downloadRequest.url)") //print("tried: \(downloadRequest.url)")
let dataResponse = try JSONDecoder().decode(DataResponse.self, from: downloadTask.0) 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) { if let decodedData = Data(base64Encoded: dataResponse.data.content), let string = String(data: decodedData, encoding: .utf8) {
return string return string

@ -57,7 +57,7 @@ extension ContactType {
static func callingGroupStageMessage(tournament: Tournament?, startDate: Date?, roundLabel: String, matchFormat: MatchFormat?) -> String { 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 { if useFullCustomMessage {
return callingGroupStageCustomMessage(tournament: tournament, startDate: startDate, roundLabel: roundLabel) return callingGroupStageCustomMessage(tournament: tournament, startDate: startDate, roundLabel: roundLabel)
@ -72,11 +72,11 @@ extension ContactType {
let localizedCalled = "convoqué" + (tournament?.tournamentCategory == .women ? "e" : "") + "s" let localizedCalled = "convoqué" + (tournament?.tournamentCategory == .women ? "e" : "") + "s"
var formatMessage: String? { var formatMessage: String? {
(DataStore.shared.appSettings.callDisplayFormat ?? false) ? matchFormat?.computedLongLabel.appending(".") : nil (DataStore.shared.appSettings.callDisplayFormat) ? matchFormat?.computedLongLabel.appending(".") : nil
} }
var entryFeeMessage: String? { var entryFeeMessage: String? {
(DataStore.shared.appSettings.callDisplayEntryFee ?? false) ? tournament?.entryFeeMessage : nil (DataStore.shared.appSettings.callDisplayEntryFee) ? tournament?.entryFeeMessage : nil
} }
var computedMessage: String { var computedMessage: String {

@ -502,7 +502,6 @@ class MatchScheduler {
} }
func updateBracketSchedule(tournament: Tournament, fromRoundId roundId: String?, fromMatchId matchId: String?, startDate: Date) { func updateBracketSchedule(tournament: Tournament, fromRoundId roundId: String?, fromMatchId matchId: String?, startDate: Date) {
let numberOfCourtsAvailablePerRotation: Int = tournament.courtCount
courtsUnavailability = tournament.eventObject?.courtsUnavailability courtsUnavailability = tournament.eventObject?.courtsUnavailability
let upperRounds = tournament.rounds() 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) round._matches().filter({ $0.disabled == false }).sorted(by: \.index)
} }
@ -575,7 +574,7 @@ class MatchScheduler {
let courts : [Int]? = initialCourts.isEmpty ? nil : initialCourts 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) let roundDispatch = self.roundDispatcher(numberOfCourtsAvailablePerRotation: tournament.courtCount, flattenedMatches: flattenedMatches, dispatcherStartDate: startDate, initialCourts: courts)
@ -608,7 +607,6 @@ class MatchScheduler {
} }
func updateSchedule(tournament: Tournament) { func updateSchedule(tournament: Tournament) {
let numberOfCourtsAvailablePerRotation: Int = tournament.courtCount
courtsUnavailability = tournament.eventObject?.courtsUnavailability courtsUnavailability = tournament.eventObject?.courtsUnavailability
let lastDate = updateGroupStageSchedule(tournament: tournament) let lastDate = updateGroupStageSchedule(tournament: tournament)
updateBracketSchedule(tournament: tournament, fromRoundId: nil, fromMatchId: nil, startDate: lastDate) updateBracketSchedule(tournament: tournament, fromRoundId: nil, fromMatchId: nil, startDate: lastDate)

@ -21,7 +21,7 @@ struct CashierView: View {
init(tournament: Tournament, teams: [TeamRegistration]) { init(tournament: Tournament, teams: [TeamRegistration]) {
self.tournaments = [tournament] self.tournaments = [tournament]
self.teams = teams self.teams = teams
if teams.filter { $0.callDate != nil }.isEmpty { if teams.filter({ $0.callDate != nil }).isEmpty {
_sortOption = .init(wrappedValue: .teamRank) _sortOption = .init(wrappedValue: .teamRank)
} else { } else {
_sortOption = .init(wrappedValue: .callDate) _sortOption = .init(wrappedValue: .callDate)

@ -74,7 +74,7 @@ struct SpinDrawView: View {
Text(time, style: .timer) Text(time, style: .timer)
} }
if let selectedIndex { if selectedIndex != nil {
Section { Section {
Text(validationLabel(drawee: drawCount, result: segments[draws.last!.drawIndex])) Text(validationLabel(drawee: drawCount, result: segments[draws.last!.drawIndex]))
if autoMode == false || drawCount == drawees.count { if autoMode == false || drawCount == drawees.count {

@ -406,7 +406,7 @@ struct MatchDetailView: View {
} label: { } label: {
Text("Horaire") Text("Horaire")
} }
.onChange(of: startDateSetup, perform: { value in .onChange(of: startDateSetup) {
switch startDateSetup { switch startDateSetup {
case .customDate: case .customDate:
break break
@ -415,7 +415,7 @@ struct MatchDetailView: View {
case .inMinutes(let minutes): case .inMinutes(let minutes):
startDate = Date().addingTimeInterval(Double(minutes) * 60) startDate = Date().addingTimeInterval(Double(minutes) * 60)
} }
}) }
} }
if match.startDate != nil || startDateSetup == .customDate { if match.startDate != nil || startDateSetup == .customDate {

@ -91,7 +91,7 @@ struct MainView: View {
} }
private func _checkSourceFileAvailability() async { private func _checkSourceFileAvailability() async {
print(dataStore.appSettings.lastDataSource) print("dataStore.appSettings.lastDataSource :", dataStore.appSettings.lastDataSource ?? "none")
print("check internet") print("check internet")
print("check files on internet") print("check files on internet")
print("check if any files on internet are more recent than here") print("check if any files on internet are more recent than here")

@ -21,7 +21,7 @@ struct RoundView: View {
if isEditingTournamentSeed.wrappedValue == false { if isEditingTournamentSeed.wrappedValue == false {
//(where: { $0.isDisabled() == false || isEditingTournamentSeed.wrappedValue }) //(where: { $0.isDisabled() == false || isEditingTournamentSeed.wrappedValue })
if loserRounds.isEmpty == false, let first = loserRounds.first { if loserRounds.isEmpty == false {
let correspondingLoserRoundTitle = round.correspondingLoserRoundTitle() let correspondingLoserRoundTitle = round.correspondingLoserRoundTitle()
Section { Section {
NavigationLink { NavigationLink {

@ -47,7 +47,7 @@ struct EditScoreView: View {
Spacer() Spacer()
MatchTypeSmallSelectionView(selectedFormat: $matchDescriptor.matchFormat, format: "Format") MatchTypeSmallSelectionView(selectedFormat: $matchDescriptor.matchFormat, format: "Format")
.onChange(of: matchDescriptor.matchFormat) { newValue in .onChange(of: matchDescriptor.matchFormat) {
matchDescriptor.setDescriptors.removeAll() matchDescriptor.setDescriptors.removeAll()
matchDescriptor.addNewSet() matchDescriptor.addNewSet()
} }
@ -55,8 +55,8 @@ struct EditScoreView: View {
} }
ForEach($matchDescriptor.setDescriptors) { $setDescriptor in ForEach($matchDescriptor.setDescriptors) { $setDescriptor in
SetInputView(setDescriptor: $setDescriptor) SetInputView(setDescriptor: $setDescriptor)
.onChange(of: setDescriptor.hasEnded) { hasEnded in .onChange(of: setDescriptor.hasEnded) {
if hasEnded { if setDescriptor.hasEnded {
if matchDescriptor.hasEnded == false { if matchDescriptor.hasEnded == false {
matchDescriptor.addNewSet() matchDescriptor.addNewSet()
} }

@ -137,8 +137,8 @@ struct SetInputView: View {
} }
} }
} }
.onChange(of: setDescriptor.valueTeamOne, perform: { newValue in .onChange(of: setDescriptor.valueTeamOne) {
if let newValue { if let newValue = setDescriptor.valueTeamOne {
if newValue == setFormat.scoreToWin - 1 && setFormat.tieBreak == 8 { if newValue == setFormat.scoreToWin - 1 && setFormat.tieBreak == 8 {
setDescriptor.valueTeamTwo = setFormat.scoreToWin setDescriptor.valueTeamTwo = setFormat.scoreToWin
} else if newValue == setFormat.scoreToWin - 2 && setFormat.tieBreak == 8 { } 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 { if setDescriptor.valueTeamOne != nil && setDescriptor.valueTeamTwo != nil {
showSetInputView = false showSetInputView = false
} }
}) }
.onChange(of: setDescriptor.tieBreakValueTeamOne, perform: { newValue in .onChange(of: setDescriptor.tieBreakValueTeamOne) {
if let newValue, setDescriptor.tieBreakValueTeamTwo == nil { if let newValue = setDescriptor.tieBreakValueTeamOne, setDescriptor.tieBreakValueTeamTwo == nil {
if newValue > 7 { if newValue > 7 {
setDescriptor.tieBreakValueTeamTwo = newValue - 2 setDescriptor.tieBreakValueTeamTwo = newValue - 2
} }
@ -172,7 +172,7 @@ struct SetInputView: View {
setDescriptor.tieBreakValueTeamTwo = 7 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 { if newValue > 6 && tieBreakValueTeamTwo < newValue {
setDescriptor.tieBreakValueTeamTwo = newValue - 2 setDescriptor.tieBreakValueTeamTwo = newValue - 2
} }
@ -187,31 +187,28 @@ struct SetInputView: View {
showTieBreakInputView = false showTieBreakInputView = false
} }
} }
}) }
.onChange(of: setDescriptor.tieBreakValueTeamTwo, perform: { newValue in .onChange(of: setDescriptor.tieBreakValueTeamTwo) {
if let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne, tieBreakValueTeamOne <= 5 { if let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne, tieBreakValueTeamOne <= 5 {
showTieBreakInputView = false showTieBreakInputView = false
} else { } else {
if let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo { if let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo {
if let newValue { if tieBreakValueTeamTwo > 6 && tieBreakValueTeamTwo > setDescriptor.tieBreakValueTeamOne ?? 0 {
if newValue > 6 && tieBreakValueTeamTwo > setDescriptor.tieBreakValueTeamOne ?? 0 { setDescriptor.tieBreakValueTeamOne = tieBreakValueTeamTwo - 2
setDescriptor.tieBreakValueTeamOne = newValue - 2
}
if newValue > 4 && tieBreakValueTeamTwo < setDescriptor.tieBreakValueTeamOne ?? 0 {
setDescriptor.tieBreakValueTeamOne = newValue + 2
} }
if tieBreakValueTeamTwo > 4 && tieBreakValueTeamTwo < setDescriptor.tieBreakValueTeamOne ?? 0 {
setDescriptor.tieBreakValueTeamOne = tieBreakValueTeamTwo + 2
} }
} }
if let newValue, let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne { if let tieBreakValueTeamTwo = setDescriptor.tieBreakValueTeamTwo, let tieBreakValueTeamOne = setDescriptor.tieBreakValueTeamOne {
if newValue < 6 && tieBreakValueTeamOne == 7 { if tieBreakValueTeamTwo < 6 && tieBreakValueTeamOne == 7 {
showTieBreakInputView = false showTieBreakInputView = false
} }
} }
} }
}) }
.listRowSeparator(.hidden) .listRowSeparator(.hidden)
} }
} }

@ -42,10 +42,10 @@ struct SetLabelView: View {
.scaleEffect(0.7) .scaleEffect(0.7)
} }
} }
.onChange(of: initialValueLeft) { newValue in .onChange(of: initialValueLeft) {
valueLeft = initialValueLeft ?? 0 valueLeft = initialValueLeft ?? 0
} }
.onChange(of: initialValueRight) { newValue in .onChange(of: initialValueRight) {
valueRight = initialValueRight ?? 0 valueRight = initialValueRight ?? 0
} }
.onAppear { .onAppear {

@ -225,9 +225,9 @@ struct FileImportView: View {
ToolbarItem(placement: .topBarTrailing) { ToolbarItem(placement: .topBarTrailing) {
ButtonValidateView { ButtonValidateView {
if false { //selectedOptions.contains(.deleteBeforeImport) // if false { //selectedOptions.contains(.deleteBeforeImport)
try? dataStore.teamRegistrations.delete(contentOfs: tournament.unsortedTeams()) // try? dataStore.teamRegistrations.delete(contentOfs: tournament.unsortedTeams())
} // }
if true { //selectedOptions.contains(.notFoundAreWalkOut) if true { //selectedOptions.contains(.notFoundAreWalkOut)
let previousTeams = filteredTeams.compactMap({ $0.previousTeam }) let previousTeams = filteredTeams.compactMap({ $0.previousTeam })

Loading…
Cancel
Save