Fix snapshotting

This commit is contained in:
Ali 2023-11-11 17:48:00 +04:00
parent c2c0584dc9
commit 770cadf544
8 changed files with 40 additions and 10 deletions

View File

@ -2028,12 +2028,11 @@ xcodeproj(
"Debug": {
"//command_line_option:compilation_mode": "dbg",
},
#"Release": {
# "//command_line_option:compilation_mode": "opt",
#},
"Release": {
"//command_line_option:compilation_mode": "opt",
},
},
default_xcode_configuration = "Debug"
)
# Temporary targets used to simplify webrtc build tests

View File

@ -2435,17 +2435,22 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
if node.index == nil {
var duration = insertionAnimationDuration
if let value = self.customItemDeleteAnimationDuration(itemNode: node) {
duration = value
}
if node.animationForKey("height") == nil || !(node is ListViewTempItemNode) {
node.addHeightAnimation(0.0, duration: insertionAnimationDuration * UIView.animationDurationFactor(), beginAt: timestamp)
node.addHeightAnimation(0.0, duration: duration * UIView.animationDurationFactor(), beginAt: timestamp)
}
if node.animationForKey("apparentHeight") == nil || !(node is ListViewTempItemNode) {
node.addApparentHeightAnimation(0.0, duration: insertionAnimationDuration * UIView.animationDurationFactor(), beginAt: timestamp, update: { [weak node] progress, currentValue in
node.addApparentHeightAnimation(0.0, duration: duration * UIView.animationDurationFactor(), beginAt: timestamp, update: { [weak node] progress, currentValue in
if let node = node {
node.animateFrameTransition(progress, currentValue)
}
})
}
node.animateRemoved(timestamp, duration: insertionAnimationDuration * UIView.animationDurationFactor())
node.animateRemoved(timestamp, duration: duration * UIView.animationDurationFactor())
} else if animated {
if takenAnimation {
if let previousFrame = previousFrame {
@ -5041,6 +5046,10 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
}
return self.scrollWithDirection(scrollDirection, distance: distance)
}
open func customItemDeleteAnimationDuration(itemNode: ListViewItemNode) -> Double? {
return nil
}
}
private func findAccessibilityFocus(_ node: ASDisplayNode) -> Bool {

View File

@ -954,6 +954,7 @@ public final class MetalEngine {
}
}
#if DEBUG
#if targetEnvironment(simulator)
if #available(iOS 13.0, *) {
if let drawable = self.layer.nextDrawable() {
@ -965,6 +966,7 @@ public final class MetalEngine {
commandBuffer.present(drawable)
}
#endif
#endif
commandBuffer.commit()
commandBuffer.waitUntilScheduled()

View File

@ -80,6 +80,7 @@ swift_library(
"//submodules/TelegramUI/Components/Chat/ChatMessageGiftBubbleContentNode",
"//submodules/TelegramUI/Components/Chat/ChatMessageGiveawayBubbleContentNode",
"//submodules/TelegramUI/Components/Chat/ChatMessageJoinedChannelBubbleContentNode",
"//submodules/UIKitRuntimeUtils",
],
visibility = [
"//visibility:public",

View File

@ -70,6 +70,7 @@ import ChatMessageWallpaperBubbleContentNode
import ChatMessageGiftBubbleContentNode
import ChatMessageGiveawayBubbleContentNode
import ChatMessageJoinedChannelBubbleContentNode
import UIKitRuntimeUtils
private struct BubbleItemAttributes {
var isAttachment: Bool
@ -5387,9 +5388,8 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
UIGraphicsBeginImageContextWithOptions(self.backgroundNode.view.bounds.size, false, 0.0)
let context = UIGraphicsGetCurrentContext()!
context.translateBy(x: -self.backgroundNode.frame.minX, y: -self.insets.top - self.backgroundNode.frame.minY)
self.view.drawHierarchy(in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: self.view.bounds.size), afterScreenUpdates: false)
context.translateBy(x: -self.backgroundNode.frame.minX, y: -self.backgroundNode.frame.minY)
self.view.layer.render(in: context)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()

View File

@ -4018,4 +4018,17 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
self.view.layer.animatePosition(from: CGPoint(x: 0.0, y: self.view.bounds.height + snapshotTopInset), to: CGPoint(), duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: true, additive: true)
}
override public func customItemDeleteAnimationDuration(itemNode: ListViewItemNode) -> Double? {
if let currentDeleteAnimationCorrelationIds = self.currentDeleteAnimationCorrelationIds {
if let itemNode = itemNode as? ChatMessageItemView, let item = itemNode.item {
for (message, _) in item.content {
if currentDeleteAnimationCorrelationIds.contains(message.id) {
return 1.5
}
}
}
}
return nil
}
}

View File

@ -55,3 +55,5 @@ void applyKeyboardAutocorrection(UITextView * _Nonnull textView);
- (void)fixScrollDisplayLink;
@end
void snapshotViewByDrawingInContext(UIView * _Nonnull view);

View File

@ -483,3 +483,7 @@ void applyKeyboardAutocorrection(UITextView * _Nonnull textView) {
}
@end
void snapshotViewByDrawingInContext(UIView * _Nonnull view) {
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:false];
}