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

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

Issue 2855113003: Move the fake omnibox constraints out of GoogleLandingViewController (Closed)
Patch Set: Reviewable 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
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 95479756996c0f3b6e5fff980ee78d2d2475913f..6b707803299fcde84402366b7493141bcbcbb681 100644
--- a/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm
+++ b/ios/chrome/browser/ui/ntp/google_landing_view_controller.mm
@@ -46,7 +46,6 @@ enum {
NumberOfCollectionViewSections,
};
-const CGFloat kVoiceSearchButtonWidth = 48;
const UIEdgeInsets kSearchBoxStretchInsets = {3, 3, 3, 3};
const CGFloat kHintLabelSidePadding = 12;
@@ -417,64 +416,26 @@ const CGFloat kShiftTilesDownAnimationDuration = 0.2;
[_searchTapTarget setIsAccessibilityElement:NO];
// Set up fakebox hint label.
- CGRect hintFrame = CGRectInset([_searchTapTarget bounds], 12, 3);
- const CGFloat kVoiceSearchOffset = 48;
- hintFrame.size.width = searchFieldFrame.size.width - kVoiceSearchOffset;
- UILabel* searchHintLabel =
- [[[UILabel alloc] initWithFrame:hintFrame] autorelease];
- [_searchTapTarget addSubview:searchHintLabel];
- [searchHintLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
+ UILabel* searchHintLabel = content_suggestions::configuredSearchHintLabel(
+ _searchTapTarget.get(), searchFieldFrame.size.width);
+
_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];
- }
- [searchHintLabel
- setTextColor:[UIColor
- colorWithWhite:kiPhoneOmniboxPlaceholderColorBrightness
- alpha:1.0]];
- [searchHintLabel setFont:[MDCTypography subheadFont]];
+ [_hintLabelLeadingConstraint setActive:YES];
// Add a voice search button.
- UIImage* micImage = [UIImage imageNamed:@"voice_icon"];
UIButton* voiceTapTarget =
- [[[UIButton alloc] initWithFrame:CGRectZero] autorelease];
- [_searchTapTarget addSubview:voiceTapTarget];
+ content_suggestions::configuredVoiceTapTarget(_searchTapTarget.get());
- [voiceTapTarget setTranslatesAutoresizingMaskIntoConstraints:NO];
_voiceTapTrailingConstraint.reset([[voiceTapTarget.trailingAnchor
constraintEqualToAnchor:[_searchTapTarget trailingAnchor]] retain]);
-
[NSLayoutConstraint activateConstraints:@[
- [voiceTapTarget.centerYAnchor
- constraintEqualToAnchor:[_searchTapTarget centerYAnchor]],
- [voiceTapTarget.widthAnchor
- constraintEqualToConstant:kVoiceSearchButtonWidth],
- [voiceTapTarget.heightAnchor
- constraintEqualToAnchor:voiceTapTarget.widthAnchor],
[searchHintLabel.trailingAnchor
constraintEqualToAnchor:voiceTapTarget.leadingAnchor],
_voiceTapTrailingConstraint
]];
- [voiceTapTarget setAdjustsImageWhenHighlighted:NO];
- [voiceTapTarget setImage:micImage forState:UIControlStateNormal];
- [voiceTapTarget setTag:IDC_VOICE_SEARCH];
- [voiceTapTarget setAccessibilityLabel:l10n_util::GetNSString(
- IDS_IOS_ACCNAME_VOICE_SEARCH)];
- [voiceTapTarget setAccessibilityIdentifier:@"Voice Search"];
-
if (self.voiceSearchIsEnabled) {
[voiceTapTarget addTarget:self
action:@selector(loadVoiceSearch:)

Powered by Google App Engine
This is Rietveld 408576698