|
|
|
|
@ -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) |
|
|
|
|
|