From 9f05ad48638b00b6f9c94f87f45a5ea0080e0ee0 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Tue, 21 May 2024 10:09:13 +0200 Subject: [PATCH] fix short label player --- PadelClub/Data/TeamRegistration.swift | 9 ++------- PadelClub/ViewModel/MatchDescriptor.swift | 4 ++-- PadelClub/Views/Calling/Components/MenuWarningView.swift | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/PadelClub/Data/TeamRegistration.swift b/PadelClub/Data/TeamRegistration.swift index f11825c..7b0de30 100644 --- a/PadelClub/Data/TeamRegistration.swift +++ b/PadelClub/Data/TeamRegistration.swift @@ -134,13 +134,8 @@ class TeamRegistration: ModelObject, Storable { setWeight(from: self.players(), inTournamentCategory: tournamentCategory) } - func teamLabel(_ displayStyle: DisplayStyle = .wide) -> String { - switch displayStyle { - case .wide: - players().map { $0.playerLabel(displayStyle) }.joined(separator: " & ") - case .short: - players().map { $0.playerLabel(.short) }.joined(separator: "\n") - } + func teamLabel(_ displayStyle: DisplayStyle = .wide, twoLines: Bool = false) -> String { + players().map { $0.playerLabel(displayStyle) }.joined(separator: twoLines ? "\n" : " & ") } func index(in teams: [TeamRegistration]) -> Int? { diff --git a/PadelClub/ViewModel/MatchDescriptor.swift b/PadelClub/ViewModel/MatchDescriptor.swift index 0cd3a14..8072cb3 100644 --- a/PadelClub/ViewModel/MatchDescriptor.swift +++ b/PadelClub/ViewModel/MatchDescriptor.swift @@ -29,8 +29,8 @@ class MatchDescriptor: ObservableObject { } let teamOne = match?.team(.one) let teamTwo = match?.team(.two) - self.teamLabelOne = teamOne?.teamLabel(.short) ?? "" - self.teamLabelTwo = teamTwo?.teamLabel(.short) ?? "" + self.teamLabelOne = teamOne?.teamLabel(.wide, twoLines: true) ?? "" + self.teamLabelTwo = teamTwo?.teamLabel(.wide, twoLines: true) ?? "" if let match, let scoresTeamOne = match.teamScore(ofTeam: teamOne)?.score, let scoresTeamTwo = match.teamScore(ofTeam: teamTwo)?.score { diff --git a/PadelClub/Views/Calling/Components/MenuWarningView.swift b/PadelClub/Views/Calling/Components/MenuWarningView.swift index d8aacf8..b83ecb0 100644 --- a/PadelClub/Views/Calling/Components/MenuWarningView.swift +++ b/PadelClub/Views/Calling/Components/MenuWarningView.swift @@ -71,7 +71,7 @@ struct MenuWarningView: View { _playerView(player) } } label: { - Text(team.teamLabel(.short)) + Text(team.teamLabel(.short, twoLines: true)) } } }