| 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/text_and_error_item.h" | 5 #import "ios/chrome/browser/ui/settings/cells/text_and_error_item.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 8 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 9 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 9 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // Padding used between the image and text. | 22 // Padding used between the image and text. |
| 23 const CGFloat kHorizontalPaddingBetweenImageAndText = 10; | 23 const CGFloat kHorizontalPaddingBetweenImageAndText = 10; |
| 24 | 24 |
| 25 // Error icon fixed horizontal size. | 25 // Error icon fixed horizontal size. |
| 26 const CGFloat kHorizontalErrorIconFixedSize = 25; | 26 const CGFloat kHorizontalErrorIconFixedSize = 25; |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 @implementation TextAndErrorItem | 29 @implementation TextAndErrorItem |
| 30 | 30 |
| 31 @synthesize text = _text; | 31 @synthesize text = _text; |
| 32 @synthesize accessoryType = _accessoryType; | |
| 33 @synthesize shouldDisplayError = _shouldDisplayError; | 32 @synthesize shouldDisplayError = _shouldDisplayError; |
| 34 @synthesize enabled = _enabled; | 33 @synthesize enabled = _enabled; |
| 35 | 34 |
| 36 - (instancetype)initWithType:(NSInteger)type { | 35 - (instancetype)initWithType:(NSInteger)type { |
| 37 self = [super initWithType:type]; | 36 self = [super initWithType:type]; |
| 38 if (self) { | 37 if (self) { |
| 39 self.cellClass = [TextAndErrorCell class]; | 38 self.cellClass = [TextAndErrorCell class]; |
| 40 self.accessibilityTraits |= UIAccessibilityTraitButton; | 39 self.accessibilityTraits |= UIAccessibilityTraitButton; |
| 41 self.enabled = YES; | 40 self.enabled = YES; |
| 42 } | 41 } |
| 43 return self; | 42 return self; |
| 44 } | 43 } |
| 45 | 44 |
| 46 - (void)configureCell:(TextAndErrorCell*)cell { | 45 - (void)configureCell:(TextAndErrorCell*)cell { |
| 47 [super configureCell:cell]; | 46 [super configureCell:cell]; |
| 48 cell.textLabel.text = self.text; | 47 cell.textLabel.text = self.text; |
| 49 cell.accessoryType = self.accessoryType; | |
| 50 cell.accessibilityLabel = self.text; | 48 cell.accessibilityLabel = self.text; |
| 51 if (self.shouldDisplayError) { | 49 if (self.shouldDisplayError) { |
| 52 cell.errorIcon.image = [UIImage imageNamed:@"settings_error"]; | 50 cell.errorIcon.image = [UIImage imageNamed:@"settings_error"]; |
| 53 } else { | 51 } else { |
| 54 cell.errorIcon.image = nil; | 52 cell.errorIcon.image = nil; |
| 55 } | 53 } |
| 56 UIImageView* accessoryImage = | 54 UIImageView* accessoryImage = |
| 57 base::mac::ObjCCastStrict<UIImageView>(cell.accessoryView); | 55 base::mac::ObjCCastStrict<UIImageView>(cell.accessoryView); |
| 58 accessoryImage.image = [accessoryImage.image | 56 accessoryImage.image = [accessoryImage.image |
| 59 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | 57 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 self.textLabel.textColor = [[MDCPalette greyPalette] tint900]; | 155 self.textLabel.textColor = [[MDCPalette greyPalette] tint900]; |
| 158 [self setUserInteractionEnabled:YES]; | 156 [self setUserInteractionEnabled:YES]; |
| 159 UIImageView* accessoryImage = | 157 UIImageView* accessoryImage = |
| 160 base::mac::ObjCCastStrict<UIImageView>(self.accessoryView); | 158 base::mac::ObjCCastStrict<UIImageView>(self.accessoryView); |
| 161 accessoryImage.image = [accessoryImage.image | 159 accessoryImage.image = [accessoryImage.image |
| 162 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; | 160 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; |
| 163 [accessoryImage setTintColor:[[MDCPalette greyPalette] tint900]]; | 161 [accessoryImage setTintColor:[[MDCPalette greyPalette] tint900]]; |
| 164 } | 162 } |
| 165 | 163 |
| 166 @end | 164 @end |
| OLD | NEW |