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/tools_menu/tools_menu_view_item.h" | 5 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_item.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/mac/objc_property_releaser.h" | 8 #include "base/mac/objc_property_releaser.h" |
9 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 9 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 const CGFloat kToolsMenuItemHorizontalMargin = 16; | 13 const CGFloat kToolsMenuItemHorizontalMargin = 16; |
14 // Increase the margin for RTL so the labels don't overlap the tools icon. | 14 // Increase the margin for RTL so the labels don't overlap the tools icon. |
15 const CGFloat kToolsMenuItemHorizontalMarginRTL = 25; | 15 const CGFloat kToolsMenuItemHorizontalMarginRTL = 25; |
16 static NSString* const kMenuItemCellID = @"MenuItemCellID"; | 16 static NSString* const kMenuItemCellID = @"MenuItemCellID"; |
17 } | 17 } |
18 | 18 |
19 @implementation ToolsMenuViewItem { | 19 @implementation ToolsMenuViewItem { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 - (void)prepareForReuse { | 92 - (void)prepareForReuse { |
93 [super prepareForReuse]; | 93 [super prepareForReuse]; |
94 [_title setText:nil]; | 94 [_title setText:nil]; |
95 [self setAccessibilityIdentifier:nil]; | 95 [self setAccessibilityIdentifier:nil]; |
96 [self setAccessibilityLabel:nil]; | 96 [self setAccessibilityLabel:nil]; |
97 } | 97 } |
98 | 98 |
99 - (void)initializeTitleView { | 99 - (void)initializeTitleView { |
100 _title = [[UILabel alloc] initWithFrame:self.bounds]; | 100 _title = [[UILabel alloc] initWithFrame:self.bounds]; |
101 [_title setTranslatesAutoresizingMaskIntoConstraints:NO]; | 101 [_title setTranslatesAutoresizingMaskIntoConstraints:NO]; |
102 [_title setFont:[[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]]; | 102 [_title setFont:[[MDCTypography fontLoader] regularFontOfSize:16]]; |
103 [_title setBackgroundColor:[self backgroundColor]]; | 103 [_title setBackgroundColor:[self backgroundColor]]; |
104 [_title setTextAlignment:(base::i18n::IsRTL() ? NSTextAlignmentRight | 104 [_title setTextAlignment:(base::i18n::IsRTL() ? NSTextAlignmentRight |
105 : NSTextAlignmentLeft)]; | 105 : NSTextAlignmentLeft)]; |
106 [_title setOpaque:YES]; | 106 [_title setOpaque:YES]; |
107 } | 107 } |
108 | 108 |
109 - (void)initializeViews { | 109 - (void)initializeViews { |
110 if (_title) | 110 if (_title) |
111 return; | 111 return; |
112 | 112 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 [_title setText:[item title]]; | 150 [_title setText:[item title]]; |
151 [self setAccessibilityIdentifier:[item accessibilityIdentifier]]; | 151 [self setAccessibilityIdentifier:[item accessibilityIdentifier]]; |
152 [self setAccessibilityLabel:[item accessibilityLabel]]; | 152 [self setAccessibilityLabel:[item accessibilityLabel]]; |
153 [self setAccessibilityTraits:traits]; | 153 [self setAccessibilityTraits:traits]; |
154 [self setIsAccessibilityElement:YES]; | 154 [self setIsAccessibilityElement:YES]; |
155 [self setTag:[item tag]]; | 155 [self setTag:[item tag]]; |
156 item.tableViewCell = self; | 156 item.tableViewCell = self; |
157 } | 157 } |
158 | 158 |
159 @end | 159 @end |
OLD | NEW |