OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/tab_switcher/tab_switcher_panel_cell.h" | 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" |
6 | 6 |
7 #import "ios/chrome/browser/tabs/tab.h" | 7 #import "ios/chrome/browser/tabs/tab.h" |
8 #import "ios/chrome/browser/ui/fade_truncated_label.h" | 8 #import "ios/chrome/browser/ui/fade_truncated_label.h" |
9 #import "ios/chrome/browser/ui/image_util.h" | 9 #import "ios/chrome/browser/ui/image_util.h" |
10 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_button.h" | 10 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_button.h" |
11 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_cache.h" | 11 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_cache.h" |
12 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_utils.h" | 12 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_utils.h" |
13 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 13 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
14 #include "ios/chrome/grit/ios_strings.h" | 14 #include "ios/chrome/grit/ios_strings.h" |
15 #include "ios/chrome/grit/ios_theme_resources.h" | 15 #include "ios/chrome/grit/ios_theme_resources.h" |
16 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 16 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
17 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 17 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
18 #import "ios/third_party/material_text_accessibility_ios/src/src/MDFTextAccessib
ility.h" | 18 #import "ios/third_party/material_text_accessibility_ios/src/src/MDFTextAccessib
ility.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
22 | 22 |
23 #if !defined(__has_feature) || !__has_feature(objc_arc) | 23 #if !defined(__has_feature) || !__has_feature(objc_arc) |
24 #error "This file requires ARC support." | 24 #error "This file requires ARC support." |
25 #endif | 25 #endif |
26 | 26 |
27 namespace gfx { | 27 namespace gfx { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 ]; | 160 ]; |
161 NSDictionary* metrics = | 161 NSDictionary* metrics = |
162 @{ @"barHeight" : @(tabSwitcherLocalSessionCellTopBarHeight()) }; | 162 @{ @"barHeight" : @(tabSwitcherLocalSessionCellTopBarHeight()) }; |
163 ApplyVisualConstraintsWithMetrics(constraints, viewsDictionary, metrics, | 163 ApplyVisualConstraintsWithMetrics(constraints, viewsDictionary, metrics, |
164 [self containerView]); | 164 [self containerView]); |
165 | 165 |
166 // Create and add subviews to the cell bar. | 166 // Create and add subviews to the cell bar. |
167 // Title label. | 167 // Title label. |
168 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | 168 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
169 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; | 169 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; |
170 [_titleLabel setFont:[[MDFRobotoFontLoader sharedInstance] | 170 [_titleLabel |
171 regularFontOfSize:kFontSize]]; | 171 setFont:[[MDCTypography fontLoader] regularFontOfSize:kFontSize]]; |
172 [_topBar addSubview:_titleLabel]; | 172 [_topBar addSubview:_titleLabel]; |
173 | 173 |
174 // Favicon. | 174 // Favicon. |
175 _favicon = [[UIImageView alloc] initWithFrame:CGRectZero]; | 175 _favicon = [[UIImageView alloc] initWithFrame:CGRectZero]; |
176 [_favicon setTranslatesAutoresizingMaskIntoConstraints:NO]; | 176 [_favicon setTranslatesAutoresizingMaskIntoConstraints:NO]; |
177 [_topBar addSubview:_favicon]; | 177 [_topBar addSubview:_favicon]; |
178 | 178 |
179 // Close button. | 179 // Close button. |
180 _closeButton = [[UIButton alloc] initWithFrame:CGRectZero]; | 180 _closeButton = [[UIButton alloc] initWithFrame:CGRectZero]; |
181 [_closeButton | 181 [_closeButton |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 _verticallyCenteredView = [[UIView alloc] initWithFrame:CGRectZero]; | 347 _verticallyCenteredView = [[UIView alloc] initWithFrame:CGRectZero]; |
348 [_verticallyCenteredView setTranslatesAutoresizingMaskIntoConstraints:NO]; | 348 [_verticallyCenteredView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
349 [_verticallyCenteredView setUserInteractionEnabled:NO]; | 349 [_verticallyCenteredView setUserInteractionEnabled:NO]; |
350 [_raisedButton addSubview:_verticallyCenteredView]; | 350 [_raisedButton addSubview:_verticallyCenteredView]; |
351 | 351 |
352 // Create and add title label to |_verticallyCenteredContent|. | 352 // Create and add title label to |_verticallyCenteredContent|. |
353 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | 353 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
354 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; | 354 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; |
355 [_titleLabel setNumberOfLines:5]; | 355 [_titleLabel setNumberOfLines:5]; |
356 [_titleLabel setTextAlignment:NSTextAlignmentCenter]; | 356 [_titleLabel setTextAlignment:NSTextAlignmentCenter]; |
357 [_titleLabel setFont:[[MDFRobotoFontLoader sharedInstance] | 357 [_titleLabel |
358 regularFontOfSize:kFontSize]]; | 358 setFont:[[MDCTypography fontLoader] regularFontOfSize:kFontSize]]; |
359 [_verticallyCenteredView addSubview:_titleLabel]; | 359 [_verticallyCenteredView addSubview:_titleLabel]; |
360 | 360 |
361 // Create and add new tab icon to |_verticallyCenteredContent|. | 361 // Create and add new tab icon to |_verticallyCenteredContent|. |
362 UIImage* newTabIcon = [[UIImage imageNamed:@"tabswitcher_new_tab"] | 362 UIImage* newTabIcon = [[UIImage imageNamed:@"tabswitcher_new_tab"] |
363 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | 363 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; |
364 _newTabIcon = [[UIImageView alloc] initWithImage:newTabIcon]; | 364 _newTabIcon = [[UIImageView alloc] initWithImage:newTabIcon]; |
365 [_newTabIcon setAlpha:0]; | 365 [_newTabIcon setAlpha:0]; |
366 [_newTabIcon setTranslatesAutoresizingMaskIntoConstraints:NO]; | 366 [_newTabIcon setTranslatesAutoresizingMaskIntoConstraints:NO]; |
367 [_verticallyCenteredView addSubview:_newTabIcon]; | 367 [_verticallyCenteredView addSubview:_newTabIcon]; |
368 | 368 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 - (void)prepareForReuse { | 452 - (void)prepareForReuse { |
453 [_newTabIcon setAlpha:0]; | 453 [_newTabIcon setAlpha:0]; |
454 [_faviconObtainer cancel]; | 454 [_faviconObtainer cancel]; |
455 _faviconObtainer = nil; | 455 _faviconObtainer = nil; |
456 [_raisedButton setAlpha:0]; | 456 [_raisedButton setAlpha:0]; |
457 [_raisedButton resetState]; | 457 [_raisedButton resetState]; |
458 [super prepareForReuse]; | 458 [super prepareForReuse]; |
459 } | 459 } |
460 | 460 |
461 @end | 461 @end |
OLD | NEW |