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 3378e95cc1eac0835dac4c40c48a3145ec3a0761..2b213522e3bb10c7af79a90b92834d904342f324 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,10 +4,17 @@ |
#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/content_suggestions/cells/content_suggestions_most_visited_tile.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." |
@@ -19,6 +26,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 |
@@ -112,4 +121,60 @@ CGFloat heightForLogoHeader(CGFloat width, |
return headerHeight; |
} |
+UILabel* configuredSearchHintLabel(UIButton* searchTapTarget, |
+ CGFloat searchFieldWidth) { |
+ CGRect hintFrame = CGRectInset(searchTapTarget.bounds, 12, 3); |
+ const CGFloat kVoiceSearchOffset = 48; |
+ hintFrame.size.width = searchFieldWidth - kVoiceSearchOffset; |
+ UILabel* searchHintLabel = [[UILabel alloc] initWithFrame:hintFrame]; |
+ [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]]; |
+ |
+ return searchHintLabel; |
+} |
+ |
+UIButton* configuredVoiceTapTarget(UIButton* searchTapTarget) { |
+ UIImage* micImage = [UIImage imageNamed:@"voice_icon"]; |
+ UIButton* voiceTapTarget = [[UIButton alloc] initWithFrame:CGRectZero]; |
+ |
+ [voiceTapTarget setTranslatesAutoresizingMaskIntoConstraints:NO]; |
+ [searchTapTarget addSubview:voiceTapTarget]; |
+ |
+ [NSLayoutConstraint activateConstraints:@[ |
+ [voiceTapTarget.centerYAnchor |
+ constraintEqualToAnchor:searchTapTarget.centerYAnchor], |
+ [voiceTapTarget.widthAnchor |
+ constraintEqualToConstant:kVoiceSearchButtonWidth], |
+ [voiceTapTarget.heightAnchor |
+ constraintEqualToAnchor:voiceTapTarget.widthAnchor], |
+ ]]; |
+ |
+ [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"]; |
+ |
+ return voiceTapTarget; |
+} |
+ |
} // namespace content_suggestions |