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)
}
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] {
@ -966,6 +966,8 @@ enum MatchDateSetup: Hashable, Identifiable {
case inMinutes(Int)
case now
case customDate
case previousRotation
case nextRotation
var id: Int { hashValue }
}

@ -386,9 +386,15 @@ final class MatchScheduler : ModelObject, Storable {
return true
}
} else {
print("Setting minimumTargetedEndDate to the earlier of \(minimumPossibleEndDate) and \(minimumTargetedEndDate)")
minimumTargetedEndDate = minimumPossibleEndDate
return true
if targetedStartDate == minimumTargetedEndDate {
print("Updating minimumTargetedEndDate to minimumPossibleEndDate: \(minimumPossibleEndDate)")
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,
rotationIndex: rotationIndex,
courtIndex: courtIndex,
startDate: minimumTargetedEndDate,
startDate: rotationStartDate,
durationLeft: firstMatch.matchFormat.getEstimatedDuration(additionalEstimationDuration),
minimumBreakTime: firstMatch.matchFormat.breakTime.breakTime
)

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

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

@ -498,7 +498,7 @@ struct PlanningSettingsView: View {
} label: {
let label : String = "\(count) match\(count.pluralSuffix) en \(matchFormat.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
Text(label)
Text(subtitle)

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

Loading…
Cancel
Save