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/collection_view/cells/collection_view_account_ite
m.h" | 5 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_account_ite
m.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
9 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 9 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
10 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" | 10 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF
ontLoader.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 // Error icon fixed horizontal size. | 30 // Error icon fixed horizontal size. |
31 const CGFloat kHorizontalErrorIconFixedSize = 25; | 31 const CGFloat kHorizontalErrorIconFixedSize = 25; |
32 } | 32 } |
33 | 33 |
34 @implementation CollectionViewAccountItem | 34 @implementation CollectionViewAccountItem |
35 | 35 |
36 @synthesize image = _image; | 36 @synthesize image = _image; |
37 @synthesize text = _text; | 37 @synthesize text = _text; |
38 @synthesize detailText = _detailText; | 38 @synthesize detailText = _detailText; |
39 @synthesize accessoryType = _accessoryType; | |
40 @synthesize shouldDisplayError = _shouldDisplayError; | 39 @synthesize shouldDisplayError = _shouldDisplayError; |
41 @synthesize chromeIdentity = _chromeIdentity; | 40 @synthesize chromeIdentity = _chromeIdentity; |
42 @synthesize enabled = _enabled; | 41 @synthesize enabled = _enabled; |
43 | 42 |
44 - (instancetype)initWithType:(NSInteger)type { | 43 - (instancetype)initWithType:(NSInteger)type { |
45 self = [super initWithType:type]; | 44 self = [super initWithType:type]; |
46 if (self) { | 45 if (self) { |
47 self.cellClass = [CollectionViewAccountCell class]; | 46 self.cellClass = [CollectionViewAccountCell class]; |
48 self.accessibilityTraits |= UIAccessibilityTraitButton; | 47 self.accessibilityTraits |= UIAccessibilityTraitButton; |
49 self.enabled = YES; | 48 self.enabled = YES; |
50 } | 49 } |
51 return self; | 50 return self; |
52 } | 51 } |
53 | 52 |
54 #pragma mark - CollectionViewItem | 53 #pragma mark - CollectionViewItem |
55 | 54 |
56 - (void)configureCell:(CollectionViewAccountCell*)cell { | 55 - (void)configureCell:(CollectionViewAccountCell*)cell { |
57 [super configureCell:cell]; | 56 [super configureCell:cell]; |
58 cell.imageView.image = self.image; | 57 cell.imageView.image = self.image; |
59 cell.textLabel.text = self.text; | 58 cell.textLabel.text = self.text; |
60 cell.detailTextLabel.text = self.detailText; | 59 cell.detailTextLabel.text = self.detailText; |
61 cell.accessoryType = self.accessoryType; | |
62 if (self.shouldDisplayError) { | 60 if (self.shouldDisplayError) { |
63 cell.errorIcon.image = [UIImage imageNamed:@"settings_error"]; | 61 cell.errorIcon.image = [UIImage imageNamed:@"settings_error"]; |
64 cell.detailTextLabel.textColor = [[MDCPalette cr_redPalette] tint500]; | 62 cell.detailTextLabel.textColor = [[MDCPalette cr_redPalette] tint500]; |
65 } else { | 63 } else { |
66 cell.errorIcon.image = nil; | 64 cell.errorIcon.image = nil; |
67 cell.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; | 65 cell.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; |
68 } | 66 } |
69 | 67 |
70 if (self.isEnabled) { | 68 if (self.isEnabled) { |
71 cell.userInteractionEnabled = YES; | 69 cell.userInteractionEnabled = YES; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 #pragma mark - UICollectionReusableView | 236 #pragma mark - UICollectionReusableView |
239 | 237 |
240 - (void)prepareForReuse { | 238 - (void)prepareForReuse { |
241 [super prepareForReuse]; | 239 [super prepareForReuse]; |
242 self.imageView.image = nil; | 240 self.imageView.image = nil; |
243 self.textLabel.text = nil; | 241 self.textLabel.text = nil; |
244 self.detailTextLabel.text = nil; | 242 self.detailTextLabel.text = nil; |
245 self.textLabel.textColor = [[MDCPalette greyPalette] tint900]; | 243 self.textLabel.textColor = [[MDCPalette greyPalette] tint900]; |
246 self.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; | 244 self.detailTextLabel.textColor = [[MDCPalette greyPalette] tint500]; |
247 self.errorIcon.image = nil; | 245 self.errorIcon.image = nil; |
248 self.accessoryType = MDCCollectionViewCellAccessoryNone; | |
249 self.userInteractionEnabled = YES; | 246 self.userInteractionEnabled = YES; |
250 self.contentView.alpha = 1; | 247 self.contentView.alpha = 1; |
251 UIImageView* accessoryImage = | 248 UIImageView* accessoryImage = |
252 base::mac::ObjCCastStrict<UIImageView>(self.accessoryView); | 249 base::mac::ObjCCastStrict<UIImageView>(self.accessoryView); |
253 accessoryImage.tintColor = | 250 accessoryImage.tintColor = |
254 [accessoryImage.tintColor colorWithAlphaComponent:1]; | 251 [accessoryImage.tintColor colorWithAlphaComponent:1]; |
255 } | 252 } |
256 | 253 |
257 #pragma mark - NSObject(Accessibility) | 254 #pragma mark - NSObject(Accessibility) |
258 | 255 |
259 - (NSString*)accessibilityLabel { | 256 - (NSString*)accessibilityLabel { |
260 return self.textLabel.text; | 257 return self.textLabel.text; |
261 } | 258 } |
262 | 259 |
263 - (NSString*)accessibilityValue { | 260 - (NSString*)accessibilityValue { |
264 return self.detailTextLabel.text; | 261 return self.detailTextLabel.text; |
265 } | 262 } |
266 | 263 |
267 @end | 264 @end |
OLD | NEW |