OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/new_tab_page_header_view.h" | 5 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
9 #import "ios/chrome/browser/tabs/tab_model.h" | 9 #import "ios/chrome/browser/tabs/tab_model.h" |
10 #import "ios/chrome/browser/tabs/tab_model_observer.h" | 10 #import "ios/chrome/browser/tabs/tab_model_observer.h" |
11 #import "ios/chrome/browser/ui/image_util.h" | 11 #import "ios/chrome/browser/ui/image_util.h" |
12 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_constants.h" | 12 #import "ios/chrome/browser/ui/ntp/new_tab_page_header_constants.h" |
13 #import "ios/chrome/browser/ui/ntp/new_tab_page_toolbar_controller.h" | 13 #import "ios/chrome/browser/ui/ntp/new_tab_page_toolbar_controller.h" |
| 14 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
14 #import "ios/chrome/common/material_timing.h" | 15 #import "ios/chrome/common/material_timing.h" |
15 #include "ios/chrome/grit/ios_theme_resources.h" | 16 #include "ios/chrome/grit/ios_theme_resources.h" |
16 #include "ui/base/resource/resource_bundle.h" | |
17 #import "ui/gfx/ios/uikit_util.h" | 17 #import "ui/gfx/ios/uikit_util.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const CGFloat kOmniboxImageBottomInset = 1; | 21 const CGFloat kOmniboxImageBottomInset = 1; |
22 const CGFloat kHintLabelSidePadding = 12; | 22 const CGFloat kHintLabelSidePadding = 12; |
23 const CGFloat kMaxConstraintConstantDiff = 5; | 23 const CGFloat kMaxConstraintConstantDiff = 5; |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 - (void)addViewsToSearchField:(UIView*)searchField { | 103 - (void)addViewsToSearchField:(UIView*)searchField { |
104 [searchField setBackgroundColor:[UIColor whiteColor]]; | 104 [searchField setBackgroundColor:[UIColor whiteColor]]; |
105 UIImage* searchBorderImage = | 105 UIImage* searchBorderImage = |
106 StretchableImageNamed(@"ntp_google_search_box", 12, 12); | 106 StretchableImageNamed(@"ntp_google_search_box", 12, 12); |
107 _searchBoxBorder.reset([[UIImageView alloc] initWithImage:searchBorderImage]); | 107 _searchBoxBorder.reset([[UIImageView alloc] initWithImage:searchBorderImage]); |
108 [_searchBoxBorder setFrame:[searchField bounds]]; | 108 [_searchBoxBorder setFrame:[searchField bounds]]; |
109 [_searchBoxBorder setAutoresizingMask:UIViewAutoresizingFlexibleWidth | | 109 [_searchBoxBorder setAutoresizingMask:UIViewAutoresizingFlexibleWidth | |
110 UIViewAutoresizingFlexibleHeight]; | 110 UIViewAutoresizingFlexibleHeight]; |
111 [searchField insertSubview:_searchBoxBorder atIndex:0]; | 111 [searchField insertSubview:_searchBoxBorder atIndex:0]; |
112 | 112 |
113 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 113 UIImage* fullBleedShadow = NativeImage(IDR_IOS_TOOLBAR_SHADOW_FULL_BLEED); |
114 UIImage* fullBleedShadow = | |
115 rb.GetNativeImageNamed(IDR_IOS_TOOLBAR_SHADOW_FULL_BLEED).ToUIImage(); | |
116 _shadow.reset([[UIImageView alloc] initWithImage:fullBleedShadow]); | 114 _shadow.reset([[UIImageView alloc] initWithImage:fullBleedShadow]); |
117 CGRect shadowFrame = [searchField bounds]; | 115 CGRect shadowFrame = [searchField bounds]; |
118 shadowFrame.origin.y = | 116 shadowFrame.origin.y = |
119 searchField.bounds.size.height - kOmniboxImageBottomInset; | 117 searchField.bounds.size.height - kOmniboxImageBottomInset; |
120 shadowFrame.size.height = fullBleedShadow.size.height; | 118 shadowFrame.size.height = fullBleedShadow.size.height; |
121 [_shadow setFrame:shadowFrame]; | 119 [_shadow setFrame:shadowFrame]; |
122 [_shadow setUserInteractionEnabled:NO]; | 120 [_shadow setUserInteractionEnabled:NO]; |
123 [_shadow setAutoresizingMask:UIViewAutoresizingFlexibleWidth | | 121 [_shadow setAutoresizingMask:UIViewAutoresizingFlexibleWidth | |
124 UIViewAutoresizingFlexibleTopMargin]; | 122 UIViewAutoresizingFlexibleTopMargin]; |
125 [searchField addSubview:_shadow]; | 123 [searchField addSubview:_shadow]; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 } | 171 } |
174 | 172 |
175 - (void)fadeOutShadow { | 173 - (void)fadeOutShadow { |
176 [UIView animateWithDuration:ios::material::kDuration1 | 174 [UIView animateWithDuration:ios::material::kDuration1 |
177 animations:^{ | 175 animations:^{ |
178 [_shadow setAlpha:0]; | 176 [_shadow setAlpha:0]; |
179 }]; | 177 }]; |
180 } | 178 } |
181 | 179 |
182 @end | 180 @end |
OLD | NEW |