fix short label player

multistore
Razmig Sarkissian 1 year ago
parent 61d0c94cee
commit 9f05ad4863
  1. 9
      PadelClub/Data/TeamRegistration.swift
  2. 4
      PadelClub/ViewModel/MatchDescriptor.swift
  3. 2
      PadelClub/Views/Calling/Components/MenuWarningView.swift

@ -134,13 +134,8 @@ class TeamRegistration: ModelObject, Storable {
setWeight(from: self.players(), inTournamentCategory: tournamentCategory) setWeight(from: self.players(), inTournamentCategory: tournamentCategory)
} }
func teamLabel(_ displayStyle: DisplayStyle = .wide) -> String { func teamLabel(_ displayStyle: DisplayStyle = .wide, twoLines: Bool = false) -> String {
switch displayStyle { players().map { $0.playerLabel(displayStyle) }.joined(separator: twoLines ? "\n" : " & ")
case .wide:
players().map { $0.playerLabel(displayStyle) }.joined(separator: " & ")
case .short:
players().map { $0.playerLabel(.short) }.joined(separator: "\n")
}
} }
func index(in teams: [TeamRegistration]) -> Int? { func index(in teams: [TeamRegistration]) -> Int? {

@ -29,8 +29,8 @@ class MatchDescriptor: ObservableObject {
} }
let teamOne = match?.team(.one) let teamOne = match?.team(.one)
let teamTwo = match?.team(.two) let teamTwo = match?.team(.two)
self.teamLabelOne = teamOne?.teamLabel(.short) ?? "" self.teamLabelOne = teamOne?.teamLabel(.wide, twoLines: true) ?? ""
self.teamLabelTwo = teamTwo?.teamLabel(.short) ?? "" self.teamLabelTwo = teamTwo?.teamLabel(.wide, twoLines: true) ?? ""
if let match, let scoresTeamOne = match.teamScore(ofTeam: teamOne)?.score, let scoresTeamTwo = match.teamScore(ofTeam: teamTwo)?.score { if let match, let scoresTeamOne = match.teamScore(ofTeam: teamOne)?.score, let scoresTeamTwo = match.teamScore(ofTeam: teamTwo)?.score {

@ -71,7 +71,7 @@ struct MenuWarningView: View {
_playerView(player) _playerView(player)
} }
} label: { } label: {
Text(team.teamLabel(.short)) Text(team.teamLabel(.short, twoLines: true))
} }
} }
} }

Loading…
Cancel
Save