| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // ====== New Architecture ===== | 5 // ====== New Architecture ===== |
| 6 // = This code is only used in the new iOS Chrome architecture. = | 6 // = This code is only used in the new iOS Chrome architecture. = |
| 7 // ============================================================================ | 7 // ============================================================================ |
| 8 | 8 |
| 9 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_tab_cell.h" | 9 #import "ios/clean/chrome/browser/ui/tab_grid/tab_grid_tab_cell.h" |
| 10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 const CGFloat kCornerRadius = 4.0; | 16 const CGFloat kSelectedBorderCornerRadius = 8.0f; |
| 17 const CGFloat kSelectedBorderWidth = 2.0; | 17 const CGFloat kSelectedBorderWidth = 4.0f; |
| 18 } | 18 } |
| 19 | 19 |
| 20 @implementation TabGridTabCell | 20 @implementation TabGridTabCell |
| 21 | 21 |
| 22 @synthesize label = _label; | |
| 23 | |
| 24 - (instancetype)initWithFrame:(CGRect)frame { | 22 - (instancetype)initWithFrame:(CGRect)frame { |
| 25 if ((self = [super initWithFrame:frame])) { | 23 if ((self = [super initWithFrame:frame])) { |
| 26 self.contentView.layer.cornerRadius = kCornerRadius; | 24 self.selectedBackgroundView = [[UIView alloc] init]; |
| 27 self.selectedBackgroundView.layer.cornerRadius = kCornerRadius; | 25 self.selectedBackgroundView.backgroundColor = [UIColor blackColor]; |
| 26 self.selectedBackgroundView.layer.cornerRadius = |
| 27 kSelectedBorderCornerRadius; |
| 28 self.selectedBackgroundView.layer.borderWidth = kSelectedBorderWidth; | 28 self.selectedBackgroundView.layer.borderWidth = kSelectedBorderWidth; |
| 29 self.selectedBackgroundView.layer.borderColor = [UIColor blueColor].CGColor; | 29 self.selectedBackgroundView.layer.borderColor = self.tintColor.CGColor; |
| 30 self.selectedBackgroundView.transform = CGAffineTransformScale( | 30 self.selectedBackgroundView.transform = CGAffineTransformScale( |
| 31 self.selectedBackgroundView.transform, 1.05, 1.05); | 31 self.selectedBackgroundView.transform, 1.08, 1.08); |
| 32 | |
| 33 _label = [[UILabel alloc] initWithFrame:CGRectZero]; | |
| 34 _label.translatesAutoresizingMaskIntoConstraints = NO; | |
| 35 _label.numberOfLines = 1; | |
| 36 _label.textAlignment = NSTextAlignmentCenter; | |
| 37 [self.contentView addSubview:_label]; | |
| 38 [NSLayoutConstraint activateConstraints:@[ | |
| 39 [_label.centerYAnchor | |
| 40 constraintEqualToAnchor:self.contentView.centerYAnchor], | |
| 41 [_label.leadingAnchor | |
| 42 constraintEqualToAnchor:self.contentView.layoutMarginsGuide | |
| 43 .leadingAnchor], | |
| 44 [_label.trailingAnchor | |
| 45 constraintEqualToAnchor:self.contentView.layoutMarginsGuide | |
| 46 .trailingAnchor], | |
| 47 ]]; | |
| 48 } | 32 } |
| 49 return self; | 33 return self; |
| 50 } | 34 } |
| 51 | 35 |
| 52 @end | 36 @end |
| OLD | NEW |