module molecule
This commit is contained in:
parent
9676f41633
commit
3a1e3356bf
@ -45,6 +45,7 @@
|
|||||||
017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; };
|
017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; };
|
||||||
017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; };
|
017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; };
|
||||||
017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */; };
|
017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */; };
|
||||||
|
0189255C239AA7EB004E8AFF /* ModuleDelegateProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */; };
|
||||||
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; };
|
0198F79F225679880066C936 /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0198F79E225679870066C936 /* FormValidationProtocol.swift */; };
|
||||||
0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
0198F7A62256A80B0066C936 /* MFRadioButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 0198F7A02256A80A0066C936 /* MFRadioButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; };
|
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; };
|
||||||
@ -293,6 +294,7 @@
|
|||||||
017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = "<group>"; };
|
017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModelMoleculeViewProtocol.swift; sourceTree = "<group>"; };
|
||||||
017BEB7A236763000024EF95 /* LineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineModel.swift; sourceTree = "<group>"; };
|
017BEB7A236763000024EF95 /* LineModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineModel.swift; sourceTree = "<group>"; };
|
||||||
017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeObjectMapping.swift; sourceTree = "<group>"; };
|
017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeObjectMapping.swift; sourceTree = "<group>"; };
|
||||||
|
0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModuleDelegateProtocol.swift; sourceTree = "<group>"; };
|
||||||
0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = "<group>"; };
|
0198F79E225679870066C936 /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = "<group>"; };
|
||||||
0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = "<group>"; };
|
0198F7A02256A80A0066C936 /* MFRadioButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFRadioButton.h; sourceTree = "<group>"; };
|
||||||
0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = "<group>"; };
|
0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = "<group>"; };
|
||||||
@ -1038,6 +1040,7 @@
|
|||||||
D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */,
|
D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */,
|
||||||
017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */,
|
017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */,
|
||||||
017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */,
|
017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */,
|
||||||
|
0189255B239AA7EB004E8AFF /* ModuleDelegateProtocol.swift */,
|
||||||
);
|
);
|
||||||
path = OtherHandlers;
|
path = OtherHandlers;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -1313,6 +1316,7 @@
|
|||||||
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
|
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
|
||||||
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
|
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
|
||||||
012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */,
|
012A88C4238D86E600FE3DA1 /* CollectionCellMoleculeProtocol.swift in Sources */,
|
||||||
|
0189255C239AA7EB004E8AFF /* ModuleDelegateProtocol.swift in Sources */,
|
||||||
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */,
|
94C2D9AB23872EB50006CF46 /* LabelAttributeActionModel.swift in Sources */,
|
||||||
017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */,
|
017BEB4023620A230024EF95 /* TextFieldModel.swift in Sources */,
|
||||||
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,
|
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,
|
||||||
|
|||||||
@ -8,8 +8,24 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
extension MFViewController: ModuleDelegateProtocol {
|
||||||
|
public func getModuleWithName(_ moleculeName: String) -> Model? {
|
||||||
|
guard let moduleJSON = loadObject?.modulesJSON?.optionalDictionaryForKey(moleculeName),
|
||||||
|
let moleculeName = moduleJSON.optionalStringForKey("moleculeName"),
|
||||||
|
let modelType = ModelRegistry.getType(for: moleculeName) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
return try modelType.decode(jsonDict: moduleJSON)
|
||||||
|
} catch {
|
||||||
|
MVMCoreUILoggingHandler.logDebugMessage(withDelegate: "error: \(error)")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public extension MFViewController {
|
public extension MFViewController {
|
||||||
|
|
||||||
@objc func parsePageJSON() {
|
@objc func parsePageJSON() {
|
||||||
|
|
||||||
(self as? TemplateProtocol)?.parseTemplateJSON()
|
(self as? TemplateProtocol)?.parseTemplateJSON()
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
class ModuleMoleculeModel: MoleculeProtocol {
|
public class ModuleMoleculeModel: MoleculeProtocol {
|
||||||
public static var identifier: String = "moduleMolecule"
|
public static var identifier: String = "moduleMolecule"
|
||||||
public var moduleName: String
|
public var moduleName: String
|
||||||
public var backgroundColor: String?
|
public var backgroundColor: String?
|
||||||
|
|||||||
@ -10,7 +10,7 @@ import UIKit
|
|||||||
|
|
||||||
open class ModuleMolecule: ViewConstrainingView, ModelMoleculeViewProtocol {
|
open class ModuleMolecule: ViewConstrainingView, ModelMoleculeViewProtocol {
|
||||||
|
|
||||||
open var moduleMolecule: (UIView & MVMCoreUIMoleculeViewProtocol)?
|
open var moduleMolecule: (UIView & MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol)?
|
||||||
|
|
||||||
open override func updateView(_ size: CGFloat) {
|
open override func updateView(_ size: CGFloat) {
|
||||||
super.updateView(size)
|
super.updateView(size)
|
||||||
@ -23,58 +23,28 @@ open class ModuleMolecule: ViewConstrainingView, ModelMoleculeViewProtocol {
|
|||||||
setUpWithModel(model, delegateObject, additionalData)
|
setUpWithModel(model, delegateObject, additionalData)
|
||||||
|
|
||||||
guard let moduleMoleculeModel = model as? ModuleMoleculeModel,
|
guard let moduleMoleculeModel = model as? ModuleMoleculeModel,
|
||||||
let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleMoleculeModel.moduleName) else {
|
let moduleModel = delegateObject?.moduleProtocol?.getModuleWithName(moduleMoleculeModel.moduleName) as? MoleculeProtocol else {
|
||||||
// Critical error
|
// Critical error
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// if moduleMolecule == nil {
|
if moduleMolecule == nil {
|
||||||
// MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(<#T##model: MoleculeProtocol##MoleculeProtocol#>, <#T##delegateObject: MVMCoreUIDelegateObject?##MVMCoreUIDelegateObject?#>, <#T##constrainIfNeeded: Bool##Bool#>)
|
if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moduleModel, delegateObject, true) {
|
||||||
// if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: true) {
|
addSubview(moleculeView)
|
||||||
// addSubview(moleculeView)
|
NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values))
|
||||||
// NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values))
|
moduleMolecule = moleculeView as? (UIView & MVMCoreUIMoleculeViewProtocol & ModelMoleculeViewProtocol)
|
||||||
// moduleMolecule = moleculeView
|
|
||||||
//
|
|
||||||
// isAccessibilityElement = false
|
|
||||||
// if moleculeView.accessibilityElements != nil {
|
|
||||||
// accessibilityElements = moleculeView.accessibilityElements
|
|
||||||
// } else {
|
|
||||||
// accessibilityElements = [moleculeView]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// moduleMolecule?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
isAccessibilityElement = false
|
||||||
|
if moleculeView.accessibilityElements != nil {
|
||||||
|
accessibilityElements = moleculeView.accessibilityElements
|
||||||
|
} else {
|
||||||
|
accessibilityElements = [moleculeView]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
moduleMolecule?.setWithModel(model, delegateObject, additionalData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // MARK: - MVMCoreUIMoleculeViewProtocol
|
|
||||||
// open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
|
||||||
// super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
//
|
|
||||||
// guard let moduleName = json?.optionalStringForKey("moduleName"),
|
|
||||||
// let module = delegateObject?.moleculeDelegate?.getModuleWithName(moduleName) else {
|
|
||||||
// // Critical error
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if moduleMolecule == nil {
|
|
||||||
// if let moleculeView = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: module, delegateObject: delegateObject, constrainIfNeeded: true) {
|
|
||||||
// addSubview(moleculeView)
|
|
||||||
// NSLayoutConstraint.activate(Array(NSLayoutConstraint.pinView(toSuperview: moleculeView, useMargins: false).values))
|
|
||||||
// moduleMolecule = moleculeView
|
|
||||||
//
|
|
||||||
// isAccessibilityElement = false
|
|
||||||
// if moleculeView.accessibilityElements != nil {
|
|
||||||
// accessibilityElements = moleculeView.accessibilityElements
|
|
||||||
// } else {
|
|
||||||
// accessibilityElements = [moleculeView]
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// moduleMolecule?.setWithJSON(module, delegateObject: delegateObject, additionalData: additionalData)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
open override func setAsMolecule() {
|
open override func setAsMolecule() {
|
||||||
super.setAsMolecule()
|
super.setAsMolecule()
|
||||||
|
|||||||
@ -13,6 +13,7 @@ open class MVMCoreUIDelegateObject: DelegateObject {
|
|||||||
public weak var buttonDelegate: ButtonDelegateProtocol?
|
public weak var buttonDelegate: ButtonDelegateProtocol?
|
||||||
public weak var uiTextFieldDelegate: UITextFieldDelegate?
|
public weak var uiTextFieldDelegate: UITextFieldDelegate?
|
||||||
public weak var moleculeDelegate: MoleculeDelegateProtocol?
|
public weak var moleculeDelegate: MoleculeDelegateProtocol?
|
||||||
|
public var moduleProtocol: ModuleDelegateProtocol?
|
||||||
|
|
||||||
open override func setAll(withDelegate delegate: Any) {
|
open override func setAll(withDelegate delegate: Any) {
|
||||||
super.setAll(withDelegate: delegate)
|
super.setAll(withDelegate: delegate)
|
||||||
@ -20,9 +21,11 @@ open class MVMCoreUIDelegateObject: DelegateObject {
|
|||||||
buttonDelegate = delegate as? ButtonDelegateProtocol
|
buttonDelegate = delegate as? ButtonDelegateProtocol
|
||||||
uiTextFieldDelegate = delegate as? UITextFieldDelegate
|
uiTextFieldDelegate = delegate as? UITextFieldDelegate
|
||||||
moleculeDelegate = delegate as? MoleculeDelegateProtocol
|
moleculeDelegate = delegate as? MoleculeDelegateProtocol
|
||||||
|
moduleProtocol = delegate as? ModuleDelegateProtocol
|
||||||
}
|
}
|
||||||
|
|
||||||
class func delegateObject(from controller: MVMCoreViewControllerProtocol?) -> MVMCoreUIDelegateObject? {
|
class func delegateObject(from controller: MVMCoreViewControllerProtocol?) -> MVMCoreUIDelegateObject? {
|
||||||
return controller?.delegateObject?() as? MVMCoreUIDelegateObject
|
return controller?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -29,10 +29,10 @@
|
|||||||
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)createMoleculeForName:(nonnull NSString *)name;
|
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)createMoleculeForName:(nonnull NSString *)name;
|
||||||
|
|
||||||
/// Creates the molecule for the molecule json.
|
/// Creates the molecule for the molecule json.
|
||||||
//- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject;
|
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject;
|
||||||
//
|
|
||||||
///// Creates the molecule for the molecule json. Also checks if the molecule needs to be constrained for a stack/list style situation.
|
/// Creates the molecule for the molecule json. Also checks if the molecule needs to be constrained for a stack/list style situation.
|
||||||
//- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject constrainIfNeeded:(BOOL)constrainIfNeeded;
|
- (nullable UIView <MVMCoreUIMoleculeViewProtocol>*)createMoleculeForJSON:(nonnull NSDictionary *)json delegateObject:(nullable MVMCoreUIDelegateObject *)delegateObject constrainIfNeeded:(BOOL)constrainIfNeeded;
|
||||||
|
|
||||||
#pragma mark - Convenience
|
#pragma mark - Convenience
|
||||||
|
|
||||||
|
|||||||
14
MVMCoreUI/OtherHandlers/ModuleDelegateProtocol.swift
Normal file
14
MVMCoreUI/OtherHandlers/ModuleDelegateProtocol.swift
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
//
|
||||||
|
// ModuleDelegateProtocol.swift
|
||||||
|
// MVMCoreUI
|
||||||
|
//
|
||||||
|
// Created by Suresh, Kamlesh on 12/6/19.
|
||||||
|
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
public protocol ModuleDelegateProtocol {
|
||||||
|
func getModuleWithName(_ moleculeName: String) -> Model?
|
||||||
|
}
|
||||||
@ -30,5 +30,6 @@ import Foundation
|
|||||||
ModelRegistry.register(LabelAttributeUnderlineModel.self)
|
ModelRegistry.register(LabelAttributeUnderlineModel.self)
|
||||||
ModelRegistry.register(LabelAttributeStrikeThroughModel.self)
|
ModelRegistry.register(LabelAttributeStrikeThroughModel.self)
|
||||||
ModelRegistry.register(LabelAttributeActionModel.self)
|
ModelRegistry.register(LabelAttributeActionModel.self)
|
||||||
|
ModelRegistry.register(ModuleMoleculeModel.self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user