| 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/settings/cells/autofill_data_item.h" | 5 #import "ios/chrome/browser/ui/settings/cells/autofill_data_item.h" |
| 6 | 6 |
| 7 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 7 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 8 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 8 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
| 9 | 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) | 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 11 #error "This file requires ARC support." | 11 #error "This file requires ARC support." |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 // Padding used on the leading and trailing edges of the cell. | 15 // Padding used on the leading and trailing edges of the cell. |
| 16 const CGFloat kHorizontalPadding = 16; | 16 const CGFloat kHorizontalPadding = 16; |
| 17 // Padding used on the top and bottom edges of the cell. | 17 // Padding used on the top and bottom edges of the cell. |
| 18 const CGFloat kVerticalPadding = 16; | 18 const CGFloat kVerticalPadding = 16; |
| 19 } | 19 } |
| 20 | 20 |
| 21 @implementation AutofillDataItem | 21 @implementation AutofillDataItem |
| 22 | 22 |
| 23 @synthesize deletable = _deletable; | 23 @synthesize deletable = _deletable; |
| 24 @synthesize GUID = _GUID; | 24 @synthesize GUID = _GUID; |
| 25 @synthesize text = _text; | 25 @synthesize text = _text; |
| 26 @synthesize leadingDetailText = _leadingDetailText; | 26 @synthesize leadingDetailText = _leadingDetailText; |
| 27 @synthesize trailingDetailText = _trailingDetailText; | 27 @synthesize trailingDetailText = _trailingDetailText; |
| 28 @synthesize accessoryType = _accessoryType; | |
| 29 | 28 |
| 30 - (instancetype)initWithType:(NSInteger)type { | 29 - (instancetype)initWithType:(NSInteger)type { |
| 31 self = [super initWithType:type]; | 30 self = [super initWithType:type]; |
| 32 if (self) { | 31 if (self) { |
| 33 self.cellClass = [AutofillDataCell class]; | 32 self.cellClass = [AutofillDataCell class]; |
| 34 } | 33 } |
| 35 return self; | 34 return self; |
| 36 } | 35 } |
| 37 | 36 |
| 38 #pragma mark - CollectionViewItem | 37 #pragma mark - CollectionViewItem |
| 39 | 38 |
| 40 - (void)configureCell:(AutofillDataCell*)cell { | 39 - (void)configureCell:(AutofillDataCell*)cell { |
| 41 [super configureCell:cell]; | 40 [super configureCell:cell]; |
| 42 cell.textLabel.text = self.text; | 41 cell.textLabel.text = self.text; |
| 43 cell.leadingDetailTextLabel.text = self.leadingDetailText; | 42 cell.leadingDetailTextLabel.text = self.leadingDetailText; |
| 44 cell.trailingDetailTextLabel.text = self.trailingDetailText; | 43 cell.trailingDetailTextLabel.text = self.trailingDetailText; |
| 45 cell.accessoryType = self.accessoryType; | |
| 46 } | 44 } |
| 47 | 45 |
| 48 @end | 46 @end |
| 49 | 47 |
| 50 @implementation AutofillDataCell { | 48 @implementation AutofillDataCell { |
| 51 NSLayoutConstraint* _textLabelWidthConstraint; | 49 NSLayoutConstraint* _textLabelWidthConstraint; |
| 52 } | 50 } |
| 53 | 51 |
| 54 @synthesize textLabel = _textLabel; | 52 @synthesize textLabel = _textLabel; |
| 55 @synthesize leadingDetailTextLabel = _leadingDetailTextLabel; | 53 @synthesize leadingDetailTextLabel = _leadingDetailTextLabel; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 [super layoutSubviews]; | 155 [super layoutSubviews]; |
| 158 } | 156 } |
| 159 | 157 |
| 160 #pragma mark - UICollectionReusableView | 158 #pragma mark - UICollectionReusableView |
| 161 | 159 |
| 162 - (void)prepareForReuse { | 160 - (void)prepareForReuse { |
| 163 [super prepareForReuse]; | 161 [super prepareForReuse]; |
| 164 self.textLabel.text = nil; | 162 self.textLabel.text = nil; |
| 165 self.leadingDetailTextLabel.text = nil; | 163 self.leadingDetailTextLabel.text = nil; |
| 166 self.trailingDetailTextLabel.text = nil; | 164 self.trailingDetailTextLabel.text = nil; |
| 167 self.accessoryType = MDCCollectionViewCellAccessoryNone; | |
| 168 } | 165 } |
| 169 | 166 |
| 170 #pragma mark - NSObject(Accessibility) | 167 #pragma mark - NSObject(Accessibility) |
| 171 | 168 |
| 172 - (NSString*)accessibilityLabel { | 169 - (NSString*)accessibilityLabel { |
| 173 if (self.trailingDetailTextLabel.text) { | 170 if (self.trailingDetailTextLabel.text) { |
| 174 return [NSString stringWithFormat:@"%@, %@, %@", self.textLabel.text, | 171 return [NSString stringWithFormat:@"%@, %@, %@", self.textLabel.text, |
| 175 self.leadingDetailTextLabel.text, | 172 self.leadingDetailTextLabel.text, |
| 176 self.trailingDetailTextLabel.text]; | 173 self.trailingDetailTextLabel.text]; |
| 177 } | 174 } |
| 178 return [NSString stringWithFormat:@"%@, %@", self.textLabel.text, | 175 return [NSString stringWithFormat:@"%@, %@", self.textLabel.text, |
| 179 self.leadingDetailTextLabel.text]; | 176 self.leadingDetailTextLabel.text]; |
| 180 } | 177 } |
| 181 | 178 |
| 182 @end | 179 @end |
| OLD | NEW |