diff --git a/Telegram/BUILD b/Telegram/BUILD index d460a2b6d5..d5b7a04de4 100644 --- a/Telegram/BUILD +++ b/Telegram/BUILD @@ -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 diff --git a/submodules/Display/Source/ListView.swift b/submodules/Display/Source/ListView.swift index 2b9a819c1f..3e241ce420 100644 --- a/submodules/Display/Source/ListView.swift +++ b/submodules/Display/Source/ListView.swift @@ -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 { diff --git a/submodules/MetalEngine/Sources/MetalEngine.swift b/submodules/MetalEngine/Sources/MetalEngine.swift index 763bf8d662..9978f617fd 100644 --- a/submodules/MetalEngine/Sources/MetalEngine.swift +++ b/submodules/MetalEngine/Sources/MetalEngine.swift @@ -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() diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/BUILD b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/BUILD index c945e54830..bcba245fc1 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/BUILD +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/BUILD @@ -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", diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index da8cf2d214..7d19080edb 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -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() diff --git a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift index d72c2ed2b9..db02c66b20 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift @@ -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 + } } diff --git a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.h b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.h index 46e724a905..5afbb21710 100644 --- a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.h +++ b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.h @@ -55,3 +55,5 @@ void applyKeyboardAutocorrection(UITextView * _Nonnull textView); - (void)fixScrollDisplayLink; @end + +void snapshotViewByDrawingInContext(UIView * _Nonnull view); diff --git a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.m b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.m index c4f8086c23..6e3f53029d 100644 --- a/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.m +++ b/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIViewController+Navigation.m @@ -483,3 +483,7 @@ void applyKeyboardAutocorrection(UITextView * _Nonnull textView) { } @end + +void snapshotViewByDrawingInContext(UIView * _Nonnull view) { + [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:false]; +}