club_update
Razmig Sarkissian 1 year ago
parent bc5ad5e4a3
commit 6b02462b32
  1. 2
      PadelClub/Views/Components/MatchListView.swift
  2. 7
      PadelClub/Views/Match/Components/MatchDateView.swift
  3. 5
      PadelClub/Views/Match/EditSharingView.swift
  4. 15
      PadelClub/Views/Match/MatchDetailView.swift
  5. 3
      PadelClub/Views/Match/MatchRowView.swift
  6. 3
      PadelClub/Views/Match/MatchSetupView.swift
  7. 3
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  8. 1
      PadelClub/Views/Planning/PlanningView.swift
  9. 2
      PadelClub/Views/Round/LoserRoundView.swift
  10. 2
      PadelClub/Views/Round/RoundView.swift
  11. 9
      PadelClub/Views/Score/EditScoreView.swift

@ -34,7 +34,7 @@ struct MatchListView: View {
DisclosureGroup(isExpanded: $isExpanded) {
if let matches {
ForEach(matches) { match in
MatchRowView(match: match, tournament: self.tournament, matchViewStyle: matchViewStyle)
MatchRowView(match: match, matchViewStyle: matchViewStyle)
.listRowInsets(EdgeInsets(top: 0, leading: -2, bottom: 0, trailing: 8))
}
}

@ -11,7 +11,6 @@ import LeStorage
struct MatchDateView: View {
@EnvironmentObject var dataStore: DataStore
@Environment(Tournament.self) var tournament: Tournament
var match: Match
var showPrefix: Bool = false
@ -19,10 +18,6 @@ struct MatchDateView: View {
private var hasWalkoutTeam: Bool
private var hasEnded: Bool
var tournamentStore: TournamentStore {
return self.tournament.tournamentStore
}
init(match: Match, showPrefix: Bool) {
self.match = match
self.showPrefix = showPrefix
@ -150,7 +145,7 @@ struct MatchDateView: View {
private func _save() {
do {
try self.tournamentStore.matches.addOrUpdate(instance: match)
try self.match.tournamentStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}

@ -10,7 +10,6 @@ import TipKit
import CoreTransferable
struct EditSharingView: View {
@Environment(Tournament.self) var tournament: Tournament
var match: Match
@State private var displayRank: Bool = false
@State private var displayTeamTitle: Bool = false
@ -38,7 +37,9 @@ struct EditSharingView: View {
messageData.append(locAndTime)
}
messageData.append(tournament.tournamentTitle())
if let tournament = match.currentTournament() {
messageData.append(tournament.tournamentTitle())
}
let message = [match.isLoserBracket ? "Classement" : nil, match.roundTitle(), match.isLoserBracket ? nil : ((match.index > 0 || match.isGroupStage()) ? match.matchTitle(.short) : nil)].compactMap({ $0 }).joined(separator: " ")

@ -11,7 +11,6 @@ import LeStorage
struct MatchDetailView: View {
@EnvironmentObject var dataStore: DataStore
@Environment(Tournament.self) var tournament: Tournament
@EnvironmentObject var networkMonitor: NetworkMonitor
@Environment(\.dismiss) var dismiss
@ -36,7 +35,7 @@ struct MatchDetailView: View {
@State var showUserCreationView: Bool = false
var tournamentStore: TournamentStore {
return self.tournament.tournamentStore
return match.tournamentStore
}
var messageSentFailed: Binding<Bool> {
@ -94,8 +93,10 @@ struct MatchDetailView: View {
showDetails = true
}
Spacer()
MenuWarningView(tournament: self.match.currentTournament()!, teams: match.teams(), message: match.matchWarningMessage(), umpireMail: dataStore.user.email, subject: match.matchWarningSubject(), contactType: $contactType)
.buttonStyle(.borderless)
if let tournament = match.currentTournament() {
MenuWarningView(tournament: tournament, teams: match.teams(), message: match.matchWarningMessage(), umpireMail: dataStore.user.email, subject: match.matchWarningSubject(), contactType: $contactType)
.buttonStyle(.borderless)
}
}
}
}
@ -455,7 +456,7 @@ struct MatchDetailView: View {
if match.isReady() == false && match.teams().count == 2 {
let teamsScores = match.getOrCreateTeamScores()
do {
try self.tournamentStore.teamScores.addOrUpdate(contentOfs: teamsScores)
try tournamentStore.teamScores.addOrUpdate(contentOfs: teamsScores)
} catch {
Logger.error(error)
}
@ -477,7 +478,7 @@ struct MatchDetailView: View {
}
fileprivate func _payTournamentAndExecute(_ handler: () -> ()) {
guard let tournament = self.match.currentTournament() else { fatalError("missing tournament") }
guard let tournament = match.currentTournament() else { fatalError("missing tournament") }
do {
try tournament.payIfNecessary()
@ -489,7 +490,7 @@ struct MatchDetailView: View {
private func save() {
do {
try self.tournamentStore.matches.addOrUpdate(instance: match)
try tournamentStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}

@ -10,7 +10,6 @@ import SwiftUI
struct MatchRowView: View {
var match: Match
var tournament: Tournament
let matchViewStyle: MatchViewStyle
var title: String? = nil
@ -59,13 +58,11 @@ struct MatchRowView: View {
NavigationLink {
MatchDetailView(match: match, matchViewStyle: matchViewStyle)
.environment(self.tournament)
} label: {
MatchSummaryView(match: match, matchViewStyle: matchViewStyle, title: title)
.contextMenu {
NavigationLink {
EditSharingView(match: match)
.environment(self.tournament)
} label: {
Text("Partage sur les réseaux sociaux")
}

@ -11,13 +11,12 @@ import LeStorage
struct MatchSetupView: View {
@EnvironmentObject var dataStore: DataStore
@Environment(Tournament.self) var tournament: Tournament
var match: Match
@State private var seedGroup: SeedInterval?
var tournamentStore: TournamentStore {
return self.tournament.tournamentStore
return match.tournamentStore
}
@ViewBuilder

@ -32,8 +32,7 @@ struct OngoingView: View {
if let tournament = match.currentTournament() {
Section {
MatchRowView(match: match, tournament: tournament, matchViewStyle: .standardStyle)
.environment(tournament)
MatchRowView(match: match, matchViewStyle: .standardStyle)
} header: {
HStack {
Text(tournament.tournamentTitle(.short))

@ -37,7 +37,6 @@ struct PlanningView: View {
ForEach(_matches) { match in
NavigationLink {
MatchDetailView(match: match, matchViewStyle: .sectionedStandardStyle)
.environment(self.tournament)
} label: {
LabeledContent {
if let courtName = match.courtName() {

@ -40,7 +40,7 @@ struct LoserRoundView: View {
if matches.isEmpty == false {
Section {
ForEach(matches) { match in
MatchRowView(match: match, tournament: self.tournament, matchViewStyle: .sectionedStandardStyle)
MatchRowView(match: match, matchViewStyle: .sectionedStandardStyle)
.overlay {
if match.disabled && isEditingTournamentSeed.wrappedValue == true {
Image(systemName: "xmark")

@ -254,7 +254,7 @@ struct RoundView: View {
ForEach(displayableMatches) { match in
let matchTitle = match.matchTitle(.short, inMatches: displayableMatches)
Section {
MatchRowView(match: match, tournament: self.tournament, matchViewStyle: .sectionedStandardStyle, title: matchTitle)
MatchRowView(match: match, matchViewStyle: .sectionedStandardStyle, title: matchTitle)
} header: {
HStack {
Text(upperRound.round.roundTitle(.wide))

@ -14,12 +14,7 @@ struct EditScoreView: View {
@ObservedObject var matchDescriptor: MatchDescriptor
@Environment(\.dismiss) private var dismiss
@Environment(Tournament.self) var tournament: Tournament
var tournamentStore: TournamentStore {
return self.tournament.tournamentStore
}
func walkout(_ team: TeamPosition) {
self.matchDescriptor.match?.setWalkOut(team)
save()
@ -111,7 +106,7 @@ struct EditScoreView: View {
func save() {
if let match = matchDescriptor.match {
do {
try self.tournamentStore.matches.addOrUpdate(instance: match)
try match.tournamentStore.matches.addOrUpdate(instance: match)
} catch {
Logger.error(error)
}

Loading…
Cancel
Save