online_reg^2
Raz 12 months ago
parent 7a4628208c
commit acacfe1de2
  1. 4
      PadelClub.xcodeproj/project.pbxproj
  2. 12
      PadelClub/Data/AppSettings.swift
  3. 3
      PadelClub/ViewModel/SearchViewModel.swift
  4. 2
      PadelClub/Views/Navigation/Toolbox/ToolboxView.swift
  5. 36
      PadelClub/Views/Shared/SelectablePlayerListView.swift

@ -3262,7 +3262,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
@ -3307,7 +3307,7 @@
CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements;
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 3;
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\"";
DEVELOPMENT_TEAM = BQ3Y44M3Q6; DEVELOPMENT_TEAM = BQ3Y44M3Q6;

@ -29,6 +29,18 @@ final class AppSettings: MicroStorable {
var nationalCup: Bool var nationalCup: Bool
var dayDuration: Int? var dayDuration: Int?
var dayPeriod: DayPeriod var dayPeriod: DayPeriod
func lastDataSourceDate() -> Date? {
guard let lastDataSource else { return nil }
return URL.importDateFormatter.date(from: lastDataSource)
}
func localizedLastDataSource() -> String? {
guard let lastDataSource else { return nil }
guard let date = URL.importDateFormatter.date(from: lastDataSource) else { return nil }
return date.monthYearFormatted
}
func resetSearch() { func resetSearch() {
tournamentAges = Set() tournamentAges = Set()

@ -36,8 +36,7 @@ class SearchViewModel: ObservableObject, Identifiable {
@Published var filterSelectionEnabled: Bool = false @Published var filterSelectionEnabled: Bool = false
@Published var isPresented: Bool = false @Published var isPresented: Bool = false
@Published var selectedAgeCategory: FederalTournamentAge = .unlisted @Published var selectedAgeCategory: FederalTournamentAge = .unlisted
@Published var mostRecentDate: Date? = nil
var mostRecentDate: Date? = nil
var selectionIsOver: Bool { var selectionIsOver: Bool {
if allowSingleSelection && selectedPlayers.count == 1 { if allowSingleSelection && selectedPlayers.count == 1 {

@ -129,7 +129,7 @@ struct ToolboxView: View {
Section { Section {
NavigationLink { NavigationLink {
SelectablePlayerListView(isPresented: false) SelectablePlayerListView(isPresented: false, lastDataSource: true)
} label: { } label: {
Label("Rechercher un joueur", systemImage: "person.fill.viewfinder") Label("Rechercher un joueur", systemImage: "person.fill.viewfinder")
} }

@ -24,23 +24,19 @@ struct SelectablePlayerListView: View {
@StateObject private var searchViewModel: SearchViewModel @StateObject private var searchViewModel: SearchViewModel
@Environment(\.dismiss) var dismiss @Environment(\.dismiss) var dismiss
var lastDataSource: String? {
dataStore.appSettings.lastDataSource
}
@State private var searchText: String = "" @State private var searchText: String = ""
var mostRecentDate: Date? {
guard let lastDataSource else { return nil } init(allowSelection: Int = 0, isPresented: Bool = true, searchField: String? = nil, dataSet: DataSet = .national, filterOption: PlayerFilterOption = .all, hideAssimilation: Bool = false, ascending: Bool = true, sortOption: SortOption = .rank, fromPlayer: FederalPlayer? = nil, codeClub: String? = nil, ligue: String? = nil, showFemaleInMaleAssimilation: Bool = false, tokens: [SearchToken] = [], hidePlayers: [String]? = nil, lastDataSource: Bool = false, playerSelectionAction: PlayerSelectionAction? = nil, contentUnavailableAction: ContentUnavailableAction? = nil) {
return URL.importDateFormatter.date(from: lastDataSource)
}
init(allowSelection: Int = 0, isPresented: Bool = true, searchField: String? = nil, dataSet: DataSet = .national, filterOption: PlayerFilterOption = .all, hideAssimilation: Bool = false, ascending: Bool = true, sortOption: SortOption = .rank, fromPlayer: FederalPlayer? = nil, codeClub: String? = nil, ligue: String? = nil, showFemaleInMaleAssimilation: Bool = false, tokens: [SearchToken] = [], hidePlayers: [String]? = nil, playerSelectionAction: PlayerSelectionAction? = nil, contentUnavailableAction: ContentUnavailableAction? = nil) {
self.allowSelection = allowSelection self.allowSelection = allowSelection
self.playerSelectionAction = playerSelectionAction self.playerSelectionAction = playerSelectionAction
self.contentUnavailableAction = contentUnavailableAction self.contentUnavailableAction = contentUnavailableAction
self.searchText = searchField ?? "" self.searchText = searchField ?? ""
let searchViewModel = SearchViewModel() let searchViewModel = SearchViewModel()
searchViewModel.tokens = tokens searchViewModel.tokens = tokens
if lastDataSource {
searchViewModel.mostRecentDate = DataStore.shared.appSettings.lastDataSourceDate()
}
searchViewModel.searchText = searchField ?? "" searchViewModel.searchText = searchField ?? ""
searchViewModel.debouncableText = searchField ?? "" searchViewModel.debouncableText = searchField ?? ""
searchViewModel.showFemaleInMaleAssimilation = showFemaleInMaleAssimilation searchViewModel.showFemaleInMaleAssimilation = showFemaleInMaleAssimilation
@ -59,6 +55,18 @@ struct SelectablePlayerListView: View {
_searchViewModel = StateObject(wrappedValue: searchViewModel) _searchViewModel = StateObject(wrappedValue: searchViewModel)
} }
var enableSourceCheck: Binding<Bool> {
Binding {
searchViewModel.mostRecentDate != nil
} set: { value in
if value == false {
searchViewModel.mostRecentDate = nil
} else {
searchViewModel.mostRecentDate = dataStore.appSettings.lastDataSourceDate()
}
}
}
var body: some View { var body: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
if importObserver.isImportingFile() == false { if importObserver.isImportingFile() == false {
@ -73,6 +81,13 @@ struct SelectablePlayerListView: View {
} }
.pickerStyle(.segmented) .pickerStyle(.segmented)
Menu { Menu {
if let lastDataSource = dataStore.appSettings.localizedLastDataSource() {
Section {
Toggle(isOn: enableSourceCheck) {
Text("Limité à \(lastDataSource)")
}
}
}
Section { Section {
ForEach(SourceFileManager.getSortOption()) { option in ForEach(SourceFileManager.getSortOption()) { option in
Toggle(isOn: .init(get: { Toggle(isOn: .init(get: {
@ -191,7 +206,6 @@ struct SelectablePlayerListView: View {
} }
} }
.onAppear { .onAppear {
searchViewModel.mostRecentDate = mostRecentDate
if searchViewModel.tokens.isEmpty && searchText.isEmpty { if searchViewModel.tokens.isEmpty && searchText.isEmpty {
searchViewModel.debouncableText.removeAll() searchViewModel.debouncableText.removeAll()
searchViewModel.searchText.removeAll() searchViewModel.searchText.removeAll()

Loading…
Cancel
Save