OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/browser/ui/settings/cells/copied_to_chrome_item.h" |
| 6 |
| 7 #include "components/strings/grit/components_strings.h" |
| 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 9 #include "ios/chrome/grit/ios_chromium_strings.h" |
| 10 #import "ios/third_party/material_components_ios/src/components/Buttons/src/Mate
rialButtons.h" |
| 11 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 12 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
| 13 #include "ui/base/l10n/l10n_util_mac.h" |
| 14 |
| 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 16 #error "This file requires ARC support." |
| 17 #endif |
| 18 |
| 19 namespace { |
| 20 // Padding used on the leading and trailing edges of the cell. |
| 21 const CGFloat kHorizontalPadding = 16; |
| 22 |
| 23 // Padding used on the top and bottom edges of the cell. |
| 24 const CGFloat kVerticalPadding = 16; |
| 25 } // namespace |
| 26 |
| 27 @implementation CopiedToChromeItem |
| 28 |
| 29 - (instancetype)initWithType:(NSInteger)type { |
| 30 self = [super initWithType:type]; |
| 31 if (self) { |
| 32 self.cellClass = [CopiedToChromeCell class]; |
| 33 } |
| 34 return self; |
| 35 } |
| 36 |
| 37 @end |
| 38 |
| 39 @implementation CopiedToChromeCell |
| 40 |
| 41 @synthesize textLabel = _textLabel; |
| 42 @synthesize button = _button; |
| 43 |
| 44 - (instancetype)initWithFrame:(CGRect)frame { |
| 45 self = [super initWithFrame:frame]; |
| 46 if (self) { |
| 47 UIView* contentView = self.contentView; |
| 48 |
| 49 _textLabel = [[UILabel alloc] init]; |
| 50 _textLabel.translatesAutoresizingMaskIntoConstraints = NO; |
| 51 [contentView addSubview:_textLabel]; |
| 52 |
| 53 _button = [[MDCFlatButton alloc] init]; |
| 54 _button.translatesAutoresizingMaskIntoConstraints = NO; |
| 55 [contentView addSubview:_button]; |
| 56 |
| 57 _textLabel.font = |
| 58 [[MDFRobotoFontLoader sharedInstance] mediumFontOfSize:14]; |
| 59 _textLabel.textColor = [[MDCPalette greyPalette] tint900]; |
| 60 _textLabel.text = |
| 61 l10n_util::GetNSString(IDS_IOS_AUTOFILL_DESCRIBE_LOCAL_COPY); |
| 62 |
| 63 _button.customTitleColor = [[MDCPalette cr_bluePalette] tint600]; |
| 64 [_button |
| 65 setTitle:l10n_util::GetNSString(IDS_AUTOFILL_CLEAR_LOCAL_COPY_BUTTON) |
| 66 forState:UIControlStateNormal]; |
| 67 |
| 68 // Set up the constraints. |
| 69 [NSLayoutConstraint activateConstraints:@[ |
| 70 [_textLabel.leadingAnchor |
| 71 constraintEqualToAnchor:contentView.leadingAnchor |
| 72 constant:kHorizontalPadding], |
| 73 [_textLabel.topAnchor constraintEqualToAnchor:contentView.topAnchor |
| 74 constant:kVerticalPadding], |
| 75 [_textLabel.bottomAnchor constraintEqualToAnchor:contentView.bottomAnchor |
| 76 constant:-kVerticalPadding], |
| 77 [_button.trailingAnchor |
| 78 constraintEqualToAnchor:contentView.trailingAnchor], |
| 79 [_button.centerYAnchor constraintEqualToAnchor:contentView.centerYAnchor], |
| 80 ]]; |
| 81 } |
| 82 return self; |
| 83 } |
| 84 |
| 85 - (void)prepareForReuse { |
| 86 [super prepareForReuse]; |
| 87 [self.button removeTarget:nil |
| 88 action:nil |
| 89 forControlEvents:UIControlEventAllEvents]; |
| 90 } |
| 91 |
| 92 @end |
OLD | NEW |