Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: ios/chrome/browser/ui/ntp/google_landing_view_controller.mm

Issue 2860713002: Change the constraint to anchor constraints in GoogleLandingController (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/ntp/google_landing_view_controller.mm
diff --git a/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm b/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm
index df4d18604232b34c3a6da84d3175c651e137dc25..aab7dc7b23637227a0634a3f581b5d814fb4c201 100644
--- a/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm
+++ b/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm
@@ -420,37 +420,22 @@ const CGFloat kShiftTilesDownAnimationDuration = 0.2;
CGRect hintFrame = CGRectInset([_searchTapTarget bounds], 12, 3);
const CGFloat kVoiceSearchOffset = 48;
hintFrame.size.width = searchFieldFrame.size.width - kVoiceSearchOffset;
- base::scoped_nsobject<UILabel> searchHintLabel(
- [[UILabel alloc] initWithFrame:hintFrame]);
+ UILabel* searchHintLabel =
+ [[[UILabel alloc] initWithFrame:hintFrame] autorelease];
[_searchTapTarget addSubview:searchHintLabel];
[searchHintLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
- [searchHintLabel
- addConstraint:[NSLayoutConstraint
- constraintWithItem:searchHintLabel
- attribute:NSLayoutAttributeHeight
- relatedBy:NSLayoutRelationEqual
- toItem:nil
- attribute:NSLayoutAttributeNotAnAttribute
- multiplier:1
- constant:hintFrame.size.height]];
- [_searchTapTarget
- addConstraint:[NSLayoutConstraint
- constraintWithItem:searchHintLabel
- attribute:NSLayoutAttributeCenterY
- relatedBy:NSLayoutRelationEqual
- toItem:_searchTapTarget
- attribute:NSLayoutAttributeCenterY
- multiplier:1
- constant:0]];
- _hintLabelLeadingConstraint.reset(
- [[NSLayoutConstraint constraintWithItem:searchHintLabel
- attribute:NSLayoutAttributeLeading
- relatedBy:NSLayoutRelationEqual
- toItem:_searchTapTarget
- attribute:NSLayoutAttributeLeading
- multiplier:1
- constant:kHintLabelSidePadding] retain]);
- [_searchTapTarget addConstraint:_hintLabelLeadingConstraint];
+ _hintLabelLeadingConstraint.reset([[searchHintLabel.leadingAnchor
+ constraintEqualToAnchor:[_searchTapTarget leadingAnchor]
+ constant:kHintLabelSidePadding] retain]);
+
+ [NSLayoutConstraint activateConstraints:@[
+ [searchHintLabel.heightAnchor
+ constraintEqualToConstant:hintFrame.size.height],
+ [searchHintLabel.centerYAnchor
+ constraintEqualToAnchor:[_searchTapTarget centerYAnchor]],
+ _hintLabelLeadingConstraint
+ ]];
+
[searchHintLabel setText:l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)];
if (base::i18n::IsRTL()) {
[searchHintLabel setTextAlignment:NSTextAlignmentRight];
@@ -463,56 +448,26 @@ const CGFloat kShiftTilesDownAnimationDuration = 0.2;
// Add a voice search button.
UIImage* micImage = [UIImage imageNamed:@"voice_icon"];
- base::scoped_nsobject<UIButton> voiceTapTarget(
- [[UIButton alloc] initWithFrame:CGRectZero]);
+ UIButton* voiceTapTarget =
+ [[[UIButton alloc] initWithFrame:CGRectZero] autorelease];
[_searchTapTarget addSubview:voiceTapTarget];
[voiceTapTarget setTranslatesAutoresizingMaskIntoConstraints:NO];
- [_searchTapTarget
- addConstraint:[NSLayoutConstraint
- constraintWithItem:voiceTapTarget
- attribute:NSLayoutAttributeCenterY
- relatedBy:NSLayoutRelationEqual
- toItem:_searchTapTarget
- attribute:NSLayoutAttributeCenterY
- multiplier:1
- constant:0]];
- _voiceTapTrailingConstraint.reset(
- [[NSLayoutConstraint constraintWithItem:voiceTapTarget
- attribute:NSLayoutAttributeTrailing
- relatedBy:NSLayoutRelationEqual
- toItem:_searchTapTarget
- attribute:NSLayoutAttributeTrailing
- multiplier:1
- constant:0] retain]);
- [_searchTapTarget addConstraint:_voiceTapTrailingConstraint];
- [voiceTapTarget
- addConstraint:[NSLayoutConstraint
- constraintWithItem:voiceTapTarget
- attribute:NSLayoutAttributeHeight
- relatedBy:NSLayoutRelationEqual
- toItem:nil
- attribute:NSLayoutAttributeNotAnAttribute
- multiplier:0
- constant:kVoiceSearchButtonWidth]];
- [voiceTapTarget
- addConstraint:[NSLayoutConstraint
- constraintWithItem:voiceTapTarget
- attribute:NSLayoutAttributeWidth
- relatedBy:NSLayoutRelationEqual
- toItem:nil
- attribute:NSLayoutAttributeNotAnAttribute
- multiplier:0
- constant:kVoiceSearchButtonWidth]];
- [_searchTapTarget
- addConstraint:[NSLayoutConstraint
- constraintWithItem:searchHintLabel
- attribute:NSLayoutAttributeTrailing
- relatedBy:NSLayoutRelationEqual
- toItem:voiceTapTarget
- attribute:NSLayoutAttributeLeading
- multiplier:1
- constant:0]];
+ _voiceTapTrailingConstraint.reset([[voiceTapTarget.trailingAnchor
+ constraintEqualToAnchor:[_searchTapTarget trailingAnchor]] retain]);
+
+ [NSLayoutConstraint activateConstraints:@[
+ [voiceTapTarget.centerYAnchor
+ constraintEqualToAnchor:[_searchTapTarget centerYAnchor]],
+ [voiceTapTarget.heightAnchor
+ constraintEqualToConstant:kVoiceSearchButtonWidth],
jif 2017/05/03 13:21:08 Nit: Make the width equal to kVoiceSearchButtonWid
gambard 2017/05/03 13:25:04 Done.
+ [voiceTapTarget.widthAnchor
+ constraintEqualToAnchor:voiceTapTarget.heightAnchor],
+ [searchHintLabel.trailingAnchor
+ constraintEqualToAnchor:voiceTapTarget.leadingAnchor],
+ _voiceTapTrailingConstraint
+ ]];
+
[voiceTapTarget setAdjustsImageWhenHighlighted:NO];
[voiceTapTarget setImage:micImage forState:UIControlStateNormal];
[voiceTapTarget setTag:IDC_VOICE_SEARCH];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698