| 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 { |
| 28 class ImageSkia; | 28 class ImageSkia; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 const CGFloat kFontSize = 16; | |
| 33 const CGFloat kCellCornerRadius = 2; | 32 const CGFloat kCellCornerRadius = 2; |
| 34 const CGFloat kBarHeight = 44; | 33 const CGFloat kBarHeight = 44; |
| 35 const CGFloat kTitleLabelTextAlpha = .54; | 34 const CGFloat kTitleLabelTextAlpha = .54; |
| 36 const CGFloat kNewTabIconAlpha = .87; | 35 const CGFloat kNewTabIconAlpha = .87; |
| 37 } | 36 } |
| 38 | 37 |
| 39 CGFloat tabSwitcherLocalSessionCellTopBarHeight() { | 38 CGFloat tabSwitcherLocalSessionCellTopBarHeight() { |
| 40 return kBarHeight; | 39 return kBarHeight; |
| 41 } | 40 } |
| 42 | 41 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 ]; | 159 ]; |
| 161 NSDictionary* metrics = | 160 NSDictionary* metrics = |
| 162 @{ @"barHeight" : @(tabSwitcherLocalSessionCellTopBarHeight()) }; | 161 @{ @"barHeight" : @(tabSwitcherLocalSessionCellTopBarHeight()) }; |
| 163 ApplyVisualConstraintsWithMetrics(constraints, viewsDictionary, metrics, | 162 ApplyVisualConstraintsWithMetrics(constraints, viewsDictionary, metrics, |
| 164 [self containerView]); | 163 [self containerView]); |
| 165 | 164 |
| 166 // Create and add subviews to the cell bar. | 165 // Create and add subviews to the cell bar. |
| 167 // Title label. | 166 // Title label. |
| 168 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | 167 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
| 169 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; | 168 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| 170 [_titleLabel setFont:[[MDFRobotoFontLoader sharedInstance] | 169 [_titleLabel setFont:[MDCTypography subheadFont]]; |
| 171 regularFontOfSize:kFontSize]]; | |
| 172 [_topBar addSubview:_titleLabel]; | 170 [_topBar addSubview:_titleLabel]; |
| 173 | 171 |
| 174 // Favicon. | 172 // Favicon. |
| 175 _favicon = [[UIImageView alloc] initWithFrame:CGRectZero]; | 173 _favicon = [[UIImageView alloc] initWithFrame:CGRectZero]; |
| 176 [_favicon setTranslatesAutoresizingMaskIntoConstraints:NO]; | 174 [_favicon setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| 177 [_topBar addSubview:_favicon]; | 175 [_topBar addSubview:_favicon]; |
| 178 | 176 |
| 179 // Close button. | 177 // Close button. |
| 180 _closeButton = [[UIButton alloc] initWithFrame:CGRectZero]; | 178 _closeButton = [[UIButton alloc] initWithFrame:CGRectZero]; |
| 181 [_closeButton | 179 [_closeButton |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 _verticallyCenteredView = [[UIView alloc] initWithFrame:CGRectZero]; | 345 _verticallyCenteredView = [[UIView alloc] initWithFrame:CGRectZero]; |
| 348 [_verticallyCenteredView setTranslatesAutoresizingMaskIntoConstraints:NO]; | 346 [_verticallyCenteredView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| 349 [_verticallyCenteredView setUserInteractionEnabled:NO]; | 347 [_verticallyCenteredView setUserInteractionEnabled:NO]; |
| 350 [_raisedButton addSubview:_verticallyCenteredView]; | 348 [_raisedButton addSubview:_verticallyCenteredView]; |
| 351 | 349 |
| 352 // Create and add title label to |_verticallyCenteredContent|. | 350 // Create and add title label to |_verticallyCenteredContent|. |
| 353 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; | 351 _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |
| 354 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; | 352 [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| 355 [_titleLabel setNumberOfLines:5]; | 353 [_titleLabel setNumberOfLines:5]; |
| 356 [_titleLabel setTextAlignment:NSTextAlignmentCenter]; | 354 [_titleLabel setTextAlignment:NSTextAlignmentCenter]; |
| 357 [_titleLabel setFont:[[MDFRobotoFontLoader sharedInstance] | 355 [_titleLabel setFont:[MDCTypography subheadFont]]; |
| 358 regularFontOfSize:kFontSize]]; | |
| 359 [_verticallyCenteredView addSubview:_titleLabel]; | 356 [_verticallyCenteredView addSubview:_titleLabel]; |
| 360 | 357 |
| 361 // Create and add new tab icon to |_verticallyCenteredContent|. | 358 // Create and add new tab icon to |_verticallyCenteredContent|. |
| 362 UIImage* newTabIcon = [[UIImage imageNamed:@"tabswitcher_new_tab"] | 359 UIImage* newTabIcon = [[UIImage imageNamed:@"tabswitcher_new_tab"] |
| 363 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | 360 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; |
| 364 _newTabIcon = [[UIImageView alloc] initWithImage:newTabIcon]; | 361 _newTabIcon = [[UIImageView alloc] initWithImage:newTabIcon]; |
| 365 [_newTabIcon setAlpha:0]; | 362 [_newTabIcon setAlpha:0]; |
| 366 [_newTabIcon setTranslatesAutoresizingMaskIntoConstraints:NO]; | 363 [_newTabIcon setTranslatesAutoresizingMaskIntoConstraints:NO]; |
| 367 [_verticallyCenteredView addSubview:_newTabIcon]; | 364 [_verticallyCenteredView addSubview:_newTabIcon]; |
| 368 | 365 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 - (void)prepareForReuse { | 449 - (void)prepareForReuse { |
| 453 [_newTabIcon setAlpha:0]; | 450 [_newTabIcon setAlpha:0]; |
| 454 [_faviconObtainer cancel]; | 451 [_faviconObtainer cancel]; |
| 455 _faviconObtainer = nil; | 452 _faviconObtainer = nil; |
| 456 [_raisedButton setAlpha:0]; | 453 [_raisedButton setAlpha:0]; |
| 457 [_raisedButton resetState]; | 454 [_raisedButton resetState]; |
| 458 [super prepareForReuse]; | 455 [super prepareForReuse]; |
| 459 } | 456 } |
| 460 | 457 |
| 461 @end | 458 @end |
| OLD | NEW |