swifting
This commit is contained in:
parent
69309cf3b1
commit
629736b7fc
@ -7,13 +7,11 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
01174B912243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01174B902243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift */; };
|
||||
01BDA2D522442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01BDA2D422442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.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 */; };
|
||||
01056191224BBE8000E1557D /* FormValidationProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01056190224BBE7F00E1557D /* FormValidationProtocol.swift */; };
|
||||
01BDA2D722442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */; };
|
||||
01C0B24A224A9C2000F89DF2 /* FormValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 01C0B249224A9C2000F89DF2 /* FormValidator.swift */; };
|
||||
01C74D8C22429978009C25A3 /* MVMCoreUIFormValidator.h in Headers */ = {isa = PBXBuildFile; fileRef = 01C74D8A22429978009C25A3 /* MVMCoreUIFormValidator.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
01C74D8D22429978009C25A3 /* MVMCoreUIFormValidator.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C74D8B22429978009C25A3 /* MVMCoreUIFormValidator.m */; };
|
||||
01C74D8F22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 01C74D8E22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
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, ); }; };
|
||||
@ -169,13 +167,11 @@
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
01174B902243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIFormValidator+TextFields.swift"; sourceTree = "<group>"; };
|
||||
01BDA2D422442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUIFormValidator+FormParams.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>"; };
|
||||
01056190224BBE7F00E1557D /* FormValidationProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormValidationProtocol.swift; sourceTree = "<group>"; };
|
||||
01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormMoleculesProtocol.h; sourceTree = "<group>"; };
|
||||
01C0B249224A9C2000F89DF2 /* FormValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormValidator.swift; sourceTree = "<group>"; };
|
||||
01C74D8A22429978009C25A3 /* MVMCoreUIFormValidator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormValidator.h; sourceTree = "<group>"; };
|
||||
01C74D8B22429978009C25A3 /* MVMCoreUIFormValidator.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUIFormValidator.m; sourceTree = "<group>"; };
|
||||
01C74D8E22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIFormValidationProtocol.h; 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>"; };
|
||||
D206997521FB8A0B00CAE0DE /* MVMCoreUINavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUINavigationController.h; sourceTree = "<group>"; };
|
||||
@ -349,7 +345,7 @@
|
||||
01C74D86224298C3009C25A3 /* Protocols */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
01C74D8E22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h */,
|
||||
01056190224BBE7F00E1557D /* FormValidationProtocol.swift */,
|
||||
01BDA2D622442F59001DACC9 /* MVMCoreUIFormMoleculesProtocol.h */,
|
||||
);
|
||||
path = Protocols;
|
||||
@ -358,11 +354,9 @@
|
||||
01C74D87224298E2009C25A3 /* Models */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
01C0B249224A9C2000F89DF2 /* FormValidator.swift */,
|
||||
01C74D8A22429978009C25A3 /* MVMCoreUIFormValidator.h */,
|
||||
01C74D8B22429978009C25A3 /* MVMCoreUIFormValidator.m */,
|
||||
01174B902243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift */,
|
||||
01BDA2D422442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift */,
|
||||
0105618A224BBE7700E1557D /* FormValidator.swift */,
|
||||
0105618C224BBE7700E1557D /* FormValidator+FormParams.swift */,
|
||||
0105618B224BBE7700E1557D /* FormValidator+TextFields.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
@ -739,7 +733,6 @@
|
||||
D29DF27921E7A533003B2FB9 /* MVMCoreUISession.h in Headers */,
|
||||
D29DF25C21E6A2B6003B2FB9 /* DashLine.h in Headers */,
|
||||
D206997721FB8A0B00CAE0DE /* MVMCoreUINavigationController.h in Headers */,
|
||||
01C74D8C22429978009C25A3 /* MVMCoreUIFormValidator.h in Headers */,
|
||||
D29DF29D21E7AE38003B2FB9 /* MFStyler.h in Headers */,
|
||||
D29DF2B021E7B3A4003B2FB9 /* MFTextView.h in Headers */,
|
||||
D29DF2A921E7B2F9003B2FB9 /* MVMCoreUIConstants.h in Headers */,
|
||||
@ -799,7 +792,6 @@
|
||||
D29DF17421E69E1F003B2FB9 /* MFCustomButton.h in Headers */,
|
||||
D29DF29721E7ADB8003B2FB9 /* MFScrollingViewController.h in Headers */,
|
||||
D29DF26F21E6AA0B003B2FB9 /* FLAnimatedImageView.h in Headers */,
|
||||
01C74D8F22429A0F009C25A3 /* MVMCoreUIFormValidationProtocol.h in Headers */,
|
||||
D29DF2A121E7AF4E003B2FB9 /* MVMCoreUIUtility.h in Headers */,
|
||||
D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */,
|
||||
D29DF2C821E7BFC1003B2FB9 /* MFSizeObject.h in Headers */,
|
||||
@ -892,7 +884,6 @@
|
||||
files = (
|
||||
D29DF32121ED0CBA003B2FB9 /* LabelView.m in Sources */,
|
||||
D29770F221F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsTableViewController.m in Sources */,
|
||||
01BDA2D522442E6B001DACC9 /* MVMCoreUIFormValidator+FormParams.swift in Sources */,
|
||||
D29DF29621E7ADB8003B2FB9 /* StackableViewController.m in Sources */,
|
||||
D22D1F1F220343560077CEC0 /* MVMCoreUICheckMarkView.m in Sources */,
|
||||
D282AAB4223FDDAE00C46919 /* MFLoadImageView.swift in Sources */,
|
||||
@ -920,6 +911,7 @@
|
||||
D28B4F8B21FF967C00712C7A /* MVMCoreUIObject.m in Sources */,
|
||||
D29DF26D21E6AA0B003B2FB9 /* FLAnimatedImageView.m in Sources */,
|
||||
D29DF2EF21ECEAE1003B2FB9 /* MFFonts.m in Sources */,
|
||||
0105618F224BBE7700E1557D /* FormValidator+FormParams.swift in Sources */,
|
||||
D29DF2AE21E7B3A4003B2FB9 /* MFTextView.m in Sources */,
|
||||
D29DF18121E69E50003B2FB9 /* MFView.m in Sources */,
|
||||
D29DF18321E69E54003B2FB9 /* SeparatorView.m in Sources */,
|
||||
@ -927,7 +919,6 @@
|
||||
D274CA332236A78900B01B62 /* StandardFooterView.swift in Sources */,
|
||||
D29DF2BF21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.m in Sources */,
|
||||
D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */,
|
||||
01C74D8D22429978009C25A3 /* MVMCoreUIFormValidator.m in Sources */,
|
||||
D29DF28A21E7AC2B003B2FB9 /* MFLabel.m in Sources */,
|
||||
D206997821FB8A0B00CAE0DE /* MVMCoreUINavigationController.m in Sources */,
|
||||
D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */,
|
||||
@ -942,6 +933,7 @@
|
||||
D22D1F47220496A30077CEC0 /* MVMCoreUISwitch.m in Sources */,
|
||||
D29DF28C21E7AC2B003B2FB9 /* ViewConstrainingView.m in Sources */,
|
||||
D29DF17B21E69E1F003B2FB9 /* PrimaryButton.m in Sources */,
|
||||
01056191224BBE8000E1557D /* FormValidationProtocol.swift in Sources */,
|
||||
D29DF11D21E684A9003B2FB9 /* MVMCoreUISplitViewController.m in Sources */,
|
||||
D29DF29821E7ADB8003B2FB9 /* MFScrollingViewController.m in Sources */,
|
||||
D29770C821F7C4AE00B2F0D0 /* TopLabelsView.m in Sources */,
|
||||
@ -950,18 +942,18 @@
|
||||
D29DF17821E69E1F003B2FB9 /* MFCaretButton.m in Sources */,
|
||||
D29DF11821E6805F003B2FB9 /* NSLayoutConstraint+MFConvenience.m in Sources */,
|
||||
D29DF26C21E6AA0B003B2FB9 /* FLAnimatedImage.m in Sources */,
|
||||
01C0B24A224A9C2000F89DF2 /* FormValidator.swift in Sources */,
|
||||
D29770FC21F7C77400B2F0D0 /* MVMCoreUITextFieldView.m in Sources */,
|
||||
D29DF25121E6A177003B2FB9 /* MFDigitTextBox.m in Sources */,
|
||||
D29DF13221E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.m in Sources */,
|
||||
D2C5001E21F8EE67001DA659 /* LabelWithInternalButton.m in Sources */,
|
||||
01174B912243E54200A8FE68 /* MVMCoreUIFormValidator+TextFields.swift in Sources */,
|
||||
D29DF29C21E7ADB9003B2FB9 /* MFProgrammaticTableViewController.m in Sources */,
|
||||
0105618E224BBE7700E1557D /* FormValidator+TextFields.swift in Sources */,
|
||||
D29DF2BE21E7BEA4003B2FB9 /* TopTabbar.m in Sources */,
|
||||
D2A514632213643100345BFB /* MoleculeStackCenteredTemplate.swift in Sources */,
|
||||
D29DF32421ED0DA2003B2FB9 /* TextButtonView.m in Sources */,
|
||||
D29DF29E21E7AE3B003B2FB9 /* MFStyler.m in Sources */,
|
||||
D2A514592211C53C00345BFB /* MVMCoreUIMoleculeMappingObject.m in Sources */,
|
||||
0105618D224BBE7700E1557D /* FormValidator.swift in Sources */,
|
||||
D22D1F1B220341F60077CEC0 /* MVMCoreUICheckBox.m in Sources */,
|
||||
D29DF2CB21E7BFCC003B2FB9 /* MFSizeThreshold.m in Sources */,
|
||||
D29770F521F7C6D600B2F0D0 /* TopLabelsAndBottomButtonsViewController.m in Sources */,
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#import <MVMCoreUI/MFTextField.h>
|
||||
#import <MVMCoreUI/MFView.h>
|
||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||
#import "MVMCoreUIFormValidationProtocol.h"
|
||||
|
||||
typedef enum : NSUInteger {
|
||||
PrimaryButtonTypeRed,
|
||||
@ -27,7 +26,7 @@ typedef enum : NSUInteger {
|
||||
static CGFloat const PrimaryButtonHeight = 42.0;
|
||||
static CGFloat const PrimaryButtonSmallHeight = 30.0;
|
||||
|
||||
@interface PrimaryButton : MFCustomButton <MFTextFieldDelegate, UITextFieldDelegate, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIFormValidationProtocol>
|
||||
@interface PrimaryButton : MFCustomButton <MFTextFieldDelegate, UITextFieldDelegate, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol>
|
||||
|
||||
@property (nonatomic, readonly, assign) PrimaryButtonType primaryButtonType; //use reset function to set
|
||||
|
||||
|
||||
@ -12,14 +12,14 @@
|
||||
#import "MVMCoreUISplitViewController.h"
|
||||
#import "MFStyler.h"
|
||||
#import "UIColor+MFConvenience.h"
|
||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
|
||||
#import "MVMCoreUIFormValidator.h"
|
||||
|
||||
@import MVMCore.MVMCoreDispatchUtility;
|
||||
@import MVMCore.MVMCoreGetterUtility;
|
||||
@import MVMCore.NSDictionary_MFConvenience;
|
||||
|
||||
@interface PrimaryButton()
|
||||
@interface PrimaryButton() <FormValidationProtocol>
|
||||
|
||||
@property (nonatomic) BOOL validationRequired;
|
||||
@property (nonatomic) BOOL smallButton;
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
@property (strong, nonatomic) NSMutableArray <MFTextField *>*textFields;
|
||||
@property (nonatomic, readwrite, assign) PrimaryButtonType primaryButtonType;
|
||||
@property (strong, nonatomic) MVMCoreUIFormValidator* formValidator;
|
||||
@property (nonnull, strong, nonatomic) FormValidator* formValidator;
|
||||
|
||||
@end
|
||||
|
||||
@ -648,8 +648,8 @@
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(NSObject *)delegate additionalData:(nullable NSDictionary *)additionalData {
|
||||
|
||||
[MVMCoreUIFormValidator setupValidationFor:self delegate:delegate];
|
||||
|
||||
[FormValidator setupValidationWithMolecule:self delegate:(id<FormValidationProtocol>)delegate];
|
||||
|
||||
self.primaryButtonType = PrimaryButtonTypeCustom;
|
||||
NSString *color = [json string:@"fillColor"];
|
||||
@ -758,13 +758,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - MVMCoreUIFormValidationProtocol
|
||||
#pragma mark - FormValidationProtocol
|
||||
|
||||
- (nullable MVMCoreUIFormValidator *) formValidatorModel {
|
||||
- (nullable FormValidator*) formValidatorModel {
|
||||
return self.formValidator;
|
||||
}
|
||||
|
||||
- (void)setFormValidationModel:(nonnull MVMCoreUIFormValidator *) formValidatorModel {
|
||||
- (void)setFormValidationModel:(nonnull FormValidator*) formValidatorModel {
|
||||
self.formValidator = formValidatorModel;
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <MVMCoreUI/MFView.h>
|
||||
#import "MVMCoreUIFormValidationProtocol.h"
|
||||
|
||||
@class PrimaryButton;
|
||||
@class MFTextField;
|
||||
@ -29,7 +28,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@interface MFTextField : MFView <MVMCoreUIMoleculeViewProtocol, MVMCoreUIFormValidationProtocol>
|
||||
@interface MFTextField : MFView <MVMCoreUIMoleculeViewProtocol>
|
||||
|
||||
@property (nullable, weak, nonatomic) UIView *view;
|
||||
|
||||
|
||||
@ -15,17 +15,16 @@
|
||||
#import "MFLabel.h"
|
||||
#import "MVMCoreUIUtility.h"
|
||||
#import "MVMCoreUIConstants.h"
|
||||
#import "MVMCoreUIFormValidator.h"
|
||||
|
||||
#import <MVMCore/MVMCore-Swift.h>
|
||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
|
||||
@import MVMCore.MVMCoreDispatchUtility;
|
||||
@import MVMCore.NSDictionary_MFConvenience;
|
||||
@import MVMCore.MVMCoreJSONConstants;
|
||||
|
||||
@interface MFTextField()
|
||||
@interface MFTextField() <FormValidationProtocol>
|
||||
|
||||
@property (strong, nonatomic) MVMCoreUIFormValidator* formValidator;
|
||||
@property (strong, nonatomic) FormValidator* formValidator;
|
||||
@property (strong, nonatomic) UIColor *customPlaceHolderColor;
|
||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *separatorHeightConstraint;
|
||||
@property (strong, nonatomic) UIBezierPath *borderPath;
|
||||
@ -111,7 +110,7 @@
|
||||
}
|
||||
|
||||
- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id<UITextFieldDelegate, MFTextFieldDelegate>)delegate additionalData:(NSDictionary *)additionalData {
|
||||
[MVMCoreUIFormValidator setupValidationFor:self delegate:delegate];
|
||||
[FormValidator setupValidationWithMolecule:self delegate: (id<FormValidationProtocol>)delegate];
|
||||
|
||||
[self setWithMap:json bothDelegates:delegate];
|
||||
self.mfTextFieldDelegate = self.formValidator;
|
||||
@ -563,11 +562,11 @@
|
||||
|
||||
#pragma mark - MVMCoreUIMoleculeViewProtocol
|
||||
|
||||
- (nullable MVMCoreUIFormValidator *) formValidatorModel {
|
||||
- (nullable FormValidator*) formValidatorModel {
|
||||
return self.formValidator;
|
||||
}
|
||||
|
||||
- (void)setFormValidationModel:(nonnull MVMCoreUIFormValidator *) formValidatorModel {
|
||||
- (void)setFormValidationModel:(nonnull FormValidator*) formValidatorModel {
|
||||
self.formValidator = formValidatorModel;
|
||||
}
|
||||
|
||||
|
||||
@ -36,14 +36,12 @@
|
||||
#import "MVMCoreUILoggingHandler.h"
|
||||
#import "MVMCoreUITabBarPageControlViewController.h"
|
||||
#import "MVMCoreUINavigationController.h"
|
||||
#import "MVMCoreUIFormValidationProtocol.h"
|
||||
#import "MVMCoreUIFormValidator.h"
|
||||
#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
|
||||
|
||||
@import MVMAnimationFramework;
|
||||
|
||||
@interface MFViewController() <MVMCoreUIFormValidationProtocol>
|
||||
@interface MFViewController() <FormValidationProtocol>
|
||||
|
||||
// A flag for if this view controller is observing for cache updates or not.
|
||||
@property (nonatomic) BOOL observingForResponseJSONUpdates;
|
||||
@ -57,15 +55,15 @@
|
||||
// title view for navigation bar, used for custom navigation titles
|
||||
@property (weak, nonatomic) UILabel *titleLabel;
|
||||
|
||||
@property (strong, nonatomic) MVMCoreUIFormValidator* formValidator;
|
||||
@property (strong, nonatomic) FormValidator* formValidator;
|
||||
|
||||
@end
|
||||
|
||||
@implementation MFViewController
|
||||
|
||||
- (MVMCoreUIFormValidator *)formValidatorModel {
|
||||
- (FormValidator *)formValidatorModel {
|
||||
if (self.formValidator == nil) {
|
||||
self.formValidator = [MVMCoreUIFormValidator new];
|
||||
self.formValidator = [FormValidator new];
|
||||
}
|
||||
return self.formValidator;
|
||||
}
|
||||
@ -429,7 +427,7 @@
|
||||
|
||||
- (void) updateUI {
|
||||
[self newDataBuildScreen];
|
||||
[self.formValidator setEnabledByValidity];
|
||||
[self.formValidator enableByValidation];
|
||||
|
||||
// Update the UI after the view is loaded.
|
||||
self.needToUpdateUI = YES;
|
||||
|
||||
@ -110,11 +110,5 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[];
|
||||
#pragma mark - Molecules
|
||||
#import <MVMCoreUI/TopLabelsView.h>
|
||||
#import <MVMCoreUI/PrimaryButtonView.h>
|
||||
#import <MVMCoreUI/MVMCoreUIMoleculeViewProtocol.h>
|
||||
|
||||
#import <MVMCoreUI/MVMCoreUIFormValidator.h>
|
||||
#import <MVMCoreUI/MVMCoreUIFormValidationProtocol.h>
|
||||
|
||||
|
||||
|
||||
#pragma mark - Templates
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public extension MVMCoreUIFormValidator {
|
||||
@objc public extension FormValidator {
|
||||
@objc public func addFormParams(requestParameters: MVMCoreRequestParameters) {
|
||||
DispatchQueue.main.sync {
|
||||
requestParameters.add(self.getFormParams())
|
||||
@ -19,8 +19,7 @@ import Foundation
|
||||
|
||||
var extraParam: [String: Any] = [:]
|
||||
for molecule in self.molecules {
|
||||
if let molecule = molecule as? MVMCoreUIFormValidationProtocol,
|
||||
let formFieldName = molecule.formFieldName,
|
||||
if let formFieldName = molecule.formFieldName,
|
||||
let formFieldValue = molecule.formFieldValue,
|
||||
let fieldName = formFieldName(),
|
||||
let fieldValue = formFieldValue() {
|
||||
@ -8,39 +8,39 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc extension MVMCoreUIFormValidator: UITextFieldDelegate, UITextViewDelegate, MFTextFieldDelegate{
|
||||
@objc public func textFieldDidEndEditing(_ textField: UITextField) {
|
||||
setEnabledByValidity()
|
||||
@objc extension FormValidator: UITextFieldDelegate, UITextViewDelegate, MFTextFieldDelegate{
|
||||
public func textFieldDidEndEditing(_ textField: UITextField) {
|
||||
enableByValidation()
|
||||
}
|
||||
|
||||
@objc public func dismissFieldInput(_ sender: Any?) {
|
||||
public func dismissFieldInput(_ sender: Any?) {
|
||||
if let delegate = delegate as? MFTextFieldDelegate,
|
||||
let dismissFieldInput = delegate.dismissFieldInput {
|
||||
dismissFieldInput(sender)
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
textField.resignFirstResponder()
|
||||
return true
|
||||
}
|
||||
|
||||
@objc public func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||
public func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||
if let delegate = delegate as? UITextFieldDelegate,
|
||||
let textFieldDidBeginEditing = delegate.textFieldDidBeginEditing {
|
||||
textFieldDidBeginEditing(textField)
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func entryIsValid(_ textfield: MFTextField?) {
|
||||
public func entryIsValid(_ textfield: MFTextField?) {
|
||||
DispatchQueue.main.async {
|
||||
self.setEnabledByValidity()
|
||||
self.enableByValidation()
|
||||
}
|
||||
}
|
||||
|
||||
@objc public func entryIsInvalid(_ textfield: MFTextField?) {
|
||||
public func entryIsInvalid(_ textfield: MFTextField?) {
|
||||
DispatchQueue.main.async {
|
||||
self.setEnabledByValidity()
|
||||
self.enableByValidation()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,8 +7,48 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
class FormValidator: NSObject {
|
||||
var delegate: MVMCoreUIFormValidationProtocol?
|
||||
var molecules: [MVMCoreUIFormValidationProtocol]?
|
||||
@objcMembers public class FormValidator: NSObject {
|
||||
|
||||
var delegate: FormValidationProtocol?
|
||||
var molecules: [UIView & FormValidationProtocol] = []
|
||||
var extraValidationBlock: (() -> Bool)?
|
||||
|
||||
public func insertMolecule(_ molecule: UIView & FormValidationProtocol) {
|
||||
molecules.append(molecule)
|
||||
}
|
||||
|
||||
public static func setupValidation(molecule: UIView & FormValidationProtocol, delegate: FormValidationProtocol?) {
|
||||
if let delegateFormValidatorModel = delegate?.formValidatorModel,
|
||||
let setFormValidationModel = molecule.setFormValidationModel,
|
||||
let validator = delegateFormValidatorModel() {
|
||||
|
||||
validator.delegate = delegate
|
||||
validator.insertMolecule(molecule)
|
||||
setFormValidationModel(validator)
|
||||
}
|
||||
}
|
||||
|
||||
public func enableByValidation() {
|
||||
|
||||
var valid = true
|
||||
for molecule in molecules {
|
||||
if let isValidField = molecule.isValidField,
|
||||
isValidField() == false {
|
||||
valid = false
|
||||
}
|
||||
}
|
||||
|
||||
let enableField = valid && (extraValidationBlock?() ?? true)
|
||||
shouldEnable(enableField)
|
||||
}
|
||||
|
||||
public func shouldEnable(_ enable: Bool) {
|
||||
for molecule in molecules {
|
||||
if let enableField = molecule.enableField {
|
||||
enableField(enable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,23 +8,21 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "MVMCoreUIFormValidationProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MFTextField;
|
||||
|
||||
@interface MVMCoreUIFormValidator : NSObject
|
||||
|
||||
@property (weak, nonatomic) NSObject <MVMCoreUIFormValidationProtocol>* delegate;
|
||||
@property (strong, nonatomic) NSMutableArray <UIView <MVMCoreUIFormValidationProtocol>*>* molecules;
|
||||
@property (weak, nonatomic) NSObject <FormValidationProtocol>* delegate;
|
||||
@property (strong, nonatomic) NSMutableArray <UIView <FormValidationProtocol>*>* molecules;
|
||||
|
||||
@property (nullable, copy, nonatomic) BOOL(^extraValidationBlock)(void);
|
||||
|
||||
- (void)setEnabledByValidity;
|
||||
- (void)insertMolecule:(nonnull UIView <MVMCoreUIFormValidationProtocol>*) molecule;
|
||||
- (void)insertMolecule:(nonnull UIView <FormValidationProtocol>*) molecule;
|
||||
|
||||
+ (void)setupValidationFor:(nonnull UIView <MVMCoreUIFormValidationProtocol>*) molecule delegate:(nonnull NSObject <MVMCoreUIFormValidationProtocol>*)delegate;
|
||||
+ (void)setupValidationFor:(nonnull UIView <FormValidationProtocol>*) molecule delegate:(nonnull NSObject <FormValidationProtocol>*)delegate;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -11,14 +11,10 @@
|
||||
@import MVMCore.MVMCoreDispatchUtility;
|
||||
|
||||
|
||||
@interface MVMCoreUIFormValidator() <MFTextFieldDelegate, UITextFieldDelegate>
|
||||
@property (strong, nonatomic) NSMutableArray <MFTextField *>*textFields;
|
||||
@end
|
||||
|
||||
@implementation MVMCoreUIFormValidator
|
||||
|
||||
|
||||
- (void)insertMolecule:(nonnull UIView <MVMCoreUIFormValidationProtocol>*) molecule {
|
||||
- (void)insertMolecule:(nonnull UIView <FormValidationProtocol>*) molecule {
|
||||
if (self.molecules == nil) {
|
||||
self.molecules = [NSMutableArray array];
|
||||
}
|
||||
@ -27,10 +23,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)setupValidationFor:(nonnull UIView <MVMCoreUIFormValidationProtocol>*) molecule delegate:(nonnull NSObject <MVMCoreUIFormValidationProtocol>*)delegate {
|
||||
if ([delegate conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)]
|
||||
+ (void)setupValidationFor:(nonnull UIView <FormValidationProtocol>*) molecule delegate:(nonnull NSObject <FormValidationProtocol>*)delegate {
|
||||
if ([delegate conformsToProtocol:@protocol(FormValidationProtocol)]
|
||||
&& [delegate respondsToSelector:@selector(formValidatorModel)]
|
||||
&& [molecule conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)]
|
||||
&& [molecule conformsToProtocol:@protocol(FormValidationProtocol)]
|
||||
&& [molecule respondsToSelector:@selector(setFormValidationModel:)]) {
|
||||
|
||||
MVMCoreUIFormValidator *validator = [delegate formValidatorModel];
|
||||
@ -43,7 +39,7 @@
|
||||
|
||||
- (void)setEnabledByValidity {
|
||||
__block BOOL valid = YES;
|
||||
[self.molecules enumerateObjectsUsingBlock:^(UIView<MVMCoreUIFormValidationProtocol> * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
[self.molecules enumerateObjectsUsingBlock:^(UIView<FormValidationProtocol> * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)]
|
||||
&& [obj respondsToSelector:@selector(isValidField)]
|
||||
&& [obj isValidField] == NO) {
|
||||
@ -56,8 +52,8 @@
|
||||
}
|
||||
|
||||
- (void)shouldEnable:(BOOL) enable {
|
||||
[self.molecules enumerateObjectsUsingBlock:^(UIView<MVMCoreUIFormValidationProtocol> * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj conformsToProtocol:@protocol(MVMCoreUIFormValidationProtocol)]
|
||||
[self.molecules enumerateObjectsUsingBlock:^(UIView<FormValidationProtocol> * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj conformsToProtocol:@protocol(FormValidationProtocol)]
|
||||
&& [obj respondsToSelector:@selector(enableField:)]) {
|
||||
|
||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
||||
|
||||
21
MVMCoreUI/Protocols/FormValidationProtocol.swift
Normal file
21
MVMCoreUI/Protocols/FormValidationProtocol.swift
Normal file
@ -0,0 +1,21 @@
|
||||
//
|
||||
// FormValidationProtocol.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Suresh, Kamlesh on 3/26/19.
|
||||
// Copyright © 2019 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public protocol FormValidationProtocol: NSObjectProtocol {
|
||||
|
||||
@objc func formValidatorModel() -> FormValidator?
|
||||
|
||||
@objc optional func setFormValidationModel(_ formValidatorModel:FormValidator)
|
||||
@objc optional func isValidField() -> Bool
|
||||
@objc optional func enableField(_ enable: Bool)
|
||||
|
||||
@objc optional func formFieldName() -> String?
|
||||
@objc optional func formFieldValue() -> String?
|
||||
}
|
||||
@ -7,6 +7,8 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
//#import <MVMCoreUI/MVMCoreUI-Swift.h>
|
||||
//#import "MVMCoreUI-Swift.h"
|
||||
|
||||
@class MVMCoreUIFormValidator;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user