Skip to content

Commit

Permalink
[TextFields] {BreakingChange} Remove unused backgroundColor property (
Browse files Browse the repository at this point in the history
#4452)

Only MDCTextInputControllerFullWidth is using `backgroundColor` in any
meaningful way. For MDCTextInputControllerBase, the property wasn't used
anywhere in the input controller.

Reduces the scope of #3357
  • Loading branch information
Robert Moore committed Jun 29, 2018
1 parent 2abcf53 commit 55eead6
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 55 deletions.
Expand Up @@ -26,7 +26,6 @@ @implementation MDCFilledTextFieldColorThemer

+ (void)applySemanticColorScheme:(nonnull id<MDCColorScheming>)colorScheme
toTextInputControllerFilled:(nonnull MDCTextInputControllerFilled *)textInputControllerFilled {
textInputControllerFilled.backgroundColor = colorScheme.surfaceColor;
textInputControllerFilled.borderFillColor =
[colorScheme.onSurfaceColor colorWithAlphaComponent:kFilledTextFieldSurfaceOverlayAlpha];
textInputControllerFilled.normalColor =
Expand Down
Expand Up @@ -63,7 +63,6 @@ + (void)applySemanticColorScheme:(id<MDCColorScheming>)colorScheme
textInputController.inlinePlaceholderColor = onSurface60Opacity;
textInputController.trailingUnderlineLabelTextColor = onSurface60Opacity;
textInputController.leadingUnderlineLabelTextColor = onSurface60Opacity;
textInputController.backgroundColor = colorScheme.surfaceColor;

if ([textInputController
conformsToProtocol:@protocol(MDCTextInputControllerFloatingPlaceholder)]) {
Expand Down
13 changes: 0 additions & 13 deletions components/TextFields/src/MDCTextInputController.h
Expand Up @@ -36,19 +36,6 @@
*/
@property(class, nonatomic, null_resettable, strong) UIColor *activeColorDefault;

/**
Color for background for the various views making up a text field.
Default is backgroundColorDefault.
*/
@property(nonatomic, null_resettable, strong) UIColor *backgroundColor;

/**
Default value for backgroundColor.
*/
@property(class, nonatomic, null_resettable, strong) UIColor *backgroundColorDefault;


/**
The character counter. Override to use a custom character counter.
Expand Down
7 changes: 0 additions & 7 deletions components/TextFields/src/MDCTextInputControllerBase.h
Expand Up @@ -59,13 +59,6 @@ extern const CGFloat MDCTextInputControllerBaseDefaultBorderRadius;
*/
@interface MDCTextInputControllerBase : NSObject <MDCTextInputControllerFloatingPlaceholder>

/**
Color for background for the various views making up a text field.
Default is backgroundColorDefault.
*/
@property(nonatomic, null_resettable, strong) UIColor *backgroundColor;

/**
The color behind the input and label that defines the preferred tap zone.
Expand Down
33 changes: 0 additions & 33 deletions components/TextFields/src/MDCTextInputControllerBase.m
Expand Up @@ -45,8 +45,6 @@

static NSString *const MDCTextInputControllerBaseActiveColorKey =
@"MDCTextInputControllerBaseActiveColorKey";
static NSString *const MDCTextInputControllerBaseBackgroundColorKey =
@"MDCTextInputControllerBaseBackgroundColorKey";
static NSString *const MDCTextInputControllerBaseBorderFillColorKey =
@"MDCTextInputControllerBaseBorderFillColorKey";
static NSString *const MDCTextInputControllerBaseCharacterCounterKey =
Expand Down Expand Up @@ -129,7 +127,6 @@
static CGFloat _underlineHeightNormalDefault = 0;

static UIColor *_activeColorDefault;
static UIColor *_backgroundColorDefault;
static UIColor *_borderFillColorDefault;
static UIColor *_disabledColorDefault;
static UIColor *_errorColorDefault;
Expand Down Expand Up @@ -157,7 +154,6 @@ @interface MDCTextInputControllerBase () {
NSNumber *_floatingPlaceholderScale;

UIColor *_activeColor;
UIColor *_backgroundColor;
UIColor *_borderFillColor;
UIColor *_disabledColor;
UIColor *_errorColor;
Expand Down Expand Up @@ -192,7 +188,6 @@ @interface MDCTextInputControllerBase () {

@implementation MDCTextInputControllerBase

@synthesize backgroundColor = _backgroundColor;
@synthesize characterCountMax = _characterCountMax;
@synthesize characterCountViewMode = _characterCountViewMode;
@synthesize floatingEnabled = _floatingEnabled;
Expand Down Expand Up @@ -222,8 +217,6 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self) {
_activeColor = [aDecoder decodeObjectOfClass:[UIColor class]
forKey:MDCTextInputControllerBaseActiveColorKey];
_backgroundColor = [aDecoder decodeObjectOfClass:[UIColor class]
forKey:MDCTextInputControllerBaseBackgroundColorKey];
_borderFillColor = [aDecoder decodeObjectOfClass:[UIColor class]
forKey:MDCTextInputControllerBaseBorderFillColorKey];
_characterCounter =
Expand Down Expand Up @@ -322,7 +315,6 @@ - (instancetype)initWithTextInput:(UIView<MDCTextInput> *)textInput {

- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:self.activeColor forKey:MDCTextInputControllerBaseActiveColorKey];
[aCoder encodeObject:self.backgroundColor forKey:MDCTextInputControllerBaseBackgroundColorKey];
[aCoder encodeObject:self.borderFillColor forKey:MDCTextInputControllerBaseBorderFillColorKey];
if ([self.characterCounter conformsToProtocol:@protocol(NSSecureCoding)]) {
[aCoder encodeObject:self.characterCounter
Expand Down Expand Up @@ -376,7 +368,6 @@ - (instancetype)copyWithZone:(__unused NSZone *)zone {
MDCTextInputControllerBase *copy = [[[self class] alloc] init];

copy.activeColor = self.activeColor;
copy.backgroundColor = self.backgroundColor;
copy.borderFillColor = self.borderFillColor;
copy.characterCounter = self.characterCounter; // Just a pointer value copy
copy.characterCountViewMode = self.characterCountViewMode;
Expand Down Expand Up @@ -961,30 +952,6 @@ + (void)setActiveColorDefault:(UIColor *)activeColorDefault {
: MDCTextInputControllerBaseDefaultActiveColorDefault();
}

- (UIColor *)backgroundColor {
if (!_backgroundColor) {
_backgroundColor = [self class].backgroundColorDefault;
}
return _backgroundColor;
}

- (void)setBackgroundColor:(UIColor *)backgroundColor {
if (_backgroundColor != backgroundColor) {
_backgroundColor = backgroundColor ?: [self class].backgroundColorDefault;
}
}

+ (UIColor *)backgroundColorDefault {
if (!_backgroundColorDefault) {
_backgroundColorDefault = [UIColor clearColor];
}
return _backgroundColorDefault;
}

+ (void)setBackgroundColorDefault:(UIColor *)backgroundColorDefault {
_backgroundColorDefault = backgroundColorDefault ?: [UIColor clearColor];
}

- (UIColor *)borderFillColor {
if (!_borderFillColor) {
_borderFillColor = [self class].borderFillColorDefault;
Expand Down
12 changes: 12 additions & 0 deletions components/TextFields/src/MDCTextInputControllerFullWidth.h
Expand Up @@ -56,4 +56,16 @@
*/
@interface MDCTextInputControllerFullWidth : NSObject <MDCTextInputController>

/**
Color for background for the various views making up a text field.
Default is backgroundColorDefault.
*/
@property(nonatomic, null_resettable, strong) UIColor *backgroundColor;

/**
Default value for backgroundColor.
*/
@property(class, nonatomic, null_resettable, strong) UIColor *backgroundColorDefault;

@end

0 comments on commit 55eead6

Please sign in to comment.