Various improvements

This commit is contained in:
Ilya Laktyushin
2025-07-28 02:08:28 +02:00
parent 6ff5012e18
commit aa244fbcce
8 changed files with 162 additions and 55 deletions

View File

@@ -34,6 +34,7 @@ public final class MultilineTextWithEntitiesComponent: Component {
public let handleSpoilers: Bool
public let manualVisibilityControl: Bool
public let resetAnimationsOnVisibilityChange: Bool
public let displaysAsynchronously: Bool
public let highlightAction: (([NSAttributedString.Key: Any]) -> NSAttributedString.Key?)?
public let tapAction: (([NSAttributedString.Key: Any], Int) -> Void)?
public let longTapAction: (([NSAttributedString.Key: Any], Int) -> Void)?
@@ -58,6 +59,7 @@ public final class MultilineTextWithEntitiesComponent: Component {
handleSpoilers: Bool = false,
manualVisibilityControl: Bool = false,
resetAnimationsOnVisibilityChange: Bool = false,
displaysAsynchronously: Bool = true,
highlightAction: (([NSAttributedString.Key: Any]) -> NSAttributedString.Key?)? = nil,
tapAction: (([NSAttributedString.Key: Any], Int) -> Void)? = nil,
longTapAction: (([NSAttributedString.Key: Any], Int) -> Void)? = nil
@@ -82,6 +84,7 @@ public final class MultilineTextWithEntitiesComponent: Component {
self.handleSpoilers = handleSpoilers
self.manualVisibilityControl = manualVisibilityControl
self.resetAnimationsOnVisibilityChange = resetAnimationsOnVisibilityChange
self.displaysAsynchronously = displaysAsynchronously
self.tapAction = tapAction
self.longTapAction = longTapAction
}
@@ -120,6 +123,9 @@ public final class MultilineTextWithEntitiesComponent: Component {
if lhs.resetAnimationsOnVisibilityChange != rhs.resetAnimationsOnVisibilityChange {
return false
}
if lhs.displaysAsynchronously != rhs.displaysAsynchronously {
return false
}
if let lhsTextShadowColor = lhs.textShadowColor, let rhsTextShadowColor = rhs.textShadowColor {
if !lhsTextShadowColor.isEqual(rhsTextShadowColor) {
return false
@@ -161,6 +167,7 @@ public final class MultilineTextWithEntitiesComponent: Component {
public override init(frame: CGRect) {
self.textNode = ImmediateTextNodeWithEntities()
super.init(frame: frame)
self.addSubview(self.textNode.view)
@@ -175,6 +182,8 @@ public final class MultilineTextWithEntitiesComponent: Component {
}
public func update(component: MultilineTextWithEntitiesComponent, availableSize: CGSize, transition: ComponentTransition) -> CGSize {
self.textNode.displaysAsynchronously = component.displaysAsynchronously
let attributedString: NSAttributedString
switch component.text {
case let .plain(string):