added delay only for tabbar change & added webPageChanged notificationtype
This commit is contained in:
parent
fedd056175
commit
49ba311d26
@ -8,10 +8,11 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import Combine
|
import Combine
|
||||||
|
import MVMCore
|
||||||
|
|
||||||
public enum AccessibilityNotificationType {
|
public enum AccessibilityNotificationType: String, Codable {
|
||||||
|
|
||||||
case controllerChanged, layoutChanged, screenChanged, announcement
|
case controllerChanged, layoutChanged, screenChanged, announcement, webPageChanged
|
||||||
|
|
||||||
//TODO: - Foucs is shifting to respective element only if we add delay only on new viewcontroller appear. Need to investigate futher.
|
//TODO: - Foucs is shifting to respective element only if we add delay only on new viewcontroller appear. Need to investigate futher.
|
||||||
//https://developer.apple.com/forums/thread/132699,
|
//https://developer.apple.com/forums/thread/132699,
|
||||||
@ -36,6 +37,8 @@ public enum AccessibilityNotificationType {
|
|||||||
return .screenChanged
|
return .screenChanged
|
||||||
case .layoutChanged, .controllerChanged:
|
case .layoutChanged, .controllerChanged:
|
||||||
return .layoutChanged
|
return .layoutChanged
|
||||||
|
case .webPageChanged:
|
||||||
|
return .layoutChanged
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,14 +97,13 @@ open class AccessibilityHandler {
|
|||||||
private var anyCancellable: Set<AnyCancellable> = []
|
private var anyCancellable: Set<AnyCancellable> = []
|
||||||
private weak var delegate: MVMCoreViewControllerProtocol?
|
private weak var delegate: MVMCoreViewControllerProtocol?
|
||||||
private var accessibilityId: String?
|
private var accessibilityId: String?
|
||||||
private var operationType: UINavigationController.Operation?
|
|
||||||
private var previousAccessiblityElement: Any?
|
private var previousAccessiblityElement: Any?
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
registerWithNotificationCenter()
|
registerWithNotificationCenter()
|
||||||
registerForPageChanges()
|
registerForPageChanges()
|
||||||
registerForFocusChanges()
|
registerForFocusChanges()
|
||||||
// registerForTopNotificationsChanges()
|
registerForTopNotificationsChanges()
|
||||||
registerForWebpageNavigation()
|
registerForWebpageNavigation()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +143,7 @@ open class AccessibilityHandler {
|
|||||||
|
|
||||||
private func registerForWebpageNavigation() {
|
private func registerForWebpageNavigation() {
|
||||||
webPageNavigated.sink { [weak self] _ in
|
webPageNavigated.sink { [weak self] _ in
|
||||||
self?.post(notification: .controllerChanged, argument: self?.getFirstFocusedElementOnScreen())
|
self?.post(notification: .layoutChanged, argument: self?.getFirstFocusedElementOnScreen())
|
||||||
}.store(in: &anyCancellable)
|
}.store(in: &anyCancellable)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +155,7 @@ open class AccessibilityHandler {
|
|||||||
accessibilityOperationQueue.cancelAllOperations()
|
accessibilityOperationQueue.cancelAllOperations()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func post(notification type: AccessibilityNotificationType, argument: Any?) {
|
public func post(notification type: AccessibilityNotificationType, argument: Any? = nil) {
|
||||||
guard UIAccessibility.isVoiceOverRunning else { return }
|
guard UIAccessibility.isVoiceOverRunning else { return }
|
||||||
let accessbilityOperation = AccessbilityOperation(notificationType: type, argument: argument)
|
let accessbilityOperation = AccessbilityOperation(notificationType: type, argument: argument)
|
||||||
add(operation: accessbilityOperation)
|
add(operation: accessbilityOperation)
|
||||||
@ -168,16 +170,17 @@ extension AccessibilityHandler: MVMCorePresentationDelegateProtocol {
|
|||||||
|
|
||||||
public func navigationController(_ navigationController: UINavigationController, prepareDisplayFor viewController: UIViewController) {
|
public func navigationController(_ navigationController: UINavigationController, prepareDisplayFor viewController: UIViewController) {
|
||||||
delegate = viewController as? MVMCoreViewControllerProtocol
|
delegate = viewController as? MVMCoreViewControllerProtocol
|
||||||
operationType = navigationController.viewControllers.contains(viewController) ? .pop : .push
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) {
|
public func navigationController(_ navigationController: UINavigationController, displayedViewController viewController: UIViewController) {
|
||||||
//TODO: - For push operation we are posting accessibility notification to the top left item or the identified accessibility element from pageJSON. Need to check the logic for pop operation
|
|
||||||
guard UIAccessibility.isVoiceOverRunning,
|
guard UIAccessibility.isVoiceOverRunning,
|
||||||
operationType == .push,
|
|
||||||
canPostAccessbilityNotification(for: viewController) else { return }
|
canPostAccessbilityNotification(for: viewController) else { return }
|
||||||
|
var navigationOperationType: NavigationType = .push
|
||||||
|
if let presentationStyle = delegate?.loadObject??.pageJSON?.optionalStringForKey(KeyPresentationStyle) ?? delegate?.loadObject??.requestParameters?.actionMap?.optionalStringForKey(KeyPresentationStyle), presentationStyle == "root" {
|
||||||
|
navigationOperationType = .set //TODO: - For Tabbar change: adding 1.5 sec delay to shift focus to the top.
|
||||||
|
}
|
||||||
let accessbilityElement = getAccessbilityFocusedElement()
|
let accessbilityElement = getAccessbilityFocusedElement()
|
||||||
post(notification: .controllerChanged, argument: accessbilityElement ?? getFirstFocusedElementOnScreen())
|
post(notification: navigationOperationType == .set ? .controllerChanged : .layoutChanged, argument: accessbilityElement ?? getFirstFocusedElementOnScreen())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +193,6 @@ extension AccessibilityHandler {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return (delegate as? UIViewController)?.view?.getMoleculeViews { (subView: MoleculeViewProtocol) in
|
return (delegate as? UIViewController)?.view?.getMoleculeViews { (subView: MoleculeViewProtocol) in
|
||||||
print("subview: \(subView)")
|
|
||||||
guard let moleculeModel = (subView as? MoleculeViewModelProtocol)?.getMoleculeModel() as? (any AccessibilityElementProtocol),
|
guard let moleculeModel = (subView as? MoleculeViewModelProtocol)?.getMoleculeModel() as? (any AccessibilityElementProtocol),
|
||||||
moleculeModel.id == (accessibilityModel as? (any AccessibilityElementProtocol))?.id else {
|
moleculeModel.id == (accessibilityModel as? (any AccessibilityElementProtocol))?.id else {
|
||||||
return false
|
return false
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user