enhancements

This commit is contained in:
Suresh, Kamlesh 2019-05-13 13:42:18 -04:00
parent 15388abe2e
commit e90b4c299e
8 changed files with 24 additions and 66 deletions

View File

@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
01004F3022721C3800991ECC /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F2F22721C3800991ECC /* RadioButton.swift */; }; 01004F3022721C3800991ECC /* RadioButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F2F22721C3800991ECC /* RadioButton.swift */; };
01004F322273972F00991ECC /* MFView+FormValidation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01004F312273972F00991ECC /* MFView+FormValidation.swift */; };
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; }; 0105618D224BBE7700E1557D /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618A224BBE7700E1557D /* FormValidator.swift */; };
0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */; }; 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 */; }; 0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */; };
@ -171,7 +170,6 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
01004F2F22721C3800991ECC /* RadioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = "<group>"; }; 01004F2F22721C3800991ECC /* RadioButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RadioButton.swift; sourceTree = "<group>"; };
01004F312273972F00991ECC /* MFView+FormValidation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MFView+FormValidation.swift"; sourceTree = "<group>"; };
0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = "<group>"; }; 0105618A224BBE7700E1557D /* FormValidator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = "<group>"; };
0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+TextFields.swift"; sourceTree = "<group>"; }; 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>"; }; 0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FormValidator+FormParams.swift"; sourceTree = "<group>"; };
@ -325,10 +323,10 @@
D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = "<group>"; }; D2C5001621F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIViewControllerMappingObject.h; sourceTree = "<group>"; };
D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = "<group>"; }; D2C5001721F8ECDD001DA659 /* MVMCoreUIViewControllerMappingObject.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIViewControllerMappingObject.m; sourceTree = "<group>"; };
D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = "<group>"; }; D2E1FADA2260D3D200AEFD8C /* MVMCoreUIDelegateObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MVMCoreUIDelegateObject.swift; sourceTree = "<group>"; };
DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = "<group>"; }; D2E1FADC2268B25E00AEFD8C /* MoleculeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeTableViewCell.swift; sourceTree = "<group>"; };
D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = "<group>"; }; D2E1FADE2268B8E700AEFD8C /* ThreeLayerTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerTableViewController.swift; sourceTree = "<group>"; };
D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = "<group>"; }; D2E1FAE02268E81D00AEFD8C /* MoleculeListTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoleculeListTemplate.swift; sourceTree = "<group>"; };
DB891E822253FA8500022516 /* Label.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Label.swift; sourceTree = "<group>"; };
DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = "<group>"; }; DBC4391622442196001AB423 /* CaretView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretView.swift; sourceTree = "<group>"; };
DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = "<group>"; }; DBC4391722442197001AB423 /* DashLine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DashLine.swift; sourceTree = "<group>"; };
DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = "<group>"; }; DBC4391A224421A0001AB423 /* CaretButton.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CaretButton.swift; sourceTree = "<group>"; };
@ -578,7 +576,6 @@
DBC4391622442196001AB423 /* CaretView.swift */, DBC4391622442196001AB423 /* CaretView.swift */,
DBC4391722442197001AB423 /* DashLine.swift */, DBC4391722442197001AB423 /* DashLine.swift */,
D29DF17E21E69E2E003B2FB9 /* MFView.h */, D29DF17E21E69E2E003B2FB9 /* MFView.h */,
01004F312273972F00991ECC /* MFView+FormValidation.swift */,
D29DF17F21E69E2E003B2FB9 /* MFView.m */, D29DF17F21E69E2E003B2FB9 /* MFView.m */,
D29DF31E21ED0CBA003B2FB9 /* LabelView.h */, D29DF31E21ED0CBA003B2FB9 /* LabelView.h */,
D29DF31F21ED0CBA003B2FB9 /* LabelView.m */, D29DF31F21ED0CBA003B2FB9 /* LabelView.m */,
@ -899,7 +896,6 @@
D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */, D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */,
01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */, 01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */,
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */, D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
01004F322273972F00991ECC /* MFView+FormValidation.swift in Sources */,
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */, D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */, D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */, D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,

View File

@ -1,34 +0,0 @@
//
// MFView+FormValidation.swift
// MVMCoreUI
//
// Created by Suresh, Kamlesh on 4/26/19.
// Copyright © 2019 Verizon Wireless. All rights reserved.
//
import Foundation
fileprivate struct FormValidatorHolder {
static var formValidator: FormValidator?
}
extension FormValidationProtocol where Self: MFView {
var formValidator: FormValidator? {
get {
return FormValidatorHolder.formValidator
}
set(newValue) {
FormValidatorHolder.formValidator = newValue
}
}
func setupFormValidation(delegateObject: DelegateObject?) {
if let delegateObject = delegateObject as? MVMCoreUIDelegateObject,
let formValidationProtocol = delegateObject.formValidationProtocol {
FormValidator.setupValidation(molecule: self, delegate:formValidationProtocol)
formValidator = FormValidator.getFormValidatorFor(delegate:formValidationProtocol)
}
}
}

View File

@ -42,7 +42,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
@property (nonatomic) BOOL isRequired; @property (nonatomic) BOOL isRequired;
@property (nullable, strong, nonatomic) NSString *fieldKey; @property (nullable, strong, nonatomic) NSString *fieldKey;
@property (nullable, strong, nonatomic) DelegateObject *delegate; @property (nullable, strong, nonatomic) MVMCoreUIDelegateObject *delegateObject;
@end @end
@ -61,7 +61,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData { - (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
[FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol]; [FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
self.delegate = delegateObject; self.delegateObject = (MVMCoreUIDelegateObject *) delegateObject;
self.fieldKey = [json stringForKey:KeyFieldKey]; self.fieldKey = [json stringForKey:KeyFieldKey];
self.isRequired = [json boolForKey:KeyRequired]; self.isRequired = [json boolForKey:KeyRequired];
@ -342,10 +342,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
[self.checkMark updateCheckSelected:NO animated:animated]; [self.checkMark updateCheckSelected:NO animated:animated];
} }
if (self.delegate && [self.delegate respondsToSelector:@selector(formValidationProtocol)] && [[self.delegate performSelector:@selector(formValidationProtocol)] respondsToSelector:@selector(formValidatorModel)]) { [FormValidator enableByValidationWithDelegate:((MVMCoreUIDelegateObject *)self.delegateObject).formValidationProtocol];
FormValidator *formValidator = [[self.delegate performSelector:@selector(formValidationProtocol)] performSelector:@selector(formValidatorModel)];
[formValidator enableByValidation];
}
} }
- (void)setColor:(nullable UIColor *)color forState:(UIControlState)state { - (void)setColor:(nullable UIColor *)color forState:(UIControlState)state {

View File

@ -17,12 +17,9 @@ import Foundation
var extraParam: [String: Any] = [:] var extraParam: [String: Any] = [:]
MVMCoreDispatchUtility.performSyncBlock(onMainThread: { MVMCoreDispatchUtility.performSyncBlock(onMainThread: {
for molecule in self.molecules { for molecule in self.molecules {
if let formFieldName = molecule.formFieldName, if let formFieldName = molecule.formFieldName?(),
let formFieldValue = molecule.formFieldValue, let formFieldValue = molecule.formFieldValue?() {
let fieldName = formFieldName(), extraParam[formFieldName] = formFieldValue
let fieldValue = formFieldValue() {
extraParam[fieldName] = fieldValue
} }
} }
}) })

View File

@ -19,19 +19,19 @@ import UIKit
molecules.append(molecule) molecules.append(molecule)
} }
public static func getFormValidatorFor(delegate: FormValidationProtocol) -> FormValidator? { public static func enableByValidationWith(delegate: FormValidationProtocol?) {
if let delegateFormValidatorModel = delegate.formValidatorModel, if let delegate = delegate {
let validator = delegateFormValidatorModel() { let formValidator = FormValidator.getFormValidatorFor(delegate: delegate)
return validator formValidator?.enableByValidation()
} else {
return nil
} }
} }
public static func getFormValidatorFor(delegate: FormValidationProtocol) -> FormValidator? {
return delegate.formValidatorModel?()
}
public static func setupValidation(molecule: UIView & FormValidationProtocol, delegate: FormValidationProtocol?) { public static func setupValidation(molecule: UIView & FormValidationProtocol, delegate: FormValidationProtocol?) {
if let delegateFormValidatorModel = delegate?.formValidatorModel, if let validator = delegate?.formValidatorModel?() {
let validator = delegateFormValidatorModel() {
validator.delegate = delegate validator.delegate = delegate
validator.insertMolecule(molecule) validator.insertMolecule(molecule)
} }

View File

@ -81,7 +81,6 @@ import UIKit
} else { } else {
radioButton.isSelected = !radioButton.isSelected radioButton.isSelected = !radioButton.isSelected
} }
formValidator?.enableByValidation()
} }
func getColor( _ json: [AnyHashable: Any], _ key: String) -> UIColor? { func getColor( _ json: [AnyHashable: Any], _ key: String) -> UIColor? {

View File

@ -17,6 +17,8 @@ import UIKit
var selectedRadioButton: RadioButton? var selectedRadioButton: RadioButton?
var selectedValue: String? var selectedValue: String?
var delegateObject:MVMCoreUIDelegateObject?
// MARK: - Inits // MARK: - Inits
public init() { public init() {
@ -35,7 +37,8 @@ import UIKit
selectedRadioButton?.radioButton.isSelected = false selectedRadioButton?.radioButton.isSelected = false
selectedRadioButton = radioButton selectedRadioButton = radioButton
selectedRadioButton?.radioButton.isSelected = true selectedRadioButton?.radioButton.isSelected = true
formValidator?.enableByValidation()
FormValidator.enableByValidationWith(delegate: self.delegateObject?.formValidationProtocol)
} }
open override func setupView() { open override func setupView() {
@ -56,7 +59,7 @@ extension RadioButtonList: FormValidationProtocol {
// The Field name key value pair for sending to server // The Field name key value pair for sending to server
@objc public func formFieldName() -> String? { @objc public func formFieldName() -> String? {
return selectedRadioButton?.formFieldName() return json?.optionalStringForKey("fieldKey")
} }
// The Feild value key value paid for sending to server // The Feild value key value paid for sending to server
@ -78,7 +81,8 @@ extension RadioButtonList {
return return
} }
setupFormValidation(delegateObject: delegateObject) self.delegateObject = delegateObject
FormValidator.setupValidation(molecule: self, delegate: delegateObject.formValidationProtocol)
StackableViewController.remove(self.subviews) StackableViewController.remove(self.subviews)

View File

@ -33,8 +33,7 @@
@"caretView": CaretView.class, @"caretView": CaretView.class,
@"caretButton": CaretButton.class, @"caretButton": CaretButton.class,
@"textField" : MFTextField.class, @"textField" : MFTextField.class,
@"radioButtonList": RadioButtonList.class, @"radioButton": RadioButtonList.class,
@"radioButton": RadioButton.class,
@"checkbox" : MVMCoreUICheckBox.class @"checkbox" : MVMCoreUICheckBox.class
} mutableCopy]; } mutableCopy];
}); });