mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
8201e493f3
commit
8068a2490a
@ -671,6 +671,12 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
}
|
||||
}
|
||||
}
|
||||
selectionView.longPressed = { [weak self, weak entityView] in
|
||||
if let self, let entityView {
|
||||
let entityViews = self.subviews.filter { $0 is DrawingEntityView }
|
||||
self.requestedMenuForEntityView(entityView, entityViews.last === entityView)
|
||||
}
|
||||
}
|
||||
entityView.selectionView = selectionView
|
||||
self.selectionContainerView?.addSubview(selectionView)
|
||||
}
|
||||
@ -1015,6 +1021,7 @@ public class DrawingEntitySelectionView: UIView {
|
||||
public var tapGestureRecognizer: UITapGestureRecognizer?
|
||||
|
||||
var tapped: () -> Void = { }
|
||||
var longPressed: () -> Void = { }
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
@ -70,6 +70,8 @@ public final class DrawingLocationEntityView: DrawingEntityView, UITextViewDeleg
|
||||
self.textView.keyboardAppearance = .dark
|
||||
self.textView.autocorrectionType = .default
|
||||
self.textView.spellCheckingType = .no
|
||||
self.textView.textContainer.maximumNumberOfLines = 1
|
||||
self.textView.textContainer.lineBreakMode = .byTruncatingTail
|
||||
|
||||
self.iconView = UIImageView()
|
||||
|
||||
@ -133,23 +135,21 @@ public final class DrawingLocationEntityView: DrawingEntityView, UITextViewDeleg
|
||||
}
|
||||
self.locationEntity.style = updatedStyle
|
||||
|
||||
// if let snapshotView = self.snapshotView(afterScreenUpdates: false) {
|
||||
// self.addSubview(snapshotView)
|
||||
//
|
||||
// snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak snapshotView] _ in
|
||||
// snapshotView?.removeFromSuperview()
|
||||
// })
|
||||
// self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
// }
|
||||
self.update()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private var displayFontSize: CGFloat {
|
||||
var textFontSize: CGFloat = 0.07
|
||||
let textLength = self.locationEntity.title.count
|
||||
if textLength > 10 {
|
||||
textFontSize = max(0.01, 0.07 - CGFloat(textLength - 10) / 100.0)
|
||||
}
|
||||
|
||||
let minFontSize = max(10.0, max(self.locationEntity.referenceDrawingSize.width, self.locationEntity.referenceDrawingSize.height) * 0.025)
|
||||
let maxFontSize = max(10.0, max(self.locationEntity.referenceDrawingSize.width, self.locationEntity.referenceDrawingSize.height) * 0.25)
|
||||
let fontSize = minFontSize + (maxFontSize - minFontSize) * 0.07
|
||||
let fontSize = minFontSize + (maxFontSize - minFontSize) * textFontSize
|
||||
return fontSize
|
||||
}
|
||||
|
||||
@ -264,6 +264,8 @@ final class DrawingLocationEntititySelectionView: DrawingEntitySelectionView {
|
||||
private let leftHandle = SimpleShapeLayer()
|
||||
private let rightHandle = SimpleShapeLayer()
|
||||
|
||||
private var longPressGestureRecognizer: UILongPressGestureRecognizer?
|
||||
|
||||
override init(frame: CGRect) {
|
||||
let handleBounds = CGRect(origin: .zero, size: entitySelectionViewHandleSize)
|
||||
let handles = [
|
||||
@ -296,6 +298,10 @@ final class DrawingLocationEntititySelectionView: DrawingEntitySelectionView {
|
||||
entityView.onSnapUpdated(type, snapped)
|
||||
}
|
||||
}
|
||||
|
||||
let longPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.handleLongPress(_:)))
|
||||
self.addGestureRecognizer(longPressGestureRecognizer)
|
||||
self.longPressGestureRecognizer = longPressGestureRecognizer
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@ -318,6 +324,12 @@ final class DrawingLocationEntititySelectionView: DrawingEntitySelectionView {
|
||||
|
||||
private let snapTool = DrawingEntitySnapTool()
|
||||
|
||||
@objc private func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer) {
|
||||
if case .began = gestureRecognizer.state {
|
||||
self.longPressed()
|
||||
}
|
||||
}
|
||||
|
||||
private var currentHandle: CALayer?
|
||||
override func handlePan(_ gestureRecognizer: UIPanGestureRecognizer) {
|
||||
guard let entityView = self.entityView, let entity = entityView.entity as? DrawingLocationEntity else {
|
||||
@ -329,6 +341,9 @@ final class DrawingLocationEntititySelectionView: DrawingEntitySelectionView {
|
||||
self.tapGestureRecognizer?.isEnabled = false
|
||||
self.tapGestureRecognizer?.isEnabled = true
|
||||
|
||||
self.longPressGestureRecognizer?.isEnabled = false
|
||||
self.longPressGestureRecognizer?.isEnabled = true
|
||||
|
||||
self.snapTool.maybeSkipFromStart(entityView: entityView, position: entity.position)
|
||||
|
||||
if let sublayers = self.layer.sublayers {
|
||||
|
@ -577,11 +577,13 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
||||
entries.append(.location(presentationData.theme, title, venue.venue?.title ?? "", venue, queryId, resultId, venue.coordinate, nil))
|
||||
case .none:
|
||||
let title: String
|
||||
var coordinate = userLocation?.coordinate
|
||||
switch strongSelf.mode {
|
||||
case .share:
|
||||
if source == .story {
|
||||
if strongSelf.controller?.initialLocation != nil {
|
||||
if let initialLocation = strongSelf.controller?.initialLocation {
|
||||
title = "Add This Location"
|
||||
coordinate = initialLocation
|
||||
} else {
|
||||
title = "Add My Current Location"
|
||||
}
|
||||
@ -591,7 +593,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
||||
case .pick:
|
||||
title = presentationData.strings.Map_SetThisLocation
|
||||
}
|
||||
entries.append(.location(presentationData.theme, title, (userLocation?.horizontalAccuracy).flatMap { presentationData.strings.Map_AccurateTo(stringForDistance(strings: presentationData.strings, distance: $0)).string } ?? presentationData.strings.Map_Locating, nil, nil, nil, userLocation?.coordinate, state.address))
|
||||
entries.append(.location(presentationData.theme, title, (userLocation?.horizontalAccuracy).flatMap { presentationData.strings.Map_AccurateTo(stringForDistance(strings: presentationData.strings, distance: $0)).string } ?? presentationData.strings.Map_Locating, nil, nil, nil, coordinate, state.address))
|
||||
}
|
||||
|
||||
if case .share(_, _, true) = mode {
|
||||
@ -747,8 +749,9 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
if case .none = state.selectedLocation, let location = userLocation, state.address == nil {
|
||||
strongSelf.geocodingDisposable.set((reverseGeocodeLocation(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
|
||||
let coordinate = controller.initialLocation ?? userLocation?.coordinate
|
||||
if case .none = state.selectedLocation, let coordinate, state.address == nil {
|
||||
strongSelf.geocodingDisposable.set((reverseGeocodeLocation(latitude: coordinate.latitude, longitude: coordinate.longitude)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] placemark in
|
||||
if let strongSelf = self {
|
||||
var address = placemark?.fullAddress ?? ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user