From 90605c6112d03dd662ac6f5fa24d72b25c562652 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Wed, 29 May 2024 11:24:59 +0200 Subject: [PATCH] fix stuff --- PadelClub/Data/Club.swift | 10 ++++++- .../Calling/Components/MenuWarningView.swift | 23 ++++++++++------ PadelClub/Views/Match/MatchDetailView.swift | 26 +++++++------------ .../Tournament/Screen/BroadcastView.swift | 7 +++-- PadelClubTests/ServerDataTests.swift | 3 ++- 5 files changed, 40 insertions(+), 29 deletions(-) diff --git a/PadelClub/Data/Club.swift b/PadelClub/Data/Club.swift index 3aeca00..14669ea 100644 --- a/PadelClub/Data/Club.swift +++ b/PadelClub/Data/Club.swift @@ -177,7 +177,15 @@ extension Club { guard let code else { return nil } return URL(string: "https://tenup.fft.fr/club/\(code)") } - + + func courtName(atIndex courtIndex: Int) -> String { + courtNameIfAvailable(atIndex: courtIndex) ?? Court.courtIndexedTitle(atIndex: courtIndex) + } + + func courtNameIfAvailable(atIndex courtIndex: Int) -> String? { + customizedCourts.first(where: { $0.index == courtIndex })?.name + } + func update(fromClub club: Club) { self.acronym = club.acronym self.name = club.name diff --git a/PadelClub/Views/Calling/Components/MenuWarningView.swift b/PadelClub/Views/Calling/Components/MenuWarningView.swift index 6668980..ef6ca1b 100644 --- a/PadelClub/Views/Calling/Components/MenuWarningView.swift +++ b/PadelClub/Views/Calling/Components/MenuWarningView.swift @@ -26,17 +26,24 @@ struct MenuWarningView: View { // TODO: Guard @ViewBuilder private func _actionView(players: [PlayerRegistration], privateMode: Bool = false) -> some View { - Menu { - ForEach(players) { player in - if let number = player.phoneNumber?.replacingOccurrences(of: " ", with: ""), let url = URL(string: "tel:\(number)") { - Link(destination: url) { - Text(player.playerLabel(.short)) - Label(number, systemImage: "phone") + if players.count == 1, let player = players.first, let number = player.phoneNumber?.replacingOccurrences(of: " ", with: ""), let url = URL(string: "tel:\(number)") { + Link(destination: url) { + Label("Appeler", systemImage: "phone") + Text(number) + } + } else { + Menu { + ForEach(players) { player in + if let number = player.phoneNumber?.replacingOccurrences(of: " ", with: ""), let url = URL(string: "tel:\(number)") { + Link(destination: url) { + Label(player.playerLabel(.short), systemImage: "phone") + Text(number) + } } } + } label: { + Text("Appeler un joueur") } - } label: { - Label("Appeler un joueur", systemImage: "phone") } Button("Message") { diff --git a/PadelClub/Views/Match/MatchDetailView.swift b/PadelClub/Views/Match/MatchDetailView.swift index 2b16ad3..cf7000f 100644 --- a/PadelClub/Views/Match/MatchDetailView.swift +++ b/PadelClub/Views/Match/MatchDetailView.swift @@ -409,21 +409,22 @@ struct MatchDetailView: View { Picker(selection: $fieldSetup) { Text("Au hasard").tag(MatchFieldSetup.random) //Text("Premier disponible").tag(MatchFieldSetup.firstAvailable) - if let tournament = match.currentTournament() { + if let club = match.currentTournament()?.club() { + ForEach(0..