Login flow fixed

This commit is contained in:
Daniel Arantes Loverde
2026-02-05 16:57:27 -03:00
parent 01c1da0430
commit 51d02f6715
12 changed files with 859 additions and 108 deletions

View File

@@ -0,0 +1,46 @@
import Foundation
#if os(iOS)
import CoreLocation
#endif
final class LocationService: NSObject {
#if os(iOS)
private let manager = CLLocationManager()
private var completion: ((Double, Double) -> Void)?
#endif
override init() {
super.init()
#if os(iOS)
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyHundredMeters
#endif
}
func requestLocation(_ completion: @escaping (Double, Double) -> Void) {
#if os(iOS)
self.completion = completion
manager.requestWhenInUseAuthorization()
manager.requestLocation()
#else
// Android: implement later with platform-specific bridge
_ = completion
#endif
}
}
#if os(iOS)
extension LocationService: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let location = locations.first else { return }
completion?(location.coordinate.latitude, location.coordinate.longitude)
completion = nil
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
// Silence for now; UI can handle missing location.
completion = nil
}
}
#endif