|
|
|
|
@ -23,15 +23,44 @@ struct TournamentLookUpView: View { |
|
|
|
|
@State private var requestedToGetAllPages: Bool = false |
|
|
|
|
@State private var revealSearchParameters: Bool = true |
|
|
|
|
@State private var presentAlert: Bool = false |
|
|
|
|
@State private var confirmSearch: Bool = false |
|
|
|
|
|
|
|
|
|
var tournaments: [FederalTournament] { |
|
|
|
|
federalDataViewModel.searchedFederalTournaments |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var showLastError: Binding<Bool> { |
|
|
|
|
Binding { |
|
|
|
|
locationManager.lastError != nil |
|
|
|
|
} set: { value in |
|
|
|
|
if value == false { |
|
|
|
|
locationManager.lastError = nil |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var body: some View { |
|
|
|
|
List { |
|
|
|
|
searchParametersView |
|
|
|
|
} |
|
|
|
|
.alert(isPresented: showLastError, error: locationManager.lastError as? LocationManager.LocationError, actions: { |
|
|
|
|
Button("Annuler", role: .cancel) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.confirmationDialog("Attention", isPresented: $confirmSearch, titleVisibility: .visible) { |
|
|
|
|
Button("Cherchez quand même") { |
|
|
|
|
requestedToGetAllPages = true |
|
|
|
|
runSearch() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Button("Annuler", role: .cancel) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} message: { |
|
|
|
|
Text("Aucune ville n'a été indiqué, il est préférable de se localiser ou d'indiquer une ville pour réduire le nombre de résultat.") |
|
|
|
|
} |
|
|
|
|
.alert("Attention", isPresented: $presentAlert, actions: { |
|
|
|
|
Button { |
|
|
|
|
presentAlert = false |
|
|
|
|
@ -70,7 +99,11 @@ struct TournamentLookUpView: View { |
|
|
|
|
ToolbarItem(placement: .bottomBar) { |
|
|
|
|
if revealSearchParameters { |
|
|
|
|
FooterButtonView("Lancer la recherche") { |
|
|
|
|
runSearch() |
|
|
|
|
if dataStore.appSettings.city.isEmpty { |
|
|
|
|
confirmSearch = true |
|
|
|
|
} else { |
|
|
|
|
runSearch() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.disabled(searching) |
|
|
|
|
} else if searching { |
|
|
|
|
@ -230,31 +263,6 @@ struct TournamentLookUpView: View { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
var searchContollerView: some View { |
|
|
|
|
Section { |
|
|
|
|
Button { |
|
|
|
|
runSearch() |
|
|
|
|
} label: { |
|
|
|
|
HStack { |
|
|
|
|
Label("Chercher un tournoi", systemImage: "magnifyingglass") |
|
|
|
|
if searching { |
|
|
|
|
Spacer() |
|
|
|
|
ProgressView() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Button { |
|
|
|
|
dataStore.appSettings.resetSearch() |
|
|
|
|
locationManager.location = nil |
|
|
|
|
locationManager.city = nil |
|
|
|
|
revealSearchParameters = true |
|
|
|
|
} label: { |
|
|
|
|
Label("Ré-initialiser la recherche", systemImage: "xmark.circle") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ViewBuilder |
|
|
|
|
var searchParametersView: some View { |
|
|
|
|
@Bindable var appSettings = dataStore.appSettings |
|
|
|
|
|