Skip to content

Commit

Permalink
[TextFields] fixing color mapping for floatingNormal and floatingActi…
Browse files Browse the repository at this point in the history
…ve Colors. (#3617)

* fixing color mapping for floatingNormal and floatingActive Colors.

* fixing the tests.
  • Loading branch information
mohammadcazig authored and ianegordon committed May 2, 2018
1 parent cd3a53c commit 7e3c5ae
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Expand Up @@ -41,9 +41,9 @@ + (void)applySemanticColorScheme:(nonnull id<MDCColorScheming>)colorScheme
textInputControllerFilled.errorColor = colorScheme.errorColor;
textInputControllerFilled.disabledColor =
[colorScheme.onSurfaceColor colorWithAlphaComponent:kFilledTextFieldDisabledAlpha];
id<MDCTextInputControllerFloatingPlaceholder> textInputControllerFloatingPlaceholder =
(id<MDCTextInputControllerFloatingPlaceholder>)textInputControllerFilled;
textInputControllerFloatingPlaceholder.floatingPlaceholderActiveColor =
textInputControllerFilled.floatingPlaceholderNormalColor =
[colorScheme.onSurfaceColor colorWithAlphaComponent:kFilledTextFieldOnSurfaceAlpha];
textInputControllerFilled.floatingPlaceholderActiveColor =
[colorScheme.primaryColor colorWithAlphaComponent:kFilledTextFieldActiveAlpha];
}

Expand Down
Expand Up @@ -43,6 +43,7 @@ + (void)applySemanticColorScheme:(id<MDCColorScheming>)colorScheme
(id<MDCTextInputControllerFloatingPlaceholder>)textInputController;
if ([textInputControllerFloatingPlaceholder
respondsToSelector:@selector(setFloatingPlaceholderNormalColor:)]) {
textInputControllerFloatingPlaceholder.floatingPlaceholderNormalColor = onSurfaceOpacity;
textInputControllerFloatingPlaceholder.floatingPlaceholderActiveColor =
[colorScheme.primaryColor colorWithAlphaComponent:kOutlinedTextFieldActiveAlpha];
}
Expand Down
13 changes: 6 additions & 7 deletions components/TextFields/src/ColorThemer/MDCTextFieldColorThemer.m
Expand Up @@ -69,12 +69,9 @@ + (void)applySemanticColorScheme:(id<MDCColorScheming>)colorScheme
conformsToProtocol:@protocol(MDCTextInputControllerFloatingPlaceholder)]) {
id<MDCTextInputControllerFloatingPlaceholder> textInputControllerFloatingPlaceholder =
(id<MDCTextInputControllerFloatingPlaceholder>)textInputController;

if ([textInputControllerFloatingPlaceholder
respondsToSelector:@selector(setFloatingPlaceholderNormalColor:)]) {
UIColor *primary87Opacity = [colorScheme.primaryColor colorWithAlphaComponent:0.87f];
textInputControllerFloatingPlaceholder.floatingPlaceholderNormalColor = primary87Opacity;
}
UIColor *primary87Opacity = [colorScheme.primaryColor colorWithAlphaComponent:0.87f];
textInputControllerFloatingPlaceholder.floatingPlaceholderNormalColor = onSurface60Opacity;
textInputControllerFloatingPlaceholder.floatingPlaceholderActiveColor = primary87Opacity;
}
}

Expand Down Expand Up @@ -112,7 +109,9 @@ + (void)applySemanticColorScheme:(id<MDCColorScheming>)colorScheme
(Class<MDCTextInputControllerFloatingPlaceholder>)textInputControllerClass;
UIColor *primary87Opacity = [colorScheme.primaryColor colorWithAlphaComponent:0.87f];
[textInputControllerFloatingPlaceholderClass
setFloatingPlaceholderNormalColorDefault:primary87Opacity];
setFloatingPlaceholderNormalColorDefault:onSurface60Opacity];
[textInputControllerFloatingPlaceholderClass
setFloatingPlaceholderActiveColorDefault:primary87Opacity];
}
}
#if !defined(__IPHONE_11_0)
Expand Down
6 changes: 4 additions & 2 deletions components/TextFields/tests/unit/TextFieldColorThemerTests.m
Expand Up @@ -48,8 +48,8 @@ + (void)resetDefaultsForClass:(Class<MDCTextInputController>)textInputController
conformsToProtocol:@protocol(MDCTextInputControllerFloatingPlaceholder)]) {
Class<MDCTextInputControllerFloatingPlaceholder> textInputControllerFloatingPlaceholderClass =
(Class<MDCTextInputControllerFloatingPlaceholder>)textInputControllerClass;
[textInputControllerFloatingPlaceholderClass
setFloatingPlaceholderNormalColorDefault:nil];
[textInputControllerFloatingPlaceholderClass setFloatingPlaceholderActiveColorDefault:nil];
[textInputControllerFloatingPlaceholderClass setFloatingPlaceholderNormalColorDefault:nil];
}
}
#if !defined(__IPHONE_11_0)
Expand Down Expand Up @@ -96,6 +96,8 @@ - (void)testDefaultValuesAreSet {
XCTAssertEqualObjects(MDCTextInputControllerBase.leadingUnderlineLabelTextColorDefault,
onSurface60Opacity);
XCTAssertEqualObjects(MDCTextInputControllerBase.floatingPlaceholderNormalColorDefault,
onSurface60Opacity);
XCTAssertEqualObjects(MDCTextInputControllerBase.floatingPlaceholderActiveColorDefault,
primary87Opacity);

XCTAssertEqualObjects(MDCTextInputControllerFullWidth.errorColorDefault, colorScheme.errorColor);
Expand Down

0 comments on commit 7e3c5ae

Please sign in to comment.