@ -31,6 +31,7 @@ struct RoundView: View {
let availableQualifiedTeams = tournament . availableQualifiedTeams ( )
let displayableMatches = round . displayableMatches ( ) . sorted ( by : \ . index )
let spaceLeft = displayableMatches . filter ( { $0 . hasSpaceLeft ( ) } )
let seedSpaceLeft = displayableMatches . filter ( { $0 . isEmpty ( ) } )
if isEditingTournamentSeed . wrappedValue = = false {
// ( w h e r e : { $ 0 . i s D i s a b l e d ( ) = = f a l s e | | i s E d i t i n g T o u r n a m e n t S e e d . w r a p p e d V a l u e } )
if loserRounds . isEmpty = = false {
@ -45,41 +46,82 @@ struct RoundView: View {
}
}
}
} else if availableQualifiedTeams . isEmpty = = false && spaceLeft . isEmpty = = false {
NavigationLink ( " Tirer au sort la position d'un qualifié " ) {
SpinDrawView ( drawees : availableQualifiedTeams , segments : spaceLeft ) { results in
results . forEach { drawResult in
print ( availableQualifiedTeams [ drawResult . drawee ] . teamLabel ( ) )
print ( spaceLeft [ drawResult . drawIndex ] . matchTitle ( ) )
availableQualifiedTeams [ drawResult . drawee ] . setSeedPosition ( inSpot : spaceLeft [ drawResult . drawIndex ] , slot : nil , opposingSeeding : true )
}
} else {
if let availableSeedGroup = tournament . seedGroupAvailable ( atRoundIndex : round . index ) {
Section {
RowButtonView ( " Placer \( availableSeedGroup . localizedLabel ( ) ) " + ( ( availableSeedGroup . isFixed ( ) = = false ) ? " au hasard " : " " ) ) {
tournament . setSeeds ( inRoundIndex : round . index , inSeedGroup : availableSeedGroup )
_save ( )
if tournament . availableSeeds ( ) . isEmpty && tournament . availableQualifiedTeams ( ) . isEmpty {
self . isEditingTournamentSeed . wrappedValue = false
}
}
} footer : {
if availableSeedGroup . isFixed ( ) = = false {
Text ( " Le tirage au sort ne sera pas visuel. Toutes les équipes de ce chapeau seront tirées. " )
}
}
} else if let availableSeedGroup = tournament . seedGroupAvailable ( atRoundIndex : round . index ) {
if ( availableSeedGroup . isFixed ( ) = = false ) {
Section {
RowButtonView ( " Placer \( availableSeedGroup . localizedLabel ( ) ) " + ( ( availableSeedGroup . isFixed ( ) = = false ) ? " au hasard " : " " ) ) {
tournament . setSeeds ( inRoundIndex : round . index , inSeedGroup : availableSeedGroup )
RowButtonView ( " Tirage au sort \( availableSeedGroup . localizedLabel ( ) ) visuel " ) {
self . selectedSeedGroup = availableSeedGroup
}
} footer : {
Text ( " Le tirage au sort sera visuel et automatique, n'hésitez pas à enregistrer une vidéo de votre écran. Toutes les équipes de ce chapeau seront tirées les unes après les autres. " )
}
}
}
if availableQualifiedTeams . isEmpty = = false && spaceLeft . isEmpty = = false {
Section {
ForEach ( availableQualifiedTeams ) { team in
NavigationLink {
SpinDrawView ( drawees : [ team ] , segments : spaceLeft ) { results in
Task {
results . forEach { drawResult in
team . setSeedPosition ( inSpot : spaceLeft [ drawResult . drawIndex ] , slot : nil , opposingSeeding : true )
}
_save ( )
if tournament . availableSeeds ( ) . isEmpty && tournament . availableQualifiedTeams ( ) . isEmpty {
self . isEditingTournamentSeed . wrappedValue = false
}
}
}
} label : {
TeamRowView ( team : team , displayCallDate : false )
}
}
} header : {
Text ( " Tirage au sort visuel d'un qualifié " ) . font ( . subheadline )
}
}
if ( availableSeedGroup . isFixed ( ) = = false ) {
if tournament . availableSeeds ( ) . isEmpty = = false && seedSpaceLeft . isEmpty = = false {
Section {
RowButtonView ( " Tirage au sort \( availableSeedGroup . localizedLabel ( ) ) visuel " ) {
self . selectedSeedGroup = availableSeedGroup
ForEach ( tournament . availableSeeds ( ) ) { team in
NavigationLink {
SpinDrawView ( drawees : [ team ] , segments : seedSpaceLeft ) { results in
Task {
results . forEach { drawResult in
team . setSeedPosition ( inSpot : seedSpaceLeft [ drawResult . drawIndex ] , slot : nil , opposingSeeding : false )
}
_save ( )
if tournament . availableSeeds ( ) . isEmpty && tournament . availableQualifiedTeams ( ) . isEmpty {
self . isEditingTournamentSeed . wrappedValue = false
}
}
}
} label : {
TeamRowView ( team : team , displayCallDate : false )
}
}
} header : {
Text ( " Tirage au sort visuel d'une tête de série " ) . font ( . subheadline )
}
}
}
ForEach ( displayableMatches ) { match in
Section {
MatchRowView ( match : match , matchViewStyle : . sectionedStandardStyle )
@ -100,15 +142,14 @@ struct RoundView: View {
}
}
}
. sheet ( isPresented : showVisualDrawView ) {
. fullScreenCover ( isPresented : showVisualDrawView ) {
if let availableSeedGroup = selectedSeedGroup {
let seeds = tournament . seeds ( inSeedGroup : availableSeedGroup )
let availableSeedSpot = tournament . availableSeedSpot ( inRoundIndex : round . index )
NavigationStack {
SpinDrawView ( drawees : seeds , segments : availableSeedSpot ) { draws in
SpinDrawView ( drawees : seeds , segments : availableSeedSpot , autoMode : true ) { draws in
Task {
draws . forEach { drawResult in
print ( seeds [ drawResult . drawee ] . teamLabel ( ) )
print ( availableSeedSpot [ drawResult . drawIndex ] . matchTitle ( ) )
seeds [ drawResult . drawee ] . setSeedPosition ( inSpot : availableSeedSpot [ drawResult . drawIndex ] , slot : nil , opposingSeeding : false )
}
_save ( )
@ -119,6 +160,7 @@ struct RoundView: View {
}
}
}
}
. headerProminence ( . increased )
. toolbar {
ToolbarItem ( placement : . topBarTrailing ) {