paca_championship
Raz 1 year ago
parent 0e5988b4ed
commit 42a7487c63
  1. 11
      PadelClub/Views/Match/MatchSummaryView.swift
  2. 5
      PadelClub/Views/Navigation/Ongoing/OngoingContainerView.swift
  3. 9
      PadelClub/Views/Navigation/Ongoing/OngoingView.swift
  4. 26
      PadelClub/Views/Score/FollowUpMatchView.swift

@ -19,6 +19,7 @@ struct MatchSummaryView: View {
let color: Color let color: Color
let width: CGFloat let width: CGFloat
let updatedField: Int? let updatedField: Int?
let estimatedStartDate: Match.CourtIndexAndDate?
init(match: Match, matchViewStyle: MatchViewStyle, title: String? = nil, updatedField: Int? = nil) { init(match: Match, matchViewStyle: MatchViewStyle, title: String? = nil, updatedField: Int? = nil) {
self.match = match self.match = match
@ -44,6 +45,8 @@ struct MatchSummaryView: View {
} else { } else {
self.courtName = nil self.courtName = nil
} }
self.estimatedStartDate = match.estimatedStartDate()
} }
var body: some View { var body: some View {
@ -67,11 +70,13 @@ struct MatchSummaryView: View {
} else if let first = match.availableCourts().first { } else if let first = match.availableCourts().first {
Text("possible") Text("possible")
Text(match.courtName(for: first)) Text(match.courtName(for: first))
} else if let estimatedStartDate = match.estimatedStartDate() { } else if let estimatedStartDate {
Text(match.courtName(for: estimatedStartDate.0) + " possible") Text(match.courtName(for: estimatedStartDate.0) + " possible")
Text("dans ~ " + estimatedStartDate.1.timeElapsedString()) Text("dans ~ " + estimatedStartDate.1.timeElapsedString())
} else if let courtName {
Text(courtName)
} else { } else {
Text("aucun terrain disponible") Text("")
} }
} else if let courtName { } else if let courtName {
Text(courtName) Text(courtName)
@ -111,7 +116,7 @@ struct MatchSummaryView: View {
.foregroundStyle(.secondary) .foregroundStyle(.secondary)
} }
Spacer() Spacer()
MatchDateView(match: match, showPrefix: matchViewStyle == .tournamentResultStyle, updatedField: updatedField) MatchDateView(match: match, showPrefix: matchViewStyle == .tournamentResultStyle, updatedField: updatedField ?? estimatedStartDate?.0)
} }
} }
} }

@ -27,14 +27,10 @@ class OngoingViewModel {
} }
var filteredRunningAndNextMatches: [Match] { var filteredRunningAndNextMatches: [Match] {
if destination == .followUp {
return runningAndNextMatches.filter({ return runningAndNextMatches.filter({
(hideUnconfirmedMatches == false || hideUnconfirmedMatches == true && $0.confirmed) (hideUnconfirmedMatches == false || hideUnconfirmedMatches == true && $0.confirmed)
&& (hideNotReadyMatches == false || hideNotReadyMatches == true && $0.isReady() ) && (hideNotReadyMatches == false || hideNotReadyMatches == true && $0.isReady() )
}) })
} else {
return runningAndNextMatches
}
} }
} }
@ -56,7 +52,6 @@ struct OngoingContainerView: View {
OngoingCourtView() OngoingCourtView()
} }
} }
.toolbarBackground(.visible, for: .bottomBar)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.toolbarBackground(.visible, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar)
.navigationTitle("Programmation") .navigationTitle("Programmation")

@ -91,14 +91,13 @@ struct OngoingCourtView: View {
if (filterMode == .free && courtFilteredMatches.isEmpty) || (filterMode == .court && courtFilteredMatches.isEmpty == false) { if (filterMode == .free && courtFilteredMatches.isEmpty) || (filterMode == .court && courtFilteredMatches.isEmpty == false) {
Section { Section {
MatchListView(section: "En cours", matches: courtFilteredMatches, hideWhenEmpty: true, isExpanded: false) MatchListView(section: "En cours", matches: courtFilteredMatches, hideWhenEmpty: true, isExpanded: false)
if courtFilteredMatches.isEmpty {
Button("Choisir un match") {
selectedCourtForFollowUp = index
}
}
MatchListView(section: "À venir", matches: sortedMatches.filter({ $0.courtIndex == index && $0.hasStarted() == false }), isExpanded: false) MatchListView(section: "À venir", matches: sortedMatches.filter({ $0.courtIndex == index && $0.hasStarted() == false }), isExpanded: false)
} header: { } header: {
Text(title) Text(title)
} footer: {
FooterButtonView("Ajouter un match à suivre") {
selectedCourtForFollowUp = index
}
} }
} }
} }

@ -196,8 +196,32 @@ struct FollowUpMatchView: View {
if sortedMatches.isEmpty == false { if sortedMatches.isEmpty == false {
ForEach(sortedMatches) { match in ForEach(sortedMatches) { match in
let tournament = match.currentTournament()
Section { Section {
MatchRowView(match: match, matchViewStyle: .followUpStyle, updatedField: selectedCourt) MatchRowView(match: match, matchViewStyle: .followUpStyle, updatedField: selectedCourt)
} header: {
if let tournament {
HStack {
Text(tournament.tournamentTitle(.short))
Spacer()
if let club = tournament.club() {
Text("@" + club.clubTitle(.short))
}
}
}
} footer: {
HStack {
if let tournament {
Text(tournament.eventLabel())
}
#if DEBUG
Spacer()
FooterButtonView("copier l'id") {
let pasteboard = UIPasteboard.general
pasteboard.string = match.id
}
#endif
}
} }
} }
} else { } else {
@ -243,7 +267,7 @@ struct FollowUpMatchView: View {
ToolbarItem(placement: .topBarTrailing) { ToolbarItem(placement: .topBarTrailing) {
Picker(selection: $selectedCourt) { Picker(selection: $selectedCourt) {
Text("choix du terrain").tag(nil as Int?) Image(systemName: "sportscourt").tag(nil as Int?)
if let tournament = match?.currentTournament() { if let tournament = match?.currentTournament() {
ForEach(0..<tournament.courtCount, id: \.self) { courtIndex in ForEach(0..<tournament.courtCount, id: \.self) { courtIndex in
Text(tournament.courtName(atIndex: courtIndex)).tag(courtIndex as Int?) Text(tournament.courtName(atIndex: courtIndex)).tag(courtIndex as Int?)

Loading…
Cancel
Save