From af83f4f8b5e2dcceda85db03665ac45ec915c927 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Fri, 18 Dec 2020 14:47:11 -0500 Subject: [PATCH] formatting. json. updates. --- MVMCoreUI.xcodeproj/project.pbxproj | 4 ++-- MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift | 1 + .../TextFields/TextViewEntryField.swift | 3 ++- .../Atoms/{Views => Selectors}/Toggle.swift | 18 ++++++------------ .../{Views => Selectors}/ToggleModel.swift | 10 +++++----- .../Label/LabelAttributeActionModel.swift | 4 +--- .../Views/Label/LabelAttributeColorModel.swift | 4 +--- .../Views/Label/LabelAttributeFontModel.swift | 4 +--- .../Views/Label/LabelAttributeImageModel.swift | 4 +--- .../Views/Label/LabelAttributeModel.swift | 4 +--- .../LabelAttributeStrikeThroughModel.swift | 4 +--- .../Label/LabelAttributeUnderlineModel.swift | 4 +--- 12 files changed, 23 insertions(+), 41 deletions(-) rename MVMCoreUI/Atomic/Atoms/{Views => Selectors}/Toggle.swift (98%) rename MVMCoreUI/Atomic/Atoms/{Views => Selectors}/ToggleModel.swift (93%) diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 9194a70a..ed3f746f 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -1707,6 +1707,8 @@ D2092348244A51D40044AD09 /* RadioSwatchModel.swift */, AAB9C109243496DD00151545 /* RadioSwatch.swift */, AA85236B244435A20059CC1E /* RadioSwatchCollectionViewCell.swift */, + D260105223CEA61600764D80 /* ToggleModel.swift */, + 0AA33B392398524F0067DD0F /* Toggle.swift */, AAA7CD68250641F90045B959 /* HeartModel.swift */, AAA7CD6A250642080045B959 /* Heart.swift */, ); @@ -2004,8 +2006,6 @@ D28A838223CCBD3F00DFE4FC /* WheelModel.swift */, 943784F3236B77BB006A1E82 /* Wheel.swift */, 943784F4236B77BB006A1E82 /* WheelAnimationHandler.swift */, - D260105223CEA61600764D80 /* ToggleModel.swift */, - 0AA33B392398524F0067DD0F /* Toggle.swift */, 0AE98BB623FF18E9004C5109 /* ArrowModel.swift */, 0AE98BB423FF18D2004C5109 /* Arrow.swift */, 94382085243238D100B43AF3 /* WebViewModel.swift */, diff --git a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift index 5ae68241..633eecc7 100644 --- a/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift +++ b/MVMCoreUI/Atomic/Atoms/Buttons/CaretLink.swift @@ -142,6 +142,7 @@ open class CaretLink: Button, MVMCoreUIViewConstrainingProtocol { backgroundColor = color.uiColor } + accessibilityIdentifier = model.accessibilityIdentifier enabledColor = (model.inverted ? model.enabledColor_inverted : model.enabledColor).uiColor disabledColor = (model.inverted ? model.disabledColor_inverted : model.disabledColor).uiColor diff --git a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift index 54234d16..b964ee8c 100644 --- a/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift +++ b/MVMCoreUI/Atomic/Atoms/FormFields/TextFields/TextViewEntryField.swift @@ -241,6 +241,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele textView.isEditable = model.editable textView.textAlignment = model.textAlignment + textView.accessibilityIdentifier = model.accessibilityIdentifier textView.textColor = model.enabled ? model.enabledTextColor.uiColor : model.disabledTextColor.uiColor textView.font = model.fontStyle.getFont() textView.placeholder = model.placeholder ?? "" @@ -258,7 +259,7 @@ class TextViewEntryField: EntryField, UITextViewDelegate, ObservingTextFieldDele case .email: textView.keyboardType = .emailAddress - default: break + default: break } /// No point in configuring if the TextView is Read-only. diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift similarity index 98% rename from MVMCoreUI/Atomic/Atoms/Views/Toggle.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift index 5712695b..f32ecbbe 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/Toggle.swift @@ -40,7 +40,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) /// Executes logic before state change. If false, then toggle state will not change and the didToggleAction will not execute. public var shouldToggleAction: ActionBlockConfirmation? = { - return { return true } + return { true } }() // Sizes are from InVision design specs. @@ -69,9 +69,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) /// Simple means to prevent user interaction with the toggle. public var isLocked: Bool = false { - didSet { - isUserInteractionEnabled = !isLocked - } + didSet { isUserInteractionEnabled = !isLocked } } /// The state on the toggle. Default value: false. @@ -109,7 +107,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) } public var toggleModel: ToggleModel? { - return model as? ToggleModel + model as? ToggleModel } //-------------------------------------------------- @@ -414,18 +412,14 @@ public typealias ActionBlockConfirmation = () -> (Bool) } public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? { - return Self.getContainerHeight() + Self.getContainerHeight() } } // MARK: - MVMCoreUIViewConstrainingProtocol extension Toggle { - public func needsToBeConstrained() -> Bool { - return true - } + public func needsToBeConstrained() -> Bool { true } - public func horizontalAlignment() -> UIStackView.Alignment { - return .trailing - } + public func horizontalAlignment() -> UIStackView.Alignment { .trailing } } diff --git a/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift similarity index 93% rename from MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift rename to MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift index b39003d2..4990df73 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/ToggleModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Selectors/ToggleModel.swift @@ -6,8 +6,6 @@ // Copyright © 2020 Verizon Wireless. All rights reserved. // -import UIKit - public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableModelProtocol { //-------------------------------------------------- @@ -15,6 +13,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo //-------------------------------------------------- public static var identifier: String = "toggle" + public var accessibilityIdentifier: String? public var backgroundColor: Color? public var state: Bool = false public var animated: Bool = true @@ -42,6 +41,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo case enabled case action case backgroundColor + case accessibilityIdentifier case alternateAction case accessibilityText case onTintColor @@ -56,9 +56,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo // MARK: - Methods //-------------------------------------------------- - public func formFieldValue() -> AnyHashable? { - return state - } + public func formFieldValue() -> AnyHashable? { state } //-------------------------------------------------- // MARK: - Initializer @@ -91,6 +89,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo action = try typeContainer.decodeModelIfPresent(codingKey: .action) alternateAction = try typeContainer.decodeModelIfPresent(codingKey: .alternateAction) backgroundColor = try typeContainer.decodeIfPresent(Color.self, forKey: .backgroundColor) + accessibilityIdentifier = try typeContainer.decodeIfPresent(String.self, forKey: .accessibilityIdentifier) if let onTintColor = try typeContainer.decodeIfPresent(Color.self, forKey: .onTintColor) { self.onTintColor = onTintColor @@ -120,6 +119,7 @@ public class ToggleModel: MoleculeModelProtocol, FormFieldProtocol, EnableableMo public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encodeIfPresent(backgroundColor, forKey: .backgroundColor) + try container.encodeIfPresent(accessibilityIdentifier, forKey: .accessibilityIdentifier) try container.encodeModelIfPresent(action, forKey: .action) try container.encodeModelIfPresent(alternateAction, forKey: .alternateAction) try container.encode(moleculeName, forKey: .moleculeName) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeActionModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeActionModel.swift index f9920dcc..1ecbe874 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeActionModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeActionModel.swift @@ -12,9 +12,7 @@ open class LabelAttributeActionModel: LabelAttributeModel { // MARK: - Properties //-------------------------------------------------- - override public class var identifier: String { - return "action" - } + override public class var identifier: String { "action" } var action: ActionModelProtocol diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift index b86251c3..94579d02 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeColorModel.swift @@ -12,9 +12,7 @@ // MARK: - Properties //-------------------------------------------------- - override public class var identifier: String { - return "color" - } + override public class var identifier: String { "color" } var textColor: Color? diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift index 59dbac3d..72d57e40 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeFontModel.swift @@ -12,9 +12,7 @@ // MARK: - Properties //-------------------------------------------------- - override public class var identifier: String { - return "font" - } + override public class var identifier: String { "font" } var style: Styler.Font? var name: String? diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift index 70cd90fd..12e8d68d 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeImageModel.swift @@ -12,9 +12,7 @@ class LabelAttributeImageModel: LabelAttributeModel { // MARK: - Properties //-------------------------------------------------- - override public class var identifier: String { - return "image" - } + override public class var identifier: String { "image" } var size: CGFloat? var name: String? diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift index 4c456a67..7df4097a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeModel.swift @@ -12,9 +12,7 @@ // MARK: - Properties //-------------------------------------------------- - public static var categoryName: String { - "\(LabelAttributeModel.self)" - } + public static var categoryName: String { "\(LabelAttributeModel.self)" } public static var categoryCodingKey: String { "type" } diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift index e84c1804..83744a68 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeStrikeThroughModel.swift @@ -12,9 +12,7 @@ // MARK: - Properties //-------------------------------------------------- - override public class var identifier: String { - return "strikethrough" - } + override public class var identifier: String { "strikethrough" } //-------------------------------------------------- // MARK: - Initializer diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift index a3adbe00..f3578418 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/LabelAttributeUnderlineModel.swift @@ -14,9 +14,7 @@ import UIKit // MARK: - Properties //-------------------------------------------------- - override public class var identifier: String { - return "underline" - } + override public class var identifier: String { "underline" } /// This returns the NSUnderlineStyle used in NSAttributedValue. If there is a pattern, it will return /// a new NSUnderlineStyle derived from the bitmask of style | pattern.