From 6791aed10aedc2173a94fcabe91cc2e206586965 Mon Sep 17 00:00:00 2001 From: Raz Date: Thu, 17 Oct 2024 13:18:00 +0200 Subject: [PATCH] fix stuff --- PadelClub.xcodeproj/project.pbxproj | 4 +- .../Views/Calling/TeamsCallingView.swift | 47 ++++++++++++++++--- PadelClub/Views/Club/ClubDetailView.swift | 9 ++-- .../Components/GroupStageTeamView.swift | 8 ++++ .../Match/Components/MatchDateView.swift | 9 +++- .../Components/MatchTeamDetailView.swift | 13 ++++- PadelClub/Views/Match/MatchDetailView.swift | 3 +- PadelClub/Views/Score/EditScoreView.swift | 8 +++- PadelClub/Views/Team/CoachListView.swift | 37 ++++++++------- PadelClub/Views/Team/EditingTeamView.swift | 35 +++++++++----- 10 files changed, 125 insertions(+), 48 deletions(-) diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index 10b7a3f..4d0522e 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3166,7 +3166,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3211,7 +3211,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; diff --git a/PadelClub/Views/Calling/TeamsCallingView.swift b/PadelClub/Views/Calling/TeamsCallingView.swift index 1760e99..f1cf5c3 100644 --- a/PadelClub/Views/Calling/TeamsCallingView.swift +++ b/PadelClub/Views/Calling/TeamsCallingView.swift @@ -11,25 +11,46 @@ import LeStorage struct TeamsCallingView: View { @Environment(Tournament.self) var tournament: Tournament let teams : [TeamRegistration] + + var filteredTeams: [TeamRegistration] { + teams.filter({ searchText.isEmpty || $0.contains(searchText) }) + } + + @State private var searchText: String = "" var body: some View { List { PlayersWithoutContactView(players: teams.flatMap({ $0.unsortedPlayers() }).sorted(by: \.computedRank)) let called = teams.filter { tournament.isStartDateIsDifferentThanCallDate($0) == false } + let confirmed = teams.filter { $0.confirmed() } let justCalled = teams.filter { $0.called() } - let label = "\(justCalled.count.formatted()) / \(teams.count.formatted()) convoquées (dont \(called.count.formatted()) au bon horaire)" - - if teams.isEmpty == false { + let label = "\(justCalled.count.formatted()) / \(teams.count.formatted())" + let subtitle = "dont \(called.count.formatted()) au bon horaire" + let confirmedLabel = "\(confirmed.count.formatted()) / \(teams.count.formatted())" + + if teams.isEmpty == false, searchText.isEmpty { Section { - Text(label) + LabeledContent { + Text(label).font(.title3) + } label: { + Text("Paire\(justCalled.count.pluralSuffix) convoquée\(justCalled.count.pluralSuffix)") + Text(subtitle) + } + LabeledContent { + Text(confirmedLabel).font(.title3) + } label: { + Text("Paire\(confirmed.count.pluralSuffix) confirmée\(confirmed.count.pluralSuffix)") + } } footer: { Text("Vous pouvez indiquer si une équipe vous a confirmé sa convocation en appuyant sur ") + Text(Image(systemName: "ellipsis.circle")) } - + } + + if teams.isEmpty == false { Section { - ForEach(teams) { team in + ForEach(filteredTeams) { team in Menu { _menuOptions(team: team) } label: { @@ -51,6 +72,7 @@ struct TeamsCallingView: View { ContentUnavailableView("Aucune équipe", systemImage: "person.2.slash") } } + .searchable(text: $searchText, placement: .navigationBarDrawer(displayMode: .always)) .headerProminence(.increased) .navigationTitle("Statut des équipes") .navigationBarTitleDisplayMode(.inline) @@ -66,6 +88,7 @@ struct TeamsCallingView: View { } catch { Logger.error(error) } + searchText = "" } label: { if team.confirmed() { Label("Confirmation reçue", systemImage: "checkmark.circle.fill").foregroundStyle(.green) @@ -73,6 +96,16 @@ struct TeamsCallingView: View { Label("Confirmation reçue", systemImage: "circle").foregroundStyle(.logoRed) } } + + Divider() + + NavigationLink { + EditingTeamView(team: team) + .environment(tournament) + } label: { + Text("Détails de l'équipe") + } + Divider() Button(role: .destructive) { @@ -82,6 +115,7 @@ struct TeamsCallingView: View { } catch { Logger.error(error) } + searchText = "" } label: { Text("Effacer la date de convocation") } @@ -96,6 +130,7 @@ struct TeamsCallingView: View { } catch { Logger.error(error) } + searchText = "" } label: { Text("Indiquer comme convoquée") } diff --git a/PadelClub/Views/Club/ClubDetailView.swift b/PadelClub/Views/Club/ClubDetailView.swift index b04b4f0..b16e079 100644 --- a/PadelClub/Views/Club/ClubDetailView.swift +++ b/PadelClub/Views/Club/ClubDetailView.swift @@ -216,9 +216,12 @@ struct ClubDetailView: View { .navigationBarBackButtonHidden(focusedField != nil) .toolbar(content: { if focusedField != nil { - ToolbarItem(placement: .topBarLeading) { - Button("Annuler", role: .cancel) { - focusedField = nil + ToolbarItem(placement: .keyboard) { + HStack { + Button("Fermer", role: .cancel) { + focusedField = nil + } + Spacer() } } } diff --git a/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift b/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift index d839870..18a3786 100644 --- a/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift +++ b/PadelClub/Views/GroupStage/Components/GroupStageTeamView.swift @@ -54,6 +54,14 @@ struct GroupStageTeamView: View { ForEach(team.players()) { player in EditablePlayerView(player: player, editingOptions: _editingOptions()) } + } footer: { + NavigationLink { + EditingTeamView(team: team) + .environment(tournament) + } label: { + Text("détails de l'équipe") + .underline() + } } if groupStage.tournamentObject()?.hasEnded() == false { diff --git a/PadelClub/Views/Match/Components/MatchDateView.swift b/PadelClub/Views/Match/Components/MatchDateView.swift index f64f8bb..ab962ed 100644 --- a/PadelClub/Views/Match/Components/MatchDateView.swift +++ b/PadelClub/Views/Match/Components/MatchDateView.swift @@ -11,7 +11,8 @@ import LeStorage struct MatchDateView: View { @EnvironmentObject var dataStore: DataStore - + @State private var showScoreEditView: Bool = false + @State private var confirmScoreEdition: Bool = false var match: Match var showPrefix: Bool = false private var isReady: Bool @@ -84,7 +85,7 @@ struct MatchDateView: View { } } Button("Indiquer un score") { - + showScoreEditView = true } Divider() Button("Retirer l'horaire") { @@ -165,6 +166,10 @@ struct MatchDateView: View { } } } + .sheet(isPresented: $showScoreEditView) { + EditScoreView(match: match, confirmScoreEdition: $confirmScoreEdition) + .tint(.master) + } } private func _save() { diff --git a/PadelClub/Views/Match/Components/MatchTeamDetailView.swift b/PadelClub/Views/Match/Components/MatchTeamDetailView.swift index f12eb91..3ee208b 100644 --- a/PadelClub/Views/Match/Components/MatchTeamDetailView.swift +++ b/PadelClub/Views/Match/Components/MatchTeamDetailView.swift @@ -25,7 +25,6 @@ struct MatchTeamDetailView: View { .headerProminence(.increased) .tint(.master) } - .presentationDetents([.fraction(0.66)]) } @ViewBuilder @@ -41,7 +40,17 @@ struct MatchTeamDetailView: View { Text("Coachs : " + coachList).foregroundStyle(.secondary).font(.footnote) } } header: { - TeamHeaderView(team: team, teamIndex: tournament?.indexOf(team: team)) + TeamHeaderView(team: team, teamIndex: tournament?.indexOf(team: team), tournament: tournament) + } footer: { + if let tournament { + NavigationLink { + EditingTeamView(team: team) + .environment(tournament) + } label: { + Text("détails de l'équipe") + .underline() + } + } } } diff --git a/PadelClub/Views/Match/MatchDetailView.swift b/PadelClub/Views/Match/MatchDetailView.swift index 24f19ae..0071351 100644 --- a/PadelClub/Views/Match/MatchDetailView.swift +++ b/PadelClub/Views/Match/MatchDetailView.swift @@ -194,8 +194,7 @@ struct MatchDetailView: View { } } }) { scoreType in - let matchDescriptor = MatchDescriptor(match: match) - EditScoreView(matchDescriptor: matchDescriptor, confirmScoreEdition: $confirmScoreEdition) + EditScoreView(match: match, confirmScoreEdition: $confirmScoreEdition) .tint(.master) // switch scoreType { diff --git a/PadelClub/Views/Score/EditScoreView.swift b/PadelClub/Views/Score/EditScoreView.swift index d30f20e..6728c0d 100644 --- a/PadelClub/Views/Score/EditScoreView.swift +++ b/PadelClub/Views/Score/EditScoreView.swift @@ -43,7 +43,7 @@ struct EditScoreView: View { @EnvironmentObject var dataStore: DataStore - @ObservedObject var matchDescriptor: MatchDescriptor + @StateObject var matchDescriptor: MatchDescriptor @Binding var confirmScoreEdition: Bool @Environment(\.dismiss) private var dismiss @State private var showSetInputView: Bool = true @@ -51,6 +51,12 @@ struct EditScoreView: View { let colorTeamOne: Color = .teal let colorTeamTwo: Color = .indigo + + init(match: Match, confirmScoreEdition: Binding) { + let matchDescriptor = MatchDescriptor(match: match) + _matchDescriptor = .init(wrappedValue: matchDescriptor) + _confirmScoreEdition = confirmScoreEdition + } func walkout(_ team: TeamPosition) { self.matchDescriptor.match?.setWalkOut(team) diff --git a/PadelClub/Views/Team/CoachListView.swift b/PadelClub/Views/Team/CoachListView.swift index bce29b4..7a980d6 100644 --- a/PadelClub/Views/Team/CoachListView.swift +++ b/PadelClub/Views/Team/CoachListView.swift @@ -20,28 +20,31 @@ struct CoachListView: View { var body: some View { Section { - TextField("Coach", text: $coachNames) - .autocorrectionDisabled() - .keyboardType(.alphabet) - .frame(maxWidth: .infinity) - .submitLabel(.done) - .onSubmit(of: .text) { - let trimmed = coachNames.prefixTrimmed(200) - if trimmed.isEmpty { + HStack { + TextField("Coach", text: $coachNames) + .autocorrectionDisabled() + .keyboardType(.alphabet) + .frame(maxWidth: .infinity) + .submitLabel(.done) + .onSubmit(of: .text) { + let trimmed = coachNames.prefixTrimmed(200) + if trimmed.isEmpty { + team.comment = nil + } else { + team.comment = trimmed + } + _save() + } + if coachNames.isEmpty == false { + FooterButtonView("effacer", role: .destructive) { + coachNames = "" team.comment = nil - } else { - team.comment = trimmed + _save() } - _save() } + } } header: { Text("Coachs") - } footer: { - FooterButtonView("effacer") { - coachNames = "" - team.comment = nil - _save() - } } } diff --git a/PadelClub/Views/Team/EditingTeamView.swift b/PadelClub/Views/Team/EditingTeamView.swift index 133ff49..f8cc5d5 100644 --- a/PadelClub/Views/Team/EditingTeamView.swift +++ b/PadelClub/Views/Team/EditingTeamView.swift @@ -144,22 +144,31 @@ struct EditingTeamView: View { } Section { - TextField("Nom de l'équipe", text: $name) - .autocorrectionDisabled() - .focused($focusedField, equals: ._name) - .keyboardType(.alphabet) - .frame(maxWidth: .infinity) - .submitLabel(.done) - .onSubmit(of: .text) { - let trimmed = name.prefixTrimmed(200) - if trimmed.isEmpty { + HStack { + TextField("Nom de l'équipe", text: $name) + .autocorrectionDisabled() + .focused($focusedField, equals: ._name) + .keyboardType(.alphabet) + .frame(maxWidth: .infinity) + .submitLabel(.done) + .onSubmit(of: .text) { + let trimmed = name.prefixTrimmed(200) + if trimmed.isEmpty { + team.name = nil + } else { + team.name = trimmed + } + + _save() + } + if name.isEmpty == false { + FooterButtonView("effacer", role: .destructive) { + name = "" team.name = nil - } else { - team.name = trimmed + _save() } - - _save() } + } } header: { Text("Nom de l'équipe") }