parent
97e5d641fb
commit
9e4a13246c
@ -0,0 +1,61 @@ |
|||||||
|
// |
||||||
|
// GenericDestinationPickerView.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Razmig Sarkissian on 31/03/2024. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
protocol Selectable { |
||||||
|
func selectionLabel() -> String |
||||||
|
} |
||||||
|
|
||||||
|
struct GenericDestinationPickerView<T: Identifiable & Selectable>: View { |
||||||
|
@Binding var selectedDestination: T? |
||||||
|
let destinations: [T] |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
ScrollView(.horizontal) { |
||||||
|
HStack { |
||||||
|
Button { |
||||||
|
selectedDestination = nil |
||||||
|
} label: { |
||||||
|
Image(systemName: "wrench.and.screwdriver") |
||||||
|
} |
||||||
|
.padding() |
||||||
|
.background { |
||||||
|
Circle() |
||||||
|
.fill(Color.white) |
||||||
|
.opacity(selectedDestination == nil ? 1.0 : 0.5) |
||||||
|
} |
||||||
|
.buttonStyle(.plain) |
||||||
|
|
||||||
|
ForEach(destinations) { destination in |
||||||
|
Button { |
||||||
|
selectedDestination = destination |
||||||
|
} label: { |
||||||
|
Text(destination.selectionLabel()) |
||||||
|
} |
||||||
|
.padding() |
||||||
|
.background { |
||||||
|
Capsule() |
||||||
|
.fill(Color.white) |
||||||
|
.opacity(selectedDestination?.id == destination.id ? 1.0 : 0.5) |
||||||
|
} |
||||||
|
.buttonStyle(.plain) |
||||||
|
} |
||||||
|
} |
||||||
|
.fixedSize() |
||||||
|
.padding(8) |
||||||
|
} |
||||||
|
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) |
||||||
|
.background(Material.ultraThinMaterial) |
||||||
|
.overlay { |
||||||
|
VStack(spacing: 0) { |
||||||
|
Spacer() |
||||||
|
Divider() |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,145 @@ |
|||||||
|
// |
||||||
|
// GroupStageSettingsView.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Razmig Sarkissian on 31/03/2024. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
struct GroupStageSettingsView: View { |
||||||
|
@Environment(Tournament.self) var tournament: Tournament |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
List { |
||||||
|
if tournament.missingQualifiedFromGroupStages().isEmpty == false && tournament.qualifiedTeams().count >= tournament.qualifiedFromGroupStage() && tournament.groupStageAdditionalQualified > 0 { |
||||||
|
NavigationLink { |
||||||
|
//DrawView(tournament: tournament) |
||||||
|
} label: { |
||||||
|
LabeledContent { |
||||||
|
Text(tournament.moreQualifiedToDraw().formatted() + "/" + tournament.groupStageAdditionalQualified.formatted()) |
||||||
|
} label: { |
||||||
|
Text("Qualifié\(tournament.groupStageAdditionalQualified.pluralSuffix) supplémentaire\(tournament.groupStageAdditionalQualified.pluralSuffix)") |
||||||
|
let message = [tournament.groupStageAdditionalQualified.formatted(), " meilleur", tournament.groupStageAdditionalQualified.pluralSuffix, " ", (tournament.qualifiedPerGroupStage + 1).ordinalFormatted()].joined() |
||||||
|
Text(message) |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// if (tournament.groupStagesAreWrong || (tournament.emptySlotInGroupStages > 0 && tournament.entriesCount >= tournament.teamsFromGroupStages)) { |
||||||
|
// Section { |
||||||
|
// RowButtonView(title: "Reconstruire les poules") { |
||||||
|
// confirmGroupStageRebuild = true |
||||||
|
// } |
||||||
|
// .modify { |
||||||
|
// if UIDevice.current.userInterfaceIdiom == .pad { |
||||||
|
// $0.alert("Êtes-vous sûr ?", isPresented: $confirmGroupStageRebuild) { |
||||||
|
// |
||||||
|
// Button(role: .destructive) { |
||||||
|
// tournament.refreshGroupStages() |
||||||
|
// save() |
||||||
|
// } label: { |
||||||
|
// Text("Reconstruire") |
||||||
|
// } |
||||||
|
// |
||||||
|
// |
||||||
|
// Button(role: .cancel) { |
||||||
|
// |
||||||
|
// } label: { |
||||||
|
// Text("Annuler") |
||||||
|
// } |
||||||
|
// } message: { |
||||||
|
// Text("Attention, cela peut modifier les poules existants.") |
||||||
|
// |
||||||
|
// } |
||||||
|
// } else { |
||||||
|
// $0.confirmationDialog("Êtes-vous sûr ?", isPresented: $confirmGroupStageRebuild) { |
||||||
|
// Button(role: .destructive) { |
||||||
|
// tournament.refreshGroupStages() |
||||||
|
// save() |
||||||
|
// } label: { |
||||||
|
// Text("Reconstruire") |
||||||
|
// } |
||||||
|
// } message: { |
||||||
|
// Text("Attention, cela peut modifier les poules existants.") |
||||||
|
// } |
||||||
|
// } |
||||||
|
// } |
||||||
|
// } header: { |
||||||
|
// Text("Erreur détectée") |
||||||
|
// } |
||||||
|
// } |
||||||
|
// |
||||||
|
|
||||||
|
// if tournament.isRoundSwissTournament() == false && (tournament.orderedGroupStages.allSatisfy({ $0.orderedMatches.count > 0 }) == false && tournament.groupStagesAreOver == false && tournament.groupStagesCount > 0) { |
||||||
|
// Section { |
||||||
|
// RowButtonView(title: "Générer les matchs de poules") { |
||||||
|
// startAllGroupStageConfirmation = true |
||||||
|
// } |
||||||
|
// .modify { |
||||||
|
// if UIDevice.current.userInterfaceIdiom == .pad { |
||||||
|
// $0.alert("Êtes-vous sûr ?", isPresented: $startAllGroupStageConfirmation) { |
||||||
|
// Button("Générer") { |
||||||
|
// tournament.orderedGroupStages.forEach { |
||||||
|
// if $0.orderedMatches.isEmpty { |
||||||
|
// $0.startGroupStage() |
||||||
|
// } |
||||||
|
// } |
||||||
|
// save() |
||||||
|
// } |
||||||
|
// Button(role: .cancel) { |
||||||
|
// |
||||||
|
// } label: { |
||||||
|
// Text("Annuler") |
||||||
|
// } |
||||||
|
// } |
||||||
|
// |
||||||
|
// } else { |
||||||
|
// $0.confirmationDialog("Êtes-vous sûr ?", isPresented: $startAllGroupStageConfirmation) { |
||||||
|
// Button("Générer") { |
||||||
|
// tournament.orderedGroupStages.forEach { |
||||||
|
// if $0.orderedMatches.isEmpty { |
||||||
|
// $0.startGroupStage() |
||||||
|
// } |
||||||
|
// } |
||||||
|
// save() |
||||||
|
// } |
||||||
|
// } |
||||||
|
// } |
||||||
|
// } |
||||||
|
// } |
||||||
|
// } |
||||||
|
// |
||||||
|
if tournament.groupStagesAreOver() == false { |
||||||
|
// Section { |
||||||
|
// GroupStageMatchAvailableToStartView(tournament: tournament, groupStageIndex: selectedGroupStageIndex) |
||||||
|
// } header: { |
||||||
|
// if selectedGroupStageIndex == -1 { |
||||||
|
// Text("Matchs de poules prêt à démarrer") |
||||||
|
// } else { |
||||||
|
// Text("Matchs de la poule \(selectedGroupStageIndex) prêt à démarrer") |
||||||
|
// } |
||||||
|
// } footer: { |
||||||
|
// Text("présence d'au moins 2 équipes d'une même poule ayant réglé.") |
||||||
|
// } |
||||||
|
} |
||||||
|
|
||||||
|
// if tournament.teamsPerGroupStage == 3 && tournament.qualifiedPerGroupStage == 1 && tournament.numberOfGroupStages%2 == 0 && tournament.moreQualifiedFromGroupStages == 0 { |
||||||
|
// Section { |
||||||
|
// NavigationLink { |
||||||
|
// GroupStageMissingMatchView(tournament: tournament) |
||||||
|
// } label: { |
||||||
|
// Text("Matchs de classement de poules") |
||||||
|
// } |
||||||
|
// } |
||||||
|
// } |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#Preview { |
||||||
|
GroupStageSettingsView() |
||||||
|
.environment(Tournament.mock()) |
||||||
|
} |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
// |
||||||
|
// RoundSettingsView.swift |
||||||
|
// PadelClub |
||||||
|
// |
||||||
|
// Created by Razmig Sarkissian on 31/03/2024. |
||||||
|
// |
||||||
|
|
||||||
|
import SwiftUI |
||||||
|
|
||||||
|
struct RoundSettingsView: View { |
||||||
|
@Environment(Tournament.self) var tournament: Tournament |
||||||
|
|
||||||
|
var body: some View { |
||||||
|
List { |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#Preview { |
||||||
|
RoundSettingsView() |
||||||
|
.environment(Tournament.mock()) |
||||||
|
} |
||||||
Loading…
Reference in new issue