This repository was archived by the owner on Mar 7, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 143
Highlight disabled text field if it is not valid #550
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| @import UIKit; | ||
| @import XCTest; | ||
|
|
||
| #import "FORMTextField.h" | ||
| #import "FORMField+Tests.h" | ||
| #import "FORMField.h" | ||
|
|
||
| @interface FORMTextFieldTests : XCTestCase | ||
|
|
||
| @property (nonatomic, strong) UIColor* invalidColor; | ||
| @property (nonatomic, strong) UIColor* validColor; | ||
| @property (nonatomic, strong) UIColor* disabledColor; | ||
|
|
||
| @end | ||
|
|
||
| @implementation FORMTextFieldTests | ||
|
|
||
| - (void)testNotValidWithEnabledField { | ||
| FORMTextField *field = [self formField]; | ||
| field.enabled = YES; | ||
| field.valid = NO; | ||
|
|
||
| XCTAssertTrue(CGColorEqualToColor(field.backgroundColor.CGColor, self.invalidColor.CGColor)); | ||
| XCTAssertTrue(CGColorEqualToColor(field.layer.borderColor, self.invalidColor.CGColor)); | ||
| } | ||
|
|
||
| - (void)testNotValidWithDisabledField { | ||
| FORMTextField *field = [self formField]; | ||
| field.enabled = NO; | ||
| field.valid = NO; | ||
|
|
||
| XCTAssertTrue(CGColorEqualToColor(field.backgroundColor.CGColor, self.invalidColor.CGColor)); | ||
| XCTAssertTrue(CGColorEqualToColor(field.layer.borderColor, self.invalidColor.CGColor)); | ||
| } | ||
|
|
||
| - (void)testValidWithEnabledField { | ||
| FORMTextField *field = [self formField]; | ||
| field.enabled = YES; | ||
| field.valid = YES; | ||
|
|
||
| XCTAssertTrue(CGColorEqualToColor(field.backgroundColor.CGColor, self.validColor.CGColor)); | ||
| XCTAssertTrue(CGColorEqualToColor(field.layer.borderColor, self.validColor.CGColor)); | ||
| } | ||
|
|
||
| - (void)testValidWithDisabledField { | ||
| FORMTextField *field = [self formField]; | ||
| field.enabled = NO; | ||
| field.valid = YES; | ||
|
|
||
| XCTAssertTrue(CGColorEqualToColor(field.backgroundColor.CGColor, self.disabledColor.CGColor)); | ||
| XCTAssertTrue(CGColorEqualToColor(field.layer.borderColor, self.disabledColor.CGColor)); | ||
| } | ||
|
|
||
| #pragma mark - Helpers | ||
|
|
||
| - (UIColor*)invalidColor | ||
| { | ||
| if (!_invalidColor) { | ||
| _invalidColor = [UIColor redColor]; | ||
| } | ||
| return _invalidColor; | ||
| } | ||
|
|
||
| - (UIColor*)validColor | ||
| { | ||
| if (!_validColor) { | ||
| _validColor = [UIColor greenColor]; | ||
| } | ||
| return _validColor; | ||
| } | ||
|
|
||
| - (UIColor*)disabledColor | ||
| { | ||
| if (!_disabledColor) { | ||
| _disabledColor = [UIColor grayColor]; | ||
| } | ||
| return _disabledColor; | ||
| } | ||
|
|
||
|
|
||
| - (FORMTextField *)formField { | ||
| FORMTextField *field = [FORMTextField new]; | ||
| field.typeString = @"float"; | ||
| field.type = FORMFieldTypeFloat; | ||
| [field setInvalidBackgroundColor:self.invalidColor]; | ||
| [field setInvalidBorderColor:self.invalidColor]; | ||
| [field setDisabledBackgroundColor:self.disabledColor]; | ||
| [field setDisabledBorderColor:self.disabledColor]; | ||
| [field setValidBackgroundColor:self.validColor]; | ||
| [field setValidBorderColor:self.validColor]; | ||
|
|
||
| return field; | ||
| } | ||
|
|
||
| @end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if you guys see any implication of calling
validatehere. I's done to updateisValidproperty considering the new value whenever the field is changed.