|
|
|
|
@ -382,68 +382,67 @@ struct MatchDetailView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
var startingOptionView: some View { |
|
|
|
|
Section { |
|
|
|
|
|
|
|
|
|
if match.hasEnded() == false { |
|
|
|
|
let rotationDuration = match.getDuration() |
|
|
|
|
Picker(selection: $startDateSetup) { |
|
|
|
|
if match.isReady() { |
|
|
|
|
Text("Dans 5 minutes").tag(MatchDateSetup.inMinutes(5)) |
|
|
|
|
Text("Dans 15 minutes").tag(MatchDateSetup.inMinutes(15)) |
|
|
|
|
Text("Tout de suite").tag(MatchDateSetup.now) |
|
|
|
|
} |
|
|
|
|
Text("Précédente rotation").tag(MatchDateSetup.inMinutes(-rotationDuration)) |
|
|
|
|
Text("Prochaine rotation").tag(MatchDateSetup.inMinutes(rotationDuration)) |
|
|
|
|
Text("À").tag(MatchDateSetup.customDate) |
|
|
|
|
} label: { |
|
|
|
|
Text("Horaire") |
|
|
|
|
if match.hasEnded() == false { |
|
|
|
|
let rotationDuration = match.getDuration() |
|
|
|
|
Picker(selection: $startDateSetup) { |
|
|
|
|
if match.isReady() { |
|
|
|
|
Text("Dans 5 minutes").tag(MatchDateSetup.inMinutes(5)) |
|
|
|
|
Text("Dans 15 minutes").tag(MatchDateSetup.inMinutes(15)) |
|
|
|
|
Text("Tout de suite").tag(MatchDateSetup.now) |
|
|
|
|
} |
|
|
|
|
.onChange(of: startDateSetup, perform: { value in |
|
|
|
|
switch startDateSetup { |
|
|
|
|
case .customDate: |
|
|
|
|
break |
|
|
|
|
case .now: |
|
|
|
|
startDate = Date() |
|
|
|
|
case .inMinutes(let minutes): |
|
|
|
|
startDate = Date().addingTimeInterval(Double(minutes) * 60) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
Text("Précédente rotation").tag(MatchDateSetup.inMinutes(-rotationDuration)) |
|
|
|
|
Text("Prochaine rotation").tag(MatchDateSetup.inMinutes(rotationDuration)) |
|
|
|
|
Text("À").tag(MatchDateSetup.customDate) |
|
|
|
|
} label: { |
|
|
|
|
Text("Horaire") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if match.startDate != nil || startDateSetup == .customDate { |
|
|
|
|
DatePicker(selection: $startDate) { |
|
|
|
|
Label("Début", systemImage: "calendar").labelStyle(.titleOnly) |
|
|
|
|
.onChange(of: startDateSetup, perform: { value in |
|
|
|
|
switch startDateSetup { |
|
|
|
|
case .customDate: |
|
|
|
|
break |
|
|
|
|
case .now: |
|
|
|
|
startDate = Date() |
|
|
|
|
case .inMinutes(let minutes): |
|
|
|
|
startDate = Date().addingTimeInterval(Double(minutes) * 60) |
|
|
|
|
} |
|
|
|
|
.datePickerStyle(.compact) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if match.startDate != nil || startDateSetup == .customDate { |
|
|
|
|
DatePicker(selection: $startDate) { |
|
|
|
|
Label("Début", systemImage: "calendar").labelStyle(.titleOnly) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if match.endDate != nil { |
|
|
|
|
DatePicker(selection: $endDate) { |
|
|
|
|
Label("Fin", systemImage: "calendar").labelStyle(.titleOnly) |
|
|
|
|
} |
|
|
|
|
.datePickerStyle(.compact) |
|
|
|
|
.datePickerStyle(.compact) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if match.endDate != nil { |
|
|
|
|
DatePicker(selection: $endDate) { |
|
|
|
|
Label("Fin", systemImage: "calendar").labelStyle(.titleOnly) |
|
|
|
|
} |
|
|
|
|
.datePickerStyle(.compact) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Picker(selection: $fieldSetup) { |
|
|
|
|
Text("Au hasard").tag(MatchFieldSetup.random) |
|
|
|
|
//Text("Premier disponible").tag(MatchFieldSetup.firstAvailable) |
|
|
|
|
if let tournament = match.currentTournament() { |
|
|
|
|
ForEach(0..<tournament.courtCount, id: \.self) { courtIndex in |
|
|
|
|
Text(tournament.courtName(atIndex: courtIndex)) .tag(MatchFieldSetup.field(courtIndex)) |
|
|
|
|
} |
|
|
|
|
Picker(selection: $fieldSetup) { |
|
|
|
|
Text("Au hasard").tag(MatchFieldSetup.random) |
|
|
|
|
//Text("Premier disponible").tag(MatchFieldSetup.firstAvailable) |
|
|
|
|
if let tournament = match.currentTournament() { |
|
|
|
|
ForEach(0..<tournament.courtCount, id: \.self) { courtIndex in |
|
|
|
|
Text(tournament.courtName(atIndex: courtIndex)) .tag(MatchFieldSetup.field(courtIndex)) |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("Choix du terrain") |
|
|
|
|
} |
|
|
|
|
.contextMenu { |
|
|
|
|
NavigationLink { |
|
|
|
|
//FieldDrawView(match: match) |
|
|
|
|
} label: { |
|
|
|
|
Text("Tirage au sort visuel") |
|
|
|
|
} |
|
|
|
|
} label: { |
|
|
|
|
Text("Choix du terrain") |
|
|
|
|
} |
|
|
|
|
.contextMenu { |
|
|
|
|
NavigationLink { |
|
|
|
|
//FieldDrawView(match: match) |
|
|
|
|
} label: { |
|
|
|
|
Text("Tirage au sort visuel") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if match.canBroadcast() == true { |
|
|
|
|
// Picker(selection: $broadcasted) { |
|
|
|
|
@ -453,21 +452,20 @@ struct MatchDetailView: View { |
|
|
|
|
// Text("Diffuser automatiquement") |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
RowButtonView("Valider") { |
|
|
|
|
match.validateMatch(fromStartDate: startDateSetup == .now ? Date() : startDate, toEndDate: endDate, fieldSetup: fieldSetup) |
|
|
|
|
|
|
|
|
|
RowButtonView("Valider") { |
|
|
|
|
match.validateMatch(fromStartDate: startDateSetup == .now ? Date() : startDate, toEndDate: endDate, fieldSetup: fieldSetup) |
|
|
|
|
|
|
|
|
|
if broadcasted { |
|
|
|
|
broadcastAndSave() |
|
|
|
|
} else { |
|
|
|
|
save() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isEditing.toggle() |
|
|
|
|
|
|
|
|
|
if match.hasStarted() == false { |
|
|
|
|
dismiss() |
|
|
|
|
} |
|
|
|
|
if broadcasted { |
|
|
|
|
broadcastAndSave() |
|
|
|
|
} else { |
|
|
|
|
save() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
isEditing.toggle() |
|
|
|
|
|
|
|
|
|
if match.hasStarted() == false { |
|
|
|
|
dismiss() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|