diff --git a/PadelClub/Data/GroupStage.swift b/PadelClub/Data/GroupStage.swift index 48061b1..ac2d9c7 100644 --- a/PadelClub/Data/GroupStage.swift +++ b/PadelClub/Data/GroupStage.swift @@ -170,6 +170,12 @@ final class GroupStage: ModelObject, Storable { let setDifference = differences.map { $0.set }.reduce(0,+) let gameDifference = differences.map { $0.game }.reduce(0,+) return (team, wins, loses, setDifference, gameDifference) + /* + • 2 points par rencontre gagnée + • 1 point par rencontre perdue + • -1 point en cas de rencontre perdue par disqualification (scores de 6/0 6/0 attribués aux trois matchs) + • -2 points en cas de rencontre perdu par WO (scores de 6/0 6/0 attribués aux trois matchs) + */ } func matches(forGroupStagePosition groupStagePosition: Int) -> [Match] { diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 3f06644..cb9fe18 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -1012,7 +1012,7 @@ defer { func mandatoryRegistrationCloseDate() -> Date? { switch tournamentLevel { case .p500, .p1000, .p1500, .p2000: - if let date = Calendar.current.date(byAdding: .day, value: -6, to: startDate) { + if let date = Calendar.current.date(byAdding: .day, value: -13, to: startDate) { let startOfDay = Calendar.current.startOfDay(for: date) return Calendar.current.date(byAdding: .minute, value: -1, to: startOfDay) } diff --git a/PadelClub/Utils/PadelRule.swift b/PadelClub/Utils/PadelRule.swift index a509b12..b5e41a6 100644 --- a/PadelClub/Utils/PadelRule.swift +++ b/PadelClub/Utils/PadelRule.swift @@ -315,7 +315,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { case .p25: switch ageCategory { case .senior, .a45, .a55: - return category == .men ? 10000 : 1000 + return category == .men ? 20000 : 1000 default: return 0 } @@ -330,6 +330,7 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { case .p250: switch ageCategory { case .senior, .a45, .a55: + if category == .mix { return 0 } return category == .men ? 500 : 100 default: return 0 @@ -365,12 +366,18 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { } else { return .nineGamesDecisivePoint } - case .p1000, .p1500: - if roundIndex <= 1 { //demi / finale + case .p1000: + if roundIndex <= 3 { //demi / finale / quart / 8eme return .twoSetsDecisivePoint } else { return .twoSetsDecisivePointSuperTie } + case .p1500, .p2000: + if roundIndex <= 3 { //demi / finale / quart / 8eme + return .twoSetsDecisivePoint + } else { + return .twoSetsSuperTie + } default: return .superTie } @@ -391,12 +398,12 @@ enum TournamentLevel: Int, Hashable, Codable, CaseIterable, Identifiable { return .superTie case .p100, .p250, .p500: return .nineGamesDecisivePoint + case .p1000: + return .nineGamesDecisivePoint + case .p1500, .p2000: + return .twoSetsSuperTie default: - if roundIndex <= 1 { //petite finale - return .twoSetsDecisivePointSuperTie - } else { - return .nineGamesDecisivePoint - } + return .nineGamesDecisivePoint } } diff --git a/PadelClub/Utils/URLs.swift b/PadelClub/Utils/URLs.swift index 693ef37..ad03b9c 100644 --- a/PadelClub/Utils/URLs.swift +++ b/PadelClub/Utils/URLs.swift @@ -16,8 +16,15 @@ enum URLs: String, Identifiable { case beachPadel = "https://beach-padel.app.fft.fr/beachja/index/" //case padelClub = "https://padelclub.app" case tenup = "https://tenup.fft.fr" - case padelRules = "https://fft-site.cdn.prismic.io/fft-site/ZgLn3McYqOFdyF7n_LEGUIDEDELACOMPETITIONDEPADEL-MAJDECEMBRE2023.pdf" + case padelCompetitionGeneralGuide = "https://fft-site.cdn.prismic.io/fft-site/Zqi2PB5LeNNTxlrS_1-REGLESGENERALESDELACOMPETITION-ANNEESPORTIVE2025.pdf" + case padelCompetitionSpecificGuide = "https://fft-site.cdn.prismic.io/fft-site/Zqi4ax5LeNNTxlsu_3-CAHIERDESCHARGESDESTOURNOIS-ANNEESPORTIVE2025.pdf" + case padelRules = "https://fft-site.cdn.prismic.io/fft-site/ZgLnkMcYqOFdyF7i_L%27arbitragedupadel-édition2023_0.pdf" case restingDischarge = "https://club.fft.fr/tennisfirmidecazeville/60120370_d/data_1/pdf/fo/formlairededechargederesponsabilitetournoidepadel.pdf" + case appReview = "https://apps.apple.com/app/padel-club/id6484163558?mt=8&action=write-review" + case appDescription = "https://padelclub.app/download/" + case instagram = "https://www.instagram.com/padelclub.app?igsh=bmticnV5YWhpMnBn" + case appStore = "https://apps.apple.com/app/padel-club/id6484163558" + var id: String { return self.rawValue } var url: URL { diff --git a/PadelClub/Views/Navigation/MainView.swift b/PadelClub/Views/Navigation/MainView.swift index cf823a2..ba7e719 100644 --- a/PadelClub/Views/Navigation/MainView.swift +++ b/PadelClub/Views/Navigation/MainView.swift @@ -7,10 +7,12 @@ import SwiftUI import LeStorage +import StoreKit struct MainView: View { @EnvironmentObject var dataStore: DataStore - + @Environment(\.requestReview) var requestReview + @AppStorage("importingFiles") var importingFiles: Bool = false @Environment(NavigationViewModel.self) private var navigation: NavigationViewModel @@ -68,6 +70,12 @@ struct MainView: View { await self._checkSourceFileAvailability() } } + + #if DEBUG + #else + _requestReviewIfAppropriated() + #endif + } .toolbarBackground(.visible, for: .tabBar) TournamentOrganizerView() @@ -134,6 +142,15 @@ struct MainView: View { } } + @MainActor + private func _requestReviewIfAppropriated() { + let isConnected = StoreCenter.main.userId != nil + let numberOfSignificantTournaments = dataStore.tournaments.filter({ $0.isDeleted == false && $0.endDate != nil }).count + if isConnected || numberOfSignificantTournaments > 0 { + requestReview() + } + } + func _activityStatusBoxView() -> some View { return _activityStatus() .toastFormatted() diff --git a/PadelClub/Views/Navigation/Organizer/TournamentOrganizerView.swift b/PadelClub/Views/Navigation/Organizer/TournamentOrganizerView.swift index 499a2a0..b97a2b3 100644 --- a/PadelClub/Views/Navigation/Organizer/TournamentOrganizerView.swift +++ b/PadelClub/Views/Navigation/Organizer/TournamentOrganizerView.swift @@ -30,28 +30,30 @@ struct TournamentOrganizerView: View { .toolbarBackground(.visible, for: .navigationBar) } } - Divider() - HStack { - ScrollViewReader { proxy in - ScrollView(.horizontal) { - HStack { - let tournaments = dataStore.tournaments.filter({ $0.hasEnded() == false && $0.isDeleted == false && $0.isCanceled == false }).sorted(by: \.startDate).reversed() - ForEach(tournaments) { tournament in - TournamentButtonView(tournament: tournament) - .id(tournament.id) + let tournaments = dataStore.tournaments.filter({ $0.hasEnded() == false && $0.isDeleted == false && $0.isCanceled == false }).sorted(by: \.startDate).reversed() + if tournaments.isEmpty == false { + Divider() + HStack { + ScrollViewReader { proxy in + ScrollView(.horizontal) { + HStack { + ForEach(tournaments) { tournament in + TournamentButtonView(tournament: tournament) + .id(tournament.id) + } } + .padding() + .buttonStyle(.plain) } - .padding() - .buttonStyle(.plain) - } - .onAppear { - if let selectedDestination = navigation.organizerTournament { - proxy.scrollTo(selectedDestination.id, anchor: .center) + .onAppear { + if let selectedDestination = navigation.organizerTournament { + proxy.scrollTo(selectedDestination.id, anchor: .center) + } } - } - .onChange(of: navigation.organizerTournament) { - if let selectedDestination = navigation.organizerTournament { - proxy.scrollTo(selectedDestination.id, anchor: .center) + .onChange(of: navigation.organizerTournament) { + if let selectedDestination = navigation.organizerTournament { + proxy.scrollTo(selectedDestination.id, anchor: .center) + } } } } diff --git a/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift b/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift index 7980173..9677449 100644 --- a/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift +++ b/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift @@ -31,24 +31,25 @@ struct ToolboxView: View { @Bindable var navigation = navigation NavigationStack(path: $navigation.toolboxPath) { List { - Section { - Text("Version de l'application").badge(PadelClubApp.appVersion) - .onTapGesture(count: 5) { - StoreCenter.main.resetApiCalls() - didResetApiCalls = true - } - - SupportButtonView(contentIsUnavailable: false) Link(destination: URLs.main.url) { - Text("Accéder au site Padel Club") + Text("Accéder à padelclub.app") } .contextMenu { ShareLink(item: URLs.main.url) } + + SupportButtonView(contentIsUnavailable: false) + + Link(destination: URLs.appReview.url) { + Text("Partagez vos impressions !") + } + + Link(destination: URLs.instagram.url) { + Text("Compte Instagram PadelClub.app") + } } - #if DEBUG Section { @@ -124,7 +125,21 @@ struct ToolboxView: View { } #endif + + Section { + NavigationLink { + SelectablePlayerListView() + } label: { + Label("Rechercher un joueur", systemImage: "person.fill.viewfinder") + } + NavigationLink { + RankCalculatorView() + } label: { + Label("Calculateur de points", systemImage: "scalemass") + } + } + Section { NavigationLink { PadelClubView() @@ -154,24 +169,22 @@ struct ToolboxView: View { } Section { - NavigationLink { - SelectablePlayerListView() - } label: { - Label("Rechercher un joueur", systemImage: "person.fill.viewfinder") - } - - NavigationLink { - RankCalculatorView() - } label: { - Label("Calculateur de points", systemImage: "scalemass") - } - } - - Section { - Link("Accéder au guide de la compétition", destination: URLs.padelRules.url) - Link("Formulaire de décharge des temps de repos", destination: URLs.restingDischarge.url) + Link("Accéder au guide de la compétition", destination: URLs.padelCompetitionGeneralGuide.url) + Link("Accéder aux CDC des tournois", destination: URLs.padelCompetitionSpecificGuide.url) + Link("Accéder aux règles du jeu", destination: URLs.padelRules.url) + Link("Décharge des temps de repos", destination: URLs.restingDischarge.url) } header: { Text("Documents fédéraux") + .onTapGesture(count: 5) { + StoreCenter.main.resetApiCalls() + didResetApiCalls = true + } + } + + Section { + Link(destination: URLs.appDescription.url) { + Text("Page de présentation de Padel Club") + } } } @@ -187,8 +200,14 @@ struct ToolboxView: View { } } } - .navigationTitle(TabDestination.toolbox.title) + .toolbar { + ToolbarItem(placement: .topBarTrailing) { + Link(destination: URLs.appStore.url) { + Text("v\(PadelClubApp.appVersion)") + } + } + } } } }