diff --git a/Display/ActionSheetController.swift b/Display/ActionSheetController.swift index 6f6ff08e7c..6977020358 100644 --- a/Display/ActionSheetController.swift +++ b/Display/ActionSheetController.swift @@ -1,6 +1,6 @@ import Foundation -open class ActionSheetController: ViewController { +open class ActionSheetController: ViewController, PresentableController { private var actionSheetNode: ActionSheetControllerNode { return self.displayNode as! ActionSheetControllerNode } @@ -23,6 +23,8 @@ open class ActionSheetController: ViewController { self.theme = theme super.init(navigationBarPresentationData: nil) + + self.blocksBackgroundWhenInOverlay = true } required public init(coder aDecoder: NSCoder) { @@ -54,10 +56,14 @@ open class ActionSheetController: ViewController { self.actionSheetNode.containerLayoutUpdated(layout, transition: transition) } - open override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) + open override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) - self.actionSheetNode.animateIn() + self.viewDidAppear(completion: {}) + } + + public func viewDidAppear(completion: @escaping () -> Void) { + self.actionSheetNode.animateIn(completion: completion) } public func setItemGroups(_ groups: [ActionSheetItemGroup]) { diff --git a/Display/ActionSheetControllerNode.swift b/Display/ActionSheetControllerNode.swift index 7d03e0996f..820547892d 100644 --- a/Display/ActionSheetControllerNode.swift +++ b/Display/ActionSheetControllerNode.swift @@ -110,7 +110,7 @@ final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate { self.updateScrollDimViews(size: layout.size, insets: insets) } - func animateIn() { + func animateIn(completion: @escaping () -> Void) { let tempDimView = UIView() tempDimView.backgroundColor = self.theme.dimColor tempDimView.frame = self.bounds.offsetBy(dx: 0.0, dy: -self.bounds.size.height) @@ -124,6 +124,7 @@ final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate { self.layer.animateBounds(from: self.bounds.offsetBy(dx: 0.0, dy: -self.bounds.size.height), to: self.bounds, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, completion: { [weak tempDimView] _ in tempDimView?.removeFromSuperview() + completion() }) } diff --git a/Display/ContainableController.swift b/Display/ContainableController.swift index fb77d8e463..6e940cec68 100644 --- a/Display/ContainableController.swift +++ b/Display/ContainableController.swift @@ -2,6 +2,10 @@ import UIKit import AsyncDisplayKit import SwiftSignalKit +public protocol PresentableController: class { + func viewDidAppear(completion: @escaping () -> Void) +} + public protocol ContainableController: class { var view: UIView! { get } var displayNode: ASDisplayNode { get } diff --git a/Display/PresentationContext.swift b/Display/PresentationContext.swift index bbfb45dc09..88b3198c8e 100644 --- a/Display/PresentationContext.swift +++ b/Display/PresentationContext.swift @@ -189,7 +189,14 @@ final class PresentationContext { (controller as? UIViewController)?.setIgnoreAppearanceMethodInvocations(false) view.layer.invalidateUpTheTree() controller.viewWillAppear(false) - controller.viewDidAppear(false) + if let controller = controller as? PresentableController { + controller.viewDidAppear(completion: { [weak self] in + self?.notifyAccessibilityScreenChanged() + }) + } else { + controller.viewDidAppear(false) + strongSelf.notifyAccessibilityScreenChanged() + } } strongSelf.updateViews() } @@ -246,7 +253,14 @@ final class PresentationContext { } controller.view.frame = CGRect(origin: CGPoint(), size: layout.size) controller.containerLayoutUpdated(layout, transition: .immediate) - controller.viewDidAppear(false) + if let controller = controller as? PresentableController { + controller.viewDidAppear(completion: { [weak self] in + self?.notifyAccessibilityScreenChanged() + }) + } else { + controller.viewDidAppear(false) + self.notifyAccessibilityScreenChanged() + } } self.updateViews() } @@ -261,7 +275,7 @@ final class PresentationContext { } private func updateViews() { - self.hasOpaqueOverlay = self.isCurrentlyOpaque + self.hasOpaqueOverlay = self.currentlyBlocksBackgroundWhenInOverlay var topHasOpaque = false for (controller, _) in self.controllers.reversed() { if topHasOpaque { @@ -275,6 +289,10 @@ final class PresentationContext { } } + private func notifyAccessibilityScreenChanged() { + UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil) + } + func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { for (controller, _) in self.controllers.reversed() { if controller.isViewLoaded { diff --git a/Display/ViewController.swift b/Display/ViewController.swift index a6653141f7..9308b6a5b5 100644 --- a/Display/ViewController.swift +++ b/Display/ViewController.swift @@ -321,6 +321,10 @@ open class ViewControllerPresentationArguments { layer.setTraceableInfo(CATracingLayerInfo(shouldBeAdjustedToInverseTransform: false, userData: self.displayNode.layer, tracingTag: WindowTracingTags.keyboard, disableChildrenTracingTags: 0)) } self.updateScrollToTopView() + if let backgroundColor = self.displayNode.backgroundColor, backgroundColor.alpha.isEqual(to: 1.0) { + self.blocksBackgroundWhenInOverlay = true + self.isOpaqueWhenInOverlay = true + } } public func requestLayout(transition: ContainedViewLayoutTransition) {