fixes
This commit is contained in:
parent
478498a9b6
commit
bf20fb3104
@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extension KeyedDecodingContainer where Key : CodingKey{
|
extension KeyedDecodingContainer where Key : CodingKey{
|
||||||
private enum TypeCodingKey: String, CodingKey {
|
private enum TypeCodingKey: String, CodingKey {
|
||||||
case moleculeName
|
case moleculeName
|
||||||
|
|||||||
@ -29,7 +29,6 @@ import Foundation
|
|||||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName)
|
self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName)
|
||||||
self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule)
|
self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
|||||||
@ -13,9 +13,4 @@ import Foundation
|
|||||||
public static var identifier: String = "label"
|
public static var identifier: String = "label"
|
||||||
public var moleculeName: String?
|
public var moleculeName: String?
|
||||||
public var text: String?
|
public var text: String?
|
||||||
|
|
||||||
public init(text: String?) {
|
|
||||||
self.text = text
|
|
||||||
self.moleculeName = Self.identifier
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,4 +38,5 @@ import Foundation
|
|||||||
try container.encode(moleculeName, forKey: .moleculeName)
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
try container.encodeIfPresent(self.molecule, forKey: .molecule)
|
try container.encodeIfPresent(self.molecule, forKey: .molecule)
|
||||||
try container.encodeIfPresent(actionMap, forKey: .actionMap)
|
try container.encodeIfPresent(actionMap, forKey: .actionMap)
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objcMembers public class MoleculeStackItemModel: MoleculeProtocol {
|
@objcMembers public class MoleculeStackItemModel: MoleculeProtocol {
|
||||||
public static var identifier: String = "moleculeStackItem"
|
public static var identifier: String = "stackItem"
|
||||||
public var moleculeName: String?
|
public var moleculeName: String?
|
||||||
public var molecule: MoleculeProtocol?
|
public var molecule: MoleculeProtocol?
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
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]?
|
||||||
@ -19,4 +20,24 @@ import Foundation
|
|||||||
self.molecules = molecules
|
self.molecules = molecules
|
||||||
self.moleculeName = Self.identifier
|
self.moleculeName = Self.identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case moleculeName
|
||||||
|
case molecules
|
||||||
|
case axis
|
||||||
|
}
|
||||||
|
|
||||||
|
required public init(from decoder: Decoder) throws {
|
||||||
|
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
|
self.moleculeName = try typeContainer.decodeIfPresent(String.self, forKey: .moleculeName)
|
||||||
|
self.molecules = try typeContainer.decode([MoleculeStackItemModel].self, forKey: .molecules)
|
||||||
|
self.axis = try typeContainer.decodeIfPresent(String.self, forKey: .axis)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
|
try container.encode(moleculeName, forKey: .moleculeName)
|
||||||
|
try container.encodeIfPresent(molecules, forKey: .molecules)
|
||||||
|
try container.encode(axis, forKey: .axis)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,4 +15,5 @@ import UIKit
|
|||||||
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]?
|
||||||
|
public var moleculeStack: MoleculeStackModel?
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
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)? {
|
||||||
@ -28,7 +29,8 @@ public extension MVMCoreUIMoleculeMappingObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol, castMolecule.needsToBeConstrained?() ?? false {
|
if constrainIfNeeded, let castMolecule = molecule as? MVMCoreUIViewConstrainingProtocol,
|
||||||
|
castMolecule.needsToBeConstrained?() ?? false {
|
||||||
let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.alignment?() ?? .fill)
|
let view = ViewConstrainingView(molecule: molecule, alignment: castMolecule.alignment?() ?? .fill)
|
||||||
setData(view)
|
setData(view)
|
||||||
return view
|
return view
|
||||||
|
|||||||
@ -14,8 +14,8 @@ import Foundation
|
|||||||
ModelRegistry.register(HeaderModel.self)
|
ModelRegistry.register(HeaderModel.self)
|
||||||
ModelRegistry.register(HeadlineBodyModel.self)
|
ModelRegistry.register(HeadlineBodyModel.self)
|
||||||
ModelRegistry.register(MoleculeStackModel.self)
|
ModelRegistry.register(MoleculeStackModel.self)
|
||||||
ModelRegistry.register(ListItemModel.self)
|
|
||||||
ModelRegistry.register(MoleculeStackItemModel.self)
|
ModelRegistry.register(MoleculeStackItemModel.self)
|
||||||
|
ModelRegistry.register(ListItemModel.self)
|
||||||
ModelRegistry.register(TextFieldModel.self)
|
ModelRegistry.register(TextFieldModel.self)
|
||||||
ModelRegistry.register(LineModel.self)
|
ModelRegistry.register(LineModel.self)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,9 +30,13 @@ open class MoleculeStackTemplate: ThreeLayerViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open override func viewForTop() -> UIView? {
|
open override func viewForTop() -> UIView? {
|
||||||
guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else {
|
guard let moleculeModel = pageModel?.header,
|
||||||
return nil
|
let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeModel, delegateObject() as? MVMCoreUIDelegateObject, true) else {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
// guard let moleculeJSON = loadObject?.pageJSON?.optionalDictionaryForKey("header"), let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject() as? MVMCoreUIDelegateObject, constrainIfNeeded: true) else {
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
return molecule
|
return molecule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user