|
|
|
@ -8,13 +8,11 @@ |
|
|
|
import SwiftUI |
|
|
|
import SwiftUI |
|
|
|
|
|
|
|
|
|
|
|
struct TeamRestingView: View { |
|
|
|
struct TeamRestingView: View { |
|
|
|
@Environment(Tournament.self) var tournament |
|
|
|
@Environment(Tournament.self) var tournament: Tournament |
|
|
|
|
|
|
|
|
|
|
|
let readyMatches: [Match] |
|
|
|
|
|
|
|
let matchesLeft: [Match] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@State private var sortingMode: SortingMode = .restingTime |
|
|
|
@State private var sortingMode: SortingMode = .restingTime |
|
|
|
@State private var selectedCourt: Int? |
|
|
|
@State private var selectedCourt: Int? |
|
|
|
|
|
|
|
@State private var readyMatches: [Match] = [] |
|
|
|
|
|
|
|
@State private var matchesLeft: [Match] = [] |
|
|
|
|
|
|
|
|
|
|
|
enum SortingMode: Int, Identifiable, CaseIterable { |
|
|
|
enum SortingMode: Int, Identifiable, CaseIterable { |
|
|
|
var id: Int { self.rawValue } |
|
|
|
var id: Int { self.rawValue } |
|
|
|
@ -65,17 +63,16 @@ struct TeamRestingView: View { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
var body: some View { |
|
|
|
NavigationStack { |
|
|
|
List { |
|
|
|
List { |
|
|
|
Section { |
|
|
|
Section { |
|
|
|
Picker(selection: $selectedCourt) { |
|
|
|
Picker(selection: $selectedCourt) { |
|
|
|
Text("Aucun").tag(nil as Int?) |
|
|
|
Text("Aucun").tag(nil as Int?) |
|
|
|
ForEach(0..<tournament.courtCount, id: \.self) { courtIndex in |
|
|
|
ForEach(0..<tournament.courtCount, id: \.self) { courtIndex in |
|
|
|
Text(tournament.courtName(atIndex: courtIndex)).tag(courtIndex as Int?) |
|
|
|
Text(tournament.courtName(atIndex: courtIndex)).tag(courtIndex as Int?) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Text("Sur le terrain") |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} label: { |
|
|
|
|
|
|
|
Text("Sur le terrain") |
|
|
|
|
|
|
|
} |
|
|
|
// |
|
|
|
// |
|
|
|
// Toggle(isOn: $checkCanPlay) { |
|
|
|
// Toggle(isOn: $checkCanPlay) { |
|
|
|
// if isFree { |
|
|
|
// if isFree { |
|
|
|
@ -90,34 +87,40 @@ struct TeamRestingView: View { |
|
|
|
// } else { |
|
|
|
// } else { |
|
|
|
// Text("Masque les matchs où un ou plusieurs joueurs n'ont pas encore réglé ou qui ne sont pas encore arrivé") |
|
|
|
// Text("Masque les matchs où un ou plusieurs joueurs n'ont pas encore réglé ou qui ne sont pas encore arrivé") |
|
|
|
// } |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Section { |
|
|
|
Section { |
|
|
|
if sortedMatches.isEmpty == false { |
|
|
|
if sortedMatches.isEmpty == false { |
|
|
|
ForEach(sortedMatches) { match in |
|
|
|
ForEach(sortedMatches) { match in |
|
|
|
MatchRowView(match: match, matchViewStyle: .followUpStyle, updatedField: selectedCourt) |
|
|
|
MatchRowView(match: match, matchViewStyle: .followUpStyle, updatedField: selectedCourt) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ContentUnavailableView("Aucun match à venir", systemImage: "xmark.circle", description: Text(contentUnavailableDescriptionLabel())) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} header: { |
|
|
|
} else { |
|
|
|
Picker(selection: $sortingMode) { |
|
|
|
ContentUnavailableView("Aucun match à venir", systemImage: "xmark.circle", description: Text(contentUnavailableDescriptionLabel())) |
|
|
|
ForEach(sortingModeCases) { sortingMode in |
|
|
|
} |
|
|
|
Text(sortingMode.localizedSortingModeLabel()).tag(sortingMode) |
|
|
|
} header: { |
|
|
|
} |
|
|
|
Picker(selection: $sortingMode) { |
|
|
|
} label: { |
|
|
|
ForEach(sortingModeCases) { sortingMode in |
|
|
|
Text("Méthode de tri") |
|
|
|
Text(sortingMode.localizedSortingModeLabel()).tag(sortingMode) |
|
|
|
} |
|
|
|
} |
|
|
|
.labelsHidden() |
|
|
|
} label: { |
|
|
|
.pickerStyle(.segmented) |
|
|
|
Text("Méthode de tri") |
|
|
|
.fixedSize() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
.headerProminence(.increased) |
|
|
|
.labelsHidden() |
|
|
|
.textCase(nil) |
|
|
|
.pickerStyle(.segmented) |
|
|
|
} |
|
|
|
} |
|
|
|
.toolbarBackground(.visible, for: .navigationBar) |
|
|
|
.headerProminence(.increased) |
|
|
|
.navigationTitle("Match à suivre") |
|
|
|
.textCase(nil) |
|
|
|
.navigationBarTitleDisplayMode(.inline) |
|
|
|
} |
|
|
|
|
|
|
|
.toolbarBackground(.visible, for: .navigationBar) |
|
|
|
|
|
|
|
.navigationTitle("Match à suivre") |
|
|
|
|
|
|
|
.navigationBarTitleDisplayMode(.inline) |
|
|
|
|
|
|
|
.onAppear { |
|
|
|
|
|
|
|
let allMatches = tournament.allMatches() |
|
|
|
|
|
|
|
let matchesLeft = tournament.matchesLeft(allMatches) |
|
|
|
|
|
|
|
let runningMatches = tournament.runningMatches(allMatches) |
|
|
|
|
|
|
|
let readyMatches = tournament.readyMatches(allMatches) |
|
|
|
|
|
|
|
self.readyMatches = tournament.availableToStart(readyMatches, in: runningMatches, checkCanPlay: false) |
|
|
|
|
|
|
|
self.matchesLeft = matchesLeft |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|