Commit f97629d5 authored by Stepan Khapugin's avatar Stepan Khapugin Committed by Commit Bot

[iOS] HL Cleanup: OmniboxContainerView.

Remove the ability to hide OmniboxContainerView's leading image, since
it's always shown in HL. Cleanup the implementation to not have that
option anymore.

Bug: 945334
Change-Id: I39107d51c69e861251f0fd2e2111542c1c075d07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2007411
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarRobbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#733987}
parent 0b2e4b98
......@@ -34,9 +34,6 @@
// Sets the leading button's image.
- (void)setLeadingImage:(UIImage*)image;
// Shows or hides the leading button.
- (void)setLeadingImageHidden:(BOOL)hidden;
// Sets the alpha level of the leading image view.
- (void)setLeadingImageAlpha:(CGFloat)alpha;
......
......@@ -42,10 +42,6 @@ const CGFloat kTextFieldClearButtonTrailingOffset = 4;
// Constraints the leading textfield side to the leading of |self|.
// Active when the |leadingView| is nil or hidden.
@property(nonatomic, strong) NSLayoutConstraint* leadingTextfieldConstraint;
// When the |leadingImageView| is not hidden, this is a constraint that links
// the leading edge of the button to self leading edge. Used for animations.
@property(nonatomic, strong)
NSLayoutConstraint* leadingImageViewLeadingConstraint;
// The leading image view. Used for autocomplete icons.
@property(nonatomic, strong) UIImageView* leadingImageView;
// Redefined as readwrite.
......@@ -58,8 +54,6 @@ const CGFloat kTextFieldClearButtonTrailingOffset = 4;
@synthesize leadingImageView = _leadingImageView;
@synthesize leadingTextfieldConstraint = _leadingTextfieldConstraint;
@synthesize incognito = _incognito;
@synthesize leadingImageViewLeadingConstraint =
_leadingImageViewLeadingConstraint;
#pragma mark - Public methods
......@@ -93,8 +87,7 @@ const CGFloat kTextFieldClearButtonTrailingOffset = 4;
forAxis:
UILayoutConstraintAxisHorizontal];
[self createLeadingImageView];
_leadingImageView.tintColor = iconTint;
[self setupLeadingImageViewWithTint:iconTint];
}
return self;
}
......@@ -111,31 +104,6 @@ const CGFloat kTextFieldClearButtonTrailingOffset = 4;
}
}
- (void)setLeadingImageHidden:(BOOL)hidden {
if (hidden) {
[_leadingImageView removeFromSuperview];
self.leadingTextfieldConstraint.active = YES;
} else {
[self addSubview:_leadingImageView];
self.leadingTextfieldConstraint.active = NO;
self.leadingImageViewLeadingConstraint = [self.leadingAnchor
constraintEqualToAnchor:self.leadingImageView.leadingAnchor
constant:-kleadingImageViewEdgeOffset];
NSLayoutConstraint* leadingImageViewToTextField = nil;
leadingImageViewToTextField = [self.leadingImageView.trailingAnchor
constraintEqualToAnchor:self.textField.leadingAnchor
constant:-kTextFieldLeadingOffsetImage];
[NSLayoutConstraint activateConstraints:@[
[_leadingImageView.centerYAnchor
constraintEqualToAnchor:self.centerYAnchor],
self.leadingImageViewLeadingConstraint,
leadingImageViewToTextField,
]];
}
}
- (void)setLeadingImage:(UIImage*)image {
[self.leadingImageView setImage:image];
}
......@@ -151,7 +119,7 @@ const CGFloat kTextFieldClearButtonTrailingOffset = 4;
#pragma mark - private
- (void)createLeadingImageView {
- (void)setupLeadingImageViewWithTint:(UIColor*)iconTint {
_leadingImageView = [[UIImageView alloc] init];
_leadingImageView.translatesAutoresizingMaskIntoConstraints = NO;
_leadingImageView.contentMode = UIViewContentModeCenter;
......@@ -162,6 +130,24 @@ const CGFloat kTextFieldClearButtonTrailingOffset = 4;
[_leadingImageView.heightAnchor
constraintEqualToAnchor:_leadingImageView.widthAnchor],
]];
_leadingImageView.tintColor = iconTint;
[self addSubview:_leadingImageView];
self.leadingTextfieldConstraint.active = NO;
NSLayoutConstraint* leadingImageViewToTextField =
[self.leadingImageView.trailingAnchor
constraintEqualToAnchor:self.textField.leadingAnchor
constant:-kTextFieldLeadingOffsetImage];
[NSLayoutConstraint activateConstraints:@[
[_leadingImageView.centerYAnchor
constraintEqualToAnchor:self.centerYAnchor],
[self.leadingAnchor
constraintEqualToAnchor:self.leadingImageView.leadingAnchor
constant:-kleadingImageViewEdgeOffset],
leadingImageViewToTextField,
]];
}
@end
......@@ -132,8 +132,6 @@ const CGFloat kClearButtonSize = 28.0f;
selector:@selector(textInputModeDidChange)
name:UITextInputCurrentInputModeDidChangeNotification
object:nil];
[self updateLeadingImageVisibility];
}
- (void)viewDidAppear:(BOOL)animated {
......@@ -149,11 +147,6 @@ const CGFloat kClearButtonSize = 28.0f;
toPosition:self.textField.beginningOfDocument];
}
- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
[self updateLeadingImageVisibility];
}
- (void)setTextChangeDelegate:(OmniboxTextChangeDelegate*)textChangeDelegate {
_textChangeDelegate = textChangeDelegate;
}
......@@ -290,10 +283,6 @@ const CGFloat kClearButtonSize = 28.0f;
#pragma mark - private
- (void)updateLeadingImageVisibility {
[self.view setLeadingImageHidden:NO];
}
// Tint color for the textfield placeholder and the clear button.
- (UIColor*)placeholderAndClearButtonColor {
return color::DarkModeDynamicColor(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment