@@ -97,22 +97,14 @@ open class TransformImageNode: ASDisplayNode {
9797 self . disposable. set ( ( result |> deliverOnMainQueue) . start ( next: { [ weak self] next in
9898 let apply : ( ) -> Void = {
9999 if let strongSelf = self {
100+ var animateFromContents : Any ?
101+
100102 if strongSelf. contents == nil {
101103 if strongSelf. contentAnimations. contains ( . firstUpdate) && !attemptSynchronously {
102104 strongSelf. layer. animateAlpha ( from: 0.0 , to: 1.0 , duration: 0.15 )
103105 }
104106 } else if strongSelf. contentAnimations. contains ( . subsequentUpdates) {
105- let tempLayer = CALayer ( )
106- if strongSelf. captureProtected {
107- setLayerDisableScreenshots ( tempLayer, strongSelf. captureProtected)
108- }
109- tempLayer. frame = strongSelf. bounds
110- tempLayer. contentsGravity = strongSelf. layer. contentsGravity
111- tempLayer. contents = strongSelf. contents
112- strongSelf. layer. addSublayer ( tempLayer)
113- tempLayer. animateAlpha ( from: 1.0 , to: 0.0 , duration: 0.15 , removeOnCompletion: false , completion: { [ weak tempLayer] _ in
114- tempLayer? . removeFromSuperlayer ( )
115- } )
107+ animateFromContents = strongSelf. contents
116108 }
117109
118110 var imageUpdate : UIImage ?
@@ -129,6 +121,23 @@ open class TransformImageNode: ASDisplayNode {
129121 if let imageUpdated = strongSelf. imageUpdated {
130122 imageUpdated ( imageUpdate)
131123 }
124+
125+ if let animateFromContents {
126+ let transition : ContainedViewLayoutTransition = . animated( duration: 0.2 , curve: . linear)
127+ transition. animateContents ( layer: strongSelf. layer, from: animateFromContents)
128+
129+ /*let tempLayer = CALayer()
130+ if strongSelf.captureProtected {
131+ setLayerDisableScreenshots(tempLayer, strongSelf.captureProtected)
132+ }
133+ tempLayer.frame = strongSelf.bounds
134+ tempLayer.contentsGravity = strongSelf.layer.contentsGravity
135+ tempLayer.contents = animateFromContents
136+ strongSelf.layer.addSublayer(tempLayer)
137+ tempLayer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15, removeOnCompletion: false, completion: { [weak tempLayer] _ in
138+ tempLayer?.removeFromSuperlayer()
139+ })*/
140+ }
132141 }
133142 }
134143 if dispatchOnDisplayLink && !attemptSynchronously {
@@ -168,6 +177,34 @@ open class TransformImageNode: ASDisplayNode {
168177 }
169178 }
170179
180+ public func asyncLayoutWithAnimation( ) -> ( TransformImageArguments ) -> ( ( ListViewItemUpdateAnimation ) -> Void ) {
181+ let currentTransform = self . currentTransform
182+ let currentArguments = self . currentArguments
183+ return { [ weak self] arguments in
184+ let updatedImage : UIImage ?
185+
186+ if currentArguments != arguments {
187+ updatedImage = currentTransform ? ( arguments) ? . generateImage ( )
188+ } else {
189+ updatedImage = nil
190+ }
191+ return { animation in
192+ guard let self else {
193+ return
194+ }
195+ if let image = updatedImage {
196+ self . contents = image. cgImage
197+ self . image = image
198+ self . currentArguments = arguments
199+ if let _ = self . overlayColor {
200+ self . applyOverlayColor ( animated: false )
201+ }
202+ }
203+ self . argumentsPromise. set ( arguments)
204+ }
205+ }
206+ }
207+
171208 public class func asyncLayout( _ maybeNode: TransformImageNode ? ) -> ( TransformImageArguments ) -> ( ( ) -> TransformImageNode ) {
172209 return { arguments in
173210 let node : TransformImageNode
0 commit comments