@ -34,264 +34,245 @@ struct BroadcastView: View {
List {
if Store . main . userId = = nil {
Section {
TipView ( createAccountTip ) { action in
switch action . id {
case CreateAccountTip . ActionKey . accessPadelClubWebPage . rawValue :
UIApplication . shared . open ( URLs . main . url )
case CreateAccountTip . ActionKey . createAccount . rawValue :
ContentUnavailableView {
Label ( " Créer votre compte Padel Club " , systemImage : " person.bust " )
} description : {
let message = " Un compte est nécessaire pour publier le tournoi sur [Padel Club]( \( URLs . main . rawValue ) ) et profiter de toutes les pages du site, comme le mode TV pour transformer l'expérience de vos tournois ! "
Text ( . init ( message ) )
} actions : {
RowButtonView ( " Créer votre compte " ) {
navigation . selectedTab = . umpire
default :
break
// t o d o
// c a s e C r e a t e A c c o u n t T i p . A c t i o n K e y . l e a r n M o r e . r a w V a l u e :
// U I A p p l i c a t i o n . s h a r e d . o p e n ( U R L s . p a d e l C l u b L a n d i n g P a g e . u r l )
}
RowButtonView ( " Jeter un oeil au site Padel Club " ) {
UIApplication . shared . open ( URLs . main . url )
}
}
. tipStyle ( tint : . master )
}
}
Section {
TipView ( tournamentPublishingTip ) { action in
UIApplication . shared . open ( URLs . main . url )
}
. tipStyle ( tint : nil )
}
Section {
TipView ( tournamentTVBroadcastTip )
. tipStyle ( tint : nil )
}
if tournament . isPrivate = = false {
if let url = tournament . shareURL ( . clubBroadcast ) {
Section {
Link ( destination : url ) {
Text ( url . absoluteString )
}
. contextMenu {
Button ( " Copier " ) {
let pasteboard = UIPasteboard . general
pasteboard . string = url . absoluteString
}
}
} header : {
Text ( " Lien pour la diffusion TV " )
} footer : {
Text ( " Lien à mettre sur une smart tv ou ordinateur dans le club house par exemple ! " )
} else {
Section {
TipView ( tournamentPublishingTip ) { action in
UIApplication . shared . open ( URLs . main . url )
}
. tipStyle ( tint : nil )
}
Section {
LabeledContent {
if tournament . isTournamentPublished ( ) {
Image ( systemName : " checkmark " ) . foregroundStyle ( . green )
} else {
Text ( tournament . publishedTournamentDate ( ) . formatted ( ) )
let links : [ PageLink ] = [ . teams , . summons , . groupStages , . matches , . rankings , . broadcast , . clubBroadcast ]
Picker ( selection : $ pageLink ) {
ForEach ( links ) { pageLink in
Text ( pageLink . localizedLabel ( ) ) . tag ( pageLink )
}
} label : {
if tournament . isTournamentPublished ( ) {
Text ( " Publiée " )
} else {
Text ( " Publication prévue " )
}
}
if tournament . canBePublished ( ) = = false {
Text ( " Pour être visible automatiquement, le tournoi doit avoir été créé il y a 24h, avoir une structure et au moins 4 inscriptions. " )
Text ( " Choisir la page à partager " )
}
. pickerStyle ( . menu )
actionForURL ( title : " Partager la page ' " + pageLink . localizedLabel ( ) + " ' " , url : tournament . shareURL ( pageLink ) )
} header : {
Text ( " Information sur le tournoi " )
} footer : {
if Date ( ) < tournament . publishedTournamentDate ( ) || tournament . canBePublished ( ) = = false {
HStack {
Spacer ( )
FooterButtonView ( tournament . publishTournament ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishTournament . toggle ( )
_save ( )
}
}
}
Text ( " Lien du tournoi à partager " )
}
Section {
LabeledContent {
if tournament . areTeamsPublished ( ) {
Image ( systemName : " checkmark " ) . foregroundStyle ( . green )
} else {
Text ( tournament . publishedTeamsDate ( ) . formatted ( ) )
}
} label : {
if tournament . areTeamsPublished ( ) {
Text ( " Publiée " )
} else {
Text ( " Publication prévue " )
}
let club = tournament . club ( )
actionForURL ( title : ( club = = nil ) ? " Aucun club indiqué pour ce tournoi " : club ! . clubTitle ( ) , description : " Page du club " , url : club ? . shareURL ( ) )
actionForURL ( title : " Padel Club " , url : URLs . main . url )
} header : {
Text ( " Autres liens " )
}
if tournament . isPrivate = = false {
Section {
TipView ( tournamentTVBroadcastTip )
. tipStyle ( tint : nil )
}
Toggle ( isOn : $ tournament . hideTeamsWeight ) {
Text ( " Masquer les poids des équipes " )
}
} header : {
Text ( " Liste des équipes " )
} footer : {
if Date ( ) < tournament . publishedTeamsDate ( ) {
HStack {
Spacer ( )
FooterButtonView ( tournament . publishTeams ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishTeams . toggle ( )
_save ( )
if let url = tournament . shareURL ( . clubBroadcast ) {
Section {
Link ( destination : url ) {
Text ( url . absoluteString )
}
. contextMenu {
Button ( " Copier " ) {
let pasteboard = UIPasteboard . general
pasteboard . string = url . absoluteString
}
}
} header : {
Text ( " Lien pour la diffusion TV " )
} footer : {
Text ( " Lien à mettre sur une smart tv ou ordinateur dans le club house par exemple ! " )
}
}
}
Section {
LabeledContent {
if tournament . areSummonsPublished ( ) {
Image ( systemName : " checkmark " ) . foregroundStyle ( . green )
} else {
Text ( tournament . publishedTeamsDate ( ) . formatted ( ) )
Section {
LabeledContent {
if tournament . isTournamentPublished ( ) {
Image ( systemName : " checkmark " ) . foregroundStyle ( . green )
} else {
Text ( tournament . publishedTournamentDate ( ) . formatted ( ) )
}
} label : {
if tournament . isTournamentPublished ( ) {
Text ( " Publiée " )
} else {
Text ( " Publication prévue " )
}
}
} label : {
if tournament . areSummonsPublished ( ) {
Text ( " Publiées " )
} else {
Text ( " Publication prévue " )
if tournament . canBePublished ( ) = = false {
Text ( " Pour être visible automatiquement, le tournoi doit avoir été créé il y a 24h, avoir une structure et au moins 4 inscriptions. " )
}
}
} header : {
Text ( " Convocations " )
} footer : {
if Date ( ) < tournament . publishedTeamsDate ( ) {
HStack {
Spacer ( )
FooterButtonView ( tournament . publishSummons ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishSummons . toggl e( )
_save ( )
} header : {
Text ( " Information sur le tournoi " )
} footer : {
if Date ( ) < tournament . publishedTournamentDate ( ) || tournament . canBePublished ( ) = = false {
HStack {
Spacer ( )
FooterButtonView ( tournament . publishTournament ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishTournament . toggle ( )
_sav e ( )
}
}
}
}
}
if let publishedGroupStagesDate = tournament . publishedGroupStagesDate ( ) {
Section {
let areGroupStagesPublished = tournament . areGroupStagesPublished ( )
LabeledContent {
if areGroupStagesPublished {
if tournament . areTeamsPublished ( ) {
Image ( systemName : " checkmark " ) . foregroundStyle ( . green )
} else {
Text ( publishedGroupStagesDate . formatted ( ) )
Text ( tournament . publishedTeamsDate ( ) . formatted ( ) )
}
} label : {
if areGroupStagesPublished {
Text ( " Publiées " )
if tournament . areTeamsPublished ( ) {
Text ( " Publiée " )
} else {
Text ( " Publication prévue " )
}
}
Toggle ( isOn : $ tournament . hideTeamsWeight ) {
Text ( " Masquer les poids des équipes " )
}
} header : {
Text ( " Poules " )
Text ( " Liste des équip es" )
} footer : {
if Date ( ) < publishedGroupStagesDate {
if Date ( ) < tournament . publishedTeamsDate ( ) {
HStack {
Spacer ( )
FooterButtonView ( tournament . publishGroupStage s ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishGroupStage s . toggle ( )
FooterButtonView ( tournament . publishTeam s ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishTeam s . toggle ( )
_save ( )
}
}
}
}
}
if let publishedBracketsDate = tournament . publishedBracketsDate ( ) {
Section {
let areBracketsPublished = tournament . areBracketsPublished ( )
LabeledContent {
if areBracketsPublished {
if tournament . areSummonsPublished ( ) {
Image ( systemName : " checkmark " ) . foregroundStyle ( . green )
} else {
Text ( publishedBracketsDate . formatted ( ) )
Text ( tournament . publishedTeamsDate ( ) . formatted ( ) )
}
} label : {
if areBracketsPublished {
Text ( " Publié " )
if tournament . areSummonsPublished ( ) {
Text ( " Publiées " )
} else {
Text ( " Publication prévue " )
}
}
} header : {
Text ( " Tableau " )
Text ( " Convocations " )
} footer : {
if Date ( ) < publishedBracketsDate {
if Date ( ) < tournament . publishedTeamsDate ( ) {
HStack {
Spacer ( )
FooterButtonView ( tournament . publishBracket s ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishBracket s . toggle ( )
FooterButtonView ( tournament . publishSummon s ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishSummon s . toggle ( )
_save ( )
}
}
}
}
}
}
// t o d o w a i t i n g l i s t & i n f o
Section {
Toggle ( isOn : $ tournament . isPrivate ) {
Text ( " Tournoi privé " )
}
} footer : {
let footerString = " Le tournoi sera masqué sur le site [Padel Club]( \( URLs . main . rawValue ) ) "
Text ( . init ( footerString ) )
}
Section {
LabeledContent {
actionForURL ( URLs . main . url )
} label : {
Text ( " Padel Club " )
}
let club = tournament . club ( )
LabeledContent {
if let clubURL = club ? . shareURL ( ) {
actionForURL ( clubURL )
}
} label : {
Text ( " Club " )
if let club {
Text ( club . clubTitle ( ) )
} else {
Text ( " Aucun club indiqué pour ce tournoi " )
if let publishedGroupStagesDate = tournament . publishedGroupStagesDate ( ) {
Section {
let areGroupStagesPublished = tournament . areGroupStagesPublished ( )
LabeledContent {
if areGroupStagesPublished {
Image ( systemName : " checkmark " ) . foregroundStyle ( . green )
} else {
Text ( publishedGroupStagesDate . formatted ( ) )
}
} label : {
if areGroupStagesPublished {
Text ( " Publiées " )
} else {
Text ( " Publication prévue " )
}
}
} header : {
Text ( " Poules " )
} footer : {
if Date ( ) < publishedGroupStagesDate {
HStack {
Spacer ( )
FooterButtonView ( tournament . publishGroupStages ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishGroupStages . toggle ( )
_save ( )
}
}
}
}
}
}
if let url = tournament . shareURL ( pageLink ) {
LabeledContent {
actionForURL ( url )
} label : {
Text ( " Tournoi " )
Text ( pageLink . localizedLabel ( ) )
if let publishedBracketsDate = tournament . publishedBracketsDate ( ) {
Section {
let areBracketsPublished = tournament . areBracketsPublished ( )
LabeledContent {
if areBracketsPublished {
Image ( systemName : " checkmark " ) . foregroundStyle ( . green )
} else {
Text ( publishedBracketsDate . formatted ( ) )
}
} label : {
if areBracketsPublished {
Text ( " Publié " )
} else {
Text ( " Publication prévue " )
}
}
} header : {
Text ( " Tableau " )
} footer : {
if Date ( ) < publishedBracketsDate {
HStack {
Spacer ( )
FooterButtonView ( tournament . publishBrackets ? " masquer sur le site " : " publier maintenant " ) {
tournament . publishBrackets . toggle ( )
_save ( )
}
}
}
}
}
}
let links : [ PageLink ] = [ . teams , . summons , . groupStages , . matches , . rankings , . broadcast , . clubBroadcast ]
Picker ( selection : $ pageLink ) {
ForEach ( links ) { pageLink in
Text ( pageLink . localizedLabel ( ) ) . tag ( pageLink )
// t o d o w a i t i n g l i s t & i n f o
Section {
Toggle ( isOn : $ tournament . isPrivate ) {
Text ( " Tournoi privé " )
}
} label : {
Text ( " Modifier la page du tournoi à partager " )
} footer : {
let footerString = " Le tournoi sera masqué sur le site [Padel Club]( \( URLs . main . rawValue ) ) "
Text ( . init ( footerString ) )
}
. pickerStyle ( . menu )
} header : {
Text ( " Liens à partager " )
. textCase ( nil )
}
}
. headerProminence ( . increased )
. navigationTitle ( " Publication " )
@ -343,31 +324,48 @@ struct BroadcastView: View {
}
@ ViewBuilder
func actionForURL ( _ url : URL , removeSource : Bool = false ) -> some View {
Menu {
Button {
UIApplication . shared . open ( url )
func actionForURL ( title : String , description : String ? = nil , url : URL ? , removeSource : Bool = false ) -> some View {
if let url {
Menu {
Button {
UIApplication . shared . open ( url )
} label : {
Label ( " Voir " , systemImage : " safari " )
}
Button {
urlToShow = url . absoluteString
} label : {
Label ( " QRCode " , systemImage : " qrcode " )
}
ShareLink ( item : url ) {
Label ( " Partager le lien " , systemImage : " link " )
}
} label : {
Label ( " Voir " , systemImage : " safari " )
LabeledContent {
Image ( systemName : " square.and.arrow.up " )
. foregroundColor ( . master )
} label : {
Text ( title )
. foregroundColor ( . primary )
if let description {
Text ( description )
. foregroundColor ( . secondary )
}
}
}
Button {
urlToShow = url . absoluteString
. buttonStyle ( . plain )
} else {
LabeledContent {
Image ( systemName : " xmark " ) . foregroundColor ( . logoYellow )
} label : {
Label ( " QRCode " , systemImage : " qrcode " )
}
ShareLink ( item : url ) {
Label ( " Partager le lien " , systemImage : " link " )
}
} label : {
HStack {
Spacer ( )
Image ( systemName : " square.and.arrow.up " )
Text ( title )
if let description {
Text ( description )
}
}
}
. frame ( maxWidth : . infinity )
. buttonStyle ( . borderless )
}