mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Various improvements
This commit is contained in:
@@ -75,6 +75,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
public var present: (ViewController) -> Void = { _ in }
|
||||
public var push: (ViewController) -> Void = { _ in }
|
||||
|
||||
public var canInteract: () -> Bool = { return true }
|
||||
public var hasSelectionChanged: (Bool) -> Void = { _ in }
|
||||
var selectionChanged: (DrawingEntity?) -> Void = { _ in }
|
||||
var requestedMenuForEntityView: (DrawingEntityView, Bool) -> Void = { _, _ in }
|
||||
@@ -633,6 +634,9 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
}
|
||||
|
||||
@objc private func handleTap(_ gestureRecognzier: UITapGestureRecognizer) {
|
||||
guard self.canInteract() else {
|
||||
return
|
||||
}
|
||||
let location = gestureRecognzier.location(in: self)
|
||||
if let entityView = self.entity(at: location) {
|
||||
self.selectEntity(entityView.entity)
|
||||
@@ -757,6 +761,9 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
}
|
||||
|
||||
public func handlePan(_ gestureRecognizer: UIPanGestureRecognizer) {
|
||||
guard self.canInteract() else {
|
||||
return
|
||||
}
|
||||
let location = gestureRecognizer.location(in: self)
|
||||
if let selectedEntityView = self.selectedEntityView, let selectionView = selectedEntityView.selectionView {
|
||||
if !self.hasBin {
|
||||
@@ -839,6 +846,9 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
}
|
||||
|
||||
public func handlePinch(_ gestureRecognizer: UIPinchGestureRecognizer) {
|
||||
guard self.canInteract() else {
|
||||
return
|
||||
}
|
||||
if !self.hasSelection, let mediaEntityView = self.subviews.first(where: { $0 is DrawingEntityMediaView }) as? DrawingEntityMediaView {
|
||||
mediaEntityView.handlePinch(gestureRecognizer)
|
||||
} else if let selectedEntityView = self.selectedEntityView, let selectionView = selectedEntityView.selectionView {
|
||||
@@ -847,6 +857,9 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
|
||||
}
|
||||
|
||||
public func handleRotate(_ gestureRecognizer: UIRotationGestureRecognizer) {
|
||||
guard self.canInteract() else {
|
||||
return
|
||||
}
|
||||
if !self.hasSelection, let mediaEntityView = self.subviews.first(where: { $0 is DrawingEntityMediaView }) as? DrawingEntityMediaView {
|
||||
mediaEntityView.handleRotate(gestureRecognizer)
|
||||
} else if let selectedEntityView = self.selectedEntityView, let selectionView = selectedEntityView.selectionView {
|
||||
|
||||
Reference in New Issue
Block a user