Merge pull request #5 in BPHVB/mvm_core_ui from feature/core_text_view to develop

* commit 'c22e1f69b206f1dcaedcd0afd5bdfeb9ddbcfc5b':
  rename
  MVMCoreUITextFormViewController
  fixes
  move MFTextFieldListView
This commit is contained in:
Pfeil, Scott Robert 2019-01-24 16:28:31 -05:00
commit 68d5ffb9a8
4 changed files with 188 additions and 1 deletions

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */; };
01DF567021FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01DF566F21FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift */; };
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */; };
D29770C921F7C4AE00B2F0D0 /* TopLabelsView.h in Headers */ = {isa = PBXBuildFile; fileRef = D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */; settings = {ATTRIBUTES = (Public, ); }; };
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */; };
@ -142,6 +144,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFTextFieldListView.swift; sourceTree = "<group>"; };
01DF566F21FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MVMCoreUITextFieldListFormViewController.swift; sourceTree = "<group>"; };
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsView.m; sourceTree = "<group>"; };
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TopLabelsView.h; sourceTree = "<group>"; };
D29770EE21F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TopLabelsAndBottomButtonsTableViewController.m; sourceTree = "<group>"; };
@ -334,6 +338,7 @@
D29DF0DF21E418B2003B2FB9 /* Templates */ = {
isa = PBXGroup;
children = (
01DF566F21FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift */,
D29DF0E021E4F3B6003B2FB9 /* MVMCoreUILargeHeaderSingleLabelTemplate.h */,
D29DF0E121E4F3B6003B2FB9 /* MVMCoreUILargeHeaderSingleLabelTemplate.m */,
);
@ -362,6 +367,7 @@
D29DF10E21E67A77003B2FB9 /* Molecules */ = {
isa = PBXGroup;
children = (
01DF55DF21F8FAA800CC099B /* MFTextFieldListView.swift */,
D29770C721F7C4AE00B2F0D0 /* TopLabelsView.h */,
D29770C621F7C4AE00B2F0D0 /* TopLabelsView.m */,
D29770F621F7C73800B2F0D0 /* PrimaryButtonView.h */,
@ -799,6 +805,7 @@
D2C5001921F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m in Sources */,
D29DF12E21E6851E003B2FB9 /* MVMCoreUITopAlertView.m in Sources */,
D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */,
01DF567021FA5AB300CC099B /* MVMCoreUITextFieldListFormViewController.swift in Sources */,
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,
@ -817,6 +824,7 @@
D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */,
D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */,
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
01DF55E021F8FAA800CC099B /* MFTextFieldListView.swift in Sources */,
D29DF2C921E7BFC6003B2FB9 /* MFSizeObject.m in Sources */,
D29DF2C721E7BF57003B2FB9 /* MFTabBarInteractor.m in Sources */,
D29DF2A521E7B2A0003B2FB9 /* MFCaretView.m in Sources */,

View File

@ -0,0 +1,123 @@
//
// MFTextFieldListView.swift
// MobileFirstFramework
//
// Created by Suresh, Kamlesh on 9/21/18.
// Copyright © 2018 Verizon Wireless. All rights reserved.
//
import UIKit
import MVMCore
public class MFTextFieldListView: MFView {
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 = MFTextField(map: textFieldMap, bothDelegates: self) {
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)
}
}
StackableViewController.populateView(self, withUIArray: viewList) { (viewObject) -> UIEdgeInsets in
var edgeInsets = StackableViewController.standardSpaceAroundUIObject()
edgeInsets.left = 0
edgeInsets.right = 0
edgeInsets.top = 0
return edgeInsets
}
primaryButton?.handleEnabling(with: textFieldsToValidate)
}
public func addParams(requestParameters: MVMCoreRequestParameters) {
requestParameters.add(getTextParamsList())
}
public func getTextParamsList() -> [String: Any] {
var extraParam: [String: Any] = [:]
for textField in textFields {
if let fieldKey = textField.fieldKey {
extraParam[fieldKey as String] = textField.text ?? ""
}
}
return extraParam
}
}
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)
}
}
}
}

View File

@ -9,6 +9,7 @@
#import "MVMCoreUIViewControllerMappingObject.h"
#import <MVMCore/MVMCoreViewControllerProgrammaticMappingObject.h>
#import "MVMCoreUILargeHeaderSingleLabelTemplate.h"
#import <MVMCoreUI/MVMCoreUI-Swift.h>
@implementation MVMCoreUIViewControllerMappingObject
@ -18,7 +19,10 @@
static dispatch_once_t onceToken;
static NSMutableDictionary *viewControllerMapping;
dispatch_once(&onceToken, ^{
viewControllerMapping = [@{ @"LargeHeaderSingleLabel": [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MVMCoreUILargeHeaderSingleLabelTemplate class]]} mutableCopy];
viewControllerMapping = [@{
@"LargeHeaderSingleLabel": [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MVMCoreUILargeHeaderSingleLabelTemplate class]],
@"TextFieldListForm" : [[MVMCoreViewControllerProgrammaticMappingObject alloc] initWithClass:[MVMCoreUITextFieldListFormViewController class]]
} mutableCopy];
});
return viewControllerMapping;
}

View File

@ -0,0 +1,52 @@
//
// MVMCoreUITextFormViewController.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 1/24/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import UIKit
public class MVMCoreUITextFieldListFormViewController: TopLabelsAndBottomButtonsViewController {
public var textFieldListView: MFTextFieldListView?
public override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
public override func updateViews() {
super.updateViews()
}
public override func newDataBuildScreen() {
super.newDataBuildScreen()
topLabelsView?.separatorView?.isHidden = true
}
public override func buildViewsBetweenLabelsAndButtons() -> [UIView]? {
var viewList: [UIView] = []
if let textFieldsList = loadObject?.pageJSON?.arrayForKey("textFieldList") as? [[String: Any]] {
let textFieldListView = MFTextFieldListView(textFieldMapList: textFieldsList,
parentViewContoller: self,
primaryButton: self.primaryButton)
self.textFieldListView = textFieldListView
viewList.append(textFieldListView)
}
return viewList
}
public override func handleOpenPage(for requestParameters: MVMCoreRequestParameters, actionInformation: [AnyHashable : Any]?, additionalData: [AnyHashable : Any]?) {
textFieldListView?.addParams(requestParameters: requestParameters)
super.handleOpenPage(for: requestParameters, actionInformation: actionInformation, additionalData: additionalData)
}
public override func spaceAboveBetweenView() -> NSNumber? {
return PaddingFour as NSNumber
}
}