diff --git a/PadelClub.xcodeproj/project.pbxproj b/PadelClub.xcodeproj/project.pbxproj index e6f594f..92eb9b4 100644 --- a/PadelClub.xcodeproj/project.pbxproj +++ b/PadelClub.xcodeproj/project.pbxproj @@ -3302,7 +3302,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 1; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; @@ -3329,7 +3329,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.6; + MARKETING_VERSION = 1.1.7; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -3350,7 +3350,7 @@ CODE_SIGN_ENTITLEMENTS = PadelClub/PadelClub.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DEVELOPMENT_ASSET_PATHS = "\"PadelClub/Preview Content\""; DEVELOPMENT_TEAM = BQ3Y44M3Q6; @@ -3376,7 +3376,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.1.6; + MARKETING_VERSION = 1.1.7; PRODUCT_BUNDLE_IDENTIFIER = app.padelclub; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/PadelClub/Utils/LocationManager.swift b/PadelClub/Utils/LocationManager.swift index 0af0e36..afd5e3f 100644 --- a/PadelClub/Utils/LocationManager.swift +++ b/PadelClub/Utils/LocationManager.swift @@ -37,6 +37,8 @@ class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate { func requestLocation() { lastError = nil manager.requestLocation() + city = nil + location = nil requestStarted = true } diff --git a/PadelClub/ViewModel/SearchViewModel.swift b/PadelClub/ViewModel/SearchViewModel.swift index be8a85c..cc16ead 100644 --- a/PadelClub/ViewModel/SearchViewModel.swift +++ b/PadelClub/ViewModel/SearchViewModel.swift @@ -319,10 +319,10 @@ class SearchViewModel: ObservableObject, Identifiable { // Remove all characters that are not in the allowedCharacterSet var text = pasteField.canonicalVersion.components(separatedBy: allowedCharacterSet.inverted).joined().trimmedMultiline // Define the regex pattern to match digits - let digitPattern = /\d+/ + let digitPattern = /\b\w*\d\w*\b/ // Replace all occurrences of the pattern (digits) with an empty string - text = text.replacing(digitPattern, with: "") + text = text.replacing(digitPattern, with: "").trimmingCharacters(in: .whitespacesAndNewlines) let textStrings: [String] = text.components(separatedBy: .whitespacesAndNewlines) let nonEmptyStrings: [String] = textStrings.compactMap { $0.isEmpty ? nil : $0 } @@ -367,6 +367,7 @@ class SearchViewModel: ObservableObject, Identifiable { } + print(predicate) return predicate } diff --git a/PadelClub/Views/Components/RowButtonView.swift b/PadelClub/Views/Components/RowButtonView.swift index 1a38101..0dce2d5 100644 --- a/PadelClub/Views/Components/RowButtonView.swift +++ b/PadelClub/Views/Components/RowButtonView.swift @@ -15,28 +15,31 @@ struct RowButtonView: View { var systemImage: String? = nil var image: String? = nil let confirmationMessage: String + let cornerRadius: CGFloat var action: (() -> ())? = nil var asyncAction: (() async -> ())? = nil @State private var askConfirmation: Bool = false @State private var isLoading = false - init(_ title: String, role: ButtonRole? = nil, systemImage: String? = nil, image: String? = nil, confirmationMessage: String? = nil, action: @escaping (() -> ())) { + init(_ title: String, role: ButtonRole? = nil, systemImage: String? = nil, image: String? = nil, cornerRadius: CGFloat = 8, confirmationMessage: String? = nil, action: @escaping (() -> ())) { self.role = role self.title = title self.systemImage = systemImage self.image = image self.confirmationMessage = confirmationMessage ?? defaultConfirmationMessage self.action = action + self.cornerRadius = cornerRadius } - init(_ title: String, role: ButtonRole? = nil, systemImage: String? = nil, image: String? = nil, confirmationMessage: String? = nil, asyncAction: @escaping (() async -> ())) { + init(_ title: String, role: ButtonRole? = nil, systemImage: String? = nil, image: String? = nil, cornerRadius: CGFloat = 8, confirmationMessage: String? = nil, asyncAction: @escaping (() async -> ())) { self.role = role self.title = title self.systemImage = systemImage self.image = image self.confirmationMessage = confirmationMessage ?? defaultConfirmationMessage self.asyncAction = asyncAction + self.cornerRadius = cornerRadius } var body: some View { @@ -79,7 +82,7 @@ struct RowButtonView: View { if isLoading { ZStack { Color.master - .cornerRadius(20) + .cornerRadius(cornerRadius) ProgressView() .tint(.white) } diff --git a/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift b/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift index f7228f6..8ebd7ee 100644 --- a/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift +++ b/PadelClub/Views/Navigation/Agenda/TournamentLookUpView.swift @@ -14,6 +14,7 @@ struct TournamentLookUpView: View { @Environment(FederalDataViewModel.self) var federalDataViewModel: FederalDataViewModel @StateObject var locationManager = LocationManager() @Environment(\.dismiss) private var dismiss + @FocusState private var isFocused: Bool @State private var searchField: String = "" @State var page: Int = 0 @@ -24,6 +25,7 @@ struct TournamentLookUpView: View { @State private var revealSearchParameters: Bool = true @State private var presentAlert: Bool = false @State private var confirmSearch: Bool = false + @State private var locationRequested = false var tournaments: [FederalTournament] { federalDataViewModel.searchedFederalTournaments @@ -96,8 +98,9 @@ struct TournamentLookUpView: View { .navigationTitle("Chercher un tournoi") .navigationBarTitleDisplayMode(.inline) .onChange(of: locationManager.city) { - if let newValue = locationManager.city, dataStore.appSettings.city.isEmpty { + if locationRequested, let newValue = locationManager.city { dataStore.appSettings.city = newValue + locationRequested = false } } .toolbarTitleDisplayMode(.large) @@ -309,19 +312,32 @@ struct TournamentLookUpView: View { HStack { TextField("Ville", text: $appSettings.city) - if let city = locationManager.city { - Divider() - Text(city).italic() - } + .onSubmit(of: .text) { + locationManager.city = nil + locationManager.location = nil + } + .focused($isFocused) + .onChange(of: isFocused) { + if isFocused { + appSettings.city = "" + } + } + +// if let city = locationManager.city { +// Divider() +// Text(city).italic() +// } if locationManager.requestStarted { ProgressView() } else if locationManager.manager.authorizationStatus != .restricted { LocationButton { if locationManager.manager.authorizationStatus == .notDetermined { + locationRequested = true locationManager.manager.requestWhenInUseAuthorization() } else if locationManager.manager.authorizationStatus == .denied { showingSettingsAlert = true } else { + locationRequested = true locationManager.requestLocation() } } diff --git a/PadelClub/Views/Tournament/Screen/AddTeamView.swift b/PadelClub/Views/Tournament/Screen/AddTeamView.swift index 4850645..7fd4bf8 100644 --- a/PadelClub/Views/Tournament/Screen/AddTeamView.swift +++ b/PadelClub/Views/Tournament/Screen/AddTeamView.swift @@ -16,7 +16,7 @@ struct AddTeamView: View { private var fetchRequest: FetchRequest private var fetchPlayers: FetchedResults { fetchRequest.wrappedValue } - var tournament: Tournament + let tournament: Tournament var cancelShouldDismiss: Bool = false enum FocusField: Hashable { case pasteField diff --git a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift index 78f3d59..e95fade 100644 --- a/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift +++ b/PadelClub/Views/Tournament/Screen/InscriptionManagerView.swift @@ -247,7 +247,7 @@ struct InscriptionManagerView: View { } if tournament.enableOnlineRegistration { - RowButtonView("RafraƮchir la liste") { + RowButtonView("RafraƮchir la liste", cornerRadius: 20) { await _refreshList() } } else if tournament.onlineRegistrationCanBeEnabled() {