From 347ebbed8c8fbbf5c614b84da87446ecc9b2a273 Mon Sep 17 00:00:00 2001 From: "Pfeil, Scott Robert" Date: Thu, 7 Nov 2019 10:05:17 -0500 Subject: [PATCH] typo fixes --- MVMCoreUI/Atoms/Views/ViewConstrainingView.h | 2 +- MVMCoreUI/Atoms/Views/ViewConstrainingView.m | 2 +- MVMCoreUI/Models/Encoder.swift | 4 ++-- MVMCoreUI/Models/HolderManager.swift | 4 ++-- MVMCoreUI/Models/JSON/JSONValue.swift | 6 +++--- .../Models/Molecules/ActionMapModel.swift | 2 +- MVMCoreUI/Models/Molecules/HeaderModel.swift | 2 +- .../Models/Molecules/HeadlineBodyModel.swift | 2 +- MVMCoreUI/Models/Molecules/ListItemModel.swift | 2 +- .../Molecules/MoleculeStackItemModel.swift | 2 +- .../Models/Molecules/MoleculeStackModel.swift | 4 ++-- .../Models/Molecules/SeperatorModel.swift | 6 +++--- MVMCoreUI/Models/PageModel.swift | 2 +- .../Molecules/MVMCoreUIMoleculeViewProtocol.h | 1 - MVMCoreUI/Molecules/MoleculeViewProtocol.swift | 1 - MVMCoreUI/Molecules/StandardHeaderView.swift | 2 +- ...IMoleculeMappingObject+ModelExtension.swift | 18 +++++++++--------- ...eUIMoleculeMappingObject+ModelMapping.swift | 2 +- .../MVMCoreUIMoleculeMappingObject.m | 8 +++++++- 19 files changed, 38 insertions(+), 34 deletions(-) diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h index df443afd..c10768b0 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.h +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.h @@ -50,7 +50,7 @@ + (nonnull ViewConstrainingView *)viewConstrainingView:(nonnull UIView *)view; // Can be initialized with a molecule to constrain -- (nullable instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment; +- (nonnull instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment; #pragma mark - Constraining diff --git a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m index 66a3a83d..57e54983 100644 --- a/MVMCoreUI/Atoms/Views/ViewConstrainingView.m +++ b/MVMCoreUI/Atoms/Views/ViewConstrainingView.m @@ -23,7 +23,7 @@ @implementation ViewConstrainingView -- (nullable instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment { +- (nonnull instancetype)initWithMolecule:(nonnull UIView *)molecule alignment:(UIStackViewAlignment)alignment { if (self = [super init]) { if (!molecule.superview) { [self addConstrainedView:molecule alignment:alignment]; diff --git a/MVMCoreUI/Models/Encoder.swift b/MVMCoreUI/Models/Encoder.swift index c8c441fd..0a236a52 100644 --- a/MVMCoreUI/Models/Encoder.swift +++ b/MVMCoreUI/Models/Encoder.swift @@ -13,12 +13,12 @@ extension Encodable { } public func toJSON() -> JSONObject? { - guard let data = try? self.encode() else { return nil } + guard let data = try? encode() else { return nil } return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments)).flatMap { $0 as? JSONObject } } public func toJSONString() -> String? { - guard let data = try? self.encode(), + guard let data = try? encode(), let string = String(data: data, encoding: .utf8) else { return nil } diff --git a/MVMCoreUI/Models/HolderManager.swift b/MVMCoreUI/Models/HolderManager.swift index 44059145..4101aa95 100644 --- a/MVMCoreUI/Models/HolderManager.swift +++ b/MVMCoreUI/Models/HolderManager.swift @@ -69,8 +69,8 @@ extension Holder { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() - guard let encode = HolderManager.encoders[self.name], - let holdable = self.object as? Holdable else{ + guard let encode = HolderManager.encoders[name], + let holdable = object as? Holdable else { throw HolderManager.Error.encoderError } try encode(holdable, &container) diff --git a/MVMCoreUI/Models/JSON/JSONValue.swift b/MVMCoreUI/Models/JSON/JSONValue.swift index 0a9061b9..38f4e613 100644 --- a/MVMCoreUI/Models/JSON/JSONValue.swift +++ b/MVMCoreUI/Models/JSON/JSONValue.swift @@ -3,7 +3,7 @@ import Foundation public typealias JSONValueArray = [[String: JSONValue]] public typealias JSONValueObject = [String: JSONValue] -public enum JSONValueError: Error{ +public enum JSONValueError: Error { case encode } @@ -105,14 +105,14 @@ extension JSONValue: ExpressibleByDictionaryLiteral { } extension Dictionary where Key == String, Value == Any { - public func toJSONValue() throws -> [String:JSONValue]{ + public func toJSONValue() throws -> [String: JSONValue] { let data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted) return try JSONDecoder().decode([String:JSONValue].self, from: data) } } extension Dictionary where Key == String, Value == JSONValue { - public func toJSONObject() throws -> JSONObject{ + public func toJSONObject() throws -> JSONObject { let encoded = try JSONEncoder().encode(self) guard let json = try JSONSerialization.jsonObject(with: encoded, options: .mutableContainers) as? JSONObject else { throw JSONValueError.encode diff --git a/MVMCoreUI/Models/Molecules/ActionMapModel.swift b/MVMCoreUI/Models/Molecules/ActionMapModel.swift index 8e2cc133..3f46db29 100644 --- a/MVMCoreUI/Models/Molecules/ActionMapModel.swift +++ b/MVMCoreUI/Models/Molecules/ActionMapModel.swift @@ -12,7 +12,7 @@ import Foundation public var actionType: String? public var pageType: String? - public init(actionType: String?, pageType: String?){ + public init(actionType: String?, pageType: String?) { self.actionType = actionType self.pageType = pageType } diff --git a/MVMCoreUI/Models/Molecules/HeaderModel.swift b/MVMCoreUI/Models/Molecules/HeaderModel.swift index 98c80e4e..f1224810 100644 --- a/MVMCoreUI/Models/Molecules/HeaderModel.swift +++ b/MVMCoreUI/Models/Molecules/HeaderModel.swift @@ -14,7 +14,7 @@ import Foundation public var molecule: MoleculeHolder? public var seperator: MoleculeHolder? - public init(molecule: MoleculeHolder?){ + public init(molecule: MoleculeHolder?) { self.molecule = molecule self.moleculeName = Self.identifier } diff --git a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift index c80991ba..557e74ba 100644 --- a/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift +++ b/MVMCoreUI/Models/Molecules/HeadlineBodyModel.swift @@ -13,7 +13,7 @@ import Foundation public var moleculeName: String? public var headline: LabelModel? - public init(headline: LabelModel?){ + public init(headline: LabelModel?) { self.headline = headline self.moleculeName = Self.identifier } diff --git a/MVMCoreUI/Models/Molecules/ListItemModel.swift b/MVMCoreUI/Models/Molecules/ListItemModel.swift index 6b1ceade..a1d297fb 100644 --- a/MVMCoreUI/Models/Molecules/ListItemModel.swift +++ b/MVMCoreUI/Models/Molecules/ListItemModel.swift @@ -14,7 +14,7 @@ import Foundation public var molecule: MoleculeHolder? public var actionMap: ActionMapModel? - public init(molecule: MoleculeHolder?, actionMap: ActionMapModel?){ + public init(molecule: MoleculeHolder?, actionMap: ActionMapModel?) { self.molecule = molecule self.actionMap = actionMap self.moleculeName = Self.identifier diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift index cb590493..3b60f0c1 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackItemModel.swift @@ -13,7 +13,7 @@ import Foundation public var moleculeName: String? public var molecule: MoleculeHolder? - public init(molecule: MoleculeHolder?){ + public init(molecule: MoleculeHolder?) { self.molecule = molecule self.moleculeName = Self.identifier } diff --git a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift index 5dfda19c..c1a223ff 100644 --- a/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift +++ b/MVMCoreUI/Models/Molecules/MoleculeStackModel.swift @@ -8,13 +8,13 @@ import Foundation -@objcMembers public class MoleculeStackModel: MoleculeProtocol{ +@objcMembers public class MoleculeStackModel: MoleculeProtocol { public static var identifier: String = "moleculeStack" public var moleculeName: String? public var molecules: [MoleculeStackItemModel]? public var axis: String? - public init(axis: String?, molecules: [MoleculeStackItemModel]?){ + public init(axis: String?, molecules: [MoleculeStackItemModel]?) { self.axis = axis self.molecules = molecules self.moleculeName = Self.identifier diff --git a/MVMCoreUI/Models/Molecules/SeperatorModel.swift b/MVMCoreUI/Models/Molecules/SeperatorModel.swift index f58f8da1..6266b03e 100644 --- a/MVMCoreUI/Models/Molecules/SeperatorModel.swift +++ b/MVMCoreUI/Models/Molecules/SeperatorModel.swift @@ -1,5 +1,5 @@ // -// SeperatorModel.swift +// LineModel.swift // MVMCoreUI // // Created by Suresh, Kamlesh on 10/28/19. @@ -8,8 +8,8 @@ import UIKit -@objcMembers public class SeperatorModel: MoleculeProtocol { - public static var identifier: String = "seperator" +@objcMembers public class LineModel: MoleculeProtocol { + public static var identifier: String = "line" public var moleculeName: String? public var type: String? diff --git a/MVMCoreUI/Models/PageModel.swift b/MVMCoreUI/Models/PageModel.swift index b23cade8..ac2a4a15 100644 --- a/MVMCoreUI/Models/PageModel.swift +++ b/MVMCoreUI/Models/PageModel.swift @@ -12,7 +12,7 @@ import UIKit public var template: String? public var pageType: String? public var screenHeading: String? - public var isAtomicTabs: Bool = false + public var isAtomicTabs: Bool? = false public var header: HeaderModel? public var molecules: [ListItemModel]? } diff --git a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h index e70c750a..2c52324b 100644 --- a/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h +++ b/MVMCoreUI/Molecules/MVMCoreUIMoleculeViewProtocol.h @@ -8,7 +8,6 @@ #import @import MVMCore.MVMCoreViewProtocol; -//@import MVMCoreUI.Swift; @class MVMCoreUIDelegateObject; @class MVMCoreErrorObject; @class MoleculeProtocol; diff --git a/MVMCoreUI/Molecules/MoleculeViewProtocol.swift b/MVMCoreUI/Molecules/MoleculeViewProtocol.swift index af1d09b4..63fff68c 100644 --- a/MVMCoreUI/Molecules/MoleculeViewProtocol.swift +++ b/MVMCoreUI/Molecules/MoleculeViewProtocol.swift @@ -10,7 +10,6 @@ import Foundation import UIKit import MVMCore.MVMCoreViewProtocol -//@import MVMCoreUI.Swift; @objc public protocol MoleculeViewProtocol: MVMCoreViewProtocol { diff --git a/MVMCoreUI/Molecules/StandardHeaderView.swift b/MVMCoreUI/Molecules/StandardHeaderView.swift index 91c3cc99..435d8e02 100644 --- a/MVMCoreUI/Molecules/StandardHeaderView.swift +++ b/MVMCoreUI/Molecules/StandardHeaderView.swift @@ -67,7 +67,7 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol return } - if let seperatorModel = headerModel.seperator?.object as? SeperatorModel { + if let seperatorModel = headerModel.seperator?.object as? LineModel { separatorView?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData) } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift index 1d3316fb..9fd6c0ca 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelExtension.swift @@ -8,7 +8,6 @@ import Foundation - public extension MVMCoreUIMoleculeMappingObject { func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { @@ -17,11 +16,11 @@ public extension MVMCoreUIMoleculeMappingObject { func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { guard let moleculeName = model.moleculeName, - let molecule = createMolecule(forName: moleculeName) as? MVMCoreUIViewConstrainingProtocol & UIView & MVMCoreUIMoleculeViewProtocol else { + let molecule = createMolecule(forName: moleculeName) else { return nil } - let setData = {() in + let setData = {(molecule: UIView & MVMCoreUIMoleculeViewProtocol) in if let molecule = molecule as? ModelMoleculeViewProtocol { molecule.setWithModel(model, delegateObject, nil) } else { @@ -29,12 +28,13 @@ public extension MVMCoreUIMoleculeMappingObject { } } - if constrainIfNeeded, molecule.needsToBeConstrained?() ?? false { - let viewConstrainingView = ViewConstrainingView(molecule: molecule, alignment: molecule.alignment?() ?? .fill) - setData() - return viewConstrainingView + if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol, castMolecule.needsToBeConstrained?() ?? false { + let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.alignment?() ?? .fill) + setData(view) + return view + } else { + setData(molecule) + return molecule } - setData() - return molecule } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift index c30c68d6..c9510436 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject+ModelMapping.swift @@ -17,6 +17,6 @@ import Foundation HolderManager.register(ListItemModel.self) HolderManager.register(MoleculeStackItemModel.self) HolderManager.register(TextFieldModel.self) - HolderManager.register(SeperatorModel.self) + HolderManager.register(LineModel.self) } } diff --git a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m index 7fcea605..28471139 100644 --- a/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m +++ b/MVMCoreUI/OtherHandlers/MVMCoreUIMoleculeMappingObject.m @@ -73,10 +73,16 @@ } + (nullable instancetype)sharedMappingObject { - [MVMCoreUIMoleculeMappingObject registerObjects]; return [MVMCoreActionUtility initializerClassCheck:[MVMCoreUIObject sharedInstance].moleculeMap classToVerify:self]; } +- (instancetype)init { + if (self = [super init]) { + [MVMCoreUIMoleculeMappingObject registerObjects]; + } + return self; +} + - (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json { NSString *moleculeName = [json string:KeyMoleculeName]; if (moleculeName) {