From 83d0786597861f9990bc6e44d0ee0f7b8d954f0c Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 2 Dec 2020 11:40:36 -0500 Subject: [PATCH] updates made. --- .../Atoms/Views/Label/LabelAttributeModel.swift | 12 ++++-------- .../ModelProtocols/MoleculeModelProtocol.swift | 12 +++++++++--- MVMCoreUI/BaseClasses/View.swift | 14 +++++++------- MVMCoreUI/Behaviors/PageBehavior.swift | 11 ++++------- .../FormUIHelpers/Rules/Rules/RulesProtocol.swift | 8 +++----- 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift index ae5f15b7..4c456a67 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift @@ -13,19 +13,15 @@ //-------------------------------------------------- public static var categoryName: String { - return "\(LabelAttributeModel.self)" + "\(LabelAttributeModel.self)" } - public static var categoryCodingKey: String { - return "type" - } + public static var categoryCodingKey: String { "type" } - public class var identifier: String { - return "" - } + public class var identifier: String { "" } var type: String { - get { return Self.identifier } + get { Self.identifier } } var location: Int diff --git a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift index dda19b35..1fdc22ad 100644 --- a/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift +++ b/MVMCoreUI/Atomic/Protocols/ModelProtocols/MoleculeModelProtocol.swift @@ -10,19 +10,25 @@ public enum MolecularError: Swift.Error { public protocol MoleculeModelProtocol: ModelProtocol { var moleculeName: String { get } var backgroundColor: Color? { get set } + var accessibilityIdentifier: String? { get set } } public extension MoleculeModelProtocol { var moleculeName: String { - get { return Self.identifier } + get { Self.identifier } + } + + var accessibilityIdentifier: String? { + get { nil } + set { } } static var categoryName: String { - return "\(MoleculeModelProtocol.self)" + "\(MoleculeModelProtocol.self)" } static var categoryCodingKey: String { - return "moleculeName" + "moleculeName" } } diff --git a/MVMCoreUI/BaseClasses/View.swift b/MVMCoreUI/BaseClasses/View.swift index cfb6ff1f..688fe28c 100644 --- a/MVMCoreUI/BaseClasses/View.swift +++ b/MVMCoreUI/BaseClasses/View.swift @@ -58,6 +58,10 @@ import UIKit if let backgroundColor = model.backgroundColor { self.backgroundColor = backgroundColor.uiColor } + + if let identifier = model.accessibilityIdentifier { + accessibilityIdentifier = identifier + } } open func reset() { @@ -67,16 +71,12 @@ import UIKit // MARK: Overridables // Base classes need to implement these functions otherwise swift won't respect the subclass functions and use the ones in the protocol extension instead. open class func nameForReuse(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> String? { - return model.moleculeName + model.moleculeName } - open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return nil - } + open class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { nil } - open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { - return nil - } + open class func requiredModules(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer?) -> [String]? { nil } } // MARK:- MVMCoreViewProtocol diff --git a/MVMCoreUI/Behaviors/PageBehavior.swift b/MVMCoreUI/Behaviors/PageBehavior.swift index d8fd99a3..9e52f778 100644 --- a/MVMCoreUI/Behaviors/PageBehavior.swift +++ b/MVMCoreUI/Behaviors/PageBehavior.swift @@ -10,23 +10,22 @@ import Foundation public protocol PageBehaviorProtocol: ModelProtocol { - // The type of rule + /// The type of rule var behaviorName: String { get } - } public extension PageBehaviorProtocol { var behaviorName: String { - get { return Self.identifier } + get { Self.identifier } } static var categoryCodingKey: String { - return "behaviorName" + "behaviorName" } static var categoryName: String { - return "\(PageBehaviorProtocol.self)" + "\(PageBehaviorProtocol.self)" } } @@ -34,11 +33,9 @@ public protocol PageVisibilityBehavior: PageBehaviorProtocol { func onPageShown() func onPageHidden() - } public protocol PageBehaviorsTemplateProtocol { var behaviors: [PageBehaviorProtocol]? { get } - } diff --git a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift index 7392ea8f..04259dbc 100644 --- a/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift +++ b/MVMCoreUI/FormUIHelpers/Rules/Rules/RulesProtocol.swift @@ -32,15 +32,13 @@ public protocol RulesProtocol: ModelProtocol { public extension RulesProtocol { var type: String { - get { return Self.identifier } + get { Self.identifier } } - static var categoryCodingKey: String { - return "type" - } + static var categoryCodingKey: String { "type" } static var categoryName: String { - return "\(RulesProtocol.self)" + "\(RulesProtocol.self)" } // Individual rule can override the function to validate based on the rule type.