This commit is contained in:
Suresh, Kamlesh 2019-05-14 09:55:25 -04:00
commit bd972e8c81
13 changed files with 71 additions and 129 deletions

View File

@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */
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 */; };
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 */; };
@ -171,7 +170,6 @@
/* Begin PBXFileReference section */
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>"; };
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>"; };
@ -325,10 +323,10 @@
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>"; };
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>"; };
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>"; };
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>"; };
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>"; };
@ -578,7 +576,6 @@
DBC4391622442196001AB423 /* CaretView.swift */,
DBC4391722442197001AB423 /* DashLine.swift */,
D29DF17E21E69E2E003B2FB9 /* MFView.h */,
01004F312273972F00991ECC /* MFView+FormValidation.swift */,
D29DF17F21E69E2E003B2FB9 /* MFView.m */,
D29DF31E21ED0CBA003B2FB9 /* LabelView.h */,
D29DF31F21ED0CBA003B2FB9 /* LabelView.m */,
@ -899,7 +896,6 @@
D22D1F572204CE5D0077CEC0 /* MVMCoreUIStackableViewController.m in Sources */,
01DF567021FA5AB300CC099B /* TextFieldListFormViewController.swift in Sources */,
D2A5145F2211DDC100345BFB /* MoleculeStackView.swift in Sources */,
01004F322273972F00991ECC /* MFView+FormValidation.swift in Sources */,
D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */,
D29DF24D21E6A177003B2FB9 /* MFTextField.m in Sources */,
D29DF2A221E7AF4E003B2FB9 /* MVMCoreUIUtility.m in Sources */,

View File

@ -298,14 +298,11 @@
self.uiTextFieldDelegate = delegate;
}
- (void)setWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id<UITextFieldDelegate, MFTextFieldDelegate>)delegate {
- (void)setWithMap:(nullable NSDictionary *)map {
if (map.count == 0) {
return;
}
[MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:delegate];
[self setBothTextFieldDelegates:delegate];
NSString *string = [map string:KeyLabel];
if (string.length > 0) {
self.formText = string;
@ -351,6 +348,12 @@
}
}
- (void)setWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id<UITextFieldDelegate, MFTextFieldDelegate>)delegate {
[MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:delegate];
[self setBothTextFieldDelegates:delegate];
[self setWithMap:map];
}
- (void)setValidationBlock:(BOOL (^)(NSString * _Nullable))validationBlock {
_validationBlock = validationBlock;
[self valueChanged];
@ -560,7 +563,11 @@
if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) {
[FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
[self setWithMap:json bothDelegates:formValidator];
[self setWithMap:json];
self.mfTextFieldDelegate = formValidator;
self.uiTextFieldDelegate = ((MVMCoreUIDelegateObject *)delegateObject).uiTextFieldDelegate;
[MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:self.uiTextFieldDelegate];
}
}

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 (nullable, strong, nonatomic) NSString *fieldKey;
@property (nullable, strong, nonatomic) DelegateObject *delegate;
@property (nullable, strong, nonatomic) MVMCoreUIDelegateObject *delegateObject;
@end
@ -60,12 +60,17 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
- (void)setWithJSON:(NSDictionary *)json delegateObject:(DelegateObject *)delegateObject additionalData:(NSDictionary *)additionalData {
<<<<<<< HEAD
if ([delegateObject isKindOfClass:[MVMCoreUIDelegateObject class]]) {
[FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
}
self.delegate = delegateObject;
=======
[FormValidator setupValidationWithMolecule:self delegate:((MVMCoreUIDelegateObject *)delegateObject).formValidationProtocol];
self.delegateObject = (MVMCoreUIDelegateObject *) delegateObject;
>>>>>>> e90b4c299e84ce13a69fc77d4e69ad027b55fa09
self.fieldKey = [json stringForKey:KeyFieldKey];
self.isRequired = [json boolForKey:KeyRequired];
@ -346,8 +351,7 @@ static const CGFloat CheckBoxHeightWidth = 18.0;
[self.checkMark updateCheckSelected:NO animated:animated];
}
FormValidator *formValidator = ((MVMCoreUIDelegateObject *)self.delegate).formValidationProtocol.formValidatorModel;
[formValidator enableByValidation];
[FormValidator enableByValidationWithDelegate:((MVMCoreUIDelegateObject *)self.delegateObject).formValidationProtocol];
}
- (void)setColor:(nullable UIColor *)color forState:(UIControlState)state {

View File

@ -343,15 +343,24 @@
- (BOOL)isOverridingRightButton {
NSDictionary *rightPanelLinkDict = [self.loadObject.pageJSON dict:@"rightPanelButtonLink"];
if (rightPanelLinkDict) {
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:rightPanelLinkDict
additionalData:nil
delegateObject:[self delegateObject]];
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:rightPanelLinkDict additionalData:nil delegateObject:[self delegateObject]];
return YES;
} else {
return NO;
}
}
- (BOOL)isOverridingLeftButton {
NSDictionary *leftPanelLinkDict = [self.loadObject.pageJSON dict:@"leftPanelButtonLink"];
if (leftPanelLinkDict) {
[[MVMCoreActionHandler sharedActionHandler] handleActionWithDictionary:leftPanelLinkDict additionalData:nil delegateObject:[self delegateObject]];
return YES;
} else {
return NO;
}
}
- (void)setSupportShouldBeAccessible:(BOOL)supportShouldBeAccessible {
MVMCoreUISplitViewController *splitViewController = [MVMCoreUISession sharedGlobal].splitViewController;

View File

@ -139,6 +139,22 @@
}
}
- (BOOL)isOverridingLeftButton {
if ([self.viewController respondsToSelector:@selector(isOverridingLeftButton)]) {
return [self.viewController performSelector:@selector(isOverridingLeftButton)];
} else {
return [super isOverridingLeftButton];
}
}
- (BOOL)isOverridingRightButton {
if ([self.viewController respondsToSelector:@selector(isOverridingRightButton)]) {
return [self.viewController performSelector:@selector(isOverridingRightButton)];
} else {
return [super isOverridingRightButton];
}
}
#pragma mark - View Cycle
- (void)loadView {

View File

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

View File

@ -8,63 +8,6 @@
import Foundation
@objc extension FormValidator: UITextFieldDelegate {
public func textFieldDidEndEditing(_ textField: UITextField) {
enableByValidation()
if let delegate = delegate as? UITextFieldDelegate {
delegate.textFieldDidEndEditing?(textField)
}
}
public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
if let delegate = delegate as? UITextFieldDelegate {
return delegate.textFieldShouldReturn?(textField) ?? true
}
return true
}
public func textFieldDidBeginEditing(_ textField: UITextField) {
if let delegate = delegate as? UITextFieldDelegate {
delegate.textFieldDidBeginEditing?(textField)
}
}
public func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
if let delegate = delegate as? UITextFieldDelegate {
return delegate.textFieldShouldBeginEditing?(textField) ?? true
}
return true
}
public func textFieldShouldEndEditing(_ textField: UITextField) -> Bool {
if let delegate = delegate as? UITextFieldDelegate {
return delegate.textFieldShouldEndEditing?(textField) ?? true
}
return true
}
public func textFieldDidEndEditing(_ textField: UITextField, reason: UITextField.DidEndEditingReason) {
if let delegate = delegate as? UITextFieldDelegate {
delegate.textFieldDidEndEditing?(textField, reason: reason)
}
}
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if let delegate = delegate as? UITextFieldDelegate {
return delegate.textField?(textField, shouldChangeCharactersIn: range, replacementString: string) ?? true
}
return true
}
public func textFieldShouldClear(_ textField: UITextField) -> Bool {
if let delegate = delegate as? UITextFieldDelegate {
return delegate.textFieldShouldClear?(textField) ?? true
}
return true
}
}
@objc extension FormValidator: MFTextFieldDelegate {
public func dismissFieldInput(_ sender: Any?) {
if let delegate = delegate as? MFTextFieldDelegate {

View File

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

View File

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

View File

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

View File

@ -11,10 +11,12 @@ import UIKit
open class MVMCoreUIDelegateObject: DelegateObject {
public weak var formValidationProtocol: FormValidationProtocol?
public weak var buttonDelegate: ButtonDelegateProtocol?
public weak var uiTextFieldDelegate: UITextFieldDelegate?
open override func setAll(withDelegate delegate: Any) {
super.setAll(withDelegate: delegate)
formValidationProtocol = delegate as? FormValidationProtocol
buttonDelegate = delegate as? ButtonDelegateProtocol
uiTextFieldDelegate = delegate as? UITextFieldDelegate
}
}

View File

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