mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix location view
This commit is contained in:
parent
d0b51d5a16
commit
d164128145
@ -52,6 +52,7 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isSelf = false
|
||||||
var selfPeer: Peer?
|
var selfPeer: Peer?
|
||||||
var title: String? = ""
|
var title: String? = ""
|
||||||
var subtitle: String? = ""
|
var subtitle: String? = ""
|
||||||
@ -78,11 +79,12 @@ class LocationPinAnnotation: NSObject, MKAnnotation {
|
|||||||
super.init()
|
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.context = context
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
self.location = nil
|
self.location = nil
|
||||||
self.peer = nil
|
self.peer = nil
|
||||||
|
self.isSelf = isSelf
|
||||||
self.message = message
|
self.message = message
|
||||||
if let location = getLocation(from: message) {
|
if let location = getLocation(from: message) {
|
||||||
self.coordinate = location.coordinate
|
self.coordinate = location.coordinate
|
||||||
|
@ -481,6 +481,9 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
|
|||||||
var distances: [Double] = []
|
var distances: [Double] = []
|
||||||
if let userLocation = userLocation {
|
if let userLocation = userLocation {
|
||||||
for annotation in annotations {
|
for annotation in annotations {
|
||||||
|
if annotation.isSelf {
|
||||||
|
continue
|
||||||
|
}
|
||||||
distances.append(userLocation.distance(from: CLLocation(latitude: annotation.coordinate.latitude, longitude: annotation.coordinate.longitude)))
|
distances.append(userLocation.distance(from: CLLocation(latitude: annotation.coordinate.latitude, longitude: annotation.coordinate.longitude)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,9 +413,9 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||||||
let distance = userLocation.flatMap { subjectLocation.distance(from: $0) }
|
let distance = userLocation.flatMap { subjectLocation.distance(from: $0) }
|
||||||
|
|
||||||
if message.localTags.contains(.OutgoingLiveLocation), let selfPeer = selfPeer {
|
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 {
|
} 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))
|
entries.append(.liveLocation(presentationData.theme, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, message, distance, index))
|
||||||
}
|
}
|
||||||
index += 1
|
index += 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user