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 #import "ios/chrome/browser/ui/autofill/cells/storage_switch_item.h" | 5 #import "ios/chrome/browser/ui/autofill/cells/storage_switch_item.h" |
6 | 6 |
7 #include "components/grit/components_scaled_resources.h" | 7 #include "components/grit/components_scaled_resources.h" |
8 #include "components/strings/grit/components_strings.h" | 8 #include "components/strings/grit/components_strings.h" |
9 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 9 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 10 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
10 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 11 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
11 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 12 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
12 #include "ui/base/l10n/l10n_util_mac.h" | 13 #include "ui/base/l10n/l10n_util_mac.h" |
13 #include "ui/base/resource/resource_bundle.h" | |
14 | 14 |
15 #if !defined(__has_feature) || !__has_feature(objc_arc) | 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
16 #error "This file requires ARC support." | 16 #error "This file requires ARC support." |
17 #endif | 17 #endif |
18 | 18 |
19 namespace { | 19 namespace { |
20 // Padding used on the leading and trailing edges of the cell. | 20 // Padding used on the leading and trailing edges of the cell. |
21 const CGFloat kHorizontalPadding = 16; | 21 const CGFloat kHorizontalPadding = 16; |
22 // Padding used on the top and bottom edges of the cell. | 22 // Padding used on the top and bottom edges of the cell. |
23 const CGFloat kVerticalPadding = 16; | 23 const CGFloat kVerticalPadding = 16; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; | 77 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; |
78 _textLabel.textColor = [[MDCPalette greyPalette] tint500]; | 78 _textLabel.textColor = [[MDCPalette greyPalette] tint500]; |
79 _textLabel.numberOfLines = 0; | 79 _textLabel.numberOfLines = 0; |
80 [_textLabel | 80 [_textLabel |
81 setContentCompressionResistancePriority:UILayoutPriorityDefaultLow | 81 setContentCompressionResistancePriority:UILayoutPriorityDefaultLow |
82 forAxis: | 82 forAxis: |
83 UILayoutConstraintAxisHorizontal]; | 83 UILayoutConstraintAxisHorizontal]; |
84 | 84 |
85 _switchView.onTintColor = [[MDCPalette cr_bluePalette] tint500]; | 85 _switchView.onTintColor = [[MDCPalette cr_bluePalette] tint500]; |
86 | 86 |
87 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 87 [_tooltipButton setImage:NativeImage(IDR_AUTOFILL_TOOLTIP_ICON_H) |
88 UIImage* highlightedImage = | 88 forState:UIControlStateSelected]; |
89 rb.GetNativeImageNamed(IDR_AUTOFILL_TOOLTIP_ICON_H).ToUIImage(); | 89 [_tooltipButton setImage:NativeImage(IDR_AUTOFILL_TOOLTIP_ICON) |
90 [_tooltipButton setImage:highlightedImage forState:UIControlStateSelected]; | 90 forState:UIControlStateNormal]; |
91 UIImage* normalImage = | |
92 rb.GetNativeImageNamed(IDR_AUTOFILL_TOOLTIP_ICON).ToUIImage(); | |
93 [_tooltipButton setImage:normalImage forState:UIControlStateNormal]; | |
94 | 91 |
95 // Set up the constraints. | 92 // Set up the constraints. |
96 [NSLayoutConstraint activateConstraints:@[ | 93 [NSLayoutConstraint activateConstraints:@[ |
97 [_textLabel.topAnchor constraintEqualToAnchor:contentView.topAnchor | 94 [_textLabel.topAnchor constraintEqualToAnchor:contentView.topAnchor |
98 constant:kVerticalPadding], | 95 constant:kVerticalPadding], |
99 [_textLabel.bottomAnchor constraintEqualToAnchor:contentView.bottomAnchor | 96 [_textLabel.bottomAnchor constraintEqualToAnchor:contentView.bottomAnchor |
100 constant:-kVerticalPadding], | 97 constant:-kVerticalPadding], |
101 [_textLabel.leadingAnchor | 98 [_textLabel.leadingAnchor |
102 constraintEqualToAnchor:contentView.leadingAnchor | 99 constraintEqualToAnchor:contentView.leadingAnchor |
103 constant:kHorizontalPadding], | 100 constant:kHorizontalPadding], |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 [super prepareForReuse]; | 137 [super prepareForReuse]; |
141 [self.tooltipButton removeTarget:nil | 138 [self.tooltipButton removeTarget:nil |
142 action:nil | 139 action:nil |
143 forControlEvents:self.tooltipButton.allControlEvents]; | 140 forControlEvents:self.tooltipButton.allControlEvents]; |
144 [self.switchView removeTarget:nil | 141 [self.switchView removeTarget:nil |
145 action:nil | 142 action:nil |
146 forControlEvents:self.switchView.allControlEvents]; | 143 forControlEvents:self.switchView.allControlEvents]; |
147 } | 144 } |
148 | 145 |
149 @end | 146 @end |
OLD | NEW |