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/autofill/storage_switch_tooltip.h" | 5 #import "ios/chrome/browser/ui/autofill/storage_switch_tooltip.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "components/strings/grit/components_strings.h" | 8 #include "components/strings/grit/components_strings.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 #if !defined(__has_feature) || !__has_feature(objc_arc) | 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
13 #error "This file requires ARC support." | 13 #error "This file requires ARC support." |
14 #endif | 14 #endif |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const CGFloat kCornerRadius = 2.0f; | 18 const CGFloat kCornerRadius = 2.0f; |
19 const CGFloat kFontSize = 12.0f; | |
20 const CGFloat kInset = 8.0f; | 19 const CGFloat kInset = 8.0f; |
21 | 20 |
22 } // namespace | 21 } // namespace |
23 | 22 |
24 @implementation StorageSwitchTooltip | 23 @implementation StorageSwitchTooltip |
25 | 24 |
26 - (instancetype)initWithFrame:(CGRect)frame { | 25 - (instancetype)initWithFrame:(CGRect)frame { |
27 self = [super initWithFrame:frame]; | 26 self = [super initWithFrame:frame]; |
28 if (self) { | 27 if (self) { |
29 NSString* tooltipText = | 28 NSString* tooltipText = |
30 l10n_util::GetNSString(IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP); | 29 l10n_util::GetNSString(IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP); |
31 [self setText:tooltipText]; | 30 [self setText:tooltipText]; |
32 [self setTextColor:[UIColor whiteColor]]; | 31 [self setTextColor:[UIColor whiteColor]]; |
33 [self setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.9]]; | 32 [self setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.9]]; |
34 [[self layer] setCornerRadius:kCornerRadius]; | 33 [[self layer] setCornerRadius:kCornerRadius]; |
35 [[self layer] setMasksToBounds:YES]; | 34 [[self layer] setMasksToBounds:YES]; |
36 [self setFont:[[MDFRobotoFontLoader sharedInstance] | 35 [self setFont:[MDCTypography captionFont]]; |
37 regularFontOfSize:kFontSize]]; | |
38 [self setNumberOfLines:0]; // Allows multi-line layout. | 36 [self setNumberOfLines:0]; // Allows multi-line layout. |
39 } | 37 } |
40 return self; | 38 return self; |
41 } | 39 } |
42 | 40 |
43 - (instancetype)init { | 41 - (instancetype)init { |
44 return [self initWithFrame:CGRectZero]; | 42 return [self initWithFrame:CGRectZero]; |
45 } | 43 } |
46 | 44 |
47 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 45 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
(...skipping 17 matching lines...) Expand all Loading... |
65 | 63 |
66 return rect; | 64 return rect; |
67 } | 65 } |
68 | 66 |
69 - (void)drawTextInRect:(CGRect)rect { | 67 - (void)drawTextInRect:(CGRect)rect { |
70 UIEdgeInsets insets = {kInset, kInset, kInset, kInset}; | 68 UIEdgeInsets insets = {kInset, kInset, kInset, kInset}; |
71 [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)]; | 69 [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)]; |
72 } | 70 } |
73 | 71 |
74 @end | 72 @end |
OLD | NEW |