merge
This commit is contained in:
commit
cc2e4751f5
@ -12,6 +12,11 @@
|
||||
0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; };
|
||||
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; };
|
||||
0116A4E5228B19640094F3ED /* RadioButtonModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0116A4E4228B19640094F3ED /* RadioButtonModel.swift */; };
|
||||
012CA98923849699003F810F /* SeperatorModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA98823849699003F810F /* SeperatorModel.swift */; };
|
||||
012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */; };
|
||||
012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */; };
|
||||
012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */; };
|
||||
012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */; };
|
||||
01509D8F2327EC6F00EF99AA /* MoleculeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */; };
|
||||
01509D912327ECE600EF99AA /* CornerLabels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D902327ECE600EF99AA /* CornerLabels.swift */; };
|
||||
01509D932327ECFB00EF99AA /* ProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01509D922327ECFB00EF99AA /* ProgressBar.swift */; };
|
||||
@ -25,7 +30,7 @@
|
||||
017BEB48236230DB0024EF95 /* MoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */; };
|
||||
017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB49236235BA0024EF95 /* ModelMoleculeViewProtocol.swift */; };
|
||||
017BEB7B236763000024EF95 /* LineModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7A236763000024EF95 /* LineModel.swift */; };
|
||||
017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */; };
|
||||
017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = 017BEB7E23676E870024EF95 /* MoleculeObjectMapping.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, ); }; };
|
||||
0198F7A82256A80B0066C936 /* MFRadioButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 0198F7A22256A80A0066C936 /* MFRadioButton.m */; };
|
||||
@ -226,6 +231,11 @@
|
||||
0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = "<group>"; };
|
||||
0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = "<group>"; };
|
||||
0116A4E4228B19640094F3ED /* RadioButtonModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButtonModel.swift; sourceTree = "<group>"; };
|
||||
012CA98823849699003F810F /* SeperatorModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeperatorModel.swift; sourceTree = "<group>"; };
|
||||
012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFTextField+ModelExtension.swift"; sourceTree = "<group>"; };
|
||||
012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ViewConstrainingView+ModelExtension.swift"; sourceTree = "<group>"; };
|
||||
012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+ModelExtension.swift"; sourceTree = "<group>"; };
|
||||
012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstrainingMoleculeProtocol.swift; sourceTree = "<group>"; };
|
||||
01509D8E2327EC6F00EF99AA /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = "<group>"; };
|
||||
01509D902327ECE600EF99AA /* CornerLabels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CornerLabels.swift; sourceTree = "<group>"; };
|
||||
01509D922327ECFB00EF99AA /* ProgressBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressBar.swift; sourceTree = "<group>"; };
|
||||
@ -239,7 +249,7 @@
|
||||
017BEB47236230DB0024EF95 /* MoleculeViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeViewProtocol.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>"; };
|
||||
017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIMoleculeMappingObject+ModelMapping.swift"; sourceTree = "<group>"; };
|
||||
017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeObjectMapping.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>"; };
|
||||
0198F7A22256A80A0066C936 /* MFRadioButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFRadioButton.m; sourceTree = "<group>"; };
|
||||
@ -456,6 +466,7 @@
|
||||
children = (
|
||||
017BEB392360EEB40024EF95 /* PageModel.swift */,
|
||||
01EB3683236097C0006832FA /* MoleculeProtocol.swift */,
|
||||
012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */,
|
||||
946EE1B5237B663A0036751F /* Extensions */,
|
||||
01EB368723609801006832FA /* Molecules */,
|
||||
);
|
||||
@ -476,6 +487,7 @@
|
||||
01EB368723609801006832FA /* Molecules */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
012CA98823849699003F810F /* SeperatorModel.swift */,
|
||||
01EB368823609801006832FA /* LabelModel.swift */,
|
||||
01EB368923609801006832FA /* ListItemModel.swift */,
|
||||
01EB368A23609801006832FA /* MoleculeStackItemModel.swift */,
|
||||
@ -817,8 +829,10 @@
|
||||
DBC4391622442196001AB423 /* CaretView.swift */,
|
||||
DBC4391722442197001AB423 /* DashLine.swift */,
|
||||
DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */,
|
||||
012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */,
|
||||
D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */,
|
||||
D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */,
|
||||
012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */,
|
||||
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */,
|
||||
D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */,
|
||||
D213347623843825008E41B3 /* Line.swift */,
|
||||
@ -855,6 +869,7 @@
|
||||
children = (
|
||||
D29DF24C21E6A177003B2FB9 /* MFTextField.h */,
|
||||
D29DF24221E6A176003B2FB9 /* MFTextField.m */,
|
||||
012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */,
|
||||
D29DF24421E6A176003B2FB9 /* MFTextField.xib */,
|
||||
D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */,
|
||||
D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */,
|
||||
@ -903,7 +918,7 @@
|
||||
D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */,
|
||||
D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */,
|
||||
017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */,
|
||||
017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */,
|
||||
017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */,
|
||||
);
|
||||
path = OtherHandlers;
|
||||
sourceTree = "<group>";
|
||||
@ -1136,7 +1151,9 @@
|
||||
D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */,
|
||||
DBC4391822442197001AB423 /* CaretView.swift in Sources */,
|
||||
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */,
|
||||
012CA9BE2385C692003F810F /* ConstrainingMoleculeProtocol.swift in Sources */,
|
||||
D29B771022C281F400D6ACE0 /* ModuleMolecule.swift in Sources */,
|
||||
012CA98923849699003F810F /* SeperatorModel.swift in Sources */,
|
||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
||||
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */,
|
||||
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
||||
@ -1174,6 +1191,7 @@
|
||||
D29DF12B21E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.m in Sources */,
|
||||
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */,
|
||||
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */,
|
||||
012CA99E2385A2D3003F810F /* MFView+ModelExtension.swift in Sources */,
|
||||
D29DF25421E6A177003B2FB9 /* MFMdnTextField.m in Sources */,
|
||||
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */,
|
||||
D213347723843825008E41B3 /* Line.swift in Sources */,
|
||||
@ -1203,7 +1221,7 @@
|
||||
D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */,
|
||||
D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */,
|
||||
017BEB7B236763000024EF95 /* LineModel.swift in Sources */,
|
||||
017BEB7F23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift in Sources */,
|
||||
017BEB7F23676E870024EF95 /* MoleculeObjectMapping.swift in Sources */,
|
||||
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */,
|
||||
D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */,
|
||||
D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */,
|
||||
@ -1225,6 +1243,7 @@
|
||||
D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */,
|
||||
D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */,
|
||||
017BEB4A236235BA0024EF95 /* ModelMoleculeViewProtocol.swift in Sources */,
|
||||
012CA99A2384A687003F810F /* MFTextField+ModelExtension.swift in Sources */,
|
||||
01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */,
|
||||
D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */,
|
||||
D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */,
|
||||
@ -1249,6 +1268,7 @@
|
||||
D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */,
|
||||
D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */,
|
||||
0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */,
|
||||
012CA99C23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift in Sources */,
|
||||
0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */,
|
||||
D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */,
|
||||
D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */,
|
||||
|
||||
77
MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift
Normal file
77
MVMCoreUI/Atoms/TextFields/MFTextField+ModelExtension.swift
Normal file
@ -0,0 +1,77 @@
|
||||
//
|
||||
// MFTextField+ModelExtension.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 11/19/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
enum TextType: String {
|
||||
case dropDown = "dropDown"
|
||||
case password = "password"
|
||||
case number = "number"
|
||||
case email = "email"
|
||||
}
|
||||
extension MFTextField: ModelMoleculeViewProtocol {
|
||||
//
|
||||
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||
//TODO: Need to create setWithModel in ViewConstraining View
|
||||
#warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.")
|
||||
//TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.
|
||||
setUpWithModel(model, delegateObject, additionalData)
|
||||
|
||||
guard let textFieldModel = model as? TextFieldModel,
|
||||
let delegateObject = delegateObject else {
|
||||
return
|
||||
}
|
||||
|
||||
if let delegate = delegateObject.formValidationProtocol {
|
||||
let formValidator = FormValidator.getFormValidatorFor(delegate: delegate)
|
||||
mfTextFieldDelegate = formValidator
|
||||
uiTextFieldDelegate = delegateObject.uiTextFieldDelegate
|
||||
if let textField = textField {
|
||||
MVMCoreUICommonViewsUtility.addDismissToolbar(textField, delegate: uiTextFieldDelegate)
|
||||
}
|
||||
}
|
||||
|
||||
formText = textFieldModel.label as NSString?
|
||||
text = textFieldModel.value as NSString?
|
||||
enable(textFieldModel.disabled)
|
||||
errMessage = textFieldModel.errorMsg
|
||||
fieldKey = textFieldModel.fieldKey
|
||||
groupName = textFieldModel.groupName
|
||||
|
||||
|
||||
switch textFieldModel.type {
|
||||
case TextType.dropDown.rawValue:
|
||||
dropDownCarrotLabel?.isHidden = true
|
||||
hasDropDown = true
|
||||
break
|
||||
case TextType.password.rawValue:
|
||||
textField?.isSecureTextEntry = true
|
||||
break
|
||||
case TextType.number.rawValue:
|
||||
textField?.keyboardType = .numberPad
|
||||
break
|
||||
case TextType.email.rawValue:
|
||||
textField?.keyboardType = .emailAddress
|
||||
break
|
||||
default:
|
||||
print("default")
|
||||
}
|
||||
|
||||
if let regex = textFieldModel.regex {
|
||||
validationBlock = {(enteredValue: String?) -> Bool in
|
||||
if let enteredValue = enteredValue {
|
||||
return MVMCoreUIUtility.validate(enteredValue, withRegularExpression: regex)
|
||||
}
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
setDefaultValidationBlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,11 @@ public struct GraphObject {
|
||||
heightConstraint?.isActive = true
|
||||
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
|
||||
}
|
||||
|
||||
|
||||
override open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||
super.setWithModel(model, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
override open func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
let object = GraphObject(json)
|
||||
|
||||
23
MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift
Normal file
23
MVMCoreUI/Atoms/Views/MFView+ModelExtension.swift
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// MFView+ModelExtension.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 11/20/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension MFView {
|
||||
public func setUpDefaultWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) {
|
||||
self.model = model
|
||||
if let backgroundColorString = model?.backgroundColor {
|
||||
backgroundColor = UIColor.mfGet(for: backgroundColorString)
|
||||
}
|
||||
}
|
||||
}
|
||||
extension ModelMoleculeViewProtocol where Self: MFView {
|
||||
func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) {
|
||||
setUpDefaultWithModel(model, delegateObject, additionalData)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
//
|
||||
// ViewConstrainingView+ModelExtension.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 11/20/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
extension ViewConstrainingView {
|
||||
public func setUpWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) {
|
||||
if self.constrainedView == nil {
|
||||
setUpDefaultWithModel(model, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
if shouldSetupMoleculeFromJSON,
|
||||
let moleculeObject = (model as? ConstrainingMoleculeProtocol)?.molecule {
|
||||
if molecule != nil {
|
||||
(molecule as? ModelMoleculeViewProtocol)?.setWithModel(moleculeObject, delegateObject, additionalData)
|
||||
} else {
|
||||
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(moleculeObject, delegateObject, true) {
|
||||
addMolecule(molecule)
|
||||
self.molecule = molecule
|
||||
setMoleculeAccessibility()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
(molecule as? ModelMoleculeViewProtocol)?.setWithModel(model, delegateObject, additionalData)
|
||||
}
|
||||
|
||||
if let useHorizontalMargins = model?.useHorizontalMargins {
|
||||
updateViewHorizontalDefaults = useHorizontalMargins
|
||||
}
|
||||
if let useVerticalMargins = model?.useVerticalMargins {
|
||||
updateViewVerticalDefaults = useVerticalMargins
|
||||
}
|
||||
|
||||
if let horizontalAlignment = model?.horizontalAlignment {
|
||||
alignHorizontal(ViewConstrainingView.getAlignmentFor(horizontalAlignment, defaultAlignment: .fill))
|
||||
}
|
||||
if let verticalAlignment = model?.verticalAlignment {
|
||||
alignVertical(ViewConstrainingView.getAlignmentFor(verticalAlignment, defaultAlignment: .fill))
|
||||
}
|
||||
|
||||
#warning("work on the below")
|
||||
// let copyBackgroundColor = self.copyBackgroundColor?()
|
||||
// if copyBackgroundColor {
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
extension ModelMoleculeViewProtocol where Self: ViewConstrainingView {
|
||||
public func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String: AnyHashable]?) {
|
||||
setUpWithModel(model, delegateObject, additionalData)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
- (void)setWithJSON:(NSDictionary *)json delegateObject:(MVMCoreUIDelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
|
||||
// Only treated as a container if we are constraining a molecule.
|
||||
|
||||
NSNumber *useHorizontalMargins = [json optionalNumberForKey:@"useHorizontalMargins"];
|
||||
if (useHorizontalMargins) {
|
||||
self.updateViewHorizontalDefaults = [useHorizontalMargins boolValue];
|
||||
}
|
||||
NSNumber *useVerticalMargins = [json optionalNumberForKey:@"useVerticalMargins"];
|
||||
if (useVerticalMargins) {
|
||||
self.updateViewVerticalDefaults = [useVerticalMargins boolValue];
|
||||
}
|
||||
|
||||
// Set the alignment for the stack in the containing view. The json driven value is for the axis direction alignment.
|
||||
NSString *alignment = [json string:@"horizontalAlignment"];
|
||||
if (alignment) {
|
||||
[self alignHorizontal:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]];
|
||||
}
|
||||
alignment = [json string:@"verticalAlignment"];
|
||||
if (alignment) {
|
||||
[self alignVertical:[ViewConstrainingView getAlignmentForString:alignment defaultAlignment:UIStackViewAlignmentFill]];
|
||||
}
|
||||
|
||||
if ([self.molecule respondsToSelector:@selector(copyBackgroundColor)] && [self.molecule performSelector:@selector(copyBackgroundColor)]) {
|
||||
self.backgroundColor = self.molecule.backgroundColor;
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ -30,6 +30,8 @@
|
||||
@property (nullable, strong, nonatomic) IBOutlet NSLayoutConstraint *topPinLow;
|
||||
@property (nullable, strong, nonatomic) IBOutlet NSLayoutConstraint *bottomPinLow;
|
||||
|
||||
@property (weak, nullable, nonatomic) UIView *constrainedView;
|
||||
|
||||
/// In updateView, will set horizontal padding to default.
|
||||
@property (nonatomic) BOOL updateViewHorizontalDefaults;
|
||||
@property (nonatomic) BOOL updateViewVerticalDefaults;
|
||||
@ -89,6 +91,9 @@
|
||||
- (void)alignBottom;
|
||||
- (void)alignFillVertical;
|
||||
|
||||
- (void)alignHorizontal:(UIStackViewAlignment)alignment;
|
||||
- (void)alignVertical:(UIStackViewAlignment)alignment;
|
||||
|
||||
/// Convenience function for getting the alignment from a map.
|
||||
+ (UIStackViewAlignment)getAlignmentForString:(nullable NSString *)alignmentString defaultAlignment:(UIStackViewAlignment)defaultAlignment;
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#import "MVMCoreUIViewConstrainingProtocol.h"
|
||||
|
||||
@interface ViewConstrainingView ()
|
||||
@property (weak, nullable, nonatomic) UIView *constrainedView;
|
||||
@end
|
||||
|
||||
@implementation ViewConstrainingView
|
||||
|
||||
@ -8,8 +8,9 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
@objcMembers open class View: UIView {
|
||||
@objcMembers open class View: UIView, ModelMoleculeViewProtocol {
|
||||
open var json: [AnyHashable: Any]?
|
||||
open var model: MoleculeProtocol?
|
||||
|
||||
private var initialSetupPerformed = false
|
||||
|
||||
@ -34,6 +35,13 @@ import UIKit
|
||||
setupView()
|
||||
}
|
||||
}
|
||||
|
||||
open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||
self.model = model
|
||||
if let backgroundColorString = model?.backgroundColor {
|
||||
backgroundColor = UIColor.mfGet(for: backgroundColorString)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension View: MVMCoreViewProtocol {
|
||||
@ -59,3 +67,4 @@ extension View: MVMCoreUIMoleculeViewProtocol {
|
||||
backgroundColor = .clear
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
@interface MFView : UIView <MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol>
|
||||
|
||||
@property (nullable, nonatomic, strong) NSDictionary *json;
|
||||
@property (nullable, nonatomic, strong) id model;
|
||||
|
||||
// Called in the initialization functions. Can setup ui here.
|
||||
- (void)setupView;
|
||||
|
||||
19
MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift
Normal file
19
MVMCoreUI/Models/ConstrainingMoleculeProtocol.swift
Normal file
@ -0,0 +1,19 @@
|
||||
//
|
||||
// ConstrainingMoleculeProtocol.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 11/20/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol ConstrainingMoleculeProtocol: MoleculeProtocol {
|
||||
var molecule: MoleculeProtocol? {get}
|
||||
}
|
||||
|
||||
extension ConstrainingMoleculeProtocol {
|
||||
public var molecule: MoleculeProtocol? {
|
||||
get { return nil }
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,14 @@ import Foundation
|
||||
|
||||
public protocol MoleculeProtocol: Model {
|
||||
var moleculeName: String? {get}
|
||||
var backgroundColor: String? {get}
|
||||
var dictionary: [AnyHashable: Any]? {get}
|
||||
var molecule: MoleculeProtocol? {get}
|
||||
|
||||
var useHorizontalMargins: Bool? {get}
|
||||
var useVerticalMargins: Bool? {get}
|
||||
var horizontalAlignment: String? {get}
|
||||
var verticalAlignment: String? {get}
|
||||
}
|
||||
|
||||
extension MoleculeProtocol {
|
||||
@ -10,6 +17,30 @@ extension MoleculeProtocol {
|
||||
get { return Self.identifier }
|
||||
}
|
||||
|
||||
public var molecule: MoleculeProtocol? {
|
||||
get { return nil }
|
||||
}
|
||||
|
||||
public var backgroundColor: String? {
|
||||
get { return toJSON()?["backgroundColor"] as? String }
|
||||
}
|
||||
|
||||
public var useHorizontalMargins: Bool? {
|
||||
get { return toJSON()?["useHorizontalMargins"] as? Bool }
|
||||
}
|
||||
|
||||
public var useVerticalMargins: Bool? {
|
||||
get { return toJSON()?["useVerticalMargins"] as? Bool }
|
||||
}
|
||||
|
||||
public var horizontalAlignment: String? {
|
||||
get { return toJSON()?["horizontalAlignment"] as? String }
|
||||
}
|
||||
|
||||
public var verticalAlignment: String? {
|
||||
get { return toJSON()?["verticalAlignment"] as? String }
|
||||
}
|
||||
|
||||
public var dictionary: [AnyHashable: Any]? {
|
||||
return toJSON()
|
||||
}
|
||||
|
||||
@ -8,9 +8,10 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class HeaderModel: MoleculeProtocol {
|
||||
@objcMembers public class HeaderModel: ConstrainingMoleculeProtocol {
|
||||
public static var identifier: String = "header"
|
||||
public var moleculeName: String?
|
||||
public var backgroundColor: String?
|
||||
public var molecule: MoleculeProtocol?
|
||||
public var seperator: MoleculeProtocol?
|
||||
|
||||
|
||||
@ -11,6 +11,5 @@ import Foundation
|
||||
|
||||
@objcMembers public class LabelModel: MoleculeProtocol {
|
||||
public static var identifier: String = "label"
|
||||
public var moleculeName: String?
|
||||
public var text: String?
|
||||
}
|
||||
|
||||
14
MVMCoreUI/Models/Molecules/SeperatorModel.swift
Normal file
14
MVMCoreUI/Models/Molecules/SeperatorModel.swift
Normal file
@ -0,0 +1,14 @@
|
||||
//
|
||||
// SeperatorModel.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 11/19/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class SeperatorModel: MoleculeProtocol {
|
||||
public static var identifier: String = "line"
|
||||
public var type: String?
|
||||
}
|
||||
@ -12,9 +12,11 @@ import UIKit
|
||||
public static var identifier: String = "textField"
|
||||
|
||||
public var editable = true
|
||||
public var disabled = false
|
||||
public var errorMsg: String?
|
||||
public var label: String?
|
||||
public var type: String?
|
||||
public var value: String?
|
||||
public var regex: String?
|
||||
|
||||
public var required: Bool?
|
||||
|
||||
@ -47,7 +47,10 @@ public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol
|
||||
|
||||
open func setWithModel(_ model: MoleculeProtocol?, _ delegateObject: MVMCoreUIDelegateObject?, _ additionalData: [String : AnyHashable]?) {
|
||||
//TODO: Need to create setWithModel in ViewConstraining View
|
||||
super.setWithJSON(model?.toJSON(), delegateObject: delegateObject, additionalData: additionalData)
|
||||
|
||||
#warning("This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.")
|
||||
//TODO: This below call should be repaced with super.setWithModel once we get rid of ViewConstrainingView.
|
||||
setUpWithModel(model, delegateObject, additionalData)
|
||||
|
||||
// This molecule will by default handle margins.
|
||||
(molecule as? MVMCoreUIViewConstrainingProtocol)?.shouldSetHorizontalMargins?(false)
|
||||
|
||||
@ -77,7 +77,7 @@
|
||||
|
||||
- (instancetype)init {
|
||||
if (self = [super init]) {
|
||||
[MVMCoreUIMoleculeMappingObject registerObjects];
|
||||
[MoleculeObjectMapping registerObjects];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public extension MVMCoreUIMoleculeMappingObject {
|
||||
@objc static func registerObjects() {
|
||||
@objcMembers public class MoleculeObjectMapping: NSObject {
|
||||
public static func registerObjects() {
|
||||
ModelRegistry.register(LabelModel.self)
|
||||
ModelRegistry.register(HeaderModel.self)
|
||||
ModelRegistry.register(HeadlineBodyModel.self)
|
||||
@ -18,5 +18,6 @@ import Foundation
|
||||
ModelRegistry.register(ListItemModel.self)
|
||||
ModelRegistry.register(TextFieldModel.self)
|
||||
ModelRegistry.register(LineModel.self)
|
||||
ModelRegistry.register(SeperatorModel.self)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user