mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-31 18:02:20 +00:00
VoiceOver updates
This commit is contained in:
parent
798e2dda42
commit
552b4a2661
@ -68,6 +68,8 @@ open class AlertController: ViewController {
|
||||
|
||||
super.init(navigationBarPresentationData: nil)
|
||||
|
||||
self.blocksBackgroundWhenInOverlay = true
|
||||
|
||||
self.statusBar.statusBarStyle = .Ignore
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,10 @@ import SwiftSignalKit
|
||||
|
||||
public protocol ContainableController: class {
|
||||
var view: UIView! { get }
|
||||
var displayNode: ASDisplayNode { get }
|
||||
var isViewLoaded: Bool { get }
|
||||
var isOpaqueWhenInOverlay: Bool { get }
|
||||
var blocksBackgroundWhenInOverlay: Bool { get }
|
||||
var ready: Promise<Bool> { get }
|
||||
|
||||
func combinedSupportedOrientations(currentOrientationToLock: UIInterfaceOrientationMask) -> ViewControllerSupportedOrientations
|
||||
|
@ -96,6 +96,7 @@ public enum NavigationControllerMode {
|
||||
|
||||
open class NavigationController: UINavigationController, ContainableController, UIGestureRecognizerDelegate {
|
||||
public var isOpaqueWhenInOverlay: Bool = true
|
||||
public var blocksBackgroundWhenInOverlay: Bool = true
|
||||
|
||||
public var ready: Promise<Bool> = Promise(true)
|
||||
|
||||
@ -140,6 +141,11 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
return self._viewControllers.last?.controller
|
||||
}
|
||||
|
||||
private var _displayNode: ASDisplayNode?
|
||||
public var displayNode: ASDisplayNode {
|
||||
return self._displayNode!
|
||||
}
|
||||
|
||||
public init(mode: NavigationControllerMode, theme: NavigationControllerTheme) {
|
||||
self.mode = mode
|
||||
self.theme = theme
|
||||
@ -594,7 +600,11 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
}
|
||||
|
||||
open override func loadView() {
|
||||
self.view = NavigationControllerView()
|
||||
self._displayNode = ASDisplayNode(viewBlock: {
|
||||
return NavigationControllerView()
|
||||
}, didLoad: nil)
|
||||
|
||||
self.view = self.displayNode.view
|
||||
self.view.clipsToBounds = true
|
||||
self.view.autoresizingMask = []
|
||||
|
||||
|
@ -33,6 +33,15 @@ final class PresentationContext {
|
||||
|
||||
var updateIsInteractionBlocked: ((Bool) -> Void)?
|
||||
|
||||
var updateHasOpaqueOverlay: ((Bool) -> Void)?
|
||||
private(set) var hasOpaqueOverlay: Bool = false {
|
||||
didSet {
|
||||
if self.hasOpaqueOverlay != oldValue {
|
||||
self.updateHasOpaqueOverlay?(self.hasOpaqueOverlay)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var layout: ContainerViewLayout?
|
||||
|
||||
private var ready: Bool {
|
||||
@ -56,6 +65,15 @@ final class PresentationContext {
|
||||
return false
|
||||
}
|
||||
|
||||
var currentlyBlocksBackgroundWhenInOverlay: Bool {
|
||||
for (controller, _) in self.controllers {
|
||||
if controller.isOpaqueWhenInOverlay || controller.blocksBackgroundWhenInOverlay {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private func topLevelSubview(for level: PresentationSurfaceLevel) -> UIView? {
|
||||
var topController: ContainableController?
|
||||
for (controller, controllerLevel) in self.controllers.reversed() {
|
||||
@ -173,10 +191,12 @@ final class PresentationContext {
|
||||
controller.viewWillAppear(false)
|
||||
controller.viewDidAppear(false)
|
||||
}
|
||||
strongSelf.updateViews()
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
self.controllers.append((controller, level))
|
||||
self.updateViews()
|
||||
}
|
||||
}
|
||||
|
||||
@ -190,6 +210,7 @@ final class PresentationContext {
|
||||
controller.viewWillDisappear(false)
|
||||
controller.view.removeFromSuperview()
|
||||
controller.viewDidDisappear(false)
|
||||
self.updateViews()
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,6 +248,7 @@ final class PresentationContext {
|
||||
controller.containerLayoutUpdated(layout, transition: .immediate)
|
||||
controller.viewDidAppear(false)
|
||||
}
|
||||
self.updateViews()
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,6 +260,21 @@ final class PresentationContext {
|
||||
}
|
||||
}
|
||||
|
||||
private func updateViews() {
|
||||
self.hasOpaqueOverlay = self.isCurrentlyOpaque
|
||||
var topHasOpaque = false
|
||||
for (controller, _) in self.controllers.reversed() {
|
||||
if topHasOpaque {
|
||||
controller.displayNode.accessibilityElementsHidden = true
|
||||
} else {
|
||||
if controller.isOpaqueWhenInOverlay || controller.blocksBackgroundWhenInOverlay {
|
||||
topHasOpaque = true
|
||||
}
|
||||
controller.displayNode.accessibilityElementsHidden = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
for (controller, _) in self.controllers.reversed() {
|
||||
if controller.isViewLoaded {
|
||||
|
@ -329,7 +329,16 @@ open class TabBarController: ViewController {
|
||||
}
|
||||
|> filter { $0 }
|
||||
|> take(1)
|
||||
self._ready.set(signals)
|
||||
|
||||
let allReady = signals
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { _ -> Signal<Bool, NoError> in
|
||||
// wait for tab bar items to be applied
|
||||
return .single(true)
|
||||
|> delay(0.0, queue: Queue.mainQueue())
|
||||
}
|
||||
|
||||
self._ready.set(allReady)
|
||||
|
||||
if let updatedSelectedIndex = updatedSelectedIndex {
|
||||
self.selectedIndex = updatedSelectedIndex
|
||||
|
@ -74,6 +74,7 @@ open class ViewControllerPresentationArguments {
|
||||
}
|
||||
|
||||
public final var isOpaqueWhenInOverlay: Bool = false
|
||||
public final var blocksBackgroundWhenInOverlay: Bool = false
|
||||
|
||||
public func combinedSupportedOrientations(currentOrientationToLock: UIInterfaceOrientationMask) -> ViewControllerSupportedOrientations {
|
||||
return self.supportedOrientations
|
||||
|
@ -370,6 +370,10 @@ public class Window1 {
|
||||
self?.isInteractionBlocked = value
|
||||
}
|
||||
|
||||
self.presentationContext.updateHasOpaqueOverlay = { [weak self] value in
|
||||
self?._rootController?.displayNode.accessibilityElementsHidden = value
|
||||
}
|
||||
|
||||
self.hostView.present = { [weak self] controller, level, blockInteraction, completion in
|
||||
self?.present(controller, on: level, blockInteraction: blockInteraction, completion: completion)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user