diff --git a/PadelClub/Data/TeamRegistration.swift b/PadelClub/Data/TeamRegistration.swift index be3ece8..cb298b8 100644 --- a/PadelClub/Data/TeamRegistration.swift +++ b/PadelClub/Data/TeamRegistration.swift @@ -287,7 +287,7 @@ final class TeamRegistration: ModelObject, Storable { func initialRoundColor() -> Color? { if walkOut { return Color.logoRed } - if groupStagePosition != nil { return Color.mint } + if groupStagePosition != nil { return Color.blue } if let initialRound = initialRound(), let colorHex = RoundRule.colors[safe: initialRound.index] { return Color(uiColor: .init(fromHex: colorHex)) } else { diff --git a/PadelClub/Data/Tournament.swift b/PadelClub/Data/Tournament.swift index f5d9bf4..5c812d4 100644 --- a/PadelClub/Data/Tournament.swift +++ b/PadelClub/Data/Tournament.swift @@ -923,9 +923,9 @@ defer { let _teamCount = teamCount ?? selectedSortedTeams().count let bracketCut = bracketCut(teamCount: _teamCount) if index < bracketCut { - return Color.cyan + return Color.mint } else if index - bracketCut < groupStageCut() && _teamCount > 0 { - return Color.indigo + return Color.cyan } else { return Color.gray } diff --git a/PadelClub/Utils/PadelRule.swift b/PadelClub/Utils/PadelRule.swift index dfddbff..d50d6a9 100644 --- a/PadelClub/Utils/PadelRule.swift +++ b/PadelClub/Utils/PadelRule.swift @@ -1453,7 +1453,7 @@ enum PlayersCountRange: Int, CaseIterable { } enum RoundRule { - static let colors = ["#d4afb9", "#d1cfe2", "#9cadce", "#7ec4cf", "#daeaf6", "#caffbf"] + static let colors = ["#99ff99", "#66ff66", "#33cc33", "#009900", "#006600", "#006600", "#006600", "#006600", "#006600", "#006600"] static func loserBrackets(index: Int) -> [String] { switch index { diff --git a/PadelClub/ViewModel/SearchViewModel.swift b/PadelClub/ViewModel/SearchViewModel.swift index 1852639..5b5ecfc 100644 --- a/PadelClub/ViewModel/SearchViewModel.swift +++ b/PadelClub/ViewModel/SearchViewModel.swift @@ -156,9 +156,9 @@ class SearchViewModel: ObservableObject, Identifiable { if let wordsPredicates { predicates.append(wordsPredicates) } else { - predicates.append(NSPredicate(format: "license contains[cd] %@", searchText)) + predicates.append(NSPredicate(format: "license contains[cd] %@", canonicalVersionWithoutPunctuation)) } - predicates.append(NSPredicate(format: "canonicalFullName contains[cd] %@", searchText)) + predicates.append(NSPredicate(format: "canonicalFullName contains[cd] %@", canonicalVersionWithoutPunctuation)) } case .ligue: if canonicalVersionWithoutPunctuation.isEmpty { diff --git a/PadelClub/Views/Match/MatchSetupView.swift b/PadelClub/Views/Match/MatchSetupView.swift index b91beb1..62cd255 100644 --- a/PadelClub/Views/Match/MatchSetupView.swift +++ b/PadelClub/Views/Match/MatchSetupView.swift @@ -38,46 +38,15 @@ struct MatchSetupView: View { if let teamScore, teamScore.luckyLoser != nil { Text("Repêchée").italic().font(.caption) } - TeamRowView(team: team, teamPosition: teamPosition) - .swipeActions(edge: .trailing, allowsFullSwipe: false) { - Button(role: .cancel) { - //todo - if match.isSeededBy(team: team, inTeamPosition: teamPosition) { - team.bracketPosition = nil - do { - try tournamentStore.teamRegistrations.addOrUpdate(instance: team) - } catch { - Logger.error(error) - } - match.updateTeamScores() - match.previousMatches().forEach { previousMatch in - if previousMatch.disabled { - previousMatch.enableMatch() - do { - try tournamentStore.matches.addOrUpdate(instance: previousMatch) - } catch { - Logger.error(error) - } - } - } - - do { - try tournamentStore.matches.addOrUpdate(instance: match) - } catch { - Logger.error(error) - } - } else { - match.teamWillBeWalkOut(team) - do { - try tournamentStore.matches.addOrUpdate(instance: match) - } catch { - Logger.error(error) - } - } - } label: { - Label("retirer", systemImage: "xmark") + Menu { + _removeTeam(team: team, teamPosition: teamPosition) + } label: { + TeamRowView(team: team, teamPosition: teamPosition) + .swipeActions(edge: .trailing, allowsFullSwipe: false) { + _removeTeam(team: team, teamPosition: teamPosition) } - } + } + .buttonStyle(.plain) } } else { VStack(alignment: .leading) { @@ -207,6 +176,46 @@ struct MatchSetupView: View { } } } + + func _removeTeam(team: TeamRegistration, teamPosition: TeamPosition) -> some View { + Button(role: .cancel) { + //todo + if match.isSeededBy(team: team, inTeamPosition: teamPosition) { + team.bracketPosition = nil + do { + try tournamentStore.teamRegistrations.addOrUpdate(instance: team) + } catch { + Logger.error(error) + } + match.updateTeamScores() + match.previousMatches().forEach { previousMatch in + if previousMatch.disabled { + previousMatch.enableMatch() + do { + try tournamentStore.matches.addOrUpdate(instance: previousMatch) + } catch { + Logger.error(error) + } + } + } + + do { + try tournamentStore.matches.addOrUpdate(instance: match) + } catch { + Logger.error(error) + } + } else { + match.teamWillBeWalkOut(team) + do { + try tournamentStore.matches.addOrUpdate(instance: match) + } catch { + Logger.error(error) + } + } + } label: { + Label("retirer", systemImage: "xmark") + } + } } //#Preview { diff --git a/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift b/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift index 33d274c..6d0fcbd 100644 --- a/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift +++ b/PadelClub/Views/Navigation/Toolbox/ToolboxView.swift @@ -151,6 +151,9 @@ struct ToolboxView: View { } } } + } + + Section { NavigationLink { SelectablePlayerListView() } label: { diff --git a/PadelClub/Views/Tournament/Screen/AddTeamView.swift b/PadelClub/Views/Tournament/Screen/AddTeamView.swift index 587848c..a7b2dfb 100644 --- a/PadelClub/Views/Tournament/Screen/AddTeamView.swift +++ b/PadelClub/Views/Tournament/Screen/AddTeamView.swift @@ -210,7 +210,7 @@ struct AddTeamView: View { if nameComponents.count > 1 { orPredicates = nameComponents.pairs().map { - return NSPredicate(format: "(firstName contains[cd] %@ AND lastName contains[cd] %@) OR (firstName contains[cd] %@ AND lastName contains[cd] %@)", $0, $1, $1, $0) } + return NSPredicate(format: "(firstName BEGINSWITH[cd] %@ AND lastName BEGINSWITH[cd] %@) OR (firstName BEGINSWITH[cd] %@ AND lastName BEGINSWITH[cd] %@)", $0, $1, $1, $0) } } else { orPredicates = nameComponents.map { NSPredicate(format: "firstName contains[cd] %@ OR lastName contains[cd] %@", $0,$0) } } diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index 3b4824f..fd0852d 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -691,14 +691,22 @@ struct InscriptionManagerView: View { Button { presentAddTeamView = true } label: { - Image(systemName: "plus.circle.fill") - .resizable() - .scaledToFit() - .frame(maxWidth: .infinity) + VStack(alignment: .center, spacing: -2) { + Text(" ").font(.caption).padding(.horizontal, -8) + Text(" ").font(.largeTitle) + } + .frame(maxWidth: .infinity) + .contentShape(Rectangle()) + .hidden() + .overlay { + Image(systemName: "plus.circle.fill") + .resizable() + .scaledToFit() + .padding(8) + } } - .labelStyle(.iconOnly) - .buttonStyle(.borderless) - .padding(10) + .buttonBorderShape(.roundedRectangle) + .buttonStyle(.borderedProminent) } .padding(.bottom, -4) .fixedSize(horizontal: false, vertical: false) diff --git a/PadelClub/Views/User/AccountView.swift b/PadelClub/Views/User/AccountView.swift index 6fc5ccc..75d4627 100644 --- a/PadelClub/Views/User/AccountView.swift +++ b/PadelClub/Views/User/AccountView.swift @@ -18,7 +18,7 @@ struct AccountView: View { NavigationLink("Changer de mot de passe") { ChangePasswordView() } - Button("Déconnexion") { + RowButtonView("Déconnexion", role: .destructive) { DataStore.shared.disconnect() handler() } diff --git a/PadelClub/Views/User/LoginView.swift b/PadelClub/Views/User/LoginView.swift index cddc732..31e99e0 100644 --- a/PadelClub/Views/User/LoginView.swift +++ b/PadelClub/Views/User/LoginView.swift @@ -137,11 +137,9 @@ struct LoginView: View { if !self.showEmailValidationMessage { Section { - Button(action: { + RowButtonView("Créer un compte") { self.showUserCreationForm = true - }, label: { - Text("Créer un compte") - }) + } .sheet(isPresented: self.$showUserCreationForm, onDismiss: { if let credentials { self.username = credentials.username @@ -150,16 +148,16 @@ struct LoginView: View { }) { UserCreationFormView(isPresented: self.$showUserCreationForm, credentials: self.$credentials) } - + } + + Section { // NavigationLink("Créer un compte") { // UserCreationView() // } - Button(action: { + RowButtonView("Mot passe oublié") { self.showEmailPopup = true - }, label: { - Text("Mot passe oublié") - }) + } .alert( Text("Changer de mot de passe") ,