code review
This commit is contained in:
parent
ff3055a4c7
commit
8b3d561543
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
@property (strong, nonatomic) NSMutableArray <MFTextField *>*textFields;
|
@property (strong, nonatomic) NSMutableArray <MFTextField *>*textFields;
|
||||||
@property (nonatomic, readwrite, assign) PrimaryButtonType primaryButtonType;
|
@property (nonatomic, readwrite, assign) PrimaryButtonType primaryButtonType;
|
||||||
@property (nonnull, strong, nonatomic) FormValidator* formValidator;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -682,7 +681,6 @@
|
|||||||
|
|
||||||
- (void)setEnabledByValidity {
|
- (void)setEnabledByValidity {
|
||||||
|
|
||||||
|
|
||||||
__block BOOL valid = YES;
|
__block BOOL valid = YES;
|
||||||
[self.textFields enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
[self.textFields enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||||
if (!((MFTextField *)obj).valid) {
|
if (!((MFTextField *)obj).valid) {
|
||||||
@ -711,7 +709,7 @@
|
|||||||
[self setEnabledByValidity];
|
[self setEnabledByValidity];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)addTextFieldsForValidation:(nonnull MFTextField *)textField{
|
- (void)addTextFieldsForValidation:(nonnull MFTextField *)textField {
|
||||||
if (self.textFields == nil) {
|
if (self.textFields == nil) {
|
||||||
self.textFields = [NSMutableArray array];
|
self.textFields = [NSMutableArray array];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textContainerRightPin;
|
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *textContainerRightPin;
|
||||||
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *errorLableRightPin;
|
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *errorLableRightPin;
|
||||||
|
@property (nonatomic) BOOL isMolecule;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -48,6 +49,13 @@
|
|||||||
self.label.font = [MFStyler fontForTextFieldUnderLabel];
|
self.label.font = [MFStyler fontForTextFieldUnderLabel];
|
||||||
[MFStyler styleTextField:self.textField];
|
[MFStyler styleTextField:self.textField];
|
||||||
[self.dashLine updateView:size];
|
[self.dashLine updateView:size];
|
||||||
|
|
||||||
|
if (self.isMolecule) {
|
||||||
|
[self setVerticalPadding:[MFStyler defaultHorizontalPaddingForApplicationWidth]];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
[self setVerticalPadding:0];
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,17 +117,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id<UITextFieldDelegate, MFTextFieldDelegate>)delegate additionalData:(NSDictionary *)additionalData {
|
- (void)setWithJSON:(NSDictionary *)json delegate:(nullable id<UITextFieldDelegate, MFTextFieldDelegate>)delegate additionalData:(NSDictionary *)additionalData {
|
||||||
[FormValidator setupValidationWithMolecule:self delegate: (id<FormValidationProtocol>)delegate];
|
|
||||||
|
self.isMolecule = YES;
|
||||||
|
[FormValidator setupValidationWithMolecule:self delegate:(id<FormValidationProtocol>)delegate];
|
||||||
[self setWithMap:json bothDelegates:delegate];
|
[self setWithMap:json bothDelegates:delegate];
|
||||||
|
|
||||||
FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id<FormValidationProtocol>)delegate];
|
FormValidator *formValidator = [FormValidator getFormValidatorForDelegate:(id<FormValidationProtocol>)delegate];
|
||||||
self.mfTextFieldDelegate = formValidator;
|
self.mfTextFieldDelegate = formValidator;
|
||||||
self.uiTextFieldDelegate = formValidator;
|
self.uiTextFieldDelegate = formValidator;
|
||||||
[self setVerticalPadding:[MFStyler defaultHorizontalPaddingForApplicationWidth]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setVerticalPadding:(CGFloat) padding {
|
- (void)setVerticalPadding:(CGFloat) padding {
|
||||||
self.textContainerLeftPin.constant = padding;
|
self.textContainerLeftPin.constant = padding;
|
||||||
self.errorLableLeftPin.constant = padding;
|
self.errorLableLeftPin.constant = padding;
|
||||||
self.formLabelLeftPin.constant = padding;
|
self.formLabelLeftPin.constant = padding;
|
||||||
@ -134,7 +142,6 @@
|
|||||||
MFTextField *textField = [self mfTextField];
|
MFTextField *textField = [self mfTextField];
|
||||||
textField.translatesAutoresizingMaskIntoConstraints = NO;
|
textField.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
[textField setWithJSON:map delegate:delegate additionalData:nil];
|
[textField setWithJSON:map delegate:delegate additionalData:nil];
|
||||||
[textField setVerticalPadding:0];
|
|
||||||
return textField;
|
return textField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,53 +326,55 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)setWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id<UITextFieldDelegate, MFTextFieldDelegate>)delegate {
|
- (void)setWithMap:(nullable NSDictionary *)map bothDelegates:(nullable id<UITextFieldDelegate, MFTextFieldDelegate>)delegate {
|
||||||
if (map.count > 0) {
|
if (map.count == 0) {
|
||||||
[MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:delegate];
|
return;
|
||||||
[self setBothTextFieldDelegates:delegate];
|
}
|
||||||
|
|
||||||
NSString *string = [map string:KeyLabel];
|
[MVMCoreUICommonViewsUtility addDismissToolbar:self.textField delegate:delegate];
|
||||||
if (string.length > 0) {
|
[self setBothTextFieldDelegates:delegate];
|
||||||
self.formText = string;
|
|
||||||
}
|
NSString *string = [map string:KeyLabel];
|
||||||
string = [map string:KeyValue];
|
if (string.length > 0) {
|
||||||
if (string.length > 0) {
|
self.formText = string;
|
||||||
self.text = string;
|
}
|
||||||
}
|
string = [map string:KeyValue];
|
||||||
string = [map stringForKey:KeyDisable];
|
if (string.length > 0) {
|
||||||
if ([string isEqual:StringY] || [map boolForKey:KeyDisable]) {
|
self.text = string;
|
||||||
[self enable:NO];
|
}
|
||||||
}
|
string = [map stringForKey:KeyDisable];
|
||||||
string = [map string:KeyErrorMessage];
|
if ([string isEqual:StringY] || [map boolForKey:KeyDisable]) {
|
||||||
if (string.length > 0) {
|
[self enable:NO];
|
||||||
self.errMessage = string;
|
}
|
||||||
}
|
string = [map string:KeyErrorMessage];
|
||||||
|
if (string.length > 0) {
|
||||||
// key used to send text value to server
|
self.errMessage = string;
|
||||||
string = [map string:@"fieldKey"];
|
}
|
||||||
if (string.length > 0) {
|
|
||||||
self.fieldKey = string;
|
// key used to send text value to server
|
||||||
}
|
string = [map string:@"fieldKey"];
|
||||||
|
if (string.length > 0) {
|
||||||
string = [map string:KeyType];
|
self.fieldKey = string;
|
||||||
if ([string isEqualToString:@"dropDown"]) {
|
}
|
||||||
[[self dropDownCarrotLabel] setHidden:NO];
|
|
||||||
[self setHasDropDown:YES];
|
string = [map string:KeyType];
|
||||||
} else if ([string isEqualToString:@"password"]) {
|
if ([string isEqualToString:@"dropDown"]) {
|
||||||
self.textField.secureTextEntry = YES;
|
[[self dropDownCarrotLabel] setHidden:NO];
|
||||||
} else if ([string isEqualToString:@"number"]) {
|
[self setHasDropDown:YES];
|
||||||
self.textField.keyboardType = UIKeyboardTypeNumberPad;
|
} else if ([string isEqualToString:@"password"]) {
|
||||||
} else if ([string isEqualToString:@"email"]) {
|
self.textField.secureTextEntry = YES;
|
||||||
self.textField.keyboardType = UIKeyboardTypeEmailAddress;
|
} else if ([string isEqualToString:@"number"]) {
|
||||||
}
|
self.textField.keyboardType = UIKeyboardTypeNumberPad;
|
||||||
|
} else if ([string isEqualToString:@"email"]) {
|
||||||
string = [map string:@"regex"];
|
self.textField.keyboardType = UIKeyboardTypeEmailAddress;
|
||||||
if (string.length) {
|
}
|
||||||
self.validationBlock = ^BOOL(NSString * _Nullable enteredValue) {
|
|
||||||
return [MVMCoreUIUtility validateString:enteredValue withRegularExpression:string];
|
string = [map string:@"regex"];
|
||||||
};
|
if (string.length) {
|
||||||
} else {
|
self.validationBlock = ^BOOL(NSString * _Nullable enteredValue) {
|
||||||
[self setDefaultValidationBlock];
|
return [MVMCoreUIUtility validateString:enteredValue withRegularExpression:string];
|
||||||
}
|
};
|
||||||
|
} else {
|
||||||
|
[self setDefaultValidationBlock];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user