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

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 820 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -1,56 +1,67 @@
{
"images" : [
{
"filename" : "1024.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
},
{
"filename" : "16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "32.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "32 1.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "64.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "256.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "256 1.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "512.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "512 1.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "1024 1.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"

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 {

View File

@ -25,10 +25,19 @@ struct StationComponent: View {
.foregroundColor(.secondary)
Spacer()
Text("Disponibles: \(station.numbikesavailable)")
.font(.subheadline)
.foregroundColor(.secondary)
VStack {
Text("Disponibles: \(station.numbikesavailable)")
.font(.subheadline)
.foregroundColor(.secondary)
Text("Electriques: \(station.ebike)")
.font(.subheadline)
.foregroundColor(.blue)
Text("Mécaniques: \(station.mechanical)")
.font(.subheadline)
.foregroundColor(.green)
}
}
}
.padding()

View File

@ -7,14 +7,16 @@
import SwiftUI
@main
struct velibtrackerApp: App {
@ObservedObject var locationManager = LocationManager()
var body: some Scene {
WindowGroup {
ContentView()
}
}
// init() {
// fetchVelibData()
// }
init() {
fetchVelibDataLocation(lon: Double(locationManager.userLocation?.longitude ?? 0), lat: Double(locationManager.userLocation?.latitude ?? 0))
}
}