Voice Chat UI fixes

This commit is contained in:
Ilya Laktyushin 2020-12-15 02:48:14 +04:00
parent 23d0ac26b8
commit 92895e8908
3 changed files with 16 additions and 1 deletions

View File

@ -64,6 +64,14 @@ final class VoiceChatActionButton: HighlightTrackingButtonNode {
var isDisabled: Bool = false var isDisabled: Bool = false
var ignoreHierarchyChanges: Bool {
get {
return self.backgroundNode.ignoreHierarchyChanges
} set {
self.backgroundNode.ignoreHierarchyChanges = newValue
}
}
var wasActiveWhenPressed = false var wasActiveWhenPressed = false
var pressing: Bool = false { var pressing: Bool = false {
didSet { didSet {
@ -439,6 +447,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
private let hierarchyTrackingNode: HierarchyTrackingNode private let hierarchyTrackingNode: HierarchyTrackingNode
private var isCurrentlyInHierarchy = false private var isCurrentlyInHierarchy = false
var ignoreHierarchyChanges = false
override init() { override init() {
self.state = .connecting self.state = .connecting
@ -500,7 +509,7 @@ private final class VoiceChatActionButtonBackgroundNode: ASDisplayNode {
self.maskCircleLayer.isHidden = true self.maskCircleLayer.isHidden = true
updateInHierarchy = { [weak self] value in updateInHierarchy = { [weak self] value in
if let strongSelf = self { if let strongSelf = self, !strongSelf.ignoreHierarchyChanges {
strongSelf.isCurrentlyInHierarchy = value strongSelf.isCurrentlyInHierarchy = value
strongSelf.updateAnimations() strongSelf.updateAnimations()
} }

View File

@ -1778,6 +1778,7 @@ public final class VoiceChatController: ViewController {
self.contentContainer.view.bounds = initialBounds self.contentContainer.view.bounds = initialBounds
}, completion: { _ in }, completion: { _ in
if self.actionButton.supernode !== self.bottomPanelNode { if self.actionButton.supernode !== self.bottomPanelNode {
self.actionButton.ignoreHierarchyChanges = true
self.audioOutputNode.isHidden = false self.audioOutputNode.isHidden = false
self.leaveNode.isHidden = false self.leaveNode.isHidden = false
self.audioOutputNode.layer.removeAllAnimations() self.audioOutputNode.layer.removeAllAnimations()
@ -1786,6 +1787,7 @@ public final class VoiceChatController: ViewController {
self.bottomPanelNode.addSubnode(self.leaveNode) self.bottomPanelNode.addSubnode(self.leaveNode)
self.bottomPanelNode.addSubnode(self.actionButton) self.bottomPanelNode.addSubnode(self.actionButton)
self.containerLayoutUpdated(layout, navigationHeight :navigationHeight, transition: .immediate) self.containerLayoutUpdated(layout, navigationHeight :navigationHeight, transition: .immediate)
self.actionButton.ignoreHierarchyChanges = false
} }
self.controller?.currentOverlayController?.dismiss() self.controller?.currentOverlayController?.dismiss()
@ -2366,6 +2368,7 @@ public final class VoiceChatController: ViewController {
if let strongSelf = self { if let strongSelf = self {
overlayController?.animateOut(reclaim: true, completion: { [weak self] immediate in overlayController?.animateOut(reclaim: true, completion: { [weak self] immediate in
if let strongSelf = self, immediate { if let strongSelf = self, immediate {
strongSelf.controllerNode.actionButton.ignoreHierarchyChanges = true
strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.actionButton) strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.actionButton)
strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.audioOutputNode) strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.audioOutputNode)
strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.leaveNode) strongSelf.controllerNode.bottomPanelNode.addSubnode(strongSelf.controllerNode.leaveNode)
@ -2373,6 +2376,7 @@ public final class VoiceChatController: ViewController {
if immediate, let layout = strongSelf.validLayout { if immediate, let layout = strongSelf.validLayout {
strongSelf.containerLayoutUpdated(layout, transition: .immediate) strongSelf.containerLayoutUpdated(layout, transition: .immediate)
} }
strongSelf.controllerNode.actionButton.ignoreHierarchyChanges = false
} }
}) })
strongSelf.reclaimActionButton = nil strongSelf.reclaimActionButton = nil

View File

@ -294,8 +294,10 @@ public final class VoiceChatOverlayController: ViewController {
if actionButton.supernode !== self && !self.didAnimateIn { if actionButton.supernode !== self && !self.didAnimateIn {
self.didAnimateIn = true self.didAnimateIn = true
actionButton.ignoreHierarchyChanges = true
self.addSubnode(actionButton) self.addSubnode(actionButton)
self.animateIn(from: convertedRect) self.animateIn(from: convertedRect)
actionButton.ignoreHierarchyChanges = false
} }
} }
} }