diff --git a/PadelClub/Views/Calling/Components/MenuWarningView.swift b/PadelClub/Views/Calling/Components/MenuWarningView.swift index 31c74ed..7e7d476 100644 --- a/PadelClub/Views/Calling/Components/MenuWarningView.swift +++ b/PadelClub/Views/Calling/Components/MenuWarningView.swift @@ -55,7 +55,7 @@ struct MenuWarningView: View { let players = [player] _actionView(players: players) } label: { - Text(player.playerLabel(.short)) + Text(player.playerLabel()) } } diff --git a/PadelClub/Views/Calling/SendToAllView.swift b/PadelClub/Views/Calling/SendToAllView.swift index 891cbf5..c5ae77c 100644 --- a/PadelClub/Views/Calling/SendToAllView.swift +++ b/PadelClub/Views/Calling/SendToAllView.swift @@ -71,7 +71,7 @@ struct SendToAllView: View { if contactMethod == 0 { contactType = .message(date: nil, recipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.phoneNumber }, body: tournament.tournamentTitle(), tournamentBuild: nil) } else { - contactType = .mail(date: nil, recipients: nil, bccRecipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.email }, body: nil, subject: tournament.tournamentTitle(), tournamentBuild: nil) + contactType = .mail(date: nil, recipients: tournament.umpireMail(), bccRecipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.email }, body: nil, subject: tournament.tournamentTitle(), tournamentBuild: nil) } } } diff --git a/PadelClub/Views/Match/Components/MatchDateView.swift b/PadelClub/Views/Match/Components/MatchDateView.swift index d6e06f1..4f00cb7 100644 --- a/PadelClub/Views/Match/Components/MatchDateView.swift +++ b/PadelClub/Views/Match/Components/MatchDateView.swift @@ -8,7 +8,6 @@ import SwiftUI struct MatchDateView: View { - @Environment(Tournament.self) var tournament: Tournament @EnvironmentObject var dataStore: DataStore var match: Match var showPrefix: Bool = false @@ -32,7 +31,8 @@ struct MatchDateView: View { save() } } else { - let estimatedDuration = match.matchFormat.getEstimatedDuration(tournament.additionalEstimationDuration) + let tournament = match.currentTournament() + let estimatedDuration = tournament != nil ? match.matchFormat.getEstimatedDuration(tournament!.additionalEstimationDuration) : match.matchFormat.getEstimatedDuration() Button("Décaler de \(estimatedDuration) minutes") { match.startDate = match.startDate?.addingTimeInterval(Double(estimatedDuration) * 60.0) match.endDate = nil diff --git a/PadelClub/Views/Match/MatchSummaryView.swift b/PadelClub/Views/Match/MatchSummaryView.swift index c769645..c336c7e 100644 --- a/PadelClub/Views/Match/MatchSummaryView.swift +++ b/PadelClub/Views/Match/MatchSummaryView.swift @@ -21,7 +21,7 @@ struct MatchSummaryView: View { var color: Color { return Color(white: 0.9) - matchViewStyle == .plainStyle ? Color(uiColor: .tertiaryLabel) : Color(uiColor: .secondaryLabel) + //matchViewStyle == .plainStyle ? Color(uiColor: .tertiaryLabel) : Color(uiColor: .secondaryLabel) } var width: CGFloat { @@ -58,59 +58,51 @@ struct MatchSummaryView: View { var matchSummaryView: some View { VStack(alignment: .leading) { if matchViewStyle != .plainStyle { + if matchViewStyle == .feedStyle, let tournament = match.currentTournament() { + tournamentHeaderView(tournament) + } HStack { - if match.isGroupStage() && matchViewStyle != .feedStyle { - if let groupStage = match.groupStageObject, matchViewStyle == .standardStyle { + if match.isGroupStage() { + if let groupStage = match.groupStageObject { Text(groupStage.groupStageTitle()) } else if let round = match.roundObject { Text(round.roundTitle()) } Text(match.matchTitle()) - } else if let currentTournament = match.currentTournament() { - if matchViewStyle == .feedStyle { - //tournamentHeaderView(currentTournament) - } else if matchViewStyle != .sectionedStandardStyle { - Text(match.matchTitle(.short)) - } } - if matchViewStyle == .standardStyle || matchViewStyle == .sectionedStandardStyle - { + Spacer() + if let court = match.courtName(), match.hasEnded() == false { Spacer() - if let court = match.courtName(), match.hasEnded() == false { - Spacer() - Text(court) - } + Text(court) } } .lineLimit(1) } - if matchViewStyle != .feedStyle { - HStack(spacing: 0) { - VStack(alignment: .leading, spacing: matchViewStyle == .plainStyle ? 8 : 0) { - PlayerBlockView(match: match, teamPosition: .one, color: color, width: width) - .padding(matchViewStyle == .plainStyle ? 0 : 8) - if width == 1 { - Divider() - } else { - Divider().frame(height: width).overlay(color) - } - PlayerBlockView(match: match, teamPosition: .two, color: color, width: width) - .padding(matchViewStyle == .plainStyle ? 0 : 8) + HStack(spacing: 0) { + VStack(alignment: .leading, spacing: matchViewStyle == .plainStyle ? 8 : 0) { + PlayerBlockView(match: match, teamPosition: .one, color: color, width: width) + .padding(matchViewStyle == .plainStyle ? 0 : 8) + if width == 1 { + Divider() + } else { + Divider().frame(height: width).overlay(color) } + PlayerBlockView(match: match, teamPosition: .two, color: color, width: width) + .padding(matchViewStyle == .plainStyle ? 0 : 8) } - .overlay { - if matchViewStyle != .plainStyle { - RoundedRectangle(cornerRadius: 8) - .stroke(color, lineWidth: 2) - } - } - + } + .overlay { if matchViewStyle != .plainStyle { - HStack { - Spacer() - MatchDateView(match: match, showPrefix: matchViewStyle == .tournamentResultStyle ? true : false) - } + RoundedRectangle(cornerRadius: 8) + .stroke(color, lineWidth: 2) + } + } + + if matchViewStyle != .plainStyle { + HStack { + Spacer() + MatchDateView(match: match, showPrefix: matchViewStyle == .tournamentResultStyle) } } } @@ -120,6 +112,7 @@ struct MatchSummaryView: View { @ViewBuilder func tournamentHeaderView(_ currentTournament: Tournament) -> some View { + return Text(currentTournament.tournamentTitle()) VStack(alignment: .leading) { // HStack { // ZStack(alignment: .leading) { diff --git a/PadelClub/Views/Navigation/Ongoing/OngoingView.swift b/PadelClub/Views/Navigation/Ongoing/OngoingView.swift index 4c89fd8..cfc9646 100644 --- a/PadelClub/Views/Navigation/Ongoing/OngoingView.swift +++ b/PadelClub/Views/Navigation/Ongoing/OngoingView.swift @@ -22,7 +22,9 @@ struct OngoingView: View { } } .overlay { - ContentUnavailableView("Aucun match en cours", systemImage: "figure.tennis", description: Text("Tous vos matchs en cours seront visibles ici, quelque soit le tournoi.")) + if matches.isEmpty { + ContentUnavailableView("Aucun match en cours", systemImage: "figure.tennis", description: Text("Tous vos matchs en cours seront visibles ici, quelque soit le tournoi.")) + } } .navigationTitle("En cours") .toolbar(matches.isEmpty ? .hidden : .visible, for: .navigationBar) diff --git a/PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift b/PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift index 23dd95c..330996a 100644 --- a/PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift +++ b/PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift @@ -32,6 +32,7 @@ struct TournamentGeneralSettingsView: View { .keyboardType(.decimalPad) .multilineTextAlignment(.trailing) .frame(maxWidth: .infinity) + .focused($textFieldIsFocus) } label: { Text("Inscription") } @@ -56,13 +57,14 @@ struct TournamentGeneralSettingsView: View { } } } - .focused($textFieldIsFocus) .scrollDismissesKeyboard(.immediately) .toolbarBackground(.visible, for: .navigationBar) .toolbar { - ToolbarItem(placement: .keyboard) { - Button("Valider") { - textFieldIsFocus = false + if textFieldIsFocus { + ToolbarItem(placement: .keyboard) { + Button("Valider") { + textFieldIsFocus = false + } } } } diff --git a/PadelClub/Views/Tournament/Shared/TournamentCellView.swift b/PadelClub/Views/Tournament/Shared/TournamentCellView.swift index 01135e8..991d737 100644 --- a/PadelClub/Views/Tournament/Shared/TournamentCellView.swift +++ b/PadelClub/Views/Tournament/Shared/TournamentCellView.swift @@ -72,24 +72,7 @@ struct TournamentCellView: View { Text(tournament.sortedTeams().count.formatted()) } else if let federalTournament = tournament as? FederalTournament { Button { - if let existingTournament { - navigation.agendaDestination = .activity - navigation.path.append(existingTournament) - } else { - let event = federalTournament.getEvent() - let newTournament = Tournament.newEmptyInstance() - newTournament.event = event.id - //todo - //newTournament.umpireMail() - //newTournament.jsonData = jsonData - newTournament.tournamentLevel = build.level - newTournament.tournamentCategory = build.category - newTournament.federalTournamentAge = build.age - newTournament.dayDuration = federalTournament.dayDuration - newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9) - newTournament.setupFederalSettings() - try? dataStore.tournaments.addOrUpdate(instance: newTournament) - } + _createOrShow(federalTournament: federalTournament, existingTournament: existingTournament, build: build) } label: { Image(systemName: existingTournament != nil ? "checkmark.circle.fill" : "square.and.arrow.down") .resizable() @@ -118,6 +101,27 @@ struct TournamentCellView: View { } .font(.caption) } + + private func _createOrShow(federalTournament: FederalTournament, existingTournament: Tournament?, build: any TournamentBuildHolder) { + if let existingTournament { + navigation.agendaDestination = .activity + navigation.path.append(existingTournament) + } else { + let event = federalTournament.getEvent() + let newTournament = Tournament.newEmptyInstance() + newTournament.event = event.id + //todo + //newTournament.umpireMail() + //newTournament.jsonData = jsonData + newTournament.tournamentLevel = build.level + newTournament.tournamentCategory = build.category + newTournament.federalTournamentAge = build.age + newTournament.dayDuration = federalTournament.dayDuration + newTournament.startDate = federalTournament.startDate.atBeginningOfDay(hourInt: 9) + newTournament.setupFederalSettings() + try? dataStore.tournaments.addOrUpdate(instance: newTournament) + } + } } #Preview {