Improve text spoiler animations

This commit is contained in:
Isaac
2024-05-31 11:50:48 +04:00
parent 9ea80ff9dc
commit 0e668a5fa2
6 changed files with 392 additions and 146 deletions

View File

@@ -352,6 +352,44 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget {
}
}
public weak var mirrorLayer: CALayer? {
didSet {
if let mirrorLayer = self.mirrorLayer {
mirrorLayer.contents = self.contents
var customColor = self.contentTintColor
if let file = self.file {
if file.isCustomTemplateEmoji {
customColor = self.dynamicColor
}
}
if customColor != nil {
if self.layerTintColor == nil {
setLayerContentsMaskMode(mirrorLayer, true)
}
} else {
if self.layerTintColor != nil {
setLayerContentsMaskMode(mirrorLayer, false)
}
}
if let customColor {
Transition.immediate.setTintColor(layer: mirrorLayer, color: customColor)
} else {
self.layerTintColor = nil
}
}
}
}
override public var contents: Any? {
didSet {
if let mirrorLayer = self.mirrorLayer {
mirrorLayer.contents = self.contents
}
}
}
public convenience init(context: AccountContext, userLocation: MediaResourceUserLocation, attemptSynchronousLoad: Bool, emoji: ChatTextInputTextCustomEmojiAttribute, file: TelegramMediaFile?, cache: AnimationCache, renderer: MultiAnimationRenderer, unique: Bool = false, placeholderColor: UIColor, pointSize: CGSize, dynamicColor: UIColor? = nil, loopCount: Int? = nil) {
self.init(
context: .account(context),