Laurent 2 years ago
commit c743eec8a2
  1. 2
      PadelClub/Views/Calling/Components/MenuWarningView.swift
  2. 2
      PadelClub/Views/Calling/SendToAllView.swift
  3. 4
      PadelClub/Views/Match/Components/MatchDateView.swift
  4. 67
      PadelClub/Views/Match/MatchSummaryView.swift
  5. 4
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  6. 10
      PadelClub/Views/Tournament/Screen/Components/TournamentGeneralSettingsView.swift
  7. 40
      PadelClub/Views/Tournament/Shared/TournamentCellView.swift

@ -55,7 +55,7 @@ struct MenuWarningView: View {
let players = [player] let players = [player]
_actionView(players: players) _actionView(players: players)
} label: { } label: {
Text(player.playerLabel(.short)) Text(player.playerLabel())
} }
} }

@ -71,7 +71,7 @@ struct SendToAllView: View {
if contactMethod == 0 { if contactMethod == 0 {
contactType = .message(date: nil, recipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.phoneNumber }, body: tournament.tournamentTitle(), tournamentBuild: nil) contactType = .message(date: nil, recipients: _teams().flatMap { $0.unsortedPlayers() }.compactMap { $0.phoneNumber }, body: tournament.tournamentTitle(), tournamentBuild: nil)
} else { } 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)
} }
} }
} }

@ -8,7 +8,6 @@
import SwiftUI import SwiftUI
struct MatchDateView: View { struct MatchDateView: View {
@Environment(Tournament.self) var tournament: Tournament
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
var match: Match var match: Match
var showPrefix: Bool = false var showPrefix: Bool = false
@ -32,7 +31,8 @@ struct MatchDateView: View {
save() save()
} }
} else { } 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") { Button("Décaler de \(estimatedDuration) minutes") {
match.startDate = match.startDate?.addingTimeInterval(Double(estimatedDuration) * 60.0) match.startDate = match.startDate?.addingTimeInterval(Double(estimatedDuration) * 60.0)
match.endDate = nil match.endDate = nil

@ -21,7 +21,7 @@ struct MatchSummaryView: View {
var color: Color { var color: Color {
return Color(white: 0.9) return Color(white: 0.9)
matchViewStyle == .plainStyle ? Color(uiColor: .tertiaryLabel) : Color(uiColor: .secondaryLabel) //matchViewStyle == .plainStyle ? Color(uiColor: .tertiaryLabel) : Color(uiColor: .secondaryLabel)
} }
var width: CGFloat { var width: CGFloat {
@ -58,59 +58,51 @@ struct MatchSummaryView: View {
var matchSummaryView: some View { var matchSummaryView: some View {
VStack(alignment: .leading) { VStack(alignment: .leading) {
if matchViewStyle != .plainStyle { if matchViewStyle != .plainStyle {
if matchViewStyle == .feedStyle, let tournament = match.currentTournament() {
tournamentHeaderView(tournament)
}
HStack { HStack {
if match.isGroupStage() && matchViewStyle != .feedStyle { if match.isGroupStage() {
if let groupStage = match.groupStageObject, matchViewStyle == .standardStyle { if let groupStage = match.groupStageObject {
Text(groupStage.groupStageTitle()) Text(groupStage.groupStageTitle())
} else if let round = match.roundObject { } else if let round = match.roundObject {
Text(round.roundTitle()) Text(round.roundTitle())
} }
Text(match.matchTitle()) 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() Spacer()
if let court = match.courtName(), match.hasEnded() == false { Text(court)
Spacer()
Text(court)
}
} }
} }
.lineLimit(1) .lineLimit(1)
} }
if matchViewStyle != .feedStyle { HStack(spacing: 0) {
HStack(spacing: 0) { VStack(alignment: .leading, spacing: matchViewStyle == .plainStyle ? 8 : 0) {
VStack(alignment: .leading, spacing: matchViewStyle == .plainStyle ? 8 : 0) { PlayerBlockView(match: match, teamPosition: .one, color: color, width: width)
PlayerBlockView(match: match, teamPosition: .one, color: color, width: width) .padding(matchViewStyle == .plainStyle ? 0 : 8)
.padding(matchViewStyle == .plainStyle ? 0 : 8) if width == 1 {
if width == 1 { Divider()
Divider() } else {
} else { Divider().frame(height: width).overlay(color)
Divider().frame(height: width).overlay(color)
}
PlayerBlockView(match: match, teamPosition: .two, color: color, width: width)
.padding(matchViewStyle == .plainStyle ? 0 : 8)
} }
PlayerBlockView(match: match, teamPosition: .two, color: color, width: width)
.padding(matchViewStyle == .plainStyle ? 0 : 8)
} }
.overlay { }
if matchViewStyle != .plainStyle { .overlay {
RoundedRectangle(cornerRadius: 8) if matchViewStyle != .plainStyle {
.stroke(color, lineWidth: 2) RoundedRectangle(cornerRadius: 8)
} .stroke(color, lineWidth: 2)
} }
}
if matchViewStyle != .plainStyle { if matchViewStyle != .plainStyle {
HStack { HStack {
Spacer() Spacer()
MatchDateView(match: match, showPrefix: matchViewStyle == .tournamentResultStyle ? true : false) MatchDateView(match: match, showPrefix: matchViewStyle == .tournamentResultStyle)
}
} }
} }
} }
@ -120,6 +112,7 @@ struct MatchSummaryView: View {
@ViewBuilder @ViewBuilder
func tournamentHeaderView(_ currentTournament: Tournament) -> some View { func tournamentHeaderView(_ currentTournament: Tournament) -> some View {
return Text(currentTournament.tournamentTitle())
VStack(alignment: .leading) { VStack(alignment: .leading) {
// HStack { // HStack {
// ZStack(alignment: .leading) { // ZStack(alignment: .leading) {

@ -22,7 +22,9 @@ struct OngoingView: View {
} }
} }
.overlay { .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") .navigationTitle("En cours")
.toolbar(matches.isEmpty ? .hidden : .visible, for: .navigationBar) .toolbar(matches.isEmpty ? .hidden : .visible, for: .navigationBar)

@ -32,6 +32,7 @@ struct TournamentGeneralSettingsView: View {
.keyboardType(.decimalPad) .keyboardType(.decimalPad)
.multilineTextAlignment(.trailing) .multilineTextAlignment(.trailing)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.focused($textFieldIsFocus)
} label: { } label: {
Text("Inscription") Text("Inscription")
} }
@ -56,13 +57,14 @@ struct TournamentGeneralSettingsView: View {
} }
} }
} }
.focused($textFieldIsFocus)
.scrollDismissesKeyboard(.immediately) .scrollDismissesKeyboard(.immediately)
.toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar)
.toolbar { .toolbar {
ToolbarItem(placement: .keyboard) { if textFieldIsFocus {
Button("Valider") { ToolbarItem(placement: .keyboard) {
textFieldIsFocus = false Button("Valider") {
textFieldIsFocus = false
}
} }
} }
} }

@ -72,24 +72,7 @@ struct TournamentCellView: View {
Text(tournament.sortedTeams().count.formatted()) Text(tournament.sortedTeams().count.formatted())
} else if let federalTournament = tournament as? FederalTournament { } else if let federalTournament = tournament as? FederalTournament {
Button { Button {
if let existingTournament { _createOrShow(federalTournament: federalTournament, existingTournament: existingTournament, build: build)
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)
}
} label: { } label: {
Image(systemName: existingTournament != nil ? "checkmark.circle.fill" : "square.and.arrow.down") Image(systemName: existingTournament != nil ? "checkmark.circle.fill" : "square.and.arrow.down")
.resizable() .resizable()
@ -118,6 +101,27 @@ struct TournamentCellView: View {
} }
.font(.caption) .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 { #Preview {

Loading…
Cancel
Save