Psa-related fixes

This commit is contained in:
Ali
2020-04-25 18:00:03 +04:00
parent 049cba24bf
commit e43dcbfaca
19 changed files with 93 additions and 45 deletions

View File

@@ -60,8 +60,8 @@ public class ImmediateTextNode: TextNode {
}
}
public var tapAttributeAction: (([NSAttributedString.Key: Any]) -> Void)?
public var longTapAttributeAction: (([NSAttributedString.Key: Any]) -> Void)?
public var tapAttributeAction: (([NSAttributedString.Key: Any], Int) -> Void)?
public var longTapAttributeAction: (([NSAttributedString.Key: Any], Int) -> Void)?
public func makeCopy() -> TextNode {
let node = TextNode()
@@ -179,12 +179,12 @@ public class ImmediateTextNode: TextNode {
if let (gesture, location) = recognizer.lastRecognizedGestureAndLocation {
switch gesture {
case .tap:
if let (_, attributes) = self.attributesAtPoint(CGPoint(x: location.x, y: location.y)) {
self.tapAttributeAction?(attributes)
if let (index, attributes) = self.attributesAtPoint(CGPoint(x: location.x, y: location.y)) {
self.tapAttributeAction?(attributes, index)
}
case .longTap:
if let (_, attributes) = self.attributesAtPoint(CGPoint(x: location.x, y: location.y)) {
self.longTapAttributeAction?(attributes)
if let (index, attributes) = self.attributesAtPoint(CGPoint(x: location.x, y: location.y)) {
self.longTapAttributeAction?(attributes, index)
}
default:
break

View File

@@ -147,7 +147,7 @@ public final class TextAlertContentNode: AlertContentNode {
return nil
}
}
self.textNode.tapAttributeAction = { attributes in
self.textNode.tapAttributeAction = { attributes, _ in
if let value = attributes[attribute] {
textAttributeAction(value)
}