@ -11,14 +11,15 @@ import TipKit
struct TournamentView : View {
@ EnvironmentObject var dataStore : DataStore
@ Environment ( NavigationViewModel . self ) var navigation : NavigationViewModel
@ State var tournament : Tournament
var presentationContext : PresentationContext = . agenda
let tournamentSelectionTip : TournamentSelectionTip = TournamentSelectionTip ( )
let tournamentRunningTip : TournamentRunningTip = TournamentRunningTip ( )
let onlineRegistrationTip : OnlineRegistrationTip = OnlineRegistrationTip ( )
var selectedTournamentId : Binding < String > { Binding (
get : { tournament . id } ,
set : { id in
@ -36,7 +37,7 @@ struct TournamentView: View {
guard let lastDataSource else { return nil }
return URL . importDateFormatter . date ( from : lastDataSource )
}
init ( tournament : Tournament , presentationContext : PresentationContext = . agenda ) {
self . tournament = tournament
self . presentationContext = presentationContext
@ -59,17 +60,63 @@ struct TournamentView: View {
}
}
case . initial :
if tournament . enableOnlineRegistration = = false {
TipView ( onlineRegistrationTip ) { actions in
navigation . path . append ( Screen . settings )
}
. tipStyle ( tint : . master , asSection : true )
}
Section {
TournamentInscriptionView ( tournament : tournament )
}
TournamentInitView ( tournament : tournament )
case . build :
if tournament . enableOnlineRegistration = = false {
TipView ( onlineRegistrationTip ) { actions in
navigation . path . append ( Screen . settings )
}
. tipStyle ( tint : . master , asSection : true )
}
Section {
TournamentInscriptionView ( tournament : tournament )
}
TournamentBuildView ( tournament : tournament )
TournamentInitView ( tournament : tournament )
case . running :
if tournament . shouldTournamentBeOver ( ) {
Section {
Menu {
Button ( " Scores manquants " ) {
if let activeRound = tournament . getActiveRound ( ) {
navigation . path . append ( Screen . round )
} else if let activeGroupStage = tournament . getActiveGroupStage ( ) {
navigation . path . append ( Screen . groupStage )
}
}
Button {
navigation . path . append ( Screen . stateSettings )
} label : {
Text ( " Annuler le tournoi " )
}
} label : {
Label ( " Actions rapides " , systemImage : " bolt.circle " )
. foregroundColor ( . white )
. frame ( height : 32 )
. font ( . headline )
. frame ( maxWidth : . infinity )
}
. menuStyle ( . button )
. buttonStyle ( . borderedProminent )
. tint ( . logoYellow )
. listRowBackground ( Color . clear )
. listRowInsets ( EdgeInsets ( . zero ) )
}
}
TournamentBuildView ( tournament : tournament )
TournamentRunningView ( tournament : tournament )
case . finished :
@ -113,6 +160,9 @@ struct TournamentView: View {
PrintSettingsView ( tournament : tournament )
case . restingTime :
TeamRestingView ( )
case . stateSettings :
TournamentStatusView ( tournament : tournament )
}
}
. environment ( tournament )
@ -126,17 +176,17 @@ struct TournamentView: View {
Text ( tournament . tournamentTitle ( . title ) ) . tag ( tournament . id as String )
}
} label : {
}
Divider ( )
}
NavigationLink ( value : Screen . event ) {
Text ( " Réglages de l'événement " )
}
}
}
. toolbarBackground ( . visible , for : . navigationBar )
. toolbar {
@ -151,11 +201,11 @@ struct TournamentView: View {
TournamentSelectionTip . tournamentCount = tournament . eventObject ( ) ? . tournaments . count
}
}
if tournament . isCanceled = = false {
ToolbarItem ( placement : . topBarTrailing ) {
Menu {
#if DEBUG
Button {
do {
@ -167,7 +217,7 @@ struct TournamentView: View {
Label ( " Payer le tournoi " , systemImage : " dollarsign.circle.fill " )
}
#endif
if presentationContext = = . agenda {
Button {
navigation . openTournamentInOrganizer ( tournament )
@ -176,7 +226,7 @@ struct TournamentView: View {
}
Divider ( )
}
NavigationLink ( value : Screen . event ) {
Text ( " Réglages de l'événement " )
}
@ -190,16 +240,14 @@ struct TournamentView: View {
NavigationLink ( value : Screen . broadcast ) {
Label ( " Publication " , systemImage : " airplayvideo " )
}
NavigationLink ( value : Screen . print ) {
Label ( " Imprimer " , systemImage : " printer " )
}
Divider ( )
NavigationLink {
TournamentStatusView ( tournament : tournament )
} label : {
NavigationLink ( value : Screen . stateSettings ) {
Text ( " Gestion du tournoi " )
Text ( " Annuler, supprimer ou terminer le tournoi " )
}