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

Side by Side 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, 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ntp/google_landing_view_controller.h" 5 #import "ios/chrome/browser/ui/ntp/google_landing_view_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/metrics/user_metrics.h" 10 #include "base/metrics/user_metrics.h"
(...skipping 28 matching lines...) Expand all
39 using base::UserMetricsAction; 39 using base::UserMetricsAction;
40 40
41 namespace { 41 namespace {
42 42
43 enum { 43 enum {
44 SectionWithOmnibox, 44 SectionWithOmnibox,
45 SectionWithMostVisited, 45 SectionWithMostVisited,
46 NumberOfCollectionViewSections, 46 NumberOfCollectionViewSections,
47 }; 47 };
48 48
49 const CGFloat kVoiceSearchButtonWidth = 48;
50 const UIEdgeInsets kSearchBoxStretchInsets = {3, 3, 3, 3}; 49 const UIEdgeInsets kSearchBoxStretchInsets = {3, 3, 3, 3};
51 50
52 const CGFloat kHintLabelSidePadding = 12; 51 const CGFloat kHintLabelSidePadding = 12;
53 const CGFloat kWhatsNewHeaderHiddenHeight = 8; 52 const CGFloat kWhatsNewHeaderHiddenHeight = 8;
54 const NSInteger kMaxNumMostVisitedFaviconRows = 2; 53 const NSInteger kMaxNumMostVisitedFaviconRows = 2;
55 const CGFloat kShiftTilesDownAnimationDuration = 0.2; 54 const CGFloat kShiftTilesDownAnimationDuration = 0.2;
56 55
57 } // namespace 56 } // namespace
58 57
59 @interface GoogleLandingViewController (UsedByGoogleLandingView) 58 @interface GoogleLandingViewController (UsedByGoogleLandingView)
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 [_searchTapTarget setAdjustsImageWhenHighlighted:NO]; 409 [_searchTapTarget setAdjustsImageWhenHighlighted:NO];
411 [_searchTapTarget addTarget:self 410 [_searchTapTarget addTarget:self
412 action:@selector(searchFieldTapped:) 411 action:@selector(searchFieldTapped:)
413 forControlEvents:UIControlEventTouchUpInside]; 412 forControlEvents:UIControlEventTouchUpInside];
414 [_searchTapTarget 413 [_searchTapTarget
415 setAccessibilityLabel:l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)]; 414 setAccessibilityLabel:l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)];
416 // Set isAccessibilityElement to NO so that Voice Search button is accessible. 415 // Set isAccessibilityElement to NO so that Voice Search button is accessible.
417 [_searchTapTarget setIsAccessibilityElement:NO]; 416 [_searchTapTarget setIsAccessibilityElement:NO];
418 417
419 // Set up fakebox hint label. 418 // Set up fakebox hint label.
420 CGRect hintFrame = CGRectInset([_searchTapTarget bounds], 12, 3); 419 UILabel* searchHintLabel = content_suggestions::configuredSearchHintLabel(
421 const CGFloat kVoiceSearchOffset = 48; 420 _searchTapTarget.get(), searchFieldFrame.size.width);
422 hintFrame.size.width = searchFieldFrame.size.width - kVoiceSearchOffset; 421
423 UILabel* searchHintLabel =
424 [[[UILabel alloc] initWithFrame:hintFrame] autorelease];
425 [_searchTapTarget addSubview:searchHintLabel];
426 [searchHintLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
427 _hintLabelLeadingConstraint.reset([[searchHintLabel.leadingAnchor 422 _hintLabelLeadingConstraint.reset([[searchHintLabel.leadingAnchor
428 constraintEqualToAnchor:[_searchTapTarget leadingAnchor] 423 constraintEqualToAnchor:[_searchTapTarget leadingAnchor]
429 constant:kHintLabelSidePadding] retain]); 424 constant:kHintLabelSidePadding] retain]);
430 425 [_hintLabelLeadingConstraint setActive:YES];
431 [NSLayoutConstraint activateConstraints:@[
432 [searchHintLabel.heightAnchor
433 constraintEqualToConstant:hintFrame.size.height],
434 [searchHintLabel.centerYAnchor
435 constraintEqualToAnchor:[_searchTapTarget centerYAnchor]],
436 _hintLabelLeadingConstraint
437 ]];
438
439 [searchHintLabel setText:l10n_util::GetNSString(IDS_OMNIBOX_EMPTY_HINT)];
440 if (base::i18n::IsRTL()) {
441 [searchHintLabel setTextAlignment:NSTextAlignmentRight];
442 }
443 [searchHintLabel
444 setTextColor:[UIColor
445 colorWithWhite:kiPhoneOmniboxPlaceholderColorBrightness
446 alpha:1.0]];
447 [searchHintLabel setFont:[MDCTypography subheadFont]];
448 426
449 // Add a voice search button. 427 // Add a voice search button.
450 UIImage* micImage = [UIImage imageNamed:@"voice_icon"];
451 UIButton* voiceTapTarget = 428 UIButton* voiceTapTarget =
452 [[[UIButton alloc] initWithFrame:CGRectZero] autorelease]; 429 content_suggestions::configuredVoiceTapTarget(_searchTapTarget.get());
453 [_searchTapTarget addSubview:voiceTapTarget];
454 430
455 [voiceTapTarget setTranslatesAutoresizingMaskIntoConstraints:NO];
456 _voiceTapTrailingConstraint.reset([[voiceTapTarget.trailingAnchor 431 _voiceTapTrailingConstraint.reset([[voiceTapTarget.trailingAnchor
457 constraintEqualToAnchor:[_searchTapTarget trailingAnchor]] retain]); 432 constraintEqualToAnchor:[_searchTapTarget trailingAnchor]] retain]);
458
459 [NSLayoutConstraint activateConstraints:@[ 433 [NSLayoutConstraint activateConstraints:@[
460 [voiceTapTarget.centerYAnchor
461 constraintEqualToAnchor:[_searchTapTarget centerYAnchor]],
462 [voiceTapTarget.widthAnchor
463 constraintEqualToConstant:kVoiceSearchButtonWidth],
464 [voiceTapTarget.heightAnchor
465 constraintEqualToAnchor:voiceTapTarget.widthAnchor],
466 [searchHintLabel.trailingAnchor 434 [searchHintLabel.trailingAnchor
467 constraintEqualToAnchor:voiceTapTarget.leadingAnchor], 435 constraintEqualToAnchor:voiceTapTarget.leadingAnchor],
468 _voiceTapTrailingConstraint 436 _voiceTapTrailingConstraint
469 ]]; 437 ]];
470 438
471 [voiceTapTarget setAdjustsImageWhenHighlighted:NO];
472 [voiceTapTarget setImage:micImage forState:UIControlStateNormal];
473 [voiceTapTarget setTag:IDC_VOICE_SEARCH];
474 [voiceTapTarget setAccessibilityLabel:l10n_util::GetNSString(
475 IDS_IOS_ACCNAME_VOICE_SEARCH)];
476 [voiceTapTarget setAccessibilityIdentifier:@"Voice Search"];
477
478 if (self.voiceSearchIsEnabled) { 439 if (self.voiceSearchIsEnabled) {
479 [voiceTapTarget addTarget:self 440 [voiceTapTarget addTarget:self
480 action:@selector(loadVoiceSearch:) 441 action:@selector(loadVoiceSearch:)
481 forControlEvents:UIControlEventTouchUpInside]; 442 forControlEvents:UIControlEventTouchUpInside];
482 [voiceTapTarget addTarget:self 443 [voiceTapTarget addTarget:self
483 action:@selector(preloadVoiceSearch:) 444 action:@selector(preloadVoiceSearch:)
484 forControlEvents:UIControlEventTouchDown]; 445 forControlEvents:UIControlEventTouchDown];
485 } else { 446 } else {
486 [voiceTapTarget setEnabled:NO]; 447 [voiceTapTarget setEnabled:NO];
487 } 448 }
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 - (void)setCanGoForward:(BOOL)canGoForward { 1325 - (void)setCanGoForward:(BOOL)canGoForward {
1365 _canGoForward = canGoForward; 1326 _canGoForward = canGoForward;
1366 [_headerView setCanGoForward:self.canGoForward]; 1327 [_headerView setCanGoForward:self.canGoForward];
1367 } 1328 }
1368 1329
1369 - (void)setCanGoBack:(BOOL)canGoBack { 1330 - (void)setCanGoBack:(BOOL)canGoBack {
1370 _canGoBack = canGoBack; 1331 _canGoBack = canGoBack;
1371 [_headerView setCanGoBack:self.canGoBack]; 1332 [_headerView setCanGoBack:self.canGoBack];
1372 } 1333 }
1373 @end 1334 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698