merge
This commit is contained in:
commit
437138007f
@ -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 */; };
|
||||
@ -35,7 +40,6 @@
|
||||
01EB3684236097C0006832FA /* MoleculeProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB3683236097C0006832FA /* MoleculeProtocol.swift */; };
|
||||
01EB368F23609801006832FA /* LabelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368823609801006832FA /* LabelModel.swift */; };
|
||||
01EB369023609801006832FA /* ListItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368923609801006832FA /* ListItemModel.swift */; };
|
||||
01EB369123609801006832FA /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; };
|
||||
01EB369223609801006832FA /* MoleculeStackModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368B23609801006832FA /* MoleculeStackModel.swift */; };
|
||||
01EB369323609801006832FA /* HeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368C23609801006832FA /* HeaderModel.swift */; };
|
||||
01EB369423609801006832FA /* HeadlineBodyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368D23609801006832FA /* HeadlineBodyModel.swift */; };
|
||||
@ -79,6 +83,7 @@
|
||||
D260D7B122D65BDD007E7233 /* MVMCoreUIPageControl.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7AF22D65BDD007E7233 /* MVMCoreUIPageControl.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D260D7B222D65BDD007E7233 /* MVMCoreUIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = D260D7B022D65BDD007E7233 /* MVMCoreUIPageControl.m */; };
|
||||
D260D7B622D68514007E7233 /* MVMCoreUIPagingProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D260D7B522D68509007E7233 /* MVMCoreUIPagingProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01EB368A23609801006832FA /* MoleculeStackItemModel.swift */; };
|
||||
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D274CA322236A78900B01B62 /* StandardFooterView.swift */; };
|
||||
D2755D7B23689C7500485468 /* TableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2755D7A23689C7500485468 /* TableViewCell.swift */; };
|
||||
D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; };
|
||||
@ -238,6 +243,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>"; };
|
||||
@ -251,7 +261,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>"; };
|
||||
@ -480,6 +490,7 @@
|
||||
children = (
|
||||
017BEB392360EEB40024EF95 /* PageModel.swift */,
|
||||
01EB3683236097C0006832FA /* MoleculeProtocol.swift */,
|
||||
012CA9BD2385C692003F810F /* ConstrainingMoleculeProtocol.swift */,
|
||||
946EE1B5237B663A0036751F /* Extensions */,
|
||||
01EB368723609801006832FA /* Molecules */,
|
||||
);
|
||||
@ -500,6 +511,7 @@
|
||||
01EB368723609801006832FA /* Molecules */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
012CA98823849699003F810F /* SeperatorModel.swift */,
|
||||
01EB368923609801006832FA /* ListItemModel.swift */,
|
||||
01EB368A23609801006832FA /* MoleculeStackItemModel.swift */,
|
||||
01EB368B23609801006832FA /* MoleculeStackModel.swift */,
|
||||
@ -867,8 +879,10 @@
|
||||
DBC4391722442197001AB423 /* DashLine.swift */,
|
||||
944589202385D6E900DE9FD4 /* DashLineModel.swift */,
|
||||
DB06250A2293456500B72DD3 /* LeftRightLabelView.swift */,
|
||||
012CA99D2385A2D3003F810F /* MFView+ModelExtension.swift */,
|
||||
D29DF28721E7AC2B003B2FB9 /* ViewConstrainingView.h */,
|
||||
D29DF28821E7AC2B003B2FB9 /* ViewConstrainingView.m */,
|
||||
012CA99B23859FDC003F810F /* ViewConstrainingView+ModelExtension.swift */,
|
||||
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */,
|
||||
D282AAB3223FDDAE00C46919 /* MFLoadImageView.swift */,
|
||||
944589222385DA9500DE9FD4 /* ImageViewModel.swift */,
|
||||
@ -907,6 +921,7 @@
|
||||
children = (
|
||||
D29DF24C21E6A177003B2FB9 /* MFTextField.h */,
|
||||
D29DF24221E6A176003B2FB9 /* MFTextField.m */,
|
||||
012CA9992384A687003F810F /* MFTextField+ModelExtension.swift */,
|
||||
D29DF24421E6A176003B2FB9 /* MFTextField.xib */,
|
||||
D29DF24B21E6A177003B2FB9 /* MFTextFieldSubclassExtension.h */,
|
||||
D29DF24721E6A176003B2FB9 /* MFMdnTextField.h */,
|
||||
@ -955,7 +970,7 @@
|
||||
D2A514562211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.h */,
|
||||
D2A514572211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m */,
|
||||
017BEB432362192F0024EF95 /* MVMCoreUIMoleculeMappingObject+ModelExtension.swift */,
|
||||
017BEB7E23676E870024EF95 /* MVMCoreUIMoleculeMappingObject+ModelMapping.swift */,
|
||||
017BEB7E23676E870024EF95 /* MoleculeObjectMapping.swift */,
|
||||
);
|
||||
path = OtherHandlers;
|
||||
sourceTree = "<group>";
|
||||
@ -1188,8 +1203,10 @@
|
||||
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 */,
|
||||
94C2D9A923872E5E0006CF46 /* LabelAttributeImageModel.swift in Sources */,
|
||||
012CA98923849699003F810F /* SeperatorModel.swift in Sources */,
|
||||
DBC4391922442197001AB423 /* DashLine.swift in Sources */,
|
||||
0A7BAD74232A8DC700FB8E22 /* HeadlineBodyButton.swift in Sources */,
|
||||
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
||||
@ -1231,12 +1248,14 @@
|
||||
94C2D9A723872DA90006CF46 /* LabelAttributeColorModel.swift 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 */,
|
||||
944589232385DA9600DE9FD4 /* ImageViewModel.swift in Sources */,
|
||||
D213347723843825008E41B3 /* Line.swift in Sources */,
|
||||
D2A514672213885800345BFB /* StandardHeaderView.swift in Sources */,
|
||||
01EB369023609801006832FA /* ListItemModel.swift in Sources */,
|
||||
D268C70C2386DFFD007F2C1C /* MoleculeStackItemModel.swift in Sources */,
|
||||
DBEFFA04225A829700230692 /* Label.swift in Sources */,
|
||||
D2D6CD4022E78C1A00D701B8 /* Scroller.swift in Sources */,
|
||||
01509D952327ED1900EF99AA /* HeadlineBodyTextButtonSwitch.swift in Sources */,
|
||||
@ -1261,7 +1280,7 @@
|
||||
D29DF17A21E69E1F003B2FB9 /* MFCustomButton.m in Sources */,
|
||||
017BEB7B236763000024EF95 /* LineModel.swift in Sources */,
|
||||
94C2D9A523872C350006CF46 /* LabelAttributeFontModel.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 */,
|
||||
@ -1286,6 +1305,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 */,
|
||||
@ -1312,8 +1332,8 @@
|
||||
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 */,
|
||||
01EB369123609801006832FA /* MoleculeStackItemModel.swift in Sources */,
|
||||
D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */,
|
||||
D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */,
|
||||
D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift 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)
|
||||
|
||||
@ -325,7 +325,7 @@ public typealias ActionBlock = () -> ()
|
||||
}
|
||||
|
||||
@objc public static func setUILabel(_ label: UILabel?, withJSON json: [AnyHashable: Any]?, delegate: DelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
|
||||
|
||||
guard let label = label else { return }
|
||||
label.attributedText = nil
|
||||
label.text = json?.optionalStringForKey(KeyText)
|
||||
|
||||
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 }
|
||||
}
|
||||
}
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension KeyedDecodingContainer where Key : CodingKey{
|
||||
extension KeyedDecodingContainer where Key : CodingKey {
|
||||
private enum TypeCodingKey: String, CodingKey {
|
||||
case moleculeName
|
||||
}
|
||||
|
||||
@ -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?
|
||||
|
||||
|
||||
15
MVMCoreUI/Models/Molecules/LabelModel.swift
Normal file
15
MVMCoreUI/Models/Molecules/LabelModel.swift
Normal file
@ -0,0 +1,15 @@
|
||||
//
|
||||
// Label.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 10/3/19.
|
||||
// Copyright © 2019 Suresh, Kamlesh. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
import Foundation
|
||||
|
||||
@objcMembers public class LabelModel: MoleculeProtocol {
|
||||
public static var identifier: String = "label"
|
||||
public var text: String?
|
||||
}
|
||||
@ -12,31 +12,31 @@ import Foundation
|
||||
public static var identifier: String = "listItem"
|
||||
public var moleculeName: String?
|
||||
public var molecule: MoleculeProtocol?
|
||||
public var actionMap: ActionModel?
|
||||
public var action: ActionModel?
|
||||
|
||||
public init(molecule: MoleculeProtocol?, actionMap: ActionModel?) {
|
||||
self.molecule = molecule
|
||||
self.actionMap = actionMap
|
||||
self.action = actionMap
|
||||
self.moleculeName = Self.identifier
|
||||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case moleculeName
|
||||
case molecule
|
||||
case actionMap
|
||||
case action
|
||||
}
|
||||
|
||||
required public init(from decoder: Decoder) throws {
|
||||
let typeContainer = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.moleculeName = try typeContainer.decode(String.self, forKey: .moleculeName)
|
||||
self.molecule = try typeContainer.decodeIfPresent(codingKey: .molecule)
|
||||
self.actionMap = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .actionMap)
|
||||
self.action = try typeContainer.decodeIfPresent(ActionModel.self, forKey: .action)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(moleculeName, forKey: .moleculeName)
|
||||
try container.encodeIfPresent(self.molecule, forKey: .molecule)
|
||||
try container.encodeIfPresent(actionMap, forKey: .actionMap)
|
||||
try container.encodeIfPresent(action, forKey: .action)
|
||||
}
|
||||
}
|
||||
|
||||
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?
|
||||
|
||||
@ -8,7 +8,11 @@
|
||||
|
||||
import UIKit
|
||||
|
||||
<<<<<<< HEAD
|
||||
public class StandardHeaderView: ViewConstrainingView {
|
||||
=======
|
||||
public class StandardHeaderView: ViewConstrainingView, ModelMoleculeViewProtocol {
|
||||
>>>>>>> feature/models
|
||||
var line: Line?
|
||||
|
||||
// MARK: - MVMCoreViewProtocol
|
||||
@ -50,7 +54,10 @@ public class StandardHeaderView: ViewConstrainingView {
|
||||
|
||||
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,6 +18,7 @@ import Foundation
|
||||
ModelRegistry.register(ListItemModel.self)
|
||||
ModelRegistry.register(TextFieldModel.self)
|
||||
ModelRegistry.register(LineModel.self)
|
||||
ModelRegistry.register(SeperatorModel.self)
|
||||
ModelRegistry.register(ProgressBarModel.self)
|
||||
ModelRegistry.register(MultiProgressBarModel.self)
|
||||
ModelRegistry.register(CaretViewModel.self)
|
||||
Loading…
Reference in New Issue
Block a user