Merge commit '693cae73f244111b4e210fcc33765d9b1f9f6c82'

This commit is contained in:
Ali
2020-12-09 17:32:11 +04:00
7 changed files with 148 additions and 65 deletions

View File

@@ -460,6 +460,7 @@ public final class VoiceChatController: ViewController {
self.dimNode.backgroundColor = dimColor
self.contentContainer = ASDisplayNode()
self.contentContainer.isHidden = true
self.backgroundNode = ASDisplayNode()
self.backgroundNode.backgroundColor = secondaryPanelBackgroundColor
@@ -1600,7 +1601,7 @@ public final class VoiceChatController: ViewController {
}
func animateIn() {
guard let (layout, _) = self.validLayout else {
guard let (layout, navigationHeight) = self.validLayout else {
return
}
let transition = ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring)
@@ -1609,13 +1610,23 @@ public final class VoiceChatController: ViewController {
let initialBounds = self.contentContainer.bounds
self.contentContainer.bounds = initialBounds.offsetBy(dx: 0.0, dy: -(layout.size.height - topPanelFrame.minY))
transition.animateView {
self.contentContainer.isHidden = false
transition.animateView({
self.contentContainer.view.bounds = initialBounds
}
}, completion: { _ in
self.bottomPanelNode.addSubnode(self.actionButton)
self.containerLayoutUpdated(layout, navigationHeight:navigationHeight, transition: .immediate)
self.controller?.currentOverlayController?.dismiss()
self.controller?.currentOverlayController = nil
})
self.dimNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
}
func animateOut(completion: (() -> Void)?) {
guard let (layout, _) = self.validLayout else {
return
}
var offsetCompleted = false
let internalCompletion: () -> Void = { [weak self] in
if offsetCompleted {
@@ -1631,7 +1642,9 @@ public final class VoiceChatController: ViewController {
}
}
self.contentContainer.layer.animateBoundsOriginYAdditive(from: self.contentContainer.bounds.origin.y, to: -self.contentContainer.bounds.size.height, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { _ in
let topPanelFrame = self.topPanelNode.view.convert(self.topPanelNode.bounds, to: self.view)
self.contentContainer.layer.animateBoundsOriginYAdditive(from: self.contentContainer.bounds.origin.y, to: -(layout.size.height - topPanelFrame.minY), duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { _ in
offsetCompleted = true
internalCompletion()
})
@@ -1862,6 +1875,7 @@ public final class VoiceChatController: ViewController {
private var didAppearOnce: Bool = false
private var isDismissed: Bool = false
private var isDisconnected: Bool = false
private var controllerNode: Node {
return self.displayNode as! Node
@@ -1869,7 +1883,7 @@ public final class VoiceChatController: ViewController {
private let idleTimerExtensionDisposable = MetaDisposable()
private var currentOverlayController: VoiceChatOverlayController?
private weak var currentOverlayController: VoiceChatOverlayController?
private var validLayout: ContainerViewLayout?
@@ -1943,39 +1957,41 @@ public final class VoiceChatController: ViewController {
self.idleTimerExtensionDisposable.set(nil)
DispatchQueue.main.async {
self.didAppearOnce = false
self.isDismissed = true
self.detachActionButton()
self.onViewDidDisappear?()
}
}
public func dismiss(closing: Bool) {
if closing {
self.dismiss()
if !closing {
self.detachActionButton()
} else {
let overlayController = VoiceChatOverlayController(actionButton: self.controllerNode.actionButton)
if let navigationController = self.navigationController as? NavigationController {
navigationController.presentOverlay(controller: overlayController, inGlobal: true, blockInteraction: false)
self.isDisconnected = true
}
self.dismiss()
}
private func detachActionButton() {
guard self.currentOverlayController == nil && !self.isDisconnected else {
return
}
let overlayController = VoiceChatOverlayController(actionButton: self.controllerNode.actionButton)
if let navigationController = self.navigationController as? NavigationController {
navigationController.presentOverlay(controller: overlayController, inGlobal: true, blockInteraction: false)
}
self.currentOverlayController = overlayController
self.reclaimActionButton = { [weak self, weak overlayController] in
if let strongSelf = self {
let actionButton = strongSelf.controllerNode.actionButton
overlayController?.animateOut(reclaim: true, completion: {})
strongSelf.reclaimActionButton = nil
}
self.sharedContext.presentGlobalController(overlayController, nil)
self.currentOverlayController = overlayController
self.reclaimActionButton = { [weak self, weak overlayController] in
if let strongSelf = self {
let actionButton = strongSelf.controllerNode.actionButton
overlayController?.animateOut(reclaim: true, completion: { [weak self] in
if let strongSelf = self {
strongSelf.controllerNode.bottomPanelNode.addSubnode(actionButton)
if let validLayout = strongSelf.validLayout {
strongSelf.containerLayoutUpdated(validLayout, transition: .immediate)
}
}
})
strongSelf.currentOverlayController = nil
strongSelf.reclaimActionButton = nil
}
}
self.dismiss()
}
}