From 67dfe37e97dd9c0cfe25a2e70a0c3f84b0ec3d33 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Mon, 16 Oct 2023 12:49:35 +0530 Subject: [PATCH] Addressed review comments and removed model based traits for button --- .../Accessibility/AccessibilityHandler.swift | 2 +- MVMCoreUI/Accessibility/RotorHandler.swift | 17 ++++++++--------- .../Atomic/Atoms/Buttons/ButtonModel.swift | 3 --- MVMCoreUI/BaseClasses/Button.swift | 4 ---- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/MVMCoreUI/Accessibility/AccessibilityHandler.swift b/MVMCoreUI/Accessibility/AccessibilityHandler.swift index 327681e8..cefae3ea 100644 --- a/MVMCoreUI/Accessibility/AccessibilityHandler.swift +++ b/MVMCoreUI/Accessibility/AccessibilityHandler.swift @@ -59,7 +59,7 @@ open class AccessibilityHandler { public var anyCancellable: Set = [] public weak var delegate: MVMCoreViewControllerProtocol? { delegateObject?.moleculeDelegate as? MVMCoreViewControllerProtocol } public weak var delegateObject: MVMCoreUIDelegateObject? - private var hasTopNotificationInPage: Bool { delegate?.loadObject??.responseJSON?.optionalDictionaryForKey("TopNotification") != nil || delegate?.loadObject??.responseInfoMap?.optionalStringForKey("userMessage") != nil } + private var hasTopNotificationInPage: Bool { delegate?.loadObject??.responseJSON?.optionalDictionaryForKey("TopNotification") != nil || delegate?.loadObject??.responseInfoMap?.optionalStringForKey("messageStyle") != nil } private let accessibilityOperationQueue: OperationQueue = { let queue = OperationQueue() queue.maxConcurrentOperationCount = 1 diff --git a/MVMCoreUI/Accessibility/RotorHandler.swift b/MVMCoreUI/Accessibility/RotorHandler.swift index 98841cc0..2d4b6e9c 100644 --- a/MVMCoreUI/Accessibility/RotorHandler.swift +++ b/MVMCoreUI/Accessibility/RotorHandler.swift @@ -125,7 +125,7 @@ class RotorHandler { private func getRotorElementsFrom(template: (MVMCoreViewControllerProtocol & UIViewController)?, type: RotorType) -> [Any]? { guard let template = template as? (RotorViewElementsProtocol & MVMCoreViewControllerProtocol & UIViewController) else { - return MVMCoreUIUtility.findViews(by: UIView.self, views: [template?.view].compactMap { $0 }).filter { $0.accessibilityTraits.contains(type.trait) } as [Any] //BAU Pages + return MVMCoreUIUtility.findViews(by: UIView.self, views: [template?.view].compactMap { $0 }).filter { $0.accessibilityTraits.contains(type.trait) } as [Any] } let topViewRotorElements = MVMCoreUIUtility.findViews(by: UIView.self, views: [template.topView].compactMap { $0 }).filter { $0.accessibilityTraits.contains(type.trait) } as [Any] var reusableViewRotorElements: [Any] = [] @@ -163,19 +163,18 @@ class RotorHandler { private func createRotor(for type: RotorType) -> UIAccessibilityCustomRotor? { return type.getUIAccessibilityCustomRotor { [weak self] predicate in guard let self, let elements = self.rotorElements[type] else { return UIAccessibilityCustomRotorItemResult() } - var rotorIndex = self.rotorIndexes[type] ?? 0 + var rotorIndex = self.rotorIndexes[type] ?? -1 if predicate.searchDirection == .next { - rotorIndex += 1 - if rotorIndex > elements.count { - rotorIndex = 1 + if rotorIndex + 1 < elements.count { + rotorIndex += 1 } } else { - rotorIndex -= 1 - if rotorIndex <= 0 { - rotorIndex = elements.count + if rotorIndex > 0 { + rotorIndex -= 1 } } - var rotorElement = elements[rotorIndex - 1] + guard rotorIndex >= 0 else { return UIAccessibilityCustomRotorItemResult() } + var rotorElement = elements[rotorIndex] if let element = rotorElement as? RotorElement, let controller = self.delegate as? RotorListTypeDelegateProtocol { controller.scrollToRow(at: element.indexPath, at: .middle, animated: false) diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift index 92b50d29..08afefde 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/ButtonModel.swift @@ -35,7 +35,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat public var size: Styler.Button.Size? = .standard public var groupName: String = "" public var inverted: Bool = false - public var accessibilityTraits: UIAccessibilityTraits? public lazy var enabledColors: FacadeElements = (fill: enabled_fillColor(), text: enabled_textColor(), @@ -196,7 +195,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat case disabledTextColor case disabledBorderColor case width - case accessibilityTraits } //-------------------------------------------------- @@ -209,7 +207,6 @@ open class ButtonModel: ButtonModelProtocol, MoleculeModelProtocol, FormGroupWat id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) accessibilityText = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityText) - accessibilityTraits = try typeContainer.decodeIfPresent(UIAccessibilityTraits.self, forKey: .accessibilityTraits) title = try typeContainer.decode(String.self, forKey: .title) action = try typeContainer.decodeModel(codingKey: .action) diff --git a/MVMCoreUI/BaseClasses/Button.swift b/MVMCoreUI/BaseClasses/Button.swift index f4c7c418..15ea1e03 100644 --- a/MVMCoreUI/BaseClasses/Button.swift +++ b/MVMCoreUI/BaseClasses/Button.swift @@ -107,10 +107,6 @@ public typealias ButtonAction = (Button) -> () isEnabled = model.enabled } - if let accessibilityTraits = model.accessibilityTraits { - self.accessibilityTraits = accessibilityTraits - } - guard let model = model as? ButtonModelProtocol else { return } set(with: model.action, delegateObject: delegateObject, additionalData: additionalData)