From 5c1155d66d8f3edd836662569595d6a039a867ba Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 29 Oct 2020 15:05:24 +0400 Subject: [PATCH] Various fixes --- .../LocationUI/Sources/LocationAnnotation.swift | 2 ++ .../Sources/LocationDistancePickerScreen.swift | 4 ---- .../LocationUI/Sources/LocationMapNode.swift | 10 ++++++++-- .../Sources/LocationViewControllerNode.swift | 15 +++++++++++++++ .../Sources/ChatMessageInteractiveFileNode.swift | 2 +- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/submodules/LocationUI/Sources/LocationAnnotation.swift b/submodules/LocationUI/Sources/LocationAnnotation.swift index 5a7cffa715..794f77a612 100644 --- a/submodules/LocationUI/Sources/LocationAnnotation.swift +++ b/submodules/LocationUI/Sources/LocationAnnotation.swift @@ -311,6 +311,7 @@ class LocationPinAnnotationView: MKAnnotationView { self.smallNode.image = generateSmallBackgroundImage(color: color) self.dotNode.image = generateFilledCircleImage(diameter: 6.0, color: color) + self.iconNode.isHidden = false self.dotNode.isHidden = false if !self.isSelected { @@ -354,6 +355,7 @@ class LocationPinAnnotationView: MKAnnotationView { } override func prepareForReuse() { + self.previousPeerId = nil self.smallNode.isHidden = true self.backgroundNode.isHidden = false self.appeared = false diff --git a/submodules/LocationUI/Sources/LocationDistancePickerScreen.swift b/submodules/LocationUI/Sources/LocationDistancePickerScreen.swift index b434acacf9..da08719b2a 100644 --- a/submodules/LocationUI/Sources/LocationDistancePickerScreen.swift +++ b/submodules/LocationUI/Sources/LocationDistancePickerScreen.swift @@ -372,10 +372,6 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD let smallValue = smallUnitValues[selectedSmallRow] var value = largeValue * 1000 + smallValue * 10 - if !self.usesMetricSystem { - value = Int32(Double(value) * 1.60934) - } - var formattedValue = String(format: "%0.1f", CGFloat(value) / 1000.0) if smallValue == 5 { formattedValue = formattedValue.replacingOccurrences(of: ".1", with: ".05").replacingOccurrences(of: ",1", with: ",05") diff --git a/submodules/LocationUI/Sources/LocationMapNode.swift b/submodules/LocationUI/Sources/LocationMapNode.swift index fb5532b981..e3360c4a09 100644 --- a/submodules/LocationUI/Sources/LocationMapNode.swift +++ b/submodules/LocationUI/Sources/LocationMapNode.swift @@ -255,11 +255,16 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate { self.mapView?.showsUserLocation = true self.mapView?.showsPointsOfInterest = false self.mapView?.customHitTest = { [weak self] point in - guard let strongSelf = self, let annotationView = strongSelf.customUserLocationAnnotationView else { + guard let strongSelf = self else { return false } - if let annotationRect = annotationView.superview?.convert(annotationView.frame.insetBy(dx: -16.0, dy: -16.0), to: strongSelf.mapView), annotationRect.contains(point) { + if let annotationView = strongSelf.customUserLocationAnnotationView, let annotationRect = annotationView.superview?.convert(annotationView.frame.insetBy(dx: -16.0, dy: -16.0), to: strongSelf.mapView), annotationRect.contains(point) { + strongSelf.userLocationAnnotationSelected?() + return true + } + + if let userAnnotation = strongSelf.defaultUserLocationAnnotation, let annotationView = strongSelf.mapView?.view(for: userAnnotation), let annotationRect = annotationView.superview?.convert(annotationView.frame.insetBy(dx: -16.0, dy: -16.0), to: strongSelf.mapView), annotationRect.contains(point) { strongSelf.userLocationAnnotationSelected?() return true } @@ -393,6 +398,7 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate { for view in views { if view.annotation is MKUserLocation { self.defaultUserLocationAnnotation = view.annotation + view.canShowCallout = false self.userLocationAnnotationView = view if let headingArrowView = self.headingArrowView { diff --git a/submodules/LocationUI/Sources/LocationViewControllerNode.swift b/submodules/LocationUI/Sources/LocationViewControllerNode.swift index d276100b15..6b834e63e2 100644 --- a/submodules/LocationUI/Sources/LocationViewControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationViewControllerNode.swift @@ -557,6 +557,21 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan } } + self.headerNode.mapNode.annotationSelected = { [weak self] annotation in + guard let strongSelf = self else { + return + } + if let annotation = annotation { + strongSelf.interaction.goToCoordinate(annotation.coordinate) + } + } + + self.headerNode.mapNode.userLocationAnnotationSelected = { [weak self] in + if let strongSelf = self, let location = strongSelf.headerNode.mapNode.currentUserLocation { + strongSelf.interaction.goToCoordinate(location.coordinate) + } + } + self.locationManager.manager.startUpdatingHeading() self.locationManager.manager.delegate = self } diff --git a/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift b/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift index 02b79c940c..2dca499f43 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift @@ -829,7 +829,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { wasCheck = true } - if isAudio && !isVoice { + if isAudio && !isVoice && !isSending { state = .play } else { if message.groupingKey != nil, adjustedProgress.isEqual(to: 1.0), (message.flags.contains(.Unsent) || wasCheck) {