From 035e1ac7cfdab0fc44f29d24461650223571c20f Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Thu, 18 Jul 2024 19:01:25 +0200 Subject: [PATCH] rename debug options --- PadelClub/Data/DataStore.swift | 4 +-- PadelClub/Data/GroupStage.swift | 8 ++--- PadelClub/Data/Match.swift | 8 ++--- PadelClub/Data/Round.swift | 24 +++++++------- PadelClub/Data/Tournament.swift | 16 ++++----- PadelClub/Data/TournamentStore.swift | 2 +- .../Views/Calling/CallSettingsView.swift | 2 +- PadelClub/Views/Calling/CallView.swift | 30 +++++++++++------ PadelClub/Views/Calling/SendToAllView.swift | 22 +++++++++++-- PadelClub/Views/Club/ClubsView.swift | 2 +- .../Components/GroupStageTeamView.swift | 24 +++++++++----- .../GroupStage/GroupStagesSettingsView.swift | 2 +- PadelClub/Views/Match/MatchDetailView.swift | 22 +++++++++++-- .../Navigation/Agenda/EventListView.swift | 2 +- .../Navigation/Ongoing/OngoingView.swift | 2 +- .../Navigation/Toolbox/ToolboxView.swift | 2 +- .../Views/Navigation/Umpire/UmpireView.swift | 2 +- PadelClub/Views/Round/LoserRoundView.swift | 2 +- PadelClub/Views/Round/LoserRoundsView.swift | 10 +++--- PadelClub/Views/Round/RoundView.swift | 2 +- .../Views/Shared/SupportButtonView.swift | 22 +++++++++++-- PadelClub/Views/Team/EditingTeamView.swift | 31 ++++++++++------- .../Components/TournamentStatusView.swift | 2 +- .../Screen/InscriptionManagerView.swift | 33 ++++++++++++------- .../Views/Tournament/Subscription/Guard.swift | 2 +- .../Tournament/Subscription/StoreItem.swift | 2 +- .../Tournament/TournamentBuildView.swift | 2 +- .../Views/Tournament/TournamentView.swift | 2 +- PadelClub/Views/User/LoginView.swift | 2 +- 29 files changed, 188 insertions(+), 98 deletions(-) diff --git a/PadelClub/Data/DataStore.swift b/PadelClub/Data/DataStore.swift index 7a990d4..98eb67a 100644 --- a/PadelClub/Data/DataStore.swift +++ b/PadelClub/Data/DataStore.swift @@ -54,7 +54,7 @@ class DataStore: ObservableObject { let serverURL: String = URLs.api.rawValue StoreCenter.main.blackListUserName("apple-test") - #if DEBUG + #if _DEBUG_OPTIONS if let server = PListReader.readString(plist: "local", key: "server") { StoreCenter.main.synchronizationApiURL = server } else { @@ -70,7 +70,7 @@ class DataStore: ObservableObject { _ = Guard.main // init - #if DEBUG + #if _DEBUG_OPTIONS if let sync = PListReader.readBool(plist: "local", key: "synchronized") { synchronized = sync } diff --git a/PadelClub/Data/GroupStage.swift b/PadelClub/Data/GroupStage.swift index 2b62442..48061b1 100644 --- a/PadelClub/Data/GroupStage.swift +++ b/PadelClub/Data/GroupStage.swift @@ -201,7 +201,7 @@ final class GroupStage: ModelObject, Storable { } func availableToStart(playedMatches: [Match], in runningMatches: [Match]) -> [Match] { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -212,7 +212,7 @@ final class GroupStage: ModelObject, Storable { } func runningMatches(playedMatches: [Match]) -> [Match] { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -223,7 +223,7 @@ final class GroupStage: ModelObject, Storable { } func readyMatches(playedMatches: [Match]) -> [Match] { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -234,7 +234,7 @@ final class GroupStage: ModelObject, Storable { } func finishedMatches(playedMatches: [Match]) -> [Match] { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) diff --git a/PadelClub/Data/Match.swift b/PadelClub/Data/Match.swift index 1c4683b..26af8ec 100644 --- a/PadelClub/Data/Match.swift +++ b/PadelClub/Data/Match.swift @@ -90,7 +90,7 @@ final class Match: ModelObject, Storable { } func indexInRound(in matches: [Match]? = nil) -> Int { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -114,7 +114,7 @@ defer { } func matchTitle(_ displayStyle: DisplayStyle = .wide, inMatches matches: [Match]? = nil) -> String { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -687,7 +687,7 @@ defer { } func teams() -> [TeamRegistration] { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -746,7 +746,7 @@ defer { } func team(_ team: TeamPosition) -> TeamRegistration? { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) diff --git a/PadelClub/Data/Round.swift b/PadelClub/Data/Round.swift index df107cf..27eee27 100644 --- a/PadelClub/Data/Round.swift +++ b/PadelClub/Data/Round.swift @@ -157,7 +157,7 @@ final class Round: ModelObject, Storable { } func roundProjectedTeam(_ team: TeamPosition, inMatch match: Match, previousRound: Round?) -> TeamRegistration? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -199,7 +199,7 @@ defer { } func upperBracketTopMatch(ofMatchIndex matchIndex: Int, previousRound: Round?) -> Match? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -214,7 +214,7 @@ defer { } func upperBracketBottomMatch(ofMatchIndex matchIndex: Int, previousRound: Round?) -> Match? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -231,7 +231,7 @@ defer { func topPreviousRoundMatch(ofMatch match: Match, previousRound: Round?) -> Match? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -247,7 +247,7 @@ defer { } func bottomPreviousRoundMatch(ofMatch match: Match, previousRound: Round?) -> Match? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -274,7 +274,7 @@ defer { } // func displayableMatches() -> [Match] { -//#if DEBUG_TIME //DEBUGING TIME +//#if _DEBUG_TIME //DEBUGING TIME // let start = Date() // defer { // let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -300,7 +300,7 @@ defer { } func previousRound() -> Round? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -428,7 +428,7 @@ defer { func correspondingLoserRoundTitle(_ displayStyle: DisplayStyle = .wide) -> String { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -469,7 +469,7 @@ defer { } func seedInterval(initialMode: Bool = false) -> SeedInterval? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -540,7 +540,7 @@ defer { func loserRounds() -> [Round] { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -722,7 +722,7 @@ extension Round: Selectable, Equatable { } func badgeValue() -> Int? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -743,7 +743,7 @@ extension Round: Selectable, Equatable { } func badgeImage() -> Badge? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 22a1115..c31f7b7 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -508,7 +508,7 @@ final class Tournament : ModelObject, Storable { } func courtUsed() -> [Int] { -#if DEBUG //DEBUGING TIME +#if _DEBUG_OPTIONS //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -592,7 +592,7 @@ defer { } func availableSeeds() -> [TeamRegistration] { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -815,7 +815,7 @@ defer { func selectedSortedTeams() -> [TeamRegistration] { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -1105,7 +1105,7 @@ defer { } func availableToStart(_ allMatches: [Match], in runningMatches: [Match]) -> [Match] { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -1116,7 +1116,7 @@ defer { } func runningMatches(_ allMatches: [Match]) -> [Match] { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -1127,7 +1127,7 @@ defer { } func readyMatches(_ allMatches: [Match]) -> [Match] { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -1138,7 +1138,7 @@ defer { } func finishedMatches(_ allMatches: [Match], limit: Int? = nil) -> [Match] { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -1397,7 +1397,7 @@ defer { func availableQualifiedTeams() -> [TeamRegistration] { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) diff --git a/PadelClub/Data/TournamentStore.swift b/PadelClub/Data/TournamentStore.swift index a01e6a0..6cb2fc7 100644 --- a/PadelClub/Data/TournamentStore.swift +++ b/PadelClub/Data/TournamentStore.swift @@ -38,7 +38,7 @@ class TournamentStore: Store, ObservableObject { var synchronized: Bool = true let indexed: Bool = true - #if DEBUG + #if _DEBUG_OPTIONS if let sync = PListReader.readBool(plist: "local", key: "synchronized") { synchronized = sync } diff --git a/PadelClub/Views/Calling/CallSettingsView.swift b/PadelClub/Views/Calling/CallSettingsView.swift index 7834e0e..04d0fad 100644 --- a/PadelClub/Views/Calling/CallSettingsView.swift +++ b/PadelClub/Views/Calling/CallSettingsView.swift @@ -56,7 +56,7 @@ struct CallSettingsView: View { } } - // #if DEBUG + // #if _DEBUG_OPTIONS Section { RowButtonView("Retirer toutes les convocations", role: .destructive) { let teams = tournament.unsortedTeams() diff --git a/PadelClub/Views/Calling/CallView.swift b/PadelClub/Views/Calling/CallView.swift index cd5e53a..0423958 100644 --- a/PadelClub/Views/Calling/CallView.swift +++ b/PadelClub/Views/Calling/CallView.swift @@ -125,7 +125,7 @@ struct CallView: View { Button("OK") { } } message: { - Text(self._failureMessage()) + Text(_networkErrorMessage) } .sheet(item: $contactType) { contactType in Group { @@ -188,15 +188,7 @@ struct CallView: View { } }) } - - fileprivate func _failureMessage() -> String { - return [networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." as String? : nil, - sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." as String? : nil, - (sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" as String? : nil, - sentError == .mailFailed ? "Le mail n'a pas été envoyé" as String? : nil] - .compacted().joined(separator: "\n") - } - + @ViewBuilder private func _summonMenu(byMessage: Bool) -> some View { if self.reSummon { @@ -267,4 +259,22 @@ struct CallView: View { tournamentBuild: nil) } + private var _networkErrorMessage: String { + var errors: [String] = [] + + if networkMonitor.connected == false { + errors.append("L'appareil n'est pas connecté à internet.") + } + if sentError == .mailNotSent { + errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.") + } + if (sentError == .messageFailed || sentError == .messageNotSent) { + errors.append("Le SMS n'a pas été envoyé") + } + if sentError == .mailFailed { + errors.append("Le mail n'a pas été envoyé") + } + return errors.joined(separator: "\n") + } + } diff --git a/PadelClub/Views/Calling/SendToAllView.swift b/PadelClub/Views/Calling/SendToAllView.swift index bd8648d..e54392e 100644 --- a/PadelClub/Views/Calling/SendToAllView.swift +++ b/PadelClub/Views/Calling/SendToAllView.swift @@ -122,8 +122,7 @@ struct SendToAllView: View { Button("OK") { } } message: { - let message = [networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." as String? : nil, sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." as String? : nil, (sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" as String? : nil, sentError == .mailFailed ? "Le mail n'a pas été envoyé" as String? : nil].compacted().joined(separator: "\n") - Text(message) + Text(_networkErrorMessage) } .sheet(item: $contactType) { contactType in Group { @@ -253,6 +252,25 @@ struct SendToAllView: View { self.showSubscriptionView = true } } + + private var _networkErrorMessage: String { + var errors: [String] = [] + + if networkMonitor.connected == false { + errors.append("L'appareil n'est pas connecté à internet.") + } + if sentError == .mailNotSent { + errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.") + } + if (sentError == .messageFailed || sentError == .messageNotSent) { + errors.append("Le SMS n'a pas été envoyé") + } + if sentError == .mailFailed { + errors.append("Le mail n'a pas été envoyé") + } + return errors.joined(separator: "\n") + } + } //#Preview { diff --git a/PadelClub/Views/Club/ClubsView.swift b/PadelClub/Views/Club/ClubsView.swift index b5ea93e..5210993 100644 --- a/PadelClub/Views/Club/ClubsView.swift +++ b/PadelClub/Views/Club/ClubsView.swift @@ -27,7 +27,7 @@ struct ClubsView: View { var body: some View { List { - #if DEBUG + #if _DEBUG_OPTIONS Section { RowButtonView("Delete unexisted clubs", action: { let ids = dataStore.user.clubs diff --git a/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift b/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift index f76c7af..a7b9a8f 100644 --- a/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift +++ b/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift @@ -95,7 +95,7 @@ struct GroupStageTeamView: View { Button("OK") { } } message: { - Text(_getErrorMessage()) + Text(_networkErrorMessage) } .sheet(item: $contactType) { contactType in Group { @@ -152,14 +152,22 @@ struct GroupStageTeamView: View { .navigationTitle("Détail de l'équipe") } - private func _getErrorMessage() -> String { - let m1 : String? = (networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." : nil) - let m2 : String? = (sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." : nil) - let m3 : String? = ((sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" : nil) - let m4 : String? = (sentError == .mailFailed ? "Le mail n'a pas été envoyé" : nil) + private var _networkErrorMessage: String { + var errors: [String] = [] - let message : String = [m1, m2, m3, m4].compacted().joined(separator: "\n") - return message + if networkMonitor.connected == false { + errors.append("L'appareil n'est pas connecté à internet.") + } + if sentError == .mailNotSent { + errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.") + } + if (sentError == .messageFailed || sentError == .messageNotSent) { + errors.append("Le SMS n'a pas été envoyé") + } + if sentError == .mailFailed { + errors.append("Le mail n'a pas été envoyé") + } + return errors.joined(separator: "\n") } private func _save() { diff --git a/PadelClub/Views/GroupStage/GroupStagesSettingsView.swift b/PadelClub/Views/GroupStage/GroupStagesSettingsView.swift index 8b3770c..51739af 100644 --- a/PadelClub/Views/GroupStage/GroupStagesSettingsView.swift +++ b/PadelClub/Views/GroupStage/GroupStagesSettingsView.swift @@ -73,7 +73,7 @@ struct GroupStagesSettingsView: View { } } - #if DEBUG + #if _DEBUG_OPTIONS Section { RowButtonView("delete all group stages") { tournament.deleteGroupStages() diff --git a/PadelClub/Views/Match/MatchDetailView.swift b/PadelClub/Views/Match/MatchDetailView.swift index 42a3ba9..cd96649 100644 --- a/PadelClub/Views/Match/MatchDetailView.swift +++ b/PadelClub/Views/Match/MatchDetailView.swift @@ -197,8 +197,7 @@ struct MatchDetailView: View { Button("OK") { } } message: { - let message = [networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." as String? : nil, sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." as String? : nil, (sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" as String? : nil, sentError == .mailFailed ? "Le mail n'a pas été envoyé" as String? : nil].compacted().joined(separator: "\n") - Text(message) + Text(_networkErrorMessage) } .sheet(item: $contactType) { contactType in Group { @@ -508,6 +507,25 @@ struct MatchDetailView: View { Logger.error(error) } } + + private var _networkErrorMessage: String { + var errors: [String] = [] + + if networkMonitor.connected == false { + errors.append("L'appareil n'est pas connecté à internet.") + } + if sentError == .mailNotSent { + errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.") + } + if (sentError == .messageFailed || sentError == .messageNotSent) { + errors.append("Le SMS n'a pas été envoyé") + } + if sentError == .mailFailed { + errors.append("Le mail n'a pas été envoyé") + } + return errors.joined(separator: "\n") + } + } //#Preview { diff --git a/PadelClub/Views/Navigation/Agenda/EventListView.swift b/PadelClub/Views/Navigation/Agenda/EventListView.swift index 4c89482..f6ef613 100644 --- a/PadelClub/Views/Navigation/Agenda/EventListView.swift +++ b/PadelClub/Views/Navigation/Agenda/EventListView.swift @@ -112,7 +112,7 @@ struct EventListView: View { } } } - #if DEBUG + #if _DEBUG_OPTIONS .swipeActions(edge: .trailing, allowsFullSwipe: true) { Button(role: .destructive) { do { diff --git a/PadelClub/Views/Navigation/Ongoing/OngoingView.swift b/PadelClub/Views/Navigation/Ongoing/OngoingView.swift index 3c41cbb..3fdd8f8 100644 --- a/PadelClub/Views/Navigation/Ongoing/OngoingView.swift +++ b/PadelClub/Views/Navigation/Ongoing/OngoingView.swift @@ -44,7 +44,7 @@ struct OngoingView: View { } footer: { HStack { Text(tournament.eventLabel()) -#if DEBUG +#if _DEBUG_OPTIONS Spacer() FooterButtonView("copier l'id") { let pasteboard = UIPasteboard.general diff --git a/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift b/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift index d2fdfb7..33d274c 100644 --- a/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift +++ b/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift @@ -49,7 +49,7 @@ struct ToolboxView: View { } - #if DEBUG + #if _DEBUG_OPTIONS Section { NavigationLink("Settings") { diff --git a/PadelClub/Views/Navigation/Umpire/UmpireView.swift b/PadelClub/Views/Navigation/Umpire/UmpireView.swift index 945d2d7..f15efde 100644 --- a/PadelClub/Views/Navigation/Umpire/UmpireView.swift +++ b/PadelClub/Views/Navigation/Umpire/UmpireView.swift @@ -145,7 +145,7 @@ struct UmpireView: View { } .navigationTitle("Juge-Arbitre") .toolbar { -#if DEBUG +#if _DEBUG_OPTIONS ToolbarItem(placement: .topBarTrailing) { if StoreCenter.main.collectionsCanSynchronize { Image(systemName: "checkmark.icloud") diff --git a/PadelClub/Views/Round/LoserRoundView.swift b/PadelClub/Views/Round/LoserRoundView.swift index d36bb31..017db3d 100644 --- a/PadelClub/Views/Round/LoserRoundView.swift +++ b/PadelClub/Views/Round/LoserRoundView.swift @@ -15,7 +15,7 @@ struct LoserRoundView: View { let loserBracket: LoserRound private func _roundDisabled() -> Bool { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) diff --git a/PadelClub/Views/Round/LoserRoundsView.swift b/PadelClub/Views/Round/LoserRoundsView.swift index 4bf7465..4e583c3 100644 --- a/PadelClub/Views/Round/LoserRoundsView.swift +++ b/PadelClub/Views/Round/LoserRoundsView.swift @@ -42,7 +42,7 @@ extension UpperRound: Equatable { } func badgeValue() -> Int? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -57,7 +57,7 @@ extension UpperRound: Equatable { } func badgeImage() -> Badge? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -85,7 +85,7 @@ struct LoserRound: Identifiable, Selectable { } var shouldBeDisplayed: Bool { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -97,7 +97,7 @@ struct LoserRound: Identifiable, Selectable { } static func updateDestinations(fromLoserRounds loserRounds: [Round], inUpperBracketRound upperBracketRound: Round) -> [LoserRound] { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -146,7 +146,7 @@ extension LoserRound: Equatable { } func badgeImage() -> Badge? { -#if DEBUG_TIME //DEBUGING TIME +#if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) diff --git a/PadelClub/Views/Round/RoundView.swift b/PadelClub/Views/Round/RoundView.swift index 3891599..acc50e9 100644 --- a/PadelClub/Views/Round/RoundView.swift +++ b/PadelClub/Views/Round/RoundView.swift @@ -254,7 +254,7 @@ struct RoundView: View { } } - #if DEBUG + #if _DEBUG_OPTIONS Spacer() Text(match.teamScores.count.formatted()) diff --git a/PadelClub/Views/Shared/SupportButtonView.swift b/PadelClub/Views/Shared/SupportButtonView.swift index e2c3dbf..5117abb 100644 --- a/PadelClub/Views/Shared/SupportButtonView.swift +++ b/PadelClub/Views/Shared/SupportButtonView.swift @@ -47,8 +47,7 @@ struct SupportButtonView: View { Button("OK") { } } message: { - let message = [networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." as String? : nil, sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." as String? : nil, (sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" as String? : nil, sentError == .mailFailed ? "Le mail n'a pas été envoyé" as String? : nil].compacted().joined(separator: "\n") - Text(message) + Text(_networkErrorMessage) } .sheet(item: $zipFilePath) { zipFilePath in MailComposeView(recipients: ["support@padelclub.app"], bccRecipients: nil, body: _getBody(), subject: _getSubject(), attachmentURL: zipFilePath) { result in @@ -102,4 +101,23 @@ struct SupportButtonView: View { Logger.error(error) } } + + private var _networkErrorMessage: String { + var errors: [String] = [] + + if networkMonitor.connected == false { + errors.append("L'appareil n'est pas connecté à internet.") + } + if sentError == .mailNotSent { + errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.") + } + if (sentError == .messageFailed || sentError == .messageNotSent) { + errors.append("Le SMS n'a pas été envoyé") + } + if sentError == .mailFailed { + errors.append("Le mail n'a pas été envoyé") + } + return errors.joined(separator: "\n") + } + } diff --git a/PadelClub/Views/Team/EditingTeamView.swift b/PadelClub/Views/Team/EditingTeamView.swift index b4ca5ba..492822e 100644 --- a/PadelClub/Views/Team/EditingTeamView.swift +++ b/PadelClub/Views/Team/EditingTeamView.swift @@ -186,7 +186,7 @@ struct EditingTeamView: View { Button("OK") { } } message: { - Text(_getErrorMessage()) + Text(_networkErrorMessage) } .sheet(item: $contactType) { contactType in Group { @@ -257,16 +257,6 @@ struct EditingTeamView: View { .navigationBarTitleDisplayMode(.inline) } - private func _getErrorMessage() -> String { - let m1 : String? = (networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." : nil) - let m2 : String? = (sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." : nil) - let m3 : String? = ((sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" : nil) - let m4 : String? = (sentError == .mailFailed ? "Le mail n'a pas été envoyé" : nil) - - let message : String = [m1, m2, m3, m4].compacted().joined(separator: "\n") - return message - } - private var hasArrived: Binding { Binding { team.unsortedPlayers().allSatisfy({ $0.hasArrived }) @@ -289,6 +279,25 @@ struct EditingTeamView: View { Logger.error(error) } } + + private var _networkErrorMessage: String { + var errors: [String] = [] + + if networkMonitor.connected == false { + errors.append("L'appareil n'est pas connecté à internet.") + } + if sentError == .mailNotSent { + errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.") + } + if (sentError == .messageFailed || sentError == .messageNotSent) { + errors.append("Le SMS n'a pas été envoyé") + } + if sentError == .mailFailed { + errors.append("Le mail n'a pas été envoyé") + } + return errors.joined(separator: "\n") + } + } //#Preview { diff --git a/PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift b/PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift index 9add4fd..1f66b8f 100644 --- a/PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift +++ b/PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift @@ -17,7 +17,7 @@ struct TournamentStatusView: View { var body: some View { Form { - #if DEBUG + #if _DEBUG_OPTIONS RowButtonView("debug: Un-delete le tournoi") { tournament.endDate = nil tournament.isDeleted.toggle() diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index b44ef1e..983e0af 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -167,7 +167,7 @@ struct InscriptionManagerView: View { } private func _setHash() { - #if DEBUG_TIME //DEBUGING TIME + #if _DEBUG_TIME //DEBUGING TIME let start = Date() defer { let duration = Duration.milliseconds(Date().timeIntervalSince(start) * 1_000) @@ -242,7 +242,7 @@ struct InscriptionManagerView: View { Button("OK") { } } message: { - Text(_getErrorMessage()) + Text(_networkErrorMessage) } .sheet(item: $contactType) { contactType in Group { @@ -960,16 +960,6 @@ struct InscriptionManagerView: View { } } - private func _getErrorMessage() -> String { - let m1 : String? = (networkMonitor.connected == false ? "L'appareil n'est pas connecté à internet." : nil) - let m2 : String? = (sentError == .mailNotSent ? "Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer." : nil) - let m3 : String? = ((sentError == .messageFailed || sentError == .messageNotSent) ? "Le SMS n'a pas été envoyé" : nil) - let m4 : String? = (sentError == .mailFailed ? "Le mail n'a pas été envoyé" : nil) - - let message : String = [m1, m2, m3, m4].compacted().joined(separator: "\n") - return message - } - private func _save() { do { try dataStore.tournaments.addOrUpdate(instance: tournament) @@ -977,6 +967,25 @@ struct InscriptionManagerView: View { Logger.error(error) } } + + private var _networkErrorMessage: String { + var errors: [String] = [] + + if networkMonitor.connected == false { + errors.append("L'appareil n'est pas connecté à internet.") + } + if sentError == .mailNotSent { + errors.append("Le mail est dans la boîte d'envoi de l'app Mail. Vérifiez son état dans l'app Mail avant d'essayer de le renvoyer.") + } + if (sentError == .messageFailed || sentError == .messageNotSent) { + errors.append("Le SMS n'a pas été envoyé") + } + if sentError == .mailFailed { + errors.append("Le mail n'a pas été envoyé") + } + return errors.joined(separator: "\n") + } + } //#Preview { diff --git a/PadelClub/Views/Tournament/Subscription/Guard.swift b/PadelClub/Views/Tournament/Subscription/Guard.swift index 36c77cd..bffa090 100644 --- a/PadelClub/Views/Tournament/Subscription/Guard.swift +++ b/PadelClub/Views/Tournament/Subscription/Guard.swift @@ -141,7 +141,7 @@ import LeStorage var currentPlan: StoreItem? { return .monthlyUnlimited -// #if DEBUG +// #if _DEBUG_OPTIONS // return .monthlyUnlimited // #else if let currentBestPlan = self.currentBestPlan, let plan = StoreItem(rawValue: currentBestPlan.productID) { diff --git a/PadelClub/Views/Tournament/Subscription/StoreItem.swift b/PadelClub/Views/Tournament/Subscription/StoreItem.swift index 79bab93..8a2e71e 100644 --- a/PadelClub/Views/Tournament/Subscription/StoreItem.swift +++ b/PadelClub/Views/Tournament/Subscription/StoreItem.swift @@ -12,7 +12,7 @@ enum StoreItem: String, Identifiable, CaseIterable { case fivePerMonth = "app.padelclub.tournament.subscription.five.per.month" case unit = "app.padelclub.tournament.unit" - #if DEBUG + #if _DEBUG_OPTIONS static let five: Int = 2 #else static let five: Int = 5 diff --git a/PadelClub/Views/Tournament/TournamentBuildView.swift b/PadelClub/Views/Tournament/TournamentBuildView.swift index a11e055..75e5b36 100644 --- a/PadelClub/Views/Tournament/TournamentBuildView.swift +++ b/PadelClub/Views/Tournament/TournamentBuildView.swift @@ -92,7 +92,7 @@ struct TournamentBuildView: View { Section { - #if DEBUG + #if _DEBUG_OPTIONS NavigationLink(value: Screen.rankings) { LabeledContent { if tournament.publishRankings == false { diff --git a/PadelClub/Views/Tournament/TournamentView.swift b/PadelClub/Views/Tournament/TournamentView.swift index fa14f46..6f3f946 100644 --- a/PadelClub/Views/Tournament/TournamentView.swift +++ b/PadelClub/Views/Tournament/TournamentView.swift @@ -154,7 +154,7 @@ struct TournamentView: View { ToolbarItem(placement: .topBarTrailing) { Menu { - #if DEBUG + #if _DEBUG_OPTIONS Button { do { try self.tournament.payIfNecessary() diff --git a/PadelClub/Views/User/LoginView.swift b/PadelClub/Views/User/LoginView.swift index 61c27fe..cddc732 100644 --- a/PadelClub/Views/User/LoginView.swift +++ b/PadelClub/Views/User/LoginView.swift @@ -182,7 +182,7 @@ struct LoginView: View { } .navigationTitle("Connexion") .onAppear { - #if DEBUG + #if _DEBUG_OPTIONS if let username = PListReader.readString(plist: "local", key: "username") { self.username = username }