fix graphics
club_update
Razmig Sarkissian 1 year ago
parent ccb47ff26c
commit d9fd10a317
  1. 2
      PadelClub/Data/TeamRegistration.swift
  2. 4
      PadelClub/Data/Tournament.swift
  3. 2
      PadelClub/Utils/PadelRule.swift
  4. 4
      PadelClub/ViewModel/SearchViewModel.swift
  5. 81
      PadelClub/Views/Match/MatchSetupView.swift
  6. 3
      PadelClub/Views/Navigation/Toolbox/ToolboxView.swift
  7. 2
      PadelClub/Views/Tournament/Screen/AddTeamView.swift
  8. 16
      PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift
  9. 2
      PadelClub/Views/User/AccountView.swift
  10. 14
      PadelClub/Views/User/LoginView.swift

@ -287,7 +287,7 @@ final class TeamRegistration: ModelObject, Storable {
func initialRoundColor() -> Color? { func initialRoundColor() -> Color? {
if walkOut { return Color.logoRed } 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] { if let initialRound = initialRound(), let colorHex = RoundRule.colors[safe: initialRound.index] {
return Color(uiColor: .init(fromHex: colorHex)) return Color(uiColor: .init(fromHex: colorHex))
} else { } else {

@ -923,9 +923,9 @@ defer {
let _teamCount = teamCount ?? selectedSortedTeams().count let _teamCount = teamCount ?? selectedSortedTeams().count
let bracketCut = bracketCut(teamCount: _teamCount) let bracketCut = bracketCut(teamCount: _teamCount)
if index < bracketCut { if index < bracketCut {
return Color.cyan return Color.mint
} else if index - bracketCut < groupStageCut() && _teamCount > 0 { } else if index - bracketCut < groupStageCut() && _teamCount > 0 {
return Color.indigo return Color.cyan
} else { } else {
return Color.gray return Color.gray
} }

@ -1453,7 +1453,7 @@ enum PlayersCountRange: Int, CaseIterable {
} }
enum RoundRule { 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] { static func loserBrackets(index: Int) -> [String] {
switch index { switch index {

@ -156,9 +156,9 @@ class SearchViewModel: ObservableObject, Identifiable {
if let wordsPredicates { if let wordsPredicates {
predicates.append(wordsPredicates) predicates.append(wordsPredicates)
} else { } 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: case .ligue:
if canonicalVersionWithoutPunctuation.isEmpty { if canonicalVersionWithoutPunctuation.isEmpty {

@ -38,46 +38,15 @@ struct MatchSetupView: View {
if let teamScore, teamScore.luckyLoser != nil { if let teamScore, teamScore.luckyLoser != nil {
Text("Repêchée").italic().font(.caption) Text("Repêchée").italic().font(.caption)
} }
Menu {
_removeTeam(team: team, teamPosition: teamPosition)
} label: {
TeamRowView(team: team, teamPosition: teamPosition) TeamRowView(team: team, teamPosition: teamPosition)
.swipeActions(edge: .trailing, allowsFullSwipe: false) { .swipeActions(edge: .trailing, allowsFullSwipe: false) {
Button(role: .cancel) { _removeTeam(team: team, teamPosition: teamPosition)
//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")
} }
} }
.buttonStyle(.plain)
} }
} else { } else {
VStack(alignment: .leading) { 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 { //#Preview {

@ -151,6 +151,9 @@ struct ToolboxView: View {
} }
} }
} }
}
Section {
NavigationLink { NavigationLink {
SelectablePlayerListView() SelectablePlayerListView()
} label: { } label: {

@ -210,7 +210,7 @@ struct AddTeamView: View {
if nameComponents.count > 1 { if nameComponents.count > 1 {
orPredicates = nameComponents.pairs().map { 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 { } else {
orPredicates = nameComponents.map { NSPredicate(format: "firstName contains[cd] %@ OR lastName contains[cd] %@", $0,$0) } orPredicates = nameComponents.map { NSPredicate(format: "firstName contains[cd] %@ OR lastName contains[cd] %@", $0,$0) }
} }

@ -691,14 +691,22 @@ struct InscriptionManagerView: View {
Button { Button {
presentAddTeamView = true presentAddTeamView = true
} label: { } label: {
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") Image(systemName: "plus.circle.fill")
.resizable() .resizable()
.scaledToFit() .scaledToFit()
.frame(maxWidth: .infinity) .padding(8)
}
} }
.labelStyle(.iconOnly) .buttonBorderShape(.roundedRectangle)
.buttonStyle(.borderless) .buttonStyle(.borderedProminent)
.padding(10)
} }
.padding(.bottom, -4) .padding(.bottom, -4)
.fixedSize(horizontal: false, vertical: false) .fixedSize(horizontal: false, vertical: false)

@ -18,7 +18,7 @@ struct AccountView: View {
NavigationLink("Changer de mot de passe") { NavigationLink("Changer de mot de passe") {
ChangePasswordView() ChangePasswordView()
} }
Button("Déconnexion") { RowButtonView("Déconnexion", role: .destructive) {
DataStore.shared.disconnect() DataStore.shared.disconnect()
handler() handler()
} }

@ -137,11 +137,9 @@ struct LoginView: View {
if !self.showEmailValidationMessage { if !self.showEmailValidationMessage {
Section { Section {
Button(action: { RowButtonView("Créer un compte") {
self.showUserCreationForm = true self.showUserCreationForm = true
}, label: { }
Text("Créer un compte")
})
.sheet(isPresented: self.$showUserCreationForm, onDismiss: { .sheet(isPresented: self.$showUserCreationForm, onDismiss: {
if let credentials { if let credentials {
self.username = credentials.username self.username = credentials.username
@ -150,16 +148,16 @@ struct LoginView: View {
}) { }) {
UserCreationFormView(isPresented: self.$showUserCreationForm, credentials: self.$credentials) UserCreationFormView(isPresented: self.$showUserCreationForm, credentials: self.$credentials)
} }
}
Section {
// NavigationLink("Créer un compte") { // NavigationLink("Créer un compte") {
// UserCreationView() // UserCreationView()
// } // }
Button(action: { RowButtonView("Mot passe oublié") {
self.showEmailPopup = true self.showEmailPopup = true
}, label: { }
Text("Mot passe oublié")
})
.alert( .alert(
Text("Changer de mot de passe") Text("Changer de mot de passe")
, ,

Loading…
Cancel
Save