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? {
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 {

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

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

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

@ -38,46 +38,15 @@ struct MatchSetupView: View {
if let teamScore, teamScore.luckyLoser != nil {
Text("Repêchée").italic().font(.caption)
}
Menu {
_removeTeam(team: team, teamPosition: teamPosition)
} label: {
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")
_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 {

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

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

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

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

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

Loading…
Cancel
Save