typo fixes

This commit is contained in:
Pfeil, Scott Robert 2019-11-07 10:05:17 -05:00
parent 4a1a196854
commit 347ebbed8c
19 changed files with 38 additions and 34 deletions

View File

@ -50,7 +50,7 @@
+ (nonnull ViewConstrainingView *)viewConstrainingView:(nonnull UIView *)view; + (nonnull ViewConstrainingView *)viewConstrainingView:(nonnull UIView *)view;
// Can be initialized with a molecule to constrain // Can be initialized with a molecule to constrain
- (nullable instancetype)initWithMolecule:(nonnull UIView <MVMCoreUIMoleculeViewProtocol>*)molecule alignment:(UIStackViewAlignment)alignment; - (nonnull instancetype)initWithMolecule:(nonnull UIView <MVMCoreUIMoleculeViewProtocol>*)molecule alignment:(UIStackViewAlignment)alignment;
#pragma mark - Constraining #pragma mark - Constraining

View File

@ -23,7 +23,7 @@
@implementation ViewConstrainingView @implementation ViewConstrainingView
- (nullable instancetype)initWithMolecule:(nonnull UIView <MVMCoreUIMoleculeViewProtocol>*)molecule alignment:(UIStackViewAlignment)alignment { - (nonnull instancetype)initWithMolecule:(nonnull UIView <MVMCoreUIMoleculeViewProtocol>*)molecule alignment:(UIStackViewAlignment)alignment {
if (self = [super init]) { if (self = [super init]) {
if (!molecule.superview) { if (!molecule.superview) {
[self addConstrainedView:molecule alignment:alignment]; [self addConstrainedView:molecule alignment:alignment];

View File

@ -13,12 +13,12 @@ extension Encodable {
} }
public func toJSON() -> JSONObject? { 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 } return (try? JSONSerialization.jsonObject(with: data, options: .allowFragments)).flatMap { $0 as? JSONObject }
} }
public func toJSONString() -> String? { public func toJSONString() -> String? {
guard let data = try? self.encode(), guard let data = try? encode(),
let string = String(data: data, encoding: .utf8) else { let string = String(data: data, encoding: .utf8) else {
return nil return nil
} }

View File

@ -69,8 +69,8 @@ extension Holder {
public func encode(to encoder: Encoder) throws { public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer() var container = encoder.singleValueContainer()
guard let encode = HolderManager.encoders[self.name], guard let encode = HolderManager.encoders[name],
let holdable = self.object as? Holdable else{ let holdable = object as? Holdable else {
throw HolderManager.Error.encoderError throw HolderManager.Error.encoderError
} }
try encode(holdable, &container) try encode(holdable, &container)

View File

@ -3,7 +3,7 @@ import Foundation
public typealias JSONValueArray = [[String: JSONValue]] public typealias JSONValueArray = [[String: JSONValue]]
public typealias JSONValueObject = [String: JSONValue] public typealias JSONValueObject = [String: JSONValue]
public enum JSONValueError: Error{ public enum JSONValueError: Error {
case encode case encode
} }
@ -105,14 +105,14 @@ extension JSONValue: ExpressibleByDictionaryLiteral {
} }
extension Dictionary where Key == String, Value == Any { 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) let data = try JSONSerialization.data(withJSONObject: self, options: .prettyPrinted)
return try JSONDecoder().decode([String:JSONValue].self, from: data) return try JSONDecoder().decode([String:JSONValue].self, from: data)
} }
} }
extension Dictionary where Key == String, Value == JSONValue { extension Dictionary where Key == String, Value == JSONValue {
public func toJSONObject() throws -> JSONObject{ public func toJSONObject() throws -> JSONObject {
let encoded = try JSONEncoder().encode(self) let encoded = try JSONEncoder().encode(self)
guard let json = try JSONSerialization.jsonObject(with: encoded, options: .mutableContainers) as? JSONObject else { guard let json = try JSONSerialization.jsonObject(with: encoded, options: .mutableContainers) as? JSONObject else {
throw JSONValueError.encode throw JSONValueError.encode

View File

@ -12,7 +12,7 @@ import Foundation
public var actionType: String? public var actionType: String?
public var pageType: String? public var pageType: String?
public init(actionType: String?, pageType: String?){ public init(actionType: String?, pageType: String?) {
self.actionType = actionType self.actionType = actionType
self.pageType = pageType self.pageType = pageType
} }

View File

@ -14,7 +14,7 @@ import Foundation
public var molecule: MoleculeHolder? public var molecule: MoleculeHolder?
public var seperator: MoleculeHolder? public var seperator: MoleculeHolder?
public init(molecule: MoleculeHolder?){ public init(molecule: MoleculeHolder?) {
self.molecule = molecule self.molecule = molecule
self.moleculeName = Self.identifier self.moleculeName = Self.identifier
} }

View File

@ -13,7 +13,7 @@ import Foundation
public var moleculeName: String? public var moleculeName: String?
public var headline: LabelModel? public var headline: LabelModel?
public init(headline: LabelModel?){ public init(headline: LabelModel?) {
self.headline = headline self.headline = headline
self.moleculeName = Self.identifier self.moleculeName = Self.identifier
} }

View File

@ -14,7 +14,7 @@ import Foundation
public var molecule: MoleculeHolder? public var molecule: MoleculeHolder?
public var actionMap: ActionMapModel? public var actionMap: ActionMapModel?
public init(molecule: MoleculeHolder?, actionMap: ActionMapModel?){ public init(molecule: MoleculeHolder?, actionMap: ActionMapModel?) {
self.molecule = molecule self.molecule = molecule
self.actionMap = actionMap self.actionMap = actionMap
self.moleculeName = Self.identifier self.moleculeName = Self.identifier

View File

@ -13,7 +13,7 @@ import Foundation
public var moleculeName: String? public var moleculeName: String?
public var molecule: MoleculeHolder? public var molecule: MoleculeHolder?
public init(molecule: MoleculeHolder?){ public init(molecule: MoleculeHolder?) {
self.molecule = molecule self.molecule = molecule
self.moleculeName = Self.identifier self.moleculeName = Self.identifier
} }

View File

@ -8,13 +8,13 @@
import Foundation import Foundation
@objcMembers public class MoleculeStackModel: MoleculeProtocol{ @objcMembers public class MoleculeStackModel: MoleculeProtocol {
public static var identifier: String = "moleculeStack" public static var identifier: String = "moleculeStack"
public var moleculeName: String? public var moleculeName: String?
public var molecules: [MoleculeStackItemModel]? public var molecules: [MoleculeStackItemModel]?
public var axis: String? public var axis: String?
public init(axis: String?, molecules: [MoleculeStackItemModel]?){ public init(axis: String?, molecules: [MoleculeStackItemModel]?) {
self.axis = axis self.axis = axis
self.molecules = molecules self.molecules = molecules
self.moleculeName = Self.identifier self.moleculeName = Self.identifier

View File

@ -1,5 +1,5 @@
// //
// SeperatorModel.swift // LineModel.swift
// MVMCoreUI // MVMCoreUI
// //
// Created by Suresh, Kamlesh on 10/28/19. // Created by Suresh, Kamlesh on 10/28/19.
@ -8,8 +8,8 @@
import UIKit import UIKit
@objcMembers public class SeperatorModel: MoleculeProtocol { @objcMembers public class LineModel: MoleculeProtocol {
public static var identifier: String = "seperator" public static var identifier: String = "line"
public var moleculeName: String? public var moleculeName: String?
public var type: String? public var type: String?

View File

@ -12,7 +12,7 @@ import UIKit
public var template: String? public var template: String?
public var pageType: String? public var pageType: String?
public var screenHeading: String? public var screenHeading: String?
public var isAtomicTabs: Bool = false public var isAtomicTabs: Bool? = false
public var header: HeaderModel? public var header: HeaderModel?
public var molecules: [ListItemModel]? public var molecules: [ListItemModel]?
} }

View File

@ -8,7 +8,6 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@import MVMCore.MVMCoreViewProtocol; @import MVMCore.MVMCoreViewProtocol;
//@import MVMCoreUI.Swift;
@class MVMCoreUIDelegateObject; @class MVMCoreUIDelegateObject;
@class MVMCoreErrorObject; @class MVMCoreErrorObject;
@class MoleculeProtocol; @class MoleculeProtocol;

View File

@ -10,7 +10,6 @@ import Foundation
import UIKit import UIKit
import MVMCore.MVMCoreViewProtocol import MVMCore.MVMCoreViewProtocol
//@import MVMCoreUI.Swift;
@objc public protocol MoleculeViewProtocol: MVMCoreViewProtocol { @objc public protocol MoleculeViewProtocol: MVMCoreViewProtocol {

View File

@ -67,7 +67,7 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol
return 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) separatorView?.setWithJSON(seperatorModel.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
} }
} }

View File

@ -8,7 +8,6 @@
import Foundation import Foundation
public extension MVMCoreUIMoleculeMappingObject { public extension MVMCoreUIMoleculeMappingObject {
func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> (UIView & MVMCoreUIMoleculeViewProtocol)? { 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)? { func createMolecule(_ model: MoleculeProtocol, _ delegateObject: MVMCoreUIDelegateObject?, _ constrainIfNeeded: Bool) -> (UIView & MVMCoreUIMoleculeViewProtocol)? {
guard let moleculeName = model.moleculeName, guard let moleculeName = model.moleculeName,
let molecule = createMolecule(forName: moleculeName) as? MVMCoreUIViewConstrainingProtocol & UIView & MVMCoreUIMoleculeViewProtocol else { let molecule = createMolecule(forName: moleculeName) else {
return nil return nil
} }
let setData = {() in let setData = {(molecule: UIView & MVMCoreUIMoleculeViewProtocol) in
if let molecule = molecule as? ModelMoleculeViewProtocol { if let molecule = molecule as? ModelMoleculeViewProtocol {
molecule.setWithModel(model, delegateObject, nil) molecule.setWithModel(model, delegateObject, nil)
} else { } else {
@ -29,12 +28,13 @@ public extension MVMCoreUIMoleculeMappingObject {
} }
} }
if constrainIfNeeded, molecule.needsToBeConstrained?() ?? false { if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol, castMolecule.needsToBeConstrained?() ?? false {
let viewConstrainingView = ViewConstrainingView(molecule: molecule, alignment: molecule.alignment?() ?? .fill) let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.alignment?() ?? .fill)
setData() setData(view)
return viewConstrainingView return view
} else {
setData(molecule)
return molecule
} }
setData()
return molecule
} }
} }

View File

@ -17,6 +17,6 @@ import Foundation
HolderManager.register(ListItemModel.self) HolderManager.register(ListItemModel.self)
HolderManager.register(MoleculeStackItemModel.self) HolderManager.register(MoleculeStackItemModel.self)
HolderManager.register(TextFieldModel.self) HolderManager.register(TextFieldModel.self)
HolderManager.register(SeperatorModel.self) HolderManager.register(LineModel.self)
} }
} }

View File

@ -73,10 +73,16 @@
} }
+ (nullable instancetype)sharedMappingObject { + (nullable instancetype)sharedMappingObject {
[MVMCoreUIMoleculeMappingObject registerObjects];
return [MVMCoreActionUtility initializerClassCheck:[MVMCoreUIObject sharedInstance].moleculeMap classToVerify:self]; return [MVMCoreActionUtility initializerClassCheck:[MVMCoreUIObject sharedInstance].moleculeMap classToVerify:self];
} }
- (instancetype)init {
if (self = [super init]) {
[MVMCoreUIMoleculeMappingObject registerObjects];
}
return self;
}
- (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json { - (nullable Class)getMoleculeClassWithJSON:(nonnull NSDictionary *)json {
NSString *moleculeName = [json string:KeyMoleculeName]; NSString *moleculeName = [json string:KeyMoleculeName];
if (moleculeName) { if (moleculeName) {