From ad93eeaf3901a40c98e89c137afd8c45aee209c7 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 10 Jun 2021 17:42:29 +0300 Subject: [PATCH] Video Chat Improvements --- .../TelegramCallsUI/Sources/GroupVideoNode.swift | 7 +++++++ .../Sources/VoiceChatFullscreenParticipantItem.swift | 10 ++++++++-- .../Sources/VoiceChatMainStageNode.swift | 5 ++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/submodules/TelegramCallsUI/Sources/GroupVideoNode.swift b/submodules/TelegramCallsUI/Sources/GroupVideoNode.swift index 1f5163643e..0f379d911e 100644 --- a/submodules/TelegramCallsUI/Sources/GroupVideoNode.swift +++ b/submodules/TelegramCallsUI/Sources/GroupVideoNode.swift @@ -347,4 +347,11 @@ final class GroupVideoNode: ASDisplayNode { let transition: ContainedViewLayoutTransition = .immediate transition.updateTransformRotation(view: self.videoView.view, angle: angle) } + + var snapshotView: UIView? + func storeSnapshot() { + if self.frame.size.width == 180.0 { + self.snapshotView = self.view.snapshotView(afterScreenUpdates: false) + } + } } diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift b/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift index e1574a3f2c..147b8f86fe 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatFullscreenParticipantItem.swift @@ -483,9 +483,12 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { let videoNode = item.getVideo() if let currentVideoNode = strongSelf.videoNode, currentVideoNode !== videoNode { if videoNode == nil { + let snapshotView = currentVideoNode.snapshotView if strongSelf.avatarNode.alpha.isZero { strongSelf.animatingSelection = true - strongSelf.videoContainerNode.layer.animateScale(from: videoContainerScale, to: 0.001, duration: appearanceDuration) + strongSelf.videoContainerNode.layer.animateScale(from: videoContainerScale, to: 0.001, duration: appearanceDuration, completion: { _ in + snapshotView?.removeFromSuperview() + }) strongSelf.avatarNode.layer.animateScale(from: 0.0, to: 1.0, duration: appearanceDuration, completion: { [weak self] _ in self?.animatingSelection = false }) @@ -494,6 +497,9 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { } if currentVideoNode.supernode === strongSelf.videoContainerNode { apperanceTransition.updateAlpha(node: currentVideoNode, alpha: 0.0) + } else if let snapshotView = snapshotView { + strongSelf.videoContainerNode.view.insertSubview(snapshotView, at: 0) + apperanceTransition.updateAlpha(layer: snapshotView.layer, alpha: 0.0) } apperanceTransition.updateAlpha(node: strongSelf.videoFadeNode, alpha: 0.0) apperanceTransition.updateAlpha(node: strongSelf.avatarNode, alpha: 1.0) @@ -873,7 +879,7 @@ class VoiceChatFullscreenParticipantItemNode: ItemListRevealOptionsItemNode { if !strongSelf.isExtracted && !strongSelf.animatingExtraction { if videoNode.supernode !== strongSelf.videoContainerNode { videoNode.clipsToBounds = true - strongSelf.videoContainerNode.addSubnode(videoNode) + strongSelf.videoContainerNode.insertSubnode(videoNode, at: 0) } videoNode.position = CGPoint(x: videoSize.width / 2.0, y: videoSize.height / 2.0) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift b/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift index d3972732fc..3bb7b990f2 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatMainStageNode.swift @@ -830,7 +830,10 @@ final class VoiceChatMainStageNode: ASDisplayNode { return } - videoNode.isMainstageExclusive = isMyPeer + videoNode.isMainstageExclusive = isMyPeer && !isPresentation + if videoNode.isMainstageExclusive { + videoNode.storeSnapshot() + } videoNode.tapped = { [weak self] in guard let strongSelf = self else { return