@ -10,7 +10,6 @@ import SwiftUI
class SearchViewModel : ObservableObject , Identifiable {
let id : UUID = UUID ( )
var allowSelection : Int = 0
var user : User ? = nil
var codeClub : String ? = nil
var clubName : String ? = nil
var ligueName : String ? = nil
@ -74,13 +73,13 @@ class SearchViewModel: ObservableObject, Identifiable {
func getCodeClub ( ) -> String ? {
if let codeClub { return codeClub }
// i f l e t u s e r C o d e C l u b = u s e r ? . p l a y e r ? . c o d e C l u b { r e t u r n u s e r C o d e C l u b }
if let userCodeClub = DataStore . shared . user . currentPlayerData ( ) ? . clubCode { return userCodeClub }
return nil
}
func getClub Name ( ) -> String ? {
if let clubName { return club Name }
// i f l e t u s e r C l u b N a m e = u s e r ? . p l a y e r ? . c l u b N a m e { r e t u r n u s e r C l u b N a m e }
func getLigue Name ( ) -> String ? {
if let ligueName { return ligue Name }
if let userLigueName = DataStore . shared . user . currentPlayerData ( ) ? . ligueName { return userLigueName }
return nil
}
@ -217,13 +216,13 @@ class SearchViewModel: ObservableObject, Identifiable {
case . national :
break
case . ligue :
if let ligueName {
if let ligueName = getLigueName ( ) {
predicates . append ( NSPredicate ( format : " ligueName == %@ " , ligueName ) )
} else {
predicates . append ( NSPredicate ( format : " ligueName == nil " ) )
}
case . club :
if let codeClub {
if let codeClub = getCodeClub ( ) {
predicates . append ( NSPredicate ( format : " clubCode == %@ " , codeClub ) )
} else {
predicates . append ( NSPredicate ( format : " clubCode == nil " ) )
@ -352,13 +351,15 @@ enum SearchToken: String, CaseIterable, Identifiable {
}
}
enum DataSet : Int , CaseIterable , Identifiable {
enum DataSet : Int , Identifiable {
case national
case ligue
case club
case favoriteClubs
case favoritePlayers
static let allCases : [ DataSet ] = [ . national , . ligue , . club , . favoriteClubs ]
var id : Int { rawValue }
func localizedLabel ( _ displayStyle : DisplayStyle = . wide ) -> String {
switch self {