Commit cb9e6ed7 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Fix Copied to Chrome button

The cell wasn't converted to UITableViewCell.

Bug: 894791
Change-Id: I44fdd29f4d3179eefa0d4515c4b8655bb77cd6c0
Reviewed-on: https://chromium-review.googlesource.com/c/1392960
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarYi Su <mrsuyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619424}
parent 92cb78d9
...@@ -142,7 +142,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -142,7 +142,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)loadModel { - (void)loadModel {
[super loadModel]; [super loadModel];
TableViewModel* model = self.tableViewModel; TableViewModel<TableViewItem*>* model = self.tableViewModel;
BOOL isEditing = self.tableView.editing; BOOL isEditing = self.tableView.editing;
......
...@@ -7,18 +7,15 @@ ...@@ -7,18 +7,15 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
#import "ios/third_party/material_components_ios/src/components/CollectionCells/src/MaterialCollectionCells.h"
@class MDCButton;
// Item that configures a CopiedToChromeCell. // Item that configures a CopiedToChromeCell.
@interface CopiedToChromeItem : CollectionViewItem @interface CopiedToChromeItem : TableViewItem
@end @end
// A cell indicating that the credit card has been copied to Chrome. Includes a // A cell indicating that the credit card has been copied to Chrome. Includes a
// button to clear the copy. // button to clear the copy.
@interface CopiedToChromeCell : MDCCollectionViewCell @interface CopiedToChromeCell : UITableViewCell
// Text label displaying the item's text. // Text label displaying the item's text.
@property(nonatomic, readonly, strong) UILabel* textLabel; @property(nonatomic, readonly, strong) UILabel* textLabel;
......
...@@ -5,28 +5,16 @@ ...@@ -5,28 +5,16 @@
#import "ios/chrome/browser/ui/settings/cells/copied_to_chrome_item.h" #import "ios/chrome/browser/ui/settings/cells/copied_to_chrome_item.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/collection_view/cells/collection_view_cell_constants.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h"
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_chromium_strings.h" #include "ios/chrome/grit/ios_chromium_strings.h"
#import "ios/third_party/material_components_ios/src/components/Buttons/src/MaterialButtons.h"
#import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h"
#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
namespace {
// Padding used on the leading and trailing edges of the cell.
const CGFloat kHorizontalPadding = 16;
// Padding used on the top and bottom edges of the cell.
const CGFloat kVerticalPadding = 16;
} // namespace
@implementation CopiedToChromeItem @implementation CopiedToChromeItem
- (instancetype)initWithType:(NSInteger)type { - (instancetype)initWithType:(NSInteger)type {
...@@ -42,10 +30,10 @@ const CGFloat kVerticalPadding = 16; ...@@ -42,10 +30,10 @@ const CGFloat kVerticalPadding = 16;
@implementation CopiedToChromeCell @implementation CopiedToChromeCell
@synthesize textLabel = _textLabel; @synthesize textLabel = _textLabel;
@synthesize button = _button;
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithStyle:(UITableViewCellStyle)style
self = [super initWithFrame:frame]; reuseIdentifier:(NSString*)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) { if (self) {
UIView* contentView = self.contentView; UIView* contentView = self.contentView;
...@@ -53,8 +41,9 @@ const CGFloat kVerticalPadding = 16; ...@@ -53,8 +41,9 @@ const CGFloat kVerticalPadding = 16;
_textLabel.translatesAutoresizingMaskIntoConstraints = NO; _textLabel.translatesAutoresizingMaskIntoConstraints = NO;
_textLabel.text = _textLabel.text =
l10n_util::GetNSString(IDS_IOS_AUTOFILL_DESCRIBE_LOCAL_COPY); l10n_util::GetNSString(IDS_IOS_AUTOFILL_DESCRIBE_LOCAL_COPY);
_textLabel.font = [UIFont systemFontOfSize:kUIKitMainFontSize]; _textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_textLabel.textColor = UIColorFromRGB(kUIKitMainTextColor); _textLabel.adjustsFontForContentSizeCategory = YES;
_textLabel.textColor = UIColor.blackColor;
[_textLabel [_textLabel
setContentCompressionResistancePriority:UILayoutPriorityDefaultLow setContentCompressionResistancePriority:UILayoutPriorityDefaultLow
forAxis: forAxis:
...@@ -62,7 +51,7 @@ const CGFloat kVerticalPadding = 16; ...@@ -62,7 +51,7 @@ const CGFloat kVerticalPadding = 16;
[contentView addSubview:_textLabel]; [contentView addSubview:_textLabel];
_button = [UIButton buttonWithType:UIButtonTypeCustom]; _button = [UIButton buttonWithType:UIButtonTypeCustom];
[_button setTitleColor:UIColorFromRGB(kUIKitFooterLinkColor) [_button setTitleColor:UIColorFromRGB(kTableViewTextLabelColorBlue)
forState:UIControlStateNormal]; forState:UIControlStateNormal];
_button.translatesAutoresizingMaskIntoConstraints = NO; _button.translatesAutoresizingMaskIntoConstraints = NO;
...@@ -75,18 +64,20 @@ const CGFloat kVerticalPadding = 16; ...@@ -75,18 +64,20 @@ const CGFloat kVerticalPadding = 16;
[NSLayoutConstraint activateConstraints:@[ [NSLayoutConstraint activateConstraints:@[
[_textLabel.leadingAnchor [_textLabel.leadingAnchor
constraintEqualToAnchor:contentView.leadingAnchor constraintEqualToAnchor:contentView.leadingAnchor
constant:kHorizontalPadding], constant:kTableViewHorizontalSpacing],
[_textLabel.trailingAnchor [_textLabel.trailingAnchor
constraintLessThanOrEqualToAnchor:_button.leadingAnchor constraintLessThanOrEqualToAnchor:_button.leadingAnchor
constant:-kHorizontalPadding], constant:-kTableViewHorizontalSpacing],
[_textLabel.centerYAnchor [_textLabel.centerYAnchor
constraintEqualToAnchor:contentView.centerYAnchor], constraintEqualToAnchor:contentView.centerYAnchor],
[_button.trailingAnchor constraintEqualToAnchor:contentView.trailingAnchor [_button.trailingAnchor
constant:-kHorizontalPadding], constraintEqualToAnchor:contentView.trailingAnchor
constant:-kTableViewHorizontalSpacing],
[_button.firstBaselineAnchor [_button.firstBaselineAnchor
constraintEqualToAnchor:_textLabel.firstBaselineAnchor], constraintEqualToAnchor:_textLabel.firstBaselineAnchor],
]]; ]];
AddOptionalVerticalPadding(contentView, _textLabel, kVerticalPadding); AddOptionalVerticalPadding(contentView, _textLabel,
kTableViewLargeVerticalSpacing);
} }
return self; return self;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h" #import "ios/chrome/browser/ui/autofill/cells/autofill_edit_item.h"
#import "ios/chrome/browser/ui/icons/chrome_icon.h" #import "ios/chrome/browser/ui/icons/chrome_icon.h"
#import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h"
#import "ios/chrome/browser/ui/settings/cells/copied_to_chrome_item.h"
#import "ios/chrome/browser/ui/settings/cells/encryption_item.h" #import "ios/chrome/browser/ui/settings/cells/encryption_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_detail_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_detail_item.h"
#import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_item.h" #import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_item.h"
...@@ -282,6 +283,11 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -282,6 +283,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
[model addItem:autofillItemWithAllTexts [model addItem:autofillItemWithAllTexts
toSectionWithIdentifier:SectionIdentifierAutofill]; toSectionWithIdentifier:SectionIdentifierAutofill];
CopiedToChromeItem* copiedToChrome =
[[CopiedToChromeItem alloc] initWithType:ItemTypeAutofillData];
[model addItem:copiedToChrome
toSectionWithIdentifier:SectionIdentifierAutofill];
// SectionIdentifierAccount. // SectionIdentifierAccount.
TableViewSigninPromoItem* signinPromo = TableViewSigninPromoItem* signinPromo =
[[TableViewSigninPromoItem alloc] initWithType:ItemTypeAccount]; [[TableViewSigninPromoItem alloc] initWithType:ItemTypeAccount];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment