Fix location view

This commit is contained in:
Ilya Laktyushin 2020-10-29 17:23:10 +04:00
parent d0b51d5a16
commit d164128145
3 changed files with 8 additions and 3 deletions

View File

@ -52,6 +52,7 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
}
}
var isSelf = false
var selfPeer: Peer?
var title: String? = ""
var subtitle: String? = ""
@ -78,11 +79,12 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
super.init()
}
init(context: AccountContext, theme: PresentationTheme, message: Message, selfPeer: Peer?, heading: Int32?) {
init(context: AccountContext, theme: PresentationTheme, message: Message, selfPeer: Peer?, isSelf: Bool, heading: Int32?) {
self.context = context
self.theme = theme
self.location = nil
self.peer = nil
self.isSelf = isSelf
self.message = message
if let location = getLocation(from: message) {
self.coordinate = location.coordinate

View File

@ -481,6 +481,9 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
var distances: [Double] = []
if let userLocation = userLocation {
for annotation in annotations {
if annotation.isSelf {
continue
}
distances.append(userLocation.distance(from: CLLocation(latitude: annotation.coordinate.latitude, longitude: annotation.coordinate.longitude)))
}
}

View File

@ -413,9 +413,9 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
let distance = userLocation.flatMap { subjectLocation.distance(from: $0) }
if message.localTags.contains(.OutgoingLiveLocation), let selfPeer = selfPeer {
userAnnotation = LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, heading: location.heading)
userAnnotation = LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, isSelf: true, heading: location.heading)
} else {
annotations.append(LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, heading: location.heading))
annotations.append(LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, isSelf: message.author?.id == context.account.peerId, heading: location.heading))
entries.append(.liveLocation(presentationData.theme, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, message, distance, index))
}
index += 1