Getting rid of paddedLabel Class since it's not needed anymore.
MODIFY
components/TextFields/src/MDCTextInputControllerOutlined.m
components/TextFields/src/MDCTextInputControllerOutlined.m
#import "MDCTextInputControllerBase.h"
#import "MDCTextInputControllerFloatingPlaceholder.h"
#import "MDCTextInputUnderlineView.h"
-#import "private/MDCPaddedLabel.h"
#import "private/MDCTextInputControllerBase+Subclassing.h"
#import "MaterialMath.h"
static const CGFloat MDCTextInputOutlinedTextFieldFullPadding = 16.f;
static const CGFloat MDCTextInputOutlinedTextFieldNormalPlaceholderPadding = 20.f;
-static const CGFloat MDCTextInputOutlinedTextFieldPlaceholderPadding = 4.f;
+static const CGFloat MDCTextInputOutlinedTextFieldFloatingPlaceholderPadding = 8.f;
static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
@@ -69,8 +68,6 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
UIOffset offset = [super floatingPlaceholderOffset];
CGFloat textVerticalOffset = 0;
offset.vertical = textVerticalOffset;
- MDCPaddedLabel *placeholderLabel = (MDCPaddedLabel *)self.textInput.placeholderLabel;
- offset.horizontal += placeholderLabel.horizontalPadding;
return offset;
}
@@ -140,9 +137,12 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
[self.textInput.placeholderLabel systemLayoutSizeFittingSize:UILayoutFittingCompressedSize]
.width * (CGFloat)self.floatingPlaceholderScale.floatValue;
+ placeholderWidth += MDCTextInputOutlinedTextFieldFloatingPlaceholderPadding;
+
path = [self roundedPathFromRect:pathRect
withTextSpace:placeholderWidth
- leftOffset:MDCTextInputOutlinedTextFieldFullPadding];
+ leftOffset:MDCTextInputOutlinedTextFieldFullPadding -
+ MDCTextInputOutlinedTextFieldFloatingPlaceholderPadding/2.0f];
} else {
CGSize cornerRadius = CGSizeMake(MDCTextInputControllerBaseDefaultBorderRadius,
MDCTextInputControllerBaseDefaultBorderRadius);
@@ -171,9 +171,9 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
// Draw the path
[path moveToPoint:CGPointMake(radius + xOffset, yOffset)];
- [path addLineToPoint:CGPointMake(offset + xOffset - radius, yOffset)];
+ [path addLineToPoint:CGPointMake(offset + xOffset, yOffset)];
- [path moveToPoint:CGPointMake(textSpace + offset + xOffset - radius, yOffset)];
+ [path moveToPoint:CGPointMake(textSpace + offset + xOffset, yOffset)];
[path addLineToPoint:CGPointMake(f.size.width - radius + xOffset, yOffset)];
[path addArcWithCenter:CGPointMake(f.size.width - radius + xOffset, radius + yOffset)
@@ -229,9 +229,6 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
}
self.placeholderCenterY.constant = placeholderConstant;
- MDCPaddedLabel *placeholderLabel = (MDCPaddedLabel *)self.textInput.placeholderLabel;
- placeholderLabel.horizontalPadding = MDCTextInputOutlinedTextFieldPlaceholderPadding;
-
if (!self.placeholderLeading) {
self.placeholderLeading =
[NSLayoutConstraint constraintWithItem:self.textInput.placeholderLabel
@@ -240,8 +237,7 @@ static UIRectCorner _roundedCornersDefault = UIRectCornerAllCorners;
toItem:self.textInput
attribute:NSLayoutAttributeLeading
multiplier:1
- constant:MDCTextInputOutlinedTextFieldFullPadding -
- placeholderLabel.horizontalPadding];
+ constant:MDCTextInputOutlinedTextFieldFullPadding];
self.placeholderLeading.priority = UILayoutPriorityDefaultHigh;
self.placeholderLeading.active = YES;
}

DELETE
components/TextFields/src/private/MDCPaddedLabel.h
-/*
- Copyright 2017-present the Material Components for iOS authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#import <UIKit/UIKit.h>
-
-/**
- A label with in-frame padding.
-
- @note This label was created for use with auto layout. If you are using manual layout, test it
- first. You may need to adjust code around sizeThatFits: etc.
- */
-@interface MDCPaddedLabel : UILabel
-
-/**
- The padding to be applied.
-
- The padding is applied the same on each side (left and right both get the value of
- .horizontalPadding added to them. This will result in a label that's 2 * .horizontalPadding wider
- than a plain UILabel.
- */
-@property(nonatomic, assign) CGFloat horizontalPadding;
-
-@end

DELETE
components/TextFields/src/private/MDCPaddedLabel.m
-/*
- Copyright 2017-present the Material Components for iOS authors. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#import "MDCPaddedLabel.h"
-
-static NSString *const MDCPaddedLabelHorizontalPaddingKey = @"MDCPaddedLabelHorizontalPaddingKey";
-
-@implementation MDCPaddedLabel
-
-- (instancetype)initWithCoder:(NSCoder *)aDecoder {
- self = [super initWithCoder:aDecoder];
- if (self) {
- _horizontalPadding = (CGFloat)[aDecoder decodeDoubleForKey:MDCPaddedLabelHorizontalPaddingKey];
- }
- return self;
-}
-
-- (void)encodeWithCoder:(NSCoder *)aCoder {
- [super encodeWithCoder:aCoder];
- [aCoder encodeDouble:(double)_horizontalPadding forKey:MDCPaddedLabelHorizontalPaddingKey];
-}
-
-#pragma mark - Setters
-
-- (void)setHorizontalPadding:(CGFloat)horizontalPadding {
- _horizontalPadding = horizontalPadding;
-
- [self invalidateIntrinsicContentSize];
-}
-
-#pragma mark - UILabel Overrides
-
-- (void)drawTextInRect:(CGRect)rect {
- [super drawTextInRect:CGRectInset(rect, self.horizontalPadding, 0)];
-}
-
-#pragma mark - UIView Overrides
-
-- (CGSize)intrinsicContentSize {
- CGSize size = [super intrinsicContentSize];
-
- size.width += self.horizontalPadding * 2.f;
-
- return size;
-}
-
-@end

MODIFY
components/TextFields/src/private/MDCTextInputCommonFundament.m
components/TextFields/src/private/MDCTextInputCommonFundament.m
#import "MDCMultilineTextField.h"
#import "MDCMultilineTextInputDelegate.h"
-#import "MDCPaddedLabel.h"
#import "MDCTextField.h"
#import "MDCTextFieldPositioningDelegate.h"
#import "MDCTextInput.h"
@@ -337,7 +336,7 @@ static inline UIColor *MDCTextInputUnderlineColor() {
- (void)setupPlaceholderLabel {
if (!_placeholderLabel) {
- _placeholderLabel = [[MDCPaddedLabel alloc] initWithFrame:CGRectZero];
+ _placeholderLabel = [[UILabel alloc] initWithFrame:CGRectZero];
}
_placeholderLabel.translatesAutoresizingMaskIntoConstraints = NO;
[_placeholderLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow - 2

Getting rid of paddedLabel Class since it's not needed anymore. (#4196)