From cf44ce13109344756ba4109a3fc3f5dccee2e845 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Wed, 15 May 2024 23:31:36 +0200 Subject: [PATCH] build 7 --- PadelClub.xcodeproj/project.pbxproj | 4 +- PadelClub/Data/Tournament.swift | 10 ++++- .../Tournament/Screen/BroadcastView.swift | 44 ++++++++++++------- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index ab7dc72..9a82ca4 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -1830,7 +1830,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; @@ -1868,7 +1868,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index dae330b..ee99eac 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -303,9 +303,13 @@ class Tournament : ModelObject, Storable { } func areTeamsPublished() -> Bool { - Date() >= startDate + Date() >= startDate || publishTeams } - + + func areSummonsPublished() -> Bool { + Date() >= startDate || publishSummons + } + func publishedGroupStagesDate() -> Date? { if let first = groupStages().flatMap({ $0.playedMatches() }).compactMap({ $0.startDate }).sorted().first?.atNine() { if first.isEarlierThan(startDate) { @@ -319,6 +323,7 @@ class Tournament : ModelObject, Storable { } func areGroupStagesPublished() -> Bool { + if publishGroupStages { return true } if let publishedGroupStagesDate = publishedGroupStagesDate() { return Date() >= publishedGroupStagesDate } else { @@ -339,6 +344,7 @@ class Tournament : ModelObject, Storable { } func areBracketsPublished() -> Bool { + if publishBrackets { return true } if let publishedBracketsDate = publishedBracketsDate() { return Date() >= publishedBracketsDate } else { diff --git a/PadelClub/Views/Tournament/Screen/BroadcastView.swift b/PadelClub/Views/Tournament/Screen/BroadcastView.swift index 0e9e3f5..4a7499f 100644 --- a/PadelClub/Views/Tournament/Screen/BroadcastView.swift +++ b/PadelClub/Views/Tournament/Screen/BroadcastView.swift @@ -58,22 +58,25 @@ struct BroadcastView: View { Text("Liste des équipes") } footer: { if Date() < tournament.publishedTeamsDate() { - FooterButtonView(tournament.publishTeams ? "masquer sur le site" : "publier maintenant") { - tournament.publishTeams.toggle() + HStack { + Spacer() + FooterButtonView(tournament.publishTeams ? "masquer sur le site" : "publier maintenant") { + tournament.publishTeams.toggle() + } } } } Section { LabeledContent { - if tournament.areTeamsPublished() { + if tournament.areSummonsPublished() { Image(systemName:"checkmark").foregroundStyle(.green) } else { Text(tournament.publishedTeamsDate().formatted()) } } label: { - if tournament.areTeamsPublished() { - Text("Publiée") + if tournament.areSummonsPublished() { + Text("Publiées") } else { Text("Publication prévue") } @@ -82,8 +85,11 @@ struct BroadcastView: View { Text("Convocations") } footer: { if Date() < tournament.publishedTeamsDate() { - FooterButtonView(tournament.publishSummons ? "masquer sur le site" : "publier maintenant") { - tournament.publishSummons.toggle() + HStack { + Spacer() + FooterButtonView(tournament.publishSummons ? "masquer sur le site" : "publier maintenant") { + tournament.publishSummons.toggle() + } } } } @@ -99,7 +105,7 @@ struct BroadcastView: View { } } label: { if areGroupStagesPublished { - Text("Publiée") + Text("Publiées") } else { Text("Publication prévue") } @@ -108,8 +114,11 @@ struct BroadcastView: View { Text("Poules") } footer: { if Date() < publishedGroupStagesDate { - FooterButtonView(tournament.publishGroupStages ? "masquer sur le site" : "publier maintenant") { - tournament.publishGroupStages.toggle() + HStack { + Spacer() + FooterButtonView(tournament.publishGroupStages ? "masquer sur le site" : "publier maintenant") { + tournament.publishGroupStages.toggle() + } } } } @@ -126,7 +135,7 @@ struct BroadcastView: View { } } label: { if areBracketsPublished { - Text("Publiée") + Text("Publié") } else { Text("Publication prévue") } @@ -134,9 +143,12 @@ struct BroadcastView: View { } header: { Text("Tableau") } footer: { - if Date() < publishedBracketsDate{ - FooterButtonView(tournament.publishBrackets ? "masquer sur le site" : "publier maintenant") { - tournament.publishBrackets.toggle() + if Date() < publishedBracketsDate { + HStack { + Spacer() + FooterButtonView(tournament.publishBrackets ? "masquer sur le site" : "publier maintenant") { + tournament.publishBrackets.toggle() + } } } } @@ -149,7 +161,7 @@ struct BroadcastView: View { Text("Tournoi privé") } } footer: { - let footerString = "Le tournoi sera masqué sur le site [Padel Club]\(URLs.main.rawValue)" + let footerString = "Le tournoi sera masqué sur le site [Padel Club](\(URLs.main.rawValue))" Text(.init(footerString)) } @@ -204,7 +216,7 @@ struct BroadcastView: View { UIPasteboard.general.string = urlToShow } } - .onChange(of: tournament.isPrivate) { + .onChange(of: [tournament.isPrivate, tournament.publishTeams, tournament.publishSummons, tournament.publishBrackets, tournament.publishGroupStages]) { _save() } }