club_update
Razmig Sarkissian 1 year ago
parent 8373509a14
commit c24835052b
  1. 2
      PadelClub/Data/Match.swift
  2. 3
      PadelClub/Data/TeamRegistration.swift
  3. 2
      PadelClub/Views/Cashier/Event/EventTournamentsView.swift
  4. 1
      PadelClub/Views/GroupStage/GroupStageView.swift
  5. 74
      PadelClub/Views/Match/Components/MatchDateView.swift
  6. 11
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  7. 6
      PadelClub/Views/Tournament/Screen/Components/TournamentStatusView.swift
  8. 2
      PadelClub/Views/Tournament/TournamentView.swift

@ -488,6 +488,8 @@ defer {
winningTeamId = teamOne?.id winningTeamId = teamOne?.id
losingTeamId = teamTwo?.id losingTeamId = teamTwo?.id
confirmed = true
groupStageObject?.updateGroupStageState() groupStageObject?.updateGroupStageState()
roundObject?.updateTournamentState() roundObject?.updateTournamentState()
updateFollowingMatchTeamScore() updateFollowingMatchTeamScore()

@ -119,6 +119,9 @@ final class TeamRegistration: ModelObject, Storable {
let seedPosition: Int = match.lockAndGetSeedPosition(atTeamPosition: slot, opposingSeeding: opposingSeeding) let seedPosition: Int = match.lockAndGetSeedPosition(atTeamPosition: slot, opposingSeeding: opposingSeeding)
tournamentObject()?.resetTeamScores(in: bracketPosition) tournamentObject()?.resetTeamScores(in: bracketPosition)
self.bracketPosition = seedPosition self.bracketPosition = seedPosition
if groupStagePosition != nil && qualified == false {
qualified = true
}
tournamentObject()?.updateTeamScores(in: bracketPosition) tournamentObject()?.updateTeamScores(in: bracketPosition)
} }

@ -28,7 +28,7 @@ struct EventTournamentsView: View {
List { List {
ForEach(tournaments) { tournament in ForEach(tournaments) { tournament in
NavigationLink { NavigationLink {
TournamentStatusView(tournament: tournament) TournamentStatusView(tournament: tournament, eventDismiss: true)
} label: { } label: {
TournamentCellView(tournament: tournament) TournamentCellView(tournament: tournament)
.contextMenu { .contextMenu {

@ -46,6 +46,7 @@ struct GroupStageView: View {
} }
.pickerStyle(.segmented) .pickerStyle(.segmented)
.fixedSize()
Spacer() Spacer()
} }
} }

@ -27,50 +27,54 @@ struct MatchDateView: View {
} }
var body: some View { var body: some View {
Menu { if match.endDate != nil {
let estimatedDuration = match.getDuration() label
if match.startDate == nil && isReady { } else {
Button("Démarrer") { Menu {
match.startDate = Date() let estimatedDuration = match.getDuration()
match.confirmed = true if match.startDate == nil && isReady {
_save() Button("Démarrer") {
}
Button("Démarrer dans 5 minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: 5, to: Date())
match.confirmed = true
_save()
}
Button("Démarrer dans 15 minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: 15, to: Date())
match.confirmed = true
_save()
}
Button("Démarrer dans \(estimatedDuration.formatted()) minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: estimatedDuration, to: Date())
match.confirmed = true
_save()
}
} else {
if isReady {
Button("Démarrer maintenant") {
match.startDate = Date() match.startDate = Date()
match.endDate = nil match.confirmed = true
_save()
}
Button("Démarrer dans 5 minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: 5, to: Date())
match.confirmed = true
_save()
}
Button("Démarrer dans 15 minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: 15, to: Date())
match.confirmed = true
_save()
}
Button("Démarrer dans \(estimatedDuration.formatted()) minutes") {
match.startDate = Calendar.current.date(byAdding: .minute, value: estimatedDuration, to: Date())
match.confirmed = true match.confirmed = true
_save() _save()
} }
} else { } else {
Button("Décaler de \(estimatedDuration) minutes") { if isReady {
match.cleanScheduleAndSave(match.startDate?.addingTimeInterval(Double(estimatedDuration) * 60.0)) Button("Démarrer maintenant") {
match.startDate = Date()
match.endDate = nil
match.confirmed = true
_save()
}
} else {
Button("Décaler de \(estimatedDuration) minutes") {
match.cleanScheduleAndSave(match.startDate?.addingTimeInterval(Double(estimatedDuration) * 60.0))
}
}
Button("Retirer l'horaire") {
match.cleanScheduleAndSave()
} }
} }
Button("Retirer l'horaire") { } label: {
match.cleanScheduleAndSave() label
}
} }
} label: { .buttonStyle(.plain)
label
} }
.buttonStyle(.plain)
} }
@ViewBuilder @ViewBuilder

@ -65,10 +65,10 @@ struct OngoingView: View {
} }
} }
.navigationTitle("En cours") .navigationTitle("En cours")
.navigationBarTitleDisplayMode(.inline) .toolbarBackground(.visible, for: .bottomBar)
.toolbar(matches.isEmpty ? .hidden : .visible, for: .navigationBar) .toolbar(matches.isEmpty ? .hidden : .visible, for: .navigationBar)
.toolbar { .toolbar {
ToolbarItem(placement: .principal) { ToolbarItem(placement: .status) {
Picker(selection: $sortByField) { Picker(selection: $sortByField) {
Text("tri par date").tag(true) Text("tri par date").tag(true)
Text("tri par terrain").tag(false) Text("tri par terrain").tag(false)
@ -76,11 +76,8 @@ struct OngoingView: View {
} }
.pickerStyle(.segmented) .pickerStyle(.segmented)
} .fixedSize()
ToolbarItem(placement: .status) { .offset(y: -4)
if matches.isEmpty == false {
Text("\(matches.count) match" + matches.count.pluralSuffix)
}
} }
} }
} }

@ -13,6 +13,7 @@ struct TournamentStatusView: View {
@Environment(NavigationViewModel.self) private var navigation: NavigationViewModel @Environment(NavigationViewModel.self) private var navigation: NavigationViewModel
@EnvironmentObject var dataStore: DataStore @EnvironmentObject var dataStore: DataStore
@Bindable var tournament: Tournament @Bindable var tournament: Tournament
var eventDismiss: Bool = false
var body: some View { var body: some View {
Form { Form {
@ -64,7 +65,10 @@ struct TournamentStatusView: View {
Logger.error(error) Logger.error(error)
} }
} }
navigation.path = NavigationPath()
if eventDismiss {
navigation.path = NavigationPath()
}
} }
} }

@ -199,7 +199,9 @@ struct TournamentView: View {
TournamentStatusView(tournament: tournament) TournamentStatusView(tournament: tournament)
} label: { } label: {
Text("Gestion du tournoi") Text("Gestion du tournoi")
.foregroundStyle(.logoRed)
Text("Annuler, supprimer ou terminer le tournoi") Text("Annuler, supprimer ou terminer le tournoi")
.foregroundStyle(.logoRed)
} }
} label: { } label: {
LabelOptions() LabelOptions()

Loading…
Cancel
Save