OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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/payments/cells/payments_selector_edit_item.h" |
| 6 |
| 7 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_detail_item
.h" |
| 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 9 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
| 15 @implementation PaymentsSelectorEditItem |
| 16 |
| 17 @synthesize accessoryType = _accessoryType; |
| 18 @synthesize name = _name; |
| 19 @synthesize value = _value; |
| 20 @synthesize autofillUIType = _autofillUIType; |
| 21 @synthesize required = _required; |
| 22 @synthesize nameFont = _nameFont; |
| 23 @synthesize nameColor = _nameColor; |
| 24 @synthesize valueFont = _valueFont; |
| 25 @synthesize valueColor = _valueColor; |
| 26 |
| 27 - (instancetype)initWithType:(NSInteger)type { |
| 28 self = [super initWithType:type]; |
| 29 if (self) { |
| 30 self.cellClass = [CollectionViewDetailCell class]; |
| 31 } |
| 32 return self; |
| 33 } |
| 34 |
| 35 - (UIFont*)nameFont { |
| 36 if (!_nameFont) { |
| 37 _nameFont = [MDCTypography body2Font]; |
| 38 } |
| 39 return _nameFont; |
| 40 } |
| 41 |
| 42 - (UIColor*)nameColor { |
| 43 if (!_nameColor) { |
| 44 _nameColor = [[MDCPalette greyPalette] tint900]; |
| 45 } |
| 46 return _nameColor; |
| 47 } |
| 48 |
| 49 - (UIFont*)valueFont { |
| 50 if (!_valueFont) { |
| 51 _valueFont = [MDCTypography body1Font]; |
| 52 } |
| 53 return _valueFont; |
| 54 } |
| 55 |
| 56 - (UIColor*)valueColor { |
| 57 if (!_valueColor) { |
| 58 _valueColor = [[MDCPalette cr_bluePalette] tint600]; |
| 59 } |
| 60 return _valueColor; |
| 61 } |
| 62 |
| 63 #pragma mark CollectionViewItem |
| 64 |
| 65 - (void)configureCell:(CollectionViewDetailCell*)cell { |
| 66 [super configureCell:cell]; |
| 67 cell.accessoryType = self.accessoryType; |
| 68 NSString* textLabelFormat = self.required ? @"%@*" : @"%@"; |
| 69 cell.textLabel.text = [NSString stringWithFormat:textLabelFormat, self.name]; |
| 70 cell.detailTextLabel.text = self.value; |
| 71 |
| 72 // Styling. |
| 73 cell.textLabel.font = self.nameFont; |
| 74 cell.textLabel.textColor = self.nameColor; |
| 75 cell.detailTextLabel.font = self.valueFont; |
| 76 cell.detailTextLabel.textColor = self.valueColor; |
| 77 } |
| 78 |
| 79 @end |
OLD | NEW |