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. 7
      PadelClub/Views/Score/EditScoreView.swift

@ -34,7 +34,7 @@ struct MatchListView: View {
DisclosureGroup(isExpanded: $isExpanded) { DisclosureGroup(isExpanded: $isExpanded) {
if let matches { if let matches {
ForEach(matches) { match in 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)) .listRowInsets(EdgeInsets(top: 0, leading: -2, bottom: 0, trailing: 8))
} }
} }

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save