From 92895e8908e585a2492d9c59f0afe603f65fce74 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 15 Dec 2020 02:48:14 +0400 Subject: [PATCH] Voice Chat UI fixes --- .../Sources/VoiceChatActionButton.swift | 11 ++++++++++- .../TelegramCallsUI/Sources/VoiceChatController.swift | 4 ++++ .../Sources/VoiceChatOverlayController.swift | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatActionButton.swift b/submodules/TelegramCallsUI/Sources/VoiceChatActionButton.swift index 69a04531cc..4e2828b520 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatActionButton.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatActionButton.swift @@ -64,6 +64,14 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode { var isDisabled: Bool = false + var ignoreHierarchyChanges: Bool { + get { + return self.backgroundNode.ignoreHierarchyChanges + } set { + self.backgroundNode.ignoreHierarchyChanges = newValue + } + } + var wasActiveWhenPressed = false var pressing: Bool = false { didSet { @@ -439,6 +447,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode { private let hierarchyTrackingNode: HierarchyTrackingNode private var isCurrentlyInHierarchy = false + var ignoreHierarchyChanges = false override init() { self.state = .connecting @@ -500,7 +509,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode { self.maskCircleLayer.isHidden = true updateInHierarchy = { [weak self] value in - if let strongSelf = self { + if let strongSelf = self, !strongSelf.ignoreHierarchyChanges { strongSelf.isCurrentlyInHierarchy = value strongSelf.updateAnimations() } diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift index fd3df49c2f..ed01e5bc55 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatController.swift @@ -1778,6 +1778,7 @@ public final class VoiceChatController: ViewController { self.contentContainer.view.bounds = initialBounds }, completion: { _ in if self.actionButton.supernode !== self.bottomPanelNode { + self.actionButton.ignoreHierarchyChanges = true self.audioOutputNode.isHidden = false self.leaveNode.isHidden = false self.audioOutputNode.layer.removeAllAnimations() @@ -1786,6 +1787,7 @@ public final class VoiceChatController: ViewController { self.bottomPanelNode.addSubnode(self.leaveNode) self.bottomPanelNode.addSubnode(self.actionButton) self.containerLayoutUpdated(layout, navigationHeight :navigationHeight, transition: .immediate) + self.actionButton.ignoreHierarchyChanges = false } self.controller?.currentOverlayController?.dismiss() @@ -2366,6 +2368,7 @@ public final class VoiceChatController: ViewController { if let strongSelf = self { overlayController?.animateOut(reclaim: true, completion: { [weak self] immediate in if let strongSelf = self, immediate { + strongSelf.controllerNode.actionButton.ignoreHierarchyChanges = true strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.actionButton) strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.audioOutputNode) strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.leaveNode) @@ -2373,6 +2376,7 @@ public final class VoiceChatController: ViewController { if immediate, let layout = strongSelf.validLayout { strongSelf.containerLayoutUpdated(layout, transition: .immediate) } + strongSelf.controllerNode.actionButton.ignoreHierarchyChanges = false } }) strongSelf.reclaimActionButton = nil diff --git a/submodules/TelegramCallsUI/Sources/VoiceChatOverlayController.swift b/submodules/TelegramCallsUI/Sources/VoiceChatOverlayController.swift index 61a1f0ecaf..2c3c6f8679 100644 --- a/submodules/TelegramCallsUI/Sources/VoiceChatOverlayController.swift +++ b/submodules/TelegramCallsUI/Sources/VoiceChatOverlayController.swift @@ -294,8 +294,10 @@ public final class VoiceChatOverlayController: ViewController { if actionButton.supernode !== self && !self.didAnimateIn { self.didAnimateIn = true + actionButton.ignoreHierarchyChanges = true self.addSubnode(actionButton) self.animateIn(from: convertedRect) + actionButton.ignoreHierarchyChanges = false } } }