diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 9f0af5b..a52daa1 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -243,6 +243,7 @@ FFDB1C6D2BB2A02000F1E467 /* AppSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFDB1C6C2BB2A02000F1E467 /* AppSettings.swift */; }; FFDB1C732BB2CFE900F1E467 /* MySortDescriptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFDB1C722BB2CFE900F1E467 /* MySortDescriptor.swift */; }; FFDDD40C2B93B2BB00C91A49 /* DeferredViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFDDD40B2B93B2BB00C91A49 /* DeferredViewModifier.swift */; }; + FFEF7F4E2BDE69130033D0F0 /* MenuWarningView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFEF7F4D2BDE69130033D0F0 /* MenuWarningView.swift */; }; FFF03C942BD91D0C00B516FC /* ButtonValidateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFF03C932BD91D0C00B516FC /* ButtonValidateView.swift */; }; FFF116E12BD2A9B600A33B06 /* DateInterval.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFF116E02BD2A9B600A33B06 /* DateInterval.swift */; }; FFF116E32BD2AF4800A33B06 /* CourtAvailabilitySettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FFF116E22BD2AF4800A33B06 /* CourtAvailabilitySettingsView.swift */; }; @@ -545,6 +546,7 @@ FFDB1C6C2BB2A02000F1E467 /* AppSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettings.swift; sourceTree = ""; }; FFDB1C722BB2CFE900F1E467 /* MySortDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MySortDescriptor.swift; sourceTree = ""; }; FFDDD40B2B93B2BB00C91A49 /* DeferredViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeferredViewModifier.swift; sourceTree = ""; }; + FFEF7F4D2BDE69130033D0F0 /* MenuWarningView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuWarningView.swift; sourceTree = ""; }; FFF03C932BD91D0C00B516FC /* ButtonValidateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonValidateView.swift; sourceTree = ""; }; FFF116E02BD2A9B600A33B06 /* DateInterval.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateInterval.swift; sourceTree = ""; }; FFF116E22BD2AF4800A33B06 /* CourtAvailabilitySettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CourtAvailabilitySettingsView.swift; sourceTree = ""; }; @@ -1087,6 +1089,7 @@ FF9268082BCEDC2C0080F940 /* CallView.swift */, FF1162792BCF8109000C4809 /* CallMessageCustomizationView.swift */, FF2EFBEF2BDE295E0049CE3B /* SendToAllView.swift */, + FFEF7F4C2BDE68F80033D0F0 /* Components */, ); path = Calling; sourceTree = ""; @@ -1172,6 +1175,14 @@ path = ViewModifiers; sourceTree = ""; }; + FFEF7F4C2BDE68F80033D0F0 /* Components */ = { + isa = PBXGroup; + children = ( + FFEF7F4D2BDE69130033D0F0 /* MenuWarningView.swift */, + ); + path = Components; + sourceTree = ""; + }; FFF8ACD02B9238A2008466FA /* Manager */ = { isa = PBXGroup; children = ( @@ -1564,6 +1575,7 @@ FF11628A2BD05247000C4809 /* DateUpdateManagerView.swift in Sources */, FFCFC01A2BBC5A8500B82851 /* MatchTypeSmallSelectionView.swift in Sources */, FF025AE92BD1307F00A86CF8 /* MonthData.swift in Sources */, + FFEF7F4E2BDE69130033D0F0 /* MenuWarningView.swift in Sources */, FF967D0B2BAF3D4C00A9A3BD /* TeamPickerView.swift in Sources */, FFA6D7872BB0B7A2003A31F3 /* CloudConvert.swift in Sources */, FF1DC55B2BAB80C400FD8220 /* DisplayContext.swift in Sources */, diff --git a/PadelClub/Views/Calling/Components/MenuWarningView.swift b/PadelClub/Views/Calling/Components/MenuWarningView.swift new file mode 100644 index 0000000..e8e5218 --- /dev/null +++ b/PadelClub/Views/Calling/Components/MenuWarningView.swift @@ -0,0 +1,80 @@ +// +// MenuWarningView.swift +// PadelClub +// +// Created by razmig on 28/04/2024. +// + +import SwiftUI + +struct MenuWarningView: View { + let teams: [TeamRegistration] + var date: Date? + var message: String? + var umpireMail: String? + var subject: String? + + @State private var contactType: ContactType? + + func getUmpireMail() -> [String]? { + if let umpireMail { + return [umpireMail] + } + return nil + } + + @ViewBuilder + private func _actionView(players: [PlayerRegistration], privateMode: Bool = false) -> some View { + Button("Message") { + contactType = .message(date: date, recipients: players.compactMap({ $0.phoneNumber }), body: message, tournamentBuild: nil) + } + Button("Mail") { + contactType = .mail(date: date, recipients: privateMode ? getUmpireMail() : players.compactMap({ $0.email }), bccRecipients: privateMode ? players.compactMap({ $0.email }) : nil, body: message, subject: subject, tournamentBuild: nil) + } + } + + var body: some View { + + Menu { + Menu("Tout le monde") { + let players = teams.flatMap({ $0.players() }) + _actionView(players: players, privateMode: true) + } + Divider() + ForEach(teams) { team in + _teamView(team) + } + } label: { + Text("Prévenir") + .underline() + } + } + + func _playerView(_ player: PlayerRegistration) -> some View { + Menu { + let players = [player] + _actionView(players: players) + } label: { + Text(player.playerLabel(.short)) + } + } + + func _teamView(_ team: TeamRegistration) -> some View { + Menu { + Menu("Toute l'équipe") { + let players = team.players() + _actionView(players: players) + } + Divider() + ForEach(team.players()) { player in + _playerView(player) + } + } label: { + Text(team.teamLabel(.short)) + } + } +} + +#Preview { + MenuWarningView(teams: []) +} diff --git a/PadelClub/Views/Calling/SendToAllView.swift b/PadelClub/Views/Calling/SendToAllView.swift index cc9f9b8..c577015 100644 --- a/PadelClub/Views/Calling/SendToAllView.swift +++ b/PadelClub/Views/Calling/SendToAllView.swift @@ -39,7 +39,6 @@ struct SendToAllView: View { } .tag(groupStage.id) } - } ForEach(tournament.rounds()) { round in let teams = round.teams() diff --git a/PadelClub/Views/Match/MatchDetailView.swift b/PadelClub/Views/Match/MatchDetailView.swift index 4285752..0e59ae9 100644 --- a/PadelClub/Views/Match/MatchDetailView.swift +++ b/PadelClub/Views/Match/MatchDetailView.swift @@ -110,18 +110,12 @@ struct MatchDetailView: View { } footer: { if match.isEmpty() == false { HStack { - Button { + FooterButtonView("Détails des joueurs") { showDetails = true - } label: { - Text("Détails des joueurs") } Spacer() - Menu { - //MenuWarnView(warningSender: match) - } label: { - Text("Prévenir") - } - .buttonStyle(.borderless) + MenuWarningView(teams: match.teams()) + .buttonStyle(.borderless) } } }