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

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.mm

Issue 2855113003: Move the fake omnibox constraints out of GoogleLandingViewController (Closed)
Patch Set: Reviewable Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_utils.h" 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_utils.h"
6 6
7 #include "base/i18n/rtl.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "components/strings/grit/components_strings.h"
10 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
8 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_mos t_visited_item.h" 11 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_mos t_visited_item.h"
9 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_mos t_visited_tile.h" 12 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_mos t_visited_tile.h"
13 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h"
10 #include "ios/chrome/browser/ui/ui_util.h" 14 #include "ios/chrome/browser/ui/ui_util.h"
15 #include "ios/chrome/grit/ios_strings.h"
16 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
17 #include "ui/base/l10n/l10n_util.h"
11 18
12 #if !defined(__has_feature) || !__has_feature(objc_arc) 19 #if !defined(__has_feature) || !__has_feature(objc_arc)
13 #error "This file requires ARC support." 20 #error "This file requires ARC support."
14 #endif 21 #endif
15 22
16 namespace { 23 namespace {
17 const CGFloat kMaxSearchFieldFrameMargin = 200; 24 const CGFloat kMaxSearchFieldFrameMargin = 200;
18 const CGFloat kDoodleTopMarginIPadPortrait = 82; 25 const CGFloat kDoodleTopMarginIPadPortrait = 82;
19 const CGFloat kDoodleTopMarginIPadLandscape = 82; 26 const CGFloat kDoodleTopMarginIPadLandscape = 82;
20 const CGFloat kNTPSearchFieldBottomPadding = 16; 27 const CGFloat kNTPSearchFieldBottomPadding = 16;
21 28
29 const CGFloat kVoiceSearchButtonWidth = 48;
30
22 // Height for the doodle frame when Google is not the default search engine. 31 // Height for the doodle frame when Google is not the default search engine.
23 const CGFloat kNonGoogleSearchDoodleHeight = 60; 32 const CGFloat kNonGoogleSearchDoodleHeight = 60;
24 // Height for the header view on tablet when Google is not the default search 33 // Height for the header view on tablet when Google is not the default search
25 // engine. 34 // engine.
26 const CGFloat kNonGoogleSearchHeaderHeightIPad = 10; 35 const CGFloat kNonGoogleSearchHeaderHeightIPad = 10;
27 36
28 enum InterfaceOrientation { 37 enum InterfaceOrientation {
29 ALL, 38 ALL,
30 IPHONE_LANDSCAPE, 39 IPHONE_LANDSCAPE,
31 }; 40 };
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ? kTopSpacingMaterialPortrait 114 ? kTopSpacingMaterialPortrait
106 : kTopSpacingMaterialLandscape; 115 : kTopSpacingMaterialLandscape;
107 } 116 }
108 } else { 117 } else {
109 headerHeight = kNonGoogleSearchHeaderHeightIPad; 118 headerHeight = kNonGoogleSearchHeaderHeightIPad;
110 } 119 }
111 } 120 }
112 return headerHeight; 121 return headerHeight;
113 } 122 }
114 123
124 UILabel* configuredSearchHintLabel(UIButton* searchTapTarget,
125 CGFloat searchFieldWidth) {
126 CGRect hintFrame = CGRectInset(searchTapTarget.bounds, 12, 3);
127 const CGFloat kVoiceSearchOffset = 48;
128 hintFrame.size.width = searchFieldWidth - kVoiceSearchOffset;
129 UILabel* searchHintLabel = [[UILabel alloc] initWithFrame:hintFrame];
130 [searchHintLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
131
132 [searchTapTarget addSubview:searchHintLabel];
133
134 [NSLayoutConstraint activateConstraints:@[
135 [searchHintLabel.heightAnchor
136 constraintEqualToConstant:hintFrame.size.height],
137 [searchHintLabel.centerYAnchor
138 constraintEqualToAnchor:searchTapTarget.centerYAnchor]
139 ]];
140
141 [searchHintLabel setText:l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)];
142 if (base::i18n::IsRTL()) {
143 [searchHintLabel setTextAlignment:NSTextAlignmentRight];
144 }
145 [searchHintLabel
146 setTextColor:[UIColor
147 colorWithWhite:kiPhoneOmniboxPlaceholderColorBrightness
148 alpha:1.0]];
149 [searchHintLabel setFont:[MDCTypography subheadFont]];
150
151 return searchHintLabel;
152 }
153
154 UIButton* configuredVoiceTapTarget(UIButton* searchTapTarget) {
155 UIImage* micImage = [UIImage imageNamed:@"voice_icon"];
156 UIButton* voiceTapTarget = [[UIButton alloc] initWithFrame:CGRectZero];
157
158 [voiceTapTarget setTranslatesAutoresizingMaskIntoConstraints:NO];
159 [searchTapTarget addSubview:voiceTapTarget];
160
161 [NSLayoutConstraint activateConstraints:@[
162 [voiceTapTarget.centerYAnchor
163 constraintEqualToAnchor:searchTapTarget.centerYAnchor],
164 [voiceTapTarget.widthAnchor
165 constraintEqualToConstant:kVoiceSearchButtonWidth],
166 [voiceTapTarget.heightAnchor
167 constraintEqualToAnchor:voiceTapTarget.widthAnchor],
168 ]];
169
170 [voiceTapTarget setAdjustsImageWhenHighlighted:NO];
171 [voiceTapTarget setImage:micImage forState:UIControlStateNormal];
172 [voiceTapTarget setTag:IDC_VOICE_SEARCH];
173 [voiceTapTarget setAccessibilityLabel:l10n_util::GetNSString(
174 IDS_IOS_ACCNAME_VOICE_SEARCH)];
175 [voiceTapTarget setAccessibilityIdentifier:@"Voice Search"];
176
177 return voiceTapTarget;
178 }
179
115 } // namespace content_suggestions 180 } // namespace content_suggestions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698