mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Fix live location start from modal location display
This commit is contained in:
parent
2f13d11224
commit
0e3b3429dc
@ -158,6 +158,8 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
|
||||
private weak var userLocationAnnotationView: MKAnnotationView?
|
||||
private var headingArrowView: UIImageView?
|
||||
|
||||
private weak var defaultUserLocationAnnotation: MKAnnotation?
|
||||
|
||||
private let pinDisposable = MetaDisposable()
|
||||
|
||||
private var mapView: LocationMapView? {
|
||||
@ -390,6 +392,8 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
|
||||
func mapView(_ mapView: MKMapView, didAdd views: [MKAnnotationView]) {
|
||||
for view in views {
|
||||
if view.annotation is MKUserLocation {
|
||||
self.defaultUserLocationAnnotation = view.annotation
|
||||
|
||||
self.userLocationAnnotationView = view
|
||||
if let headingArrowView = self.headingArrowView {
|
||||
view.addSubview(headingArrowView)
|
||||
@ -694,15 +698,15 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate {
|
||||
guard let mapView = self.mapView else {
|
||||
return
|
||||
}
|
||||
var annotations: [MKAnnotation] = []
|
||||
if let userAnnotation = self.userLocationAnnotation {
|
||||
annotations.append(userAnnotation)
|
||||
var coordinates: [CLLocationCoordinate2D] = []
|
||||
if let location = self.currentUserLocation {
|
||||
coordinates.append(location.coordinate)
|
||||
}
|
||||
annotations.append(contentsOf: self.annotations)
|
||||
coordinates.append(contentsOf: self.annotations.map { $0.coordinate })
|
||||
|
||||
var zoomRect: MKMapRect?
|
||||
for annotation in annotations {
|
||||
let pointRegionRect = MKMapRect(region: MKCoordinateRegion(center: annotation.coordinate, latitudinalMeters: 100, longitudinalMeters: 100))
|
||||
for coordinate in coordinates {
|
||||
let pointRegionRect = MKMapRect(region: MKCoordinateRegion(center: coordinate, latitudinalMeters: 100, longitudinalMeters: 100))
|
||||
if let currentZoomRect = zoomRect {
|
||||
zoomRect = currentZoomRect.union(pointRegionRect)
|
||||
} else {
|
||||
|
@ -485,7 +485,9 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
|
||||
if !strongSelf.reportedAnnotationsReady {
|
||||
strongSelf.reportedAnnotationsReady = true
|
||||
strongSelf.onAnnotationsReady?()
|
||||
if annotations.count > 0 {
|
||||
strongSelf.onAnnotationsReady?()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,7 +498,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
||||
}
|
||||
let rightBarButtonAction: LocationViewRightBarButton
|
||||
if location.liveBroadcastingTimeout != nil {
|
||||
if liveLocations.count > 1 {
|
||||
if annotations.count > 0 {
|
||||
rightBarButtonAction = .showAll
|
||||
} else {
|
||||
rightBarButtonAction = .none
|
||||
|
@ -38,7 +38,8 @@ private func presentLiveLocationController(context: AccountContext, peerId: Peer
|
||||
}, openUrl: { _ in
|
||||
}, openPeer: { peer, navigation in
|
||||
}, callPeer: { _, _ in
|
||||
}, enqueueMessage: { _ in
|
||||
}, enqueueMessage: { message in
|
||||
let _ = enqueueMessages(account: context.account, peerId: peerId, messages: [message]).start()
|
||||
}, sendSticker: nil,
|
||||
setupTemporaryHiddenMedia: { _, _, _ in
|
||||
}, chatAvatarHiddenMedia: { _, _ in
|
||||
|
Loading…
x
Reference in New Issue
Block a user