removed unused code & added support for predefinedfocused elements from server
This commit is contained in:
parent
32ba75e731
commit
e9dc771eea
@ -65,9 +65,9 @@ open class AccessibilityHandler {
|
|||||||
queue.maxConcurrentOperationCount = 1
|
queue.maxConcurrentOperationCount = 1
|
||||||
return queue
|
return queue
|
||||||
}()
|
}()
|
||||||
private var accessibilityId: String?
|
private(set) var accessibilityId: String?
|
||||||
private var announcementText: String?
|
private var announcementText: String?
|
||||||
private var hasTopNotitificationInPage: Bool = false
|
private(set) var hasTopNotitificationInPage: Bool = false
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
registerWithResponseLoaded()
|
registerWithResponseLoaded()
|
||||||
@ -121,7 +121,7 @@ open class AccessibilityHandler {
|
|||||||
switch event {
|
switch event {
|
||||||
case .willNavigate:
|
case .willNavigate:
|
||||||
willNavigate(operation)
|
willNavigate(operation)
|
||||||
@unknown default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}.store(in: &anyCancellable)
|
}.store(in: &anyCancellable)
|
||||||
@ -138,22 +138,6 @@ open class AccessibilityHandler {
|
|||||||
delegate = operation.toNavigationControllerViewControllers?.last as? MVMCoreViewControllerProtocol
|
delegate = operation.toNavigationControllerViewControllers?.last as? MVMCoreViewControllerProtocol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private func didNavigate(_ operation: NavigationOperation) {
|
|
||||||
guard UIAccessibility.isVoiceOverRunning,
|
|
||||||
let viewController = operation.toNavigationControllerViewControllers?.last,
|
|
||||||
canPostAccessbilityNotification(for: viewController) else { return }
|
|
||||||
delegate = viewController as? MVMCoreViewControllerProtocol
|
|
||||||
guard let view = operation.toNavigationControllerViewControllers?.last?.view else { return }
|
|
||||||
view.accessibilityElements = getAccessibilityElementsOnScreen()
|
|
||||||
if hasTopNotitificationInPage {
|
|
||||||
previousAccessiblityElement = getFirstFocusedElementOnScreen()
|
|
||||||
} else {
|
|
||||||
let accessbilityElement = getUIElementBasedOn(id: accessibilityId)
|
|
||||||
post(notification: .screenChanged, argument: accessbilityElement ?? getFirstFocusedElementOnScreen())
|
|
||||||
accessibilityId = nil
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// MARK: - Accessibility Handler operation events
|
// MARK: - Accessibility Handler operation events
|
||||||
open func capturePreviousFocusElement() {
|
open func capturePreviousFocusElement() {
|
||||||
@ -210,30 +194,49 @@ struct AccessibilityHandlerBehaviorModel: PageBehaviorModelProtocol {
|
|||||||
|
|
||||||
class AccessibilityHandlerBehavior: PageVisibilityBehavior {
|
class AccessibilityHandlerBehavior: PageVisibilityBehavior {
|
||||||
|
|
||||||
|
private var delegateObj: MVMCoreUIDelegateObject?
|
||||||
|
private var anyCancellable: Set<AnyCancellable> = []
|
||||||
|
|
||||||
required public init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { }
|
required public init(model: PageBehaviorModelProtocol, delegateObject: MVMCoreUIDelegateObject?) { }
|
||||||
|
|
||||||
public func willShowPage(_ delegateObject: MVMCoreUIDelegateObject?) {
|
public func willShowPage(_ delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
let viewController = updateAccessibilityViews(delegateObject)
|
guard let controller = delegateObject?.moleculeDelegate as? UIViewController,
|
||||||
AccessibilityHandler.shared()?.post(notification: .layoutChanged, argument: AccessibilityHandler.shared()?.getPreDefinedFocusedElementIfAny() ?? AccessibilityHandler.shared()?.getFirstFocusedElementOnScreen())
|
(AccessibilityHandler.shared()?.canPostAccessbilityNotification(for: controller) ?? true),
|
||||||
|
AccessibilityHandler.shared()?.accessibilityId == nil else { return }
|
||||||
|
if AccessibilityHandler.shared()?.hasTopNotitificationInPage ?? false {
|
||||||
|
AccessibilityHandler.shared()?.previousAccessiblityElement = AccessibilityHandler.shared()?.getFirstFocusedElementOnScreen()
|
||||||
|
} else {
|
||||||
|
AccessibilityHandler.shared()?.post(notification: .layoutChanged, argument: AccessibilityHandler.shared()?.getFirstFocusedElementOnScreen())
|
||||||
|
}
|
||||||
|
delegateObj = delegateObject
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateAccessibilityViews(_ delegateObject: MVMCoreUIDelegateObject?) -> UIViewController? {
|
///We need to shift focus to any element mentioned in server response i.e to retain focus of the element in new page, from where action is triggered.
|
||||||
var accessibilityElements: [Any?] = [MVMCoreUISplitViewController.main()?.topAlertView, MVMCoreUISplitViewController.main()?.navigationController]
|
///https://oneconfluence.verizon.com/display/MFD/Accessibility+-+Focus+Retain
|
||||||
var viewController: UIViewController?
|
func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
|
updateAccessibilityViews(delegateObject) //To track FAB & HAB elements on UI
|
||||||
|
guard let accessibilityElement = AccessibilityHandler.shared()?.getPreDefinedFocusedElementIfAny() else { return }
|
||||||
|
if AccessibilityHandler.shared()?.hasTopNotitificationInPage ?? false {
|
||||||
|
AccessibilityHandler.shared()?.previousAccessiblityElement = accessibilityElement
|
||||||
|
} else {
|
||||||
|
AccessibilityHandler.shared()?.post(notification: .layoutChanged, argument: accessibilityElement)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateAccessibilityViews(_ delegateObject: MVMCoreUIDelegateObject?) {
|
||||||
|
var accessibilityElements: [Any?] = [MVMCoreUISplitViewController.main()?.topAlertView]
|
||||||
if let managerController = (delegateObject?.moleculeDelegate as? MVMCoreViewManagerViewControllerProtocol)?.manager as? SubNavManagerController {
|
if let managerController = (delegateObject?.moleculeDelegate as? MVMCoreViewManagerViewControllerProtocol)?.manager as? SubNavManagerController {
|
||||||
var managerControllerViews = [Any?]()
|
accessibilityElements.append(managerController.navigationController)
|
||||||
managerControllerViews.append(managerController.navigationController)
|
accessibilityElements.append(managerController.tabs)
|
||||||
managerControllerViews.append(managerController.tabs)
|
accessibilityElements.append(contentsOf: managerController.view.subviews)
|
||||||
managerControllerViews.append(contentsOf: managerController.view.subviews)
|
accessibilityElements.append(MVMCoreUISplitViewController.main()?.tabBar)
|
||||||
managerController.view.accessibilityElements = managerControllerViews.compactMap { $0 }
|
managerController.view.accessibilityElements = accessibilityElements.compactMap { $0 }
|
||||||
} else if let controller = delegateObject?.moleculeDelegate as? UIViewController {
|
} else if let controller = delegateObject?.moleculeDelegate as? UIViewController {
|
||||||
accessibilityElements.append(controller.navigationController)
|
accessibilityElements.append(controller.navigationController)
|
||||||
accessibilityElements.append(contentsOf: controller.view.subviews.reversed())
|
accessibilityElements.append(contentsOf: controller.view.subviews.reversed())
|
||||||
accessibilityElements.append(MVMCoreUISplitViewController.main()?.tabBar)
|
accessibilityElements.append(MVMCoreUISplitViewController.main()?.tabBar)
|
||||||
controller.view.accessibilityElements = accessibilityElements
|
controller.view.accessibilityElements = accessibilityElements.compactMap { $0 }
|
||||||
viewController = controller
|
|
||||||
}
|
}
|
||||||
return viewController
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user