textfield list view and textfield list form controller been moved to mobilefirstframework
This commit is contained in:
parent
709277362f
commit
f1f34b2893
@ -20,8 +20,6 @@
|
||||
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 */; };
|
||||
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; };
|
||||
01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */; };
|
||||
01E569D3223FFFA500327251 /* ThreeLayerViewController.swift in Headers */ = {isa = PBXBuildFile; fileRef = D2A5146A2214905000345BFB /* ThreeLayerViewController.swift */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */; };
|
||||
0A1B4A96233BB18F005B3FB4 /* CheckboxWithLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A7BAFA2232BE63400FB8E22 /* CheckboxWithLabelView.swift */; };
|
||||
@ -32,7 +30,6 @@
|
||||
943784F6236B77BB006A1E82 /* GraphViewAnimationHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */; };
|
||||
9455B19C234F8A0400A574DB /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */; };
|
||||
948DB67E2326DCD90011F916 /* MultiProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 948DB67D2326DCD90011F916 /* MultiProgress.swift */; };
|
||||
C63D632123BDC3A0008F3B1F /* BulletList.swift in Sources */ = {isa = PBXBuildFile; fileRef = C63D632023BDC3A0008F3B1F /* BulletList.swift */; };
|
||||
D20A9A5E2243D3E300ADE781 /* TwoButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */; };
|
||||
D213347723843825008E41B3 /* Line.swift in Sources */ = {isa = PBXBuildFile; fileRef = D213347623843825008E41B3 /* Line.swift */; };
|
||||
D224798A2314445E003FCCF9 /* LabelSwitch.swift in Sources */ = {isa = PBXBuildFile; fileRef = D22479892314445E003FCCF9 /* LabelSwitch.swift */; };
|
||||
@ -223,8 +220,6 @@
|
||||
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>"; };
|
||||
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = "<group>"; };
|
||||
01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldListFormViewController.swift; sourceTree = "<group>"; };
|
||||
0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionDetailWithImage.swift; sourceTree = "<group>"; };
|
||||
0A41BA6D2344FCD400D4C0BC /* CATransaction+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CATransaction+Extension.swift"; sourceTree = "<group>"; };
|
||||
0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeadlineBodyButton.swift; sourceTree = "<group>"; };
|
||||
@ -234,7 +229,6 @@
|
||||
943784F4236B77BB006A1E82 /* GraphViewAnimationHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GraphViewAnimationHandler.swift; sourceTree = "<group>"; };
|
||||
9455B19B234F8A0400A574DB /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = "<group>"; };
|
||||
948DB67D2326DCD90011F916 /* MultiProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProgress.swift; sourceTree = "<group>"; };
|
||||
C63D632023BDC3A0008F3B1F /* BulletList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BulletList.swift; sourceTree = "<group>"; };
|
||||
D20A9A5D2243D3E300ADE781 /* TwoButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoButtonView.swift; sourceTree = "<group>"; };
|
||||
D213347623843825008E41B3 /* Line.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Line.swift; sourceTree = "<group>"; };
|
||||
D22479892314445E003FCCF9 /* LabelSwitch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelSwitch.swift; sourceTree = "<group>"; };
|
||||
@ -586,7 +580,6 @@
|
||||
D29DF0DF21E418B2003B2FB9 /* Templates */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
01DF566F21FA5AB300CC099B /* TextFieldListFormViewController.swift */,
|
||||
D2A5146022121FBF00345BFB /* MoleculeStackTemplate.swift */,
|
||||
D2A514622213643100345BFB /* MoleculeStackCenteredTemplate.swift */,
|
||||
D296E13B2295969C0051EBE7 /* MoleculeListCellProtocol.h */,
|
||||
@ -624,7 +617,6 @@
|
||||
D224798D2316A988003FCCF9 /* VerticalCombinationViews */,
|
||||
D2A5145C2211D22A00345BFB /* MVMCoreUIMoleculeViewProtocol.h */,
|
||||
0A12149F22C11A17007C7030 /* ActionDetailWithImage.swift */,
|
||||
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */,
|
||||
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */,
|
||||
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */,
|
||||
D2A514662213885800345BFB /* StandardHeaderView.swift */,
|
||||
@ -635,7 +627,6 @@
|
||||
0A7BAD73232A8DC700FB8E22 /* HeadlineBodyButton.swift */,
|
||||
017BEB372360C6AC0024EF95 /* RadioButtonLabel.swift */,
|
||||
D2FB151A23A2B65B00C20E10 /* MoleculeContainer.swift */,
|
||||
C63D632023BDC3A0008F3B1F /* BulletList.swift */,
|
||||
);
|
||||
path = Molecules;
|
||||
sourceTree = "<group>";
|
||||
@ -1105,7 +1096,6 @@
|
||||
D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */,
|
||||
D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */,
|
||||
D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */,
|
||||
01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */,
|
||||
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
|
||||
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
|
||||
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
|
||||
@ -1141,7 +1131,6 @@
|
||||
D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */,
|
||||
D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */,
|
||||
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
|
||||
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */,
|
||||
D2A5146B2214905000345BFB /* ThreeLayerViewController.swift in Sources */,
|
||||
D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */,
|
||||
D2A6390522CBCE160052ED1F /* MoleculeCollectionViewCell.swift in Sources */,
|
||||
@ -1180,7 +1169,6 @@
|
||||
0A41BA6E2344FCD400D4C0BC /* CATransaction+Extension.swift in Sources */,
|
||||
D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */,
|
||||
D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */,
|
||||
C63D632123BDC3A0008F3B1F /* BulletList.swift in Sources */,
|
||||
0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */,
|
||||
0A1214A022C11A18007C7030 /* ActionDetailWithImage.swift in Sources */,
|
||||
D2B18B922361E65A00A9AEDC /* CoreUIObject.swift in Sources */,
|
||||
|
||||
@ -1,291 +0,0 @@
|
||||
//
|
||||
// BulletList.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Murugan, Vimal on 02/01/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
open class BulletList: Container {
|
||||
|
||||
var contentView = MVMCoreUICommonViewsUtility.commonView()
|
||||
var reusableViews: [LeftLabelRightMoleculeContainer] = []
|
||||
var bulletChar: String?
|
||||
|
||||
/// Removes all stack items views from the view.
|
||||
func removeAllItemInViews() {
|
||||
reusableViews.forEach({ $0.removeFromSuperview() })
|
||||
}
|
||||
|
||||
// MARK: - Inits
|
||||
public override init() {
|
||||
super.init()
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
}
|
||||
|
||||
public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.init(frame: CGRect.zero)
|
||||
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
public required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
public func pinView(_ view: UIView, toView: UIView, attribute: NSLayoutConstraint.Attribute, relation: NSLayoutConstraint.Relation, priority: UILayoutPriority, constant: CGFloat) {
|
||||
let constraint = NSLayoutConstraint(item: view, attribute: attribute, relatedBy: relation, toItem: toView, attribute: attribute, multiplier: 1.0, constant: constant)
|
||||
constraint.priority = priority
|
||||
constraint.isActive = true
|
||||
}
|
||||
|
||||
// MARK: - MFViewProtocol
|
||||
public override func setupView() {
|
||||
super.setupView()
|
||||
guard contentView.superview == nil else {
|
||||
return
|
||||
}
|
||||
MVMCoreUIUtility.setMarginsFor(contentView, leading: 0, top: 0, trailing: 0, bottom: 0)
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
backgroundColor = .clear
|
||||
addSubview(contentView)
|
||||
containerHelper.constrainView(contentView)
|
||||
contentView.setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||
contentView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||
}
|
||||
|
||||
public override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
directionalLayoutMargins.leading = 0
|
||||
directionalLayoutMargins.trailing = 0
|
||||
reusableViews.forEach({ $0.updateView(size) })
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreUIMoleculeViewProtocol
|
||||
public override func reset() {
|
||||
super.reset()
|
||||
backgroundColor = .clear
|
||||
reusableViews.forEach({ $0.reset() })
|
||||
}
|
||||
|
||||
open override func setWithJSON(_ json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable: Any]?) {
|
||||
let previousJSON = self.json
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
removeAllItemInViews()
|
||||
// If the items in the stack are the same, just update previous items instead of re-allocating.
|
||||
var items: [LeftLabelRightMoleculeContainer]?
|
||||
if BulletList.name(forReuse: previousJSON, delegateObject: delegateObject) == BulletList.name(forReuse: json, delegateObject: delegateObject) {
|
||||
items = self.reusableViews
|
||||
}
|
||||
self.reusableViews = []
|
||||
|
||||
guard let list = json?.arrayForKey("list") as? [[String: Any]] else {
|
||||
return
|
||||
}
|
||||
|
||||
bulletChar = json?.optionalStringForKey("bulletChar")
|
||||
// Adds the molecules and sets the json.
|
||||
for (index, map) in list.enumerated() {
|
||||
if let item = items?[index] {
|
||||
item.leftText = bulletChar ?? String(index+1)
|
||||
item.setWithJSON(map, delegateObject: delegateObject, additionalData: nil)
|
||||
addView(item, lastItem: index == list.count - 1)
|
||||
} else {
|
||||
let leftLabel = LeftLabelRightMoleculeContainer()
|
||||
leftLabel.leftText = bulletChar ?? String(index+1)
|
||||
leftLabel.setWithJSON(map, delegateObject: delegateObject, additionalData: additionalData)
|
||||
addView(leftLabel, lastItem: index == list.count - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func addView(_ container: LeftLabelRightMoleculeContainer, lastItem: Bool) {
|
||||
container.translatesAutoresizingMaskIntoConstraints = false
|
||||
contentView.addSubview(container)
|
||||
let first = reusableViews.first == nil
|
||||
if first {
|
||||
pinView(container, toView: contentView, attribute: .top, relation: .equal, priority: .required, constant: 16)
|
||||
} else if let previousView = reusableViews.last {
|
||||
container.topAnchor.constraint(equalTo: previousView.bottomAnchor, constant: 16).isActive = true
|
||||
}
|
||||
pinView(container, toView: contentView, attribute: .leading, relation: .equal, priority: .required, constant: 0)
|
||||
pinView(contentView, toView: container, attribute: .trailing, relation: .equal, priority: .required, constant: 0)
|
||||
if lastItem {
|
||||
pinView(contentView, toView: container, attribute: .bottom, relation: .equal, priority: .required, constant: 0)
|
||||
}
|
||||
reusableViews.append(container)
|
||||
}
|
||||
|
||||
public class func name(forReuse molecule: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> String? {
|
||||
// This will aggregate names of molecules to make an id.
|
||||
guard let molecules = molecule?.optionalArrayForKey("list") else {
|
||||
return "unordered<>"
|
||||
}
|
||||
var name = "unordered<"
|
||||
for case let item as [AnyHashable: Any] in molecules {
|
||||
if let moleculeName = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: item)?.name?(forReuse: molecule, delegateObject: delegateObject) ?? item.optionalStringForKey(KeyMoleculeName) {
|
||||
name.append(moleculeName + ",")
|
||||
}
|
||||
}
|
||||
name.append(">")
|
||||
return name
|
||||
}
|
||||
|
||||
public class func estimatedHeight(forRow json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {
|
||||
guard let items = json?.optionalArrayForKey("list") else {
|
||||
return 0
|
||||
}
|
||||
var estimatedHeight: CGFloat = 0
|
||||
for case let item as [AnyHashable: AnyHashable] in items {
|
||||
if let _ = item.optionalStringForKey(KeyMoleculeName) {
|
||||
let height = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: item)?.estimatedHeight?(forRow: item, delegateObject: delegateObject)
|
||||
estimatedHeight += ((height ?? 0) + 16)
|
||||
}
|
||||
}
|
||||
return estimatedHeight
|
||||
}
|
||||
|
||||
public class func requiredModules(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, error: AutoreleasingUnsafeMutablePointer<MVMCoreErrorObject?>?) -> [String]? {
|
||||
guard let items = json?.optionalArrayForKey("list") else {
|
||||
return nil
|
||||
}
|
||||
var modules: [String] = []
|
||||
for case let item as [AnyHashable: AnyHashable] in items {
|
||||
if let modulesForMolecule = MVMCoreUIMoleculeMappingObject.shared()?.getMoleculeClass(withJSON: item)?.requiredModules?(item, delegateObject: delegateObject, error: error) {
|
||||
modules += modulesForMolecule
|
||||
}
|
||||
}
|
||||
return modules.count > 0 ? modules : nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LeftLabelRightMoleculeContainer: View {
|
||||
|
||||
var label = Label.commonLabelB2(true)
|
||||
var rightContainer = MVMCoreUICommonViewsUtility.commonView()
|
||||
var leftContainer = MVMCoreUICommonViewsUtility.commonView()
|
||||
var rightMoleculeName: String?
|
||||
var rightMolecule: View?
|
||||
let containerHelper = ContainerHelper()
|
||||
var leftText: String?
|
||||
|
||||
var constraintBtwViews: NSLayoutConstraint?
|
||||
var spaceBtwViews: CGFloat = 8 {
|
||||
didSet {
|
||||
if spaceBtwViews != oldValue {
|
||||
constraintBtwViews?.constant = spaceBtwViews
|
||||
layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Inits
|
||||
public override init() {
|
||||
super.init()
|
||||
}
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
}
|
||||
|
||||
public init(withJSON json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.init(frame: CGRect.zero)
|
||||
setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
}
|
||||
|
||||
public required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func setupView() {
|
||||
super.setupView()
|
||||
|
||||
guard rightContainer.superview == nil else {
|
||||
return
|
||||
}
|
||||
|
||||
translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(rightContainer)
|
||||
addSubview(leftContainer)
|
||||
leftContainer.addSubview(label)
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(label, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false)
|
||||
label.rightAnchor.constraint(greaterThanOrEqualTo: leftContainer.leftAnchor).isActive = true
|
||||
let labelRightAnchor = label.rightAnchor.constraint(equalTo: leftContainer.leftAnchor)
|
||||
labelRightAnchor.priority = UILayoutPriority(rawValue: 200)
|
||||
labelRightAnchor.isActive = true
|
||||
leftContainer.bottomAnchor.constraint(greaterThanOrEqualTo: label.bottomAnchor).isActive = true
|
||||
let labelBotAnchor = leftContainer.bottomAnchor.constraint(equalTo: label.bottomAnchor)
|
||||
labelBotAnchor.priority = UILayoutPriority(rawValue: 200)
|
||||
labelBotAnchor.isActive = true
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(leftContainer, pinTop: true, pinBottom: false, pinLeft: true, pinRight: false)
|
||||
bottomAnchor.constraint(greaterThanOrEqualTo: leftContainer.bottomAnchor).isActive = true
|
||||
|
||||
NSLayoutConstraint.constraintPinSubview(rightContainer, pinTop: true, pinBottom: true, pinLeft: false, pinRight: true)
|
||||
constraintBtwViews = rightContainer.leftAnchor.constraint(equalTo: leftContainer.rightAnchor, constant: spaceBtwViews)
|
||||
constraintBtwViews?.priority = .required
|
||||
constraintBtwViews?.isActive = true
|
||||
|
||||
//TODO: Need to get confirmation on this
|
||||
//leftContainer.widthAnchor.constraint(equalTo: widthAnchor, multiplier: 0.05, constant: 0).isActive = true
|
||||
setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||
setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||
rightContainer.setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
|
||||
rightContainer.setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||
|
||||
label.setContentHuggingPriority(.defaultHigh, for: .horizontal)
|
||||
label.setContentHuggingPriority(.defaultHigh, for: .vertical)
|
||||
|
||||
}
|
||||
|
||||
override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
rightMolecule?.updateView(size)
|
||||
label.updateView(size)
|
||||
}
|
||||
|
||||
override func reset() {
|
||||
super.reset()
|
||||
rightMolecule?.reset()
|
||||
}
|
||||
|
||||
override func setWithJSON(_ json: [AnyHashable : Any]?, delegateObject: MVMCoreUIDelegateObject?, additionalData: [AnyHashable : Any]?) {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
let previousMoleculeName = rightMoleculeName
|
||||
removeSubviewsInRightContainer()
|
||||
guard let moleculeJSON = json, let _ = moleculeJSON.optionalStringForKey(KeyMoleculeName) else {
|
||||
super.setWithJSON(json, delegateObject: delegateObject, additionalData: additionalData)
|
||||
return
|
||||
}
|
||||
|
||||
label.text = leftText
|
||||
rightMoleculeName = moleculeJSON.optionalStringForKey(KeyMoleculeName)
|
||||
//For reuse purpose check that allready added molecule is same
|
||||
if let rightMolecule = self.rightMolecule, previousMoleculeName == rightMoleculeName {
|
||||
rightMolecule.setWithJSON(moleculeJSON, delegateObject: delegateObject, additionalData: additionalData)
|
||||
addView(rightMolecule)
|
||||
} else {
|
||||
if let molecule = MVMCoreUIMoleculeMappingObject.shared()?.createMolecule(forJSON: moleculeJSON, delegateObject: delegateObject, constrainIfNeeded: false) {
|
||||
addView(molecule)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func removeSubviewsInRightContainer() {
|
||||
rightContainer.subviews.forEach({ $0.removeFromSuperview() })
|
||||
}
|
||||
|
||||
func addView(_ view: UIView) {
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
rightContainer.addSubview(view)
|
||||
containerHelper.constrainView(view)
|
||||
rightMolecule = view as? View
|
||||
}
|
||||
}
|
||||
@ -1,143 +0,0 @@
|
||||
//
|
||||
// MFTextFieldListView.swift
|
||||
// MobileFirstFramework
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 9/21/18.
|
||||
// Copyright © 2018 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import MVMCore
|
||||
|
||||
@objc public protocol TextFieldListHelperProtocol {
|
||||
@objc optional func fieldForMap(_ map: [String: Any], textField: MFTextField)
|
||||
@objc optional func spaceBetweenField() -> CGFloat
|
||||
}
|
||||
|
||||
public class MFTextFieldListView: ViewConstrainingView {
|
||||
|
||||
public var textFieldMapList: [[String: Any]]?
|
||||
public var parentViewContoller: MFViewController?
|
||||
public var textFieldsToValidate: [MFTextField] = []
|
||||
public var textFields: [MFTextField] = []
|
||||
public var primaryButton: PrimaryButton?
|
||||
|
||||
public init(textFieldMapList: [[String: Any]], parentViewContoller: MFViewController, primaryButton: PrimaryButton?) {
|
||||
self.textFieldMapList = textFieldMapList
|
||||
self.parentViewContoller = parentViewContoller
|
||||
self.primaryButton = primaryButton
|
||||
super.init(frame: .zero)
|
||||
}
|
||||
|
||||
public required init?(coder decoder: NSCoder) {
|
||||
super.init(coder: decoder)
|
||||
}
|
||||
|
||||
public override func updateView(_ size: CGFloat) {
|
||||
super.updateView(size)
|
||||
for textField in textFields {
|
||||
textField.updateView(size)
|
||||
}
|
||||
}
|
||||
|
||||
public override func setupView() {
|
||||
super.setupView()
|
||||
self.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
guard let textFieldMapList = textFieldMapList else {
|
||||
return
|
||||
}
|
||||
var viewList: [UIView] = []
|
||||
|
||||
for textFieldMap in textFieldMapList {
|
||||
if let textField = getTextFieldForMap(textFieldMap) {
|
||||
|
||||
(parentViewContoller as? TextFieldListHelperProtocol)?.fieldForMap?(textFieldMap, textField: textField)
|
||||
|
||||
if textFieldMap.boolForKey("required") {
|
||||
textFieldsToValidate.append(textField)
|
||||
}
|
||||
|
||||
textFields.append(textField)
|
||||
if let fieldKey = textField.fieldKey {
|
||||
parentViewContoller?.register(textField, forErrorKey: fieldKey as String)
|
||||
}
|
||||
viewList.append(textField)
|
||||
}
|
||||
}
|
||||
|
||||
let spaceBtwField = (parentViewContoller as? TextFieldListHelperProtocol)?.spaceBetweenField?() ?? 0.0
|
||||
StackableViewController.populateView(self, withUIArray: viewList) { (viewObject) -> UIEdgeInsets in
|
||||
var edgeInsets = StackableViewController.standardSpaceAroundUIObject()
|
||||
edgeInsets.left = 0
|
||||
edgeInsets.right = 0
|
||||
edgeInsets.top = 0
|
||||
edgeInsets.bottom = spaceBtwField
|
||||
return edgeInsets
|
||||
}
|
||||
|
||||
primaryButton?.handleEnabling(with: textFieldsToValidate)
|
||||
}
|
||||
|
||||
public func addParams(requestParameters: MVMCoreRequestParameters) {
|
||||
requestParameters.add(getTextParamsList())
|
||||
}
|
||||
|
||||
public func getTextParamsList() -> [String: Any] {
|
||||
return DispatchQueue.main.sync {
|
||||
var extraParam: [String: Any] = [:]
|
||||
for textField in textFields {
|
||||
if let fieldKey = textField.fieldKey {
|
||||
extraParam[fieldKey as String] = textField.text ?? ""
|
||||
}
|
||||
}
|
||||
return extraParam
|
||||
}
|
||||
}
|
||||
|
||||
private func getTextFieldForMap(_ map: [String: Any]) -> MFTextField? {
|
||||
if map.boolForKey("dropDown") {
|
||||
let dropDownFld = DropDown(map: map, bothDelegates: self)
|
||||
dropDownFld?.setWithJSON(map, delegateObject: parentViewContoller?.delegateObject() as? MVMCoreUIDelegateObject, additionalData: nil)
|
||||
dropDownFld?.showDropDown(true)
|
||||
return dropDownFld
|
||||
}
|
||||
return MFTextField(map: map, bothDelegates: self)
|
||||
}
|
||||
}
|
||||
|
||||
extension MFTextFieldListView: UITextFieldDelegate, UITextViewDelegate, MFTextFieldDelegate {
|
||||
@objc open func textFieldDidEndEditing(_ textField: UITextField) {
|
||||
parentViewContoller?.textFieldDidEndEditing(textField)
|
||||
primaryButton?.handleEnabling(with: textFieldsToValidate)
|
||||
}
|
||||
|
||||
@objc open func dismissFieldInput(_ sender: Any?) {
|
||||
parentViewContoller?.dismissFieldInput(sender)
|
||||
}
|
||||
|
||||
@objc open func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
textField.resignFirstResponder()
|
||||
return true
|
||||
}
|
||||
|
||||
@objc open func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||
parentViewContoller?.textFieldDidBeginEditing(textField)
|
||||
}
|
||||
|
||||
@objc open func entryIsValid(_ textfield: MFTextField?) {
|
||||
DispatchQueue.main.async {
|
||||
if self.parentViewContoller?.responds(to: #selector(MFTextFieldDelegate.entryIsValid(_:))) ?? false {
|
||||
self.parentViewContoller?.entryIsValid(textfield)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc open func entryIsInvalid(_ textfield: MFTextField?) {
|
||||
DispatchQueue.main.async {
|
||||
if self.parentViewContoller?.responds(to: #selector(MFTextFieldDelegate.entryIsInvalid(_:))) ?? false {
|
||||
self.parentViewContoller?.entryIsInvalid(textfield)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,8 +66,7 @@
|
||||
@"tabsListItem": TabsTableViewCell.class,
|
||||
@"dropDownListItem": DropDownFilterTableViewCell.class,
|
||||
@"headlineBodyButton": HeadlineBodyButton.class,
|
||||
@"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class,
|
||||
@"bulletList": BulletList.class
|
||||
@"eyebrowHeadlineBodyLink": EyebrowHeadlineBodyLink.class
|
||||
} mutableCopy];
|
||||
});
|
||||
return mapping;
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
static NSMutableDictionary *viewControllerMapping;
|
||||
dispatch_once(&onceToken, ^{
|
||||
viewControllerMapping = [@{
|
||||
@"textFieldListForm" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[TextFieldListFormViewController class]],
|
||||
@"moleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackTemplate class]],
|
||||
@"centerMoleculeStack" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeStackCenteredTemplate class]],
|
||||
@"moleculeList" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MoleculeListTemplate class]],
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
//
|
||||
// MVMCoreUITextFormViewController.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 1/24/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
open class TextFieldListFormViewController: TopLabelsAndBottomButtonsViewController, TextFieldListHelperProtocol {
|
||||
|
||||
|
||||
public var textFieldListView: MFTextFieldListView?
|
||||
|
||||
open override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
open override func updateViews() {
|
||||
super.updateViews()
|
||||
}
|
||||
|
||||
open override func newDataBuildScreen() {
|
||||
super.newDataBuildScreen()
|
||||
topLabelsView?.separatorView?.isHidden = true
|
||||
}
|
||||
|
||||
open override func buildViewsBetweenLabelsAndButtons() -> [UIView]? {
|
||||
var viewList: [UIView] = []
|
||||
|
||||
if let textFieldsList = textFieldsLists() {
|
||||
let textFieldListView = MFTextFieldListView(textFieldMapList: textFieldsList,
|
||||
parentViewContoller: self,
|
||||
primaryButton: self.primaryButton)
|
||||
self.textFieldListView = textFieldListView
|
||||
viewList.append(textFieldListView)
|
||||
}
|
||||
return viewList
|
||||
}
|
||||
|
||||
open override func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) {
|
||||
textFieldListView?.addParams(requestParameters: requestParameters)
|
||||
super.handleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: additionalData)
|
||||
}
|
||||
|
||||
open override func spaceAboveBetweenView() -> NSNumber? {
|
||||
return PaddingFour as NSNumber
|
||||
}
|
||||
|
||||
open func textFieldsLists() -> [[String: Any]]? {
|
||||
return loadObject?.pageJSON?.arrayForKey("textFieldList") as? [[String: Any]]
|
||||
}
|
||||
|
||||
//MARK: - Textfield list protocol
|
||||
open func spaceBetweenField() -> CGFloat {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
open func fieldForMap(_ map: [String : Any], textField: MFTextField) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user