Various improvements

This commit is contained in:
Ilya Laktyushin
2024-10-09 00:05:41 +04:00
parent 059af7d697
commit 89e3ae02a2
51 changed files with 1305 additions and 660 deletions

View File

@@ -277,6 +277,7 @@ open class ImmediateTextView: TextView {
private var linkHighlightingNode: LinkHighlightingNode?
public var linkHighlightColor: UIColor?
public var linkHighlightInset: UIEdgeInsets = .zero
public var trailingLineWidth: CGFloat?
@@ -356,7 +357,7 @@ open class ImmediateTextView: TextView {
}
}
if let rects = rects {
if var rects, !rects.isEmpty {
let linkHighlightingNode: LinkHighlightingNode
if let current = strongSelf.linkHighlightingNode {
linkHighlightingNode = current
@@ -366,7 +367,8 @@ open class ImmediateTextView: TextView {
strongSelf.addSubnode(linkHighlightingNode)
}
linkHighlightingNode.frame = strongSelf.bounds
linkHighlightingNode.updateRects(rects.map { $0.offsetBy(dx: 0.0, dy: 0.0) })
rects[rects.count - 1] = rects[rects.count - 1].inset(by: strongSelf.linkHighlightInset)
linkHighlightingNode.updateRects(rects)
} else if let linkHighlightingNode = strongSelf.linkHighlightingNode {
strongSelf.linkHighlightingNode = nil
linkHighlightingNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.18, removeOnCompletion: false, completion: { [weak linkHighlightingNode] _ in