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

Unified 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: Address comments 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.mm
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.mm
index fc76ca31dc784badbb44b3b5aa6f815657ba354c..98e64e16763de17dcaa4f81eee20d2116f68954e 100644
--- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.mm
+++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.mm
@@ -4,9 +4,16 @@
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.h"
+#include "base/i18n/rtl.h"
#include "base/logging.h"
+#include "components/strings/grit/components_strings.h"
+#include "ios/chrome/browser/ui/commands/ios_command_ids.h"
#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item.h"
+#import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h"
#include "ios/chrome/browser/ui/ui_util.h"
+#include "ios/chrome/grit/ios_strings.h"
+#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
+#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
@@ -21,6 +28,8 @@ const CGFloat kDoodleTopMarginIPadPortrait = 82;
const CGFloat kDoodleTopMarginIPadLandscape = 82;
const CGFloat kNTPSearchFieldBottomPadding = 16;
+const CGFloat kVoiceSearchButtonWidth = 48;
+
// Height for the doodle frame when Google is not the default search engine.
const CGFloat kNonGoogleSearchDoodleHeight = 60;
// Height for the header view on tablet when Google is not the default search
@@ -134,4 +143,55 @@ CGFloat heightForLogoHeader(CGFloat width,
return headerHeight;
}
+void configureSearchHintLabel(UILabel* searchHintLabel,
+ UIButton* searchTapTarget,
+ CGFloat searchFieldWidth) {
+ CGRect hintFrame = CGRectInset(searchTapTarget.bounds, 12, 3);
+ const CGFloat kVoiceSearchOffset = 48;
+ hintFrame.size.width = searchFieldWidth - kVoiceSearchOffset;
+ [searchHintLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
+
+ [searchTapTarget addSubview:searchHintLabel];
+
+ [NSLayoutConstraint activateConstraints:@[
+ [searchHintLabel.heightAnchor
+ constraintEqualToConstant:hintFrame.size.height],
+ [searchHintLabel.centerYAnchor
+ constraintEqualToAnchor:searchTapTarget.centerYAnchor]
+ ]];
+
+ [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]];
+}
+
+void configureVoiceSearchButton(UIButton* voiceSearchButton,
+ UIButton* searchTapTarget) {
+ UIImage* micImage = [UIImage imageNamed:@"voice_icon"];
+ [voiceSearchButton setTranslatesAutoresizingMaskIntoConstraints:NO];
+ [searchTapTarget addSubview:voiceSearchButton];
+
+ [NSLayoutConstraint activateConstraints:@[
+ [voiceSearchButton.centerYAnchor
+ constraintEqualToAnchor:searchTapTarget.centerYAnchor],
+ [voiceSearchButton.widthAnchor
+ constraintEqualToConstant:kVoiceSearchButtonWidth],
+ [voiceSearchButton.heightAnchor
+ constraintEqualToAnchor:voiceSearchButton.widthAnchor],
+ ]];
+
+ [voiceSearchButton setAdjustsImageWhenHighlighted:NO];
+ [voiceSearchButton setImage:micImage forState:UIControlStateNormal];
+ [voiceSearchButton setTag:IDC_VOICE_SEARCH];
+ [voiceSearchButton setAccessibilityLabel:l10n_util::GetNSString(
+ IDS_IOS_ACCNAME_VOICE_SEARCH)];
+ [voiceSearchButton setAccessibilityIdentifier:@"Voice Search"];
+}
+
} // namespace content_suggestions

Powered by Google App Engine
This is Rietveld 408576698