mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix heading display
This commit is contained in:
parent
2d39bdc16b
commit
28e2c78c81
@ -119,6 +119,19 @@ public final class DeviceLocationManager: NSObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension CLHeading {
|
||||||
|
var effectiveHeading: Double? {
|
||||||
|
if self.headingAccuracy < 0.0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if self.trueHeading > 0.0 {
|
||||||
|
return self.trueHeading
|
||||||
|
} else {
|
||||||
|
return self.magneticHeading
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension DeviceLocationManager: CLLocationManagerDelegate {
|
extension DeviceLocationManager: CLLocationManagerDelegate {
|
||||||
public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
||||||
assert(self.queue.isCurrent())
|
assert(self.queue.isCurrent())
|
||||||
@ -127,7 +140,7 @@ extension DeviceLocationManager: CLLocationManagerDelegate {
|
|||||||
if self.currentTopMode != nil {
|
if self.currentTopMode != nil {
|
||||||
self.currentLocation = location
|
self.currentLocation = location
|
||||||
for subscriber in self.subscribers {
|
for subscriber in self.subscribers {
|
||||||
subscriber.update(location, self.currentHeading?.magneticHeading)
|
subscriber.update(location, self.currentHeading?.effectiveHeading)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +153,7 @@ extension DeviceLocationManager: CLLocationManagerDelegate {
|
|||||||
self.currentHeading = newHeading
|
self.currentHeading = newHeading
|
||||||
if let currentLocation = self.currentLocation {
|
if let currentLocation = self.currentLocation {
|
||||||
for subscriber in self.subscribers {
|
for subscriber in self.subscribers {
|
||||||
subscriber.update(currentLocation, newHeading.magneticHeading)
|
subscriber.update(currentLocation, newHeading.effectiveHeading)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,14 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||||||
}
|
}
|
||||||
|
|
||||||
func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
|
func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
|
||||||
self.headerNode.mapNode.userHeading = CGFloat(newHeading.magneticHeading)
|
if newHeading.headingAccuracy < 0.0 {
|
||||||
|
self.headerNode.mapNode.userHeading = nil
|
||||||
|
}
|
||||||
|
if newHeading.trueHeading > 0.0 {
|
||||||
|
self.headerNode.mapNode.userHeading = CGFloat(newHeading.trueHeading)
|
||||||
|
} else {
|
||||||
|
self.headerNode.mapNode.userHeading = CGFloat(newHeading.magneticHeading)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updatePresentationData(_ presentationData: PresentationData) {
|
func updatePresentationData(_ presentationData: PresentationData) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user