paca_championship
Raz 1 year ago
parent df0a0b5e56
commit fe5ba820e4
  1. 4
      PadelClub/Data/Match.swift
  2. 14
      PadelClub/Data/MatchScheduler.swift
  3. 2
      PadelClub/Data/TournamentStore.swift
  4. 10
      PadelClub/Views/Match/MatchDetailView.swift
  5. 2
      PadelClub/Views/Planning/PlanningSettingsView.swift
  6. 33
      PadelClub/Views/Planning/PlanningView.swift

@ -491,7 +491,7 @@ defer {
return (groupStageObject.index + 1) * 100 + groupStageObject.indexOf(index) return (groupStageObject.index + 1) * 100 + groupStageObject.indexOf(index)
} }
guard let roundObject else { return index } guard let roundObject else { return index }
return roundObject.isLoserBracket() ? (roundObject.index + 1) * 1000 + indexInRound() : (roundObject.index + 1) * 10000 + indexInRound() return roundObject.isLoserBracket() ? (roundObject.index + 1) * 10000 + indexInRound() : (roundObject.index + 1) * 1000 + indexInRound()
} }
func previousMatches() -> [Match] { func previousMatches() -> [Match] {
@ -966,6 +966,8 @@ enum MatchDateSetup: Hashable, Identifiable {
case inMinutes(Int) case inMinutes(Int)
case now case now
case customDate case customDate
case previousRotation
case nextRotation
var id: Int { hashValue } var id: Int { hashValue }
} }

@ -386,9 +386,15 @@ final class MatchScheduler : ModelObject, Storable {
return true return true
} }
} else { } else {
print("Setting minimumTargetedEndDate to the earlier of \(minimumPossibleEndDate) and \(minimumTargetedEndDate)") if targetedStartDate == minimumTargetedEndDate {
minimumTargetedEndDate = minimumPossibleEndDate print("Updating minimumTargetedEndDate to minimumPossibleEndDate: \(minimumPossibleEndDate)")
return true minimumTargetedEndDate = minimumPossibleEndDate
} else {
print("Setting minimumTargetedEndDate to the earlier of \(minimumPossibleEndDate) and \(minimumTargetedEndDate)")
minimumTargetedEndDate = min(minimumPossibleEndDate, minimumTargetedEndDate)
}
print("Targeted start date is before the minimum possible end date, returning false.")
return false
} }
} }
@ -621,7 +627,7 @@ final class MatchScheduler : ModelObject, Storable {
matchID: firstMatch.id, matchID: firstMatch.id,
rotationIndex: rotationIndex, rotationIndex: rotationIndex,
courtIndex: courtIndex, courtIndex: courtIndex,
startDate: minimumTargetedEndDate, startDate: rotationStartDate,
durationLeft: firstMatch.matchFormat.getEstimatedDuration(additionalEstimationDuration), durationLeft: firstMatch.matchFormat.getEstimatedDuration(additionalEstimationDuration),
minimumBreakTime: firstMatch.matchFormat.breakTime.breakTime minimumBreakTime: firstMatch.matchFormat.breakTime.breakTime
) )

@ -38,7 +38,7 @@ class TournamentStore: Store, ObservableObject {
var synchronized: Bool = true var synchronized: Bool = true
let indexed: Bool = true let indexed: Bool = true
#if _DEBUG_OPTIONS #if DEBUG
if let sync = PListReader.readBool(plist: "local", key: "synchronized") { if let sync = PListReader.readBool(plist: "local", key: "synchronized") {
synchronized = sync synchronized = sync
} }

@ -461,8 +461,8 @@ struct MatchDetailView: View {
Text("Dans 5 minutes").tag(MatchDateSetup.inMinutes(5)) Text("Dans 5 minutes").tag(MatchDateSetup.inMinutes(5))
Text("Dans 15 minutes").tag(MatchDateSetup.inMinutes(15)) Text("Dans 15 minutes").tag(MatchDateSetup.inMinutes(15))
} }
Text("Précédente rotation").tag(MatchDateSetup.inMinutes(-rotationDuration)) Text("Précédente rotation").tag(MatchDateSetup.previousRotation)
Text("Prochaine rotation").tag(MatchDateSetup.inMinutes(rotationDuration)) Text("Prochaine rotation").tag(MatchDateSetup.nextRotation)
Text("À").tag(MatchDateSetup.customDate) Text("À").tag(MatchDateSetup.customDate)
} label: { } label: {
Text("Horaire") Text("Horaire")
@ -473,6 +473,12 @@ struct MatchDetailView: View {
break break
case .now: case .now:
startDate = Date() startDate = Date()
case .nextRotation:
let baseDate = match.startDate ?? Date()
startDate = baseDate.addingTimeInterval(Double(rotationDuration) * 60)
case .previousRotation:
let baseDate = match.startDate ?? Date()
startDate = baseDate.addingTimeInterval(Double(-rotationDuration) * 60)
case .inMinutes(let minutes): case .inMinutes(let minutes):
startDate = Date().addingTimeInterval(Double(minutes) * 60) startDate = Date().addingTimeInterval(Double(minutes) * 60)
} }

@ -498,7 +498,7 @@ struct PlanningSettingsView: View {
} label: { } label: {
let label : String = "\(count) match\(count.pluralSuffix) en \(matchFormat.format)" let label : String = "\(count) match\(count.pluralSuffix) en \(matchFormat.format)"
let optionA : String = "aucun match possible à ce format" let optionA : String = "aucun match possible à ce format"
let optionB : String = "max " + totalForThisFormat.formatted() + "/\(totalMatches) match\(totalForThisFormat.pluralSuffix) à ce format" let optionB : String = "pas plus de " + totalForThisFormat.formatted() + " match\(totalForThisFormat.pluralSuffix) à ce format"
let subtitle : String = (totalForThisFormat == 0) ? optionA : optionB let subtitle : String = (totalForThisFormat == 0) ? optionA : optionB
Text(label) Text(label)
Text(subtitle) Text(subtitle)

@ -86,30 +86,35 @@ struct PlanningView: View {
} }
} }
ToolbarItem(placement: .topBarTrailing) { ToolbarItemGroup(placement: .topBarTrailing) {
Menu { Menu {
Picker(selection: $filterOption) { Picker(selection: $showFinishedMatches) {
ForEach(PlanningFilterOption.allCases) { Text("Afficher tous les matchs").tag(true)
Text($0.localizedPlanningLabel()).tag($0) Text("Masquer les matchs terminés").tag(false)
}
} label: { } label: {
Text("Option de filtrage") Text("Option de filtrage")
} }
.labelsHidden() .labelsHidden()
.pickerStyle(.inline) .pickerStyle(.inline)
} label: {
Picker(selection: $showFinishedMatches) { Label("Filtrer", systemImage: "clock.badge.checkmark")
Text("Afficher tous les matchs").tag(true) .symbolVariant(showFinishedMatches ? .fill : .none)
Text("Masquer les matchs terminés").tag(false) }
Menu {
Picker(selection: $filterOption) {
ForEach(PlanningFilterOption.allCases) {
Text($0.localizedPlanningLabel()).tag($0)
}
} label: { } label: {
Text("Option de filtrage") Text("Option de triage")
} }
.labelsHidden() .labelsHidden()
.pickerStyle(.inline) .pickerStyle(.inline)
} label: { } label: {
Label("Filtrer", systemImage: "line.3.horizontal.decrease.circle") Label("Trier", systemImage: "line.3.horizontal.decrease.circle")
.symbolVariant(filterOption == .byCourt ? .fill : .none) .symbolVariant(filterOption == .byCourt ? .fill : .none)
} }
} }
}) })
.overlay { .overlay {
@ -163,7 +168,11 @@ struct PlanningView: View {
Text(day.formatted(.dateTime.day().weekday().month())) Text(day.formatted(.dateTime.day().weekday().month()))
Spacer() Spacer()
let count = _matchesCount(inDayInt: day.dayInt) let count = _matchesCount(inDayInt: day.dayInt)
Text(self._formattedMatchCount(count)) if showFinishedMatches {
Text(self._formattedMatchCount(count))
} else {
Text(self._formattedMatchCount(count) + " restant\(count.pluralSuffix)")
}
} }
} }
.headerProminence(.increased) .headerProminence(.increased)

Loading…
Cancel
Save