From 9dc16f9c81b014e551a6037a9f3b6d95899debb3 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Sun, 19 May 2024 10:00:05 +0200 Subject: [PATCH] add tips and guide --- PadelClub.xcodeproj/project.pbxproj | 4 + PadelClub/Data/Tournament.swift | 4 + PadelClub/Utils/Tips.swift | 27 +++++++ PadelClub/Utils/URLs.swift | 1 + .../Navigation/Toolbox/ToolboxView.swift | 4 + .../Tournament/TournamentBuildView.swift | 75 +++++++++++++++++++ .../Tournament/TournamentRunningView.swift | 54 +------------ .../Views/Tournament/TournamentView.swift | 15 ++-- 8 files changed, 126 insertions(+), 58 deletions(-) create mode 100644 PadelClub/Views/Tournament/TournamentBuildView.swift diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index fbdf266..e2a6856 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -126,6 +126,7 @@ FF1DC5592BAB767000FD8220 /* Tips.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF1DC5582BAB767000FD8220 /* Tips.swift */; }; FF1DC55B2BAB80C400FD8220 /* DisplayContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF1DC55A2BAB80C400FD8220 /* DisplayContext.swift */; }; FF1DF49B2BD8D23900822FA0 /* BarButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF1DF49A2BD8D23900822FA0 /* BarButtonView.swift */; }; + FF1F4B6D2BF9E60B000B4573 /* TournamentBuildView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF1F4B6C2BF9E60B000B4573 /* TournamentBuildView.swift */; }; FF2EFBF02BDE295E0049CE3B /* SendToAllView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF2EFBEF2BDE295E0049CE3B /* SendToAllView.swift */; }; FF3795622B9396D0004EA093 /* PadelClubApp.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = FF3795602B9396D0004EA093 /* PadelClubApp.xcdatamodeld */; }; FF3795662B9399AA004EA093 /* Persistence.swift in Sources */ = {isa = PBXBuildFile; fileRef = FF3795652B9399AA004EA093 /* Persistence.swift */; }; @@ -428,6 +429,7 @@ FF1DC5582BAB767000FD8220 /* Tips.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tips.swift; sourceTree = ""; }; FF1DC55A2BAB80C400FD8220 /* DisplayContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayContext.swift; sourceTree = ""; }; FF1DF49A2BD8D23900822FA0 /* BarButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BarButtonView.swift; sourceTree = ""; }; + FF1F4B6C2BF9E60B000B4573 /* TournamentBuildView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TournamentBuildView.swift; sourceTree = ""; }; FF2EFBEF2BDE295E0049CE3B /* SendToAllView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendToAllView.swift; sourceTree = ""; }; FF3795612B9396D0004EA093 /* Model.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = Model.xcdatamodel; sourceTree = ""; }; FF3795652B9399AA004EA093 /* Persistence.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Persistence.swift; sourceTree = ""; }; @@ -918,6 +920,7 @@ children = ( FF70916B2B91005400AB08DA /* TournamentView.swift */, FF8F26402BADFC8700650388 /* TournamentInitView.swift */, + FF1F4B6C2BF9E60B000B4573 /* TournamentBuildView.swift */, FF967CF52BAED51600A9A3BD /* TournamentRunningView.swift */, FF089EBE2BB0B14600F0AEC7 /* FileImportView.swift */, FF3F74F92B91A018004CFE0E /* Screen */, @@ -1600,6 +1603,7 @@ FFCFC01A2BBC5A8500B82851 /* MatchTypeSmallSelectionView.swift in Sources */, FF025AE92BD1307F00A86CF8 /* MonthData.swift in Sources */, FFEF7F4E2BDE69130033D0F0 /* MenuWarningView.swift in Sources */, + FF1F4B6D2BF9E60B000B4573 /* TournamentBuildView.swift in Sources */, FF967D0B2BAF3D4C00A9A3BD /* TeamPickerView.swift in Sources */, FFA6D7872BB0B7A2003A31F3 /* CloudConvert.swift in Sources */, FFBF41842BF75ED7001B24CB /* EventTournamentsView.swift in Sources */, diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index 21c5351..e208ac0 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -290,6 +290,7 @@ class Tournament : ModelObject, Storable { enum State { case initial case build + case running case canceled } @@ -400,6 +401,9 @@ class Tournament : ModelObject, Storable { if self.isCanceled == true { return .canceled } + + if startDate >= Date() { return .running } + if (groupStageCount > 0 && groupStages().isEmpty == false) || rounds().isEmpty == false { return .build diff --git a/PadelClub/Utils/Tips.swift b/PadelClub/Utils/Tips.swift index 8dd7576..236a89a 100644 --- a/PadelClub/Utils/Tips.swift +++ b/PadelClub/Utils/Tips.swift @@ -385,6 +385,33 @@ struct TournamentSelectionTip: Tip { } } +struct TournamentRunningTip: Tip { + @Parameter + static var isRunning: Bool = false + + var rules: [Rule] { + [ + // Define a rule based on the app state. + #Rule(Self.$isRunning) { + // Set the conditions for when the tip displays. + return $0 + } + ] + } + + var title: Text { + Text("Tournoi en cours") + } + + var message: Text? { + return Text("Le tournoi a commencé, les options utiles à sa préparation son accessible ici pour laisser la place aux matchs.") + } + + var image: Image? { + Image(systemName: "ellipsis.circle.fill") + } +} + struct TipStyleModifier: ViewModifier { @Environment(\.colorScheme) var colorScheme var tint: Color? diff --git a/PadelClub/Utils/URLs.swift b/PadelClub/Utils/URLs.swift index f62d8d4..194bb8a 100644 --- a/PadelClub/Utils/URLs.swift +++ b/PadelClub/Utils/URLs.swift @@ -12,6 +12,7 @@ enum URLs: String, Identifiable { case main = "https://xlr.alwaysdata.net/" case beachPadel = "https://beach-padel.app.fft.fr/beachja/index/" //case padelClub = "https://padelclub.app" + case padelRules = "https://fft-site.cdn.prismic.io/fft-site/ZgLn3McYqOFdyF7n_LEGUIDEDELACOMPETITIONDEPADEL-MAJDECEMBRE2023.pdf" var id: String { return self.rawValue } diff --git a/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift b/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift index 91cf3cc..1c96c50 100644 --- a/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift +++ b/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift @@ -44,6 +44,10 @@ struct ToolboxView: View { } footer: { Text("Vous pouvez définir vos propres estimations de durées de match en fonction du format de jeu.") } + + Section { + Link("Guide de la compétition", destination: URLs.padelRules) + } } .navigationTitle(TabDestination.toolbox.title) } diff --git a/PadelClub/Views/Tournament/TournamentBuildView.swift b/PadelClub/Views/Tournament/TournamentBuildView.swift new file mode 100644 index 0000000..3506d7a --- /dev/null +++ b/PadelClub/Views/Tournament/TournamentBuildView.swift @@ -0,0 +1,75 @@ +// +// TournamentBuildView.swift +// PadelClub +// +// Created by Razmig Sarkissian on 19/05/2024. +// + +import SwiftUI + +struct TournamentBuildView: View { + var tournament: Tournament + + @ViewBuilder + var body: some View { + TournamentInitView(tournament: tournament) + + Section { + NavigationLink(value: Screen.schedule) { + let tournamentStatus = tournament.scheduleStatus() + LabeledContent { + Text(tournamentStatus.completion) + } label: { + Text("Horaires") + Text(tournamentStatus.label) + } + } + + NavigationLink(value: Screen.call) { + let tournamentStatus = tournament.callStatus() + LabeledContent { + Text(tournamentStatus.completion) + } label: { + Text("Convocations") + Text(tournamentStatus.label) + } + } + + NavigationLink(value: Screen.cashier) { + let tournamentStatus = tournament.cashierStatus() + LabeledContent { + Text(tournamentStatus.completion) + } label: { + Text("Encaissement") + Text(tournamentStatus.label) + } + } + } + + Section { + if tournament.groupStages().isEmpty == false { + NavigationLink(value: Screen.groupStage) { + LabeledContent { + Text(tournament.groupStageStatus()) + } label: { + Text("Poules") + } + } + } + + if tournament.rounds().isEmpty == false { + NavigationLink(value: Screen.round) { + LabeledContent { + Text(tournament.bracketStatus()) + } label: { + Text("Tableau") + } + } + } + } + } +} + +#Preview { + TournamentBuildView(tournament: Tournament.mock()) +} diff --git a/PadelClub/Views/Tournament/TournamentRunningView.swift b/PadelClub/Views/Tournament/TournamentRunningView.swift index 3b13623..5ebd72d 100644 --- a/PadelClub/Views/Tournament/TournamentRunningView.swift +++ b/PadelClub/Views/Tournament/TournamentRunningView.swift @@ -18,59 +18,7 @@ struct TournamentRunningView: View { @ViewBuilder var body: some View { - Section { - NavigationLink(value: Screen.schedule) { - let tournamentStatus = tournament.scheduleStatus() - LabeledContent { - Text(tournamentStatus.completion) - } label: { - Text("Horaires") - Text(tournamentStatus.label) - } - } - - NavigationLink(value: Screen.call) { - let tournamentStatus = tournament.callStatus() - LabeledContent { - Text(tournamentStatus.completion) - } label: { - Text("Convocations") - Text(tournamentStatus.label) - } - } - - NavigationLink(value: Screen.cashier) { - let tournamentStatus = tournament.cashierStatus() - LabeledContent { - Text(tournamentStatus.completion) - } label: { - Text("Encaissement") - Text(tournamentStatus.label) - } - } - } - - Section { - if tournament.groupStages().isEmpty == false { - NavigationLink(value: Screen.groupStage) { - LabeledContent { - Text(tournament.groupStageStatus()) - } label: { - Text("Poules") - } - } - } - - if tournament.rounds().isEmpty == false { - NavigationLink(value: Screen.round) { - LabeledContent { - Text(tournament.bracketStatus()) - } label: { - Text("Tableau") - } - } - } - } + TournamentBuildView(tournament: tournament) MatchListView(section: "en cours", matches: tournament.runningMatches(allMatches)) MatchListView(section: "à lancer", matches: tournament.readyMatches(allMatches), isExpanded: false) diff --git a/PadelClub/Views/Tournament/TournamentView.swift b/PadelClub/Views/Tournament/TournamentView.swift index 97b8216..86c4bda 100644 --- a/PadelClub/Views/Tournament/TournamentView.swift +++ b/PadelClub/Views/Tournament/TournamentView.swift @@ -16,6 +16,7 @@ struct TournamentView: View { var presentationContext: PresentationContext = .agenda let tournamentSelectionTip = TournamentSelectionTip() + let tournamentRunningTip = TournamentRunningTip() var selectedTournamentId: Binding { Binding( get: { tournament.id }, @@ -86,6 +87,8 @@ struct TournamentView: View { case .initial: TournamentInitView(tournament: tournament) case .build: + TournamentBuildView(tournament: tournament) + case .running: TournamentRunningView(tournament: tournament) if tournament.hasEnded() { @@ -155,7 +158,7 @@ struct TournamentView: View { } } - if presentationContext == .agenda || tournament.state() == .build { + if presentationContext == .agenda || tournament.state() == .running { ToolbarItem(placement: .topBarTrailing) { Menu { if presentationContext == .agenda { @@ -167,7 +170,7 @@ struct TournamentView: View { } Divider() - if tournament.state() == .build { + if tournament.state() == .running { NavigationLink(value: Screen.event) { Text("Gestion de l'événement") } @@ -178,9 +181,7 @@ struct TournamentView: View { NavigationLink(value: Screen.structure) { LabelStructure() } - NavigationLink(value: Screen.rankings) { - Text("Classement") - } + NavigationLink(value: Screen.broadcast) { Text("Publication") } @@ -188,6 +189,10 @@ struct TournamentView: View { } label: { LabelOptions() } + .popoverTip(tournamentRunningTip) + .onAppear { + TournamentRunningTip.isRunning = tournament.state == .running + } } } }