mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-31 18:02:20 +00:00
Accessibility updates
This commit is contained in:
parent
4033e28c74
commit
5203c8a156
@ -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]) {
|
||||
|
@ -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()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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 }
|
||||
|
@ -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 {
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user