Various fixes

This commit is contained in:
Ilya Laktyushin
2024-05-21 18:15:14 +04:00
parent a9468d0dc2
commit f3e75ca2e3
45 changed files with 1927 additions and 478 deletions

View File

@@ -20,8 +20,8 @@ public final class TextLoadingEffectView: UIView {
private let backgroundView: UIImageView
private let borderBackgroundView: UIImageView
private let duration: Double
private let gradientWidth: CGFloat
private var duration: Double
private var gradientWidth: CGFloat
private var size: CGSize?
@@ -112,6 +112,33 @@ public final class TextLoadingEffectView: UIView {
self.borderBackgroundView.layer.add(animation, forKey: "shimmer")
}
public func update(color: UIColor, rect: CGRect) {
let maskFrame = CGRect(origin: CGPoint(), size: rect.size).insetBy(dx: -4.0, dy: -4.0)
self.gradientWidth = 260.0
self.duration = 1.2
self.maskContentsView.backgroundColor = .clear
self.backgroundView.alpha = 0.25
self.backgroundView.tintColor = color
self.maskContentsView.frame = maskFrame
let rectsSet: [CGRect] = [rect]
self.maskHighlightNode.updateRects(rectsSet)
self.maskHighlightNode.frame = CGRect(origin: CGPoint(x: -maskFrame.minX, y: -maskFrame.minY), size: CGSize())
if self.size != maskFrame.size {
self.size = maskFrame.size
self.backgroundView.frame = CGRect(origin: CGPoint(x: -self.gradientWidth, y: 0.0), size: CGSize(width: self.gradientWidth, height: maskFrame.height))
self.updateAnimations(size: maskFrame.size)
}
}
public func update(color: UIColor, textNode: TextNode, range: NSRange) {
var rectsSet: [CGRect] = []
if let cachedLayout = textNode.cachedLayout {