add planning feature

newoffer2025
Raz 6 months ago
parent ecdc46a968
commit 12142cde37
  1. 11
      PadelClub/Views/Cashier/Event/EventView.swift
  2. 27
      PadelClub/Views/Planning/CourtAvailabilitySettingsView.swift
  3. 1
      PadelClub/Views/Planning/PlanningByCourtView.swift
  4. 800
      PadelClub/Views/Planning/PlanningView.swift

@ -18,6 +18,7 @@ enum EventDestination: Identifiable, Selectable, Equatable {
case links
case tournaments(Event)
case cashier
case eventPlanning
var id: String {
return String(describing: self)
@ -33,6 +34,8 @@ enum EventDestination: Identifiable, Selectable, Equatable {
return "Tournois"
case .cashier:
return "Finance"
case .eventPlanning:
return "Planning"
}
}
@ -42,7 +45,7 @@ enum EventDestination: Identifiable, Selectable, Equatable {
return nil
case .tournaments(let event):
return event.tournaments.count
case .cashier:
case .cashier, .eventPlanning:
return nil
}
}
@ -77,7 +80,7 @@ struct EventView: View {
}
func allDestinations() -> [EventDestination] {
[.club(event), .tournaments(event), .cashier]
[.club(event), .eventPlanning, .tournaments(event), .cashier]
}
var body: some View {
@ -90,6 +93,10 @@ struct EventView: View {
switch selectedEventDestination {
case .club(let event):
EventClubSettingsView(event: event)
case .eventPlanning:
let allMatches = event.tournaments.flatMap { $0.allMatches() }
PlanningView(matches: allMatches, selectedScheduleDestination: .constant(.planning))
.environment(\.matchViewStyle, .feedStyle)
case .links:
EventLinksView(event: event)
case .tournaments(let event):

@ -256,13 +256,27 @@ struct CourtAvailabilityEditorView: View {
struct DateAdjusterView: View {
@Binding var date: Date
var time: Int?
var matchFormat: MatchFormat?
var body: some View {
HStack {
_createButton(label: "-1h", timeOffset: -1, component: .hour)
_createButton(label: "-30m", timeOffset: -30, component: .minute)
_createButton(label: "+30m", timeOffset: 30, component: .minute)
_createButton(label: "+1h", timeOffset: 1, component: .hour)
HStack(spacing: 4) {
if let matchFormat {
_createButton(label: "-\(matchFormat.defaultEstimatedDuration)m", timeOffset: -matchFormat.defaultEstimatedDuration, component: .minute)
_createButton(label: "+\(matchFormat.defaultEstimatedDuration)m", timeOffset: +matchFormat.defaultEstimatedDuration, component: .minute)
_createButton(label: "-\(matchFormat.estimatedTimeWithBreak)m", timeOffset: -matchFormat.estimatedTimeWithBreak, component: .minute)
_createButton(label: "+\(matchFormat.estimatedTimeWithBreak)m", timeOffset: +matchFormat.estimatedTimeWithBreak, component: .minute)
} else if let time {
_createButton(label: "-\(time)m", timeOffset: -time, component: .minute)
_createButton(label: "-\(time/2)m", timeOffset: -time/2, component: .minute)
_createButton(label: "+\(time/2)m", timeOffset: time/2, component: .minute)
_createButton(label: "+\(time)m", timeOffset: time, component: .minute)
} else {
_createButton(label: "-1h", timeOffset: -1, component: .hour)
_createButton(label: "-30m", timeOffset: -30, component: .minute)
_createButton(label: "+30m", timeOffset: 30, component: .minute)
_createButton(label: "+1h", timeOffset: 1, component: .hour)
}
}
.font(.headline)
}
@ -272,6 +286,9 @@ struct DateAdjusterView: View {
date = Calendar.current.date(byAdding: component, value: timeOffset, to: date) ?? date
}) {
Text(label)
.lineLimit(1)
.font(.footnote)
.underline()
.frame(maxWidth: .infinity) // Make buttons take equal space
}
.buttonStyle(.borderedProminent)

@ -114,7 +114,6 @@ struct PlanningByCourtView: View {
let match = _sortedMatches[index]
Section {
MatchRowView(match: match)
.matchViewStyle(.feedStyle)
} header: {
if let startDate = match.startDate {
if index > 0 {

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save