feat: Added details of the type of bike available

Added details of the type of bike available; fixed a bug where the application would not load the bikes; added a shortcut to the settings app in the event of location refusal.
This commit is contained in:
2023-09-02 22:23:24 +02:00
parent 795510a061
commit 80fdaaad35
16 changed files with 51 additions and 21 deletions

View File

@ -12,17 +12,12 @@ struct ContentView: View {
@State private var isLocationAuthorized = false
var body: some View {
VStack {
var latitude = locationManager.userLocation?.latitude
var longitude = locationManager.userLocation?.longitude
if locationManager.isLocationAuthorized {
// Afficher le contenu de l'application une fois que la localisation est autorisée
Text("Latitude: \(locationManager.userLocation?.latitude ?? 0), Longitude: \(locationManager.userLocation?.longitude ?? 0)")
} else {
// Afficher un message ou un bouton pour demander l'autorisation de localisation
Button("Autoriser la localisation") {
locationManager.onLocationUpdate = {
// Appel à la requête API lorsque la localisation est autorisée
}
openAppSettings()
}
}
}
@ -35,6 +30,7 @@ struct ContentView: View {
}
NavigationView {
ScrollView {
Text("Stations dans un rayon de 5km")
ForEach(velibStations, id: \.stationcode) { station in
StationComponent(station: station)
.padding(.bottom, 16)
@ -47,6 +43,16 @@ struct ContentView: View {
}
private func openAppSettings() {
guard let settingsURL = URL(string: UIApplication.openSettingsURLString) else {
return
}
if UIApplication.shared.canOpenURL(settingsURL) {
UIApplication.shared.open(settingsURL)
}
}
struct ContentView_Previews: PreviewProvider {