Various fixes

This commit is contained in:
Ilya Laktyushin 2025-05-15 17:43:33 +04:00
parent 0401bc8ef1
commit b6db0715d0
4 changed files with 18 additions and 22 deletions

View File

@ -109,6 +109,7 @@ public final class DrawingEntitiesView: UIView, TGPhotoDrawingEntitiesView {
public var onInteractionUpdated: (Bool) -> Void = { _ in }
public var edgePreviewUpdated: (Bool) -> Void = { _ in }
public var onTextEditingEnded: (Bool) -> Void = { _ in }
private let hapticFeedback = HapticFeedback()

View File

@ -3078,6 +3078,11 @@ public final class DrawingToolsInteraction {
self.onInteractionUpdated(isInteracting)
}
}
self.entitiesView.onTextEditingEnded = { [weak self] reset in
if let self {
self.onTextEditingEnded(reset)
}
}
self.entitiesView.requestedMenuForEntityView = { [weak self] entityView, isTopmost in
guard let self, let node = self.getControllerNode() else {
return
@ -3267,7 +3272,6 @@ public final class DrawingToolsInteraction {
public func endTextEditing(reset: Bool) {
if let entityView = self.entitiesView.selectedEntityView as? DrawingTextEntityView {
entityView.endEditing(reset: reset)
self.onTextEditingEnded(reset)
}
}

View File

@ -357,6 +357,8 @@ public final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate
selectionView.alpha = 1.0
selectionView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
}
parentView.onTextEditingEnded(reset)
}
func suspendEditing() {

View File

@ -1273,27 +1273,8 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
}
}
}
recognizer.waitForTouchUp = { [weak self] in
guard let strongSelf = self, let textInputNode = strongSelf.textInputNode else {
return true
}
if textInputNode.textView.isFirstResponder {
return true
} else if let (_, _, _, bottomInset, _, _, metrics, _, _) = strongSelf.validLayout {
let textFieldWaitsForTouchUp: Bool
if case .regular = metrics.widthClass, bottomInset.isZero {
textFieldWaitsForTouchUp = true
} else if !textInputNode.textView.text.isEmpty {
textFieldWaitsForTouchUp = true
} else {
textFieldWaitsForTouchUp = false
}
return textFieldWaitsForTouchUp
} else {
return false
}
recognizer.waitForTouchUp = {
return true
}
textInputNode.view.addGestureRecognizer(recognizer)
self.touchDownGestureRecognizer = recognizer
@ -4086,6 +4067,10 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
}
self.inputMenu.activate()
if let touchDownGestureRecognizer = self.touchDownGestureRecognizer {
self.textInputNode?.view.addGestureRecognizer(touchDownGestureRecognizer)
}
}
@objc func editableTextNodeDidBeginEditing(_ editableTextNode: ASEditableTextNode) {
@ -4120,6 +4105,10 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate, Ch
}
}
}
if let touchDownGestureRecognizer = self.touchDownGestureRecognizer {
self.textInputNode?.view.removeGestureRecognizer(touchDownGestureRecognizer)
}
}
func editableTextNodeDidFinishEditing(_ editableTextNode: ASEditableTextNode) {