Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: ios/chrome/browser/ui/settings/cells/encryption_item.mm

Issue 2814793003: Adds accessoryType property to CollectionViewItem (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/encryption_item.h" 5 #import "ios/chrome/browser/ui/settings/cells/encryption_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)
(...skipping 10 matching lines...) Expand all
21 21
22 @interface EncryptionCell () 22 @interface EncryptionCell ()
23 23
24 // Returns the default text color used for the given |enabled| state. 24 // Returns the default text color used for the given |enabled| state.
25 + (UIColor*)defaultTextColorForEnabledState:(BOOL)enabled; 25 + (UIColor*)defaultTextColorForEnabledState:(BOOL)enabled;
26 26
27 @end 27 @end
28 28
29 @implementation EncryptionItem 29 @implementation EncryptionItem
30 30
31 @synthesize accessoryType = _accessoryType;
32 @synthesize text = _text; 31 @synthesize text = _text;
33 @synthesize enabled = _enabled; 32 @synthesize enabled = _enabled;
34 33
35 - (instancetype)initWithType:(NSInteger)type { 34 - (instancetype)initWithType:(NSInteger)type {
36 self = [super initWithType:type]; 35 self = [super initWithType:type];
37 if (self) { 36 if (self) {
38 self.cellClass = [EncryptionCell class]; 37 self.cellClass = [EncryptionCell class];
39 self.enabled = YES; 38 self.enabled = YES;
40 self.accessibilityTraits |= UIAccessibilityTraitButton; 39 self.accessibilityTraits |= UIAccessibilityTraitButton;
41 } 40 }
42 return self; 41 return self;
43 } 42 }
44 43
45 - (void)configureCell:(EncryptionCell*)cell { 44 - (void)configureCell:(EncryptionCell*)cell {
46 [super configureCell:cell]; 45 [super configureCell:cell];
47 cell.accessoryType = self.accessoryType;
48 cell.textLabel.text = self.text; 46 cell.textLabel.text = self.text;
49 cell.textLabel.textColor = 47 cell.textLabel.textColor =
50 [EncryptionCell defaultTextColorForEnabledState:self.enabled]; 48 [EncryptionCell defaultTextColorForEnabledState:self.enabled];
51 } 49 }
52 50
53 @end 51 @end
54 52
55 @implementation EncryptionCell 53 @implementation EncryptionCell
56 54
57 @synthesize textLabel = _textLabel; 55 @synthesize textLabel = _textLabel;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // Re-layout with the new preferred width to allow the label to adjust its 113 // Re-layout with the new preferred width to allow the label to adjust its
116 // height. 114 // height.
117 [super layoutSubviews]; 115 [super layoutSubviews];
118 116
119 // Restore the real accessory type at the end of the layout. 117 // Restore the real accessory type at the end of the layout.
120 self.accessoryType = realAccessoryType; 118 self.accessoryType = realAccessoryType;
121 } 119 }
122 120
123 - (void)prepareForReuse { 121 - (void)prepareForReuse {
124 [super prepareForReuse]; 122 [super prepareForReuse];
125 self.accessoryType = MDCCollectionViewCellAccessoryNone;
126 self.textLabel.text = nil; 123 self.textLabel.text = nil;
127 [EncryptionCell defaultTextColorForEnabledState:YES]; 124 [EncryptionCell defaultTextColorForEnabledState:YES];
128 } 125 }
129 126
130 #pragma mark - UIAccessibility 127 #pragma mark - UIAccessibility
131 128
132 - (NSString*)accessibilityLabel { 129 - (NSString*)accessibilityLabel {
133 return self.textLabel.text; 130 return self.textLabel.text;
134 } 131 }
135 132
136 @end 133 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/settings/cells/encryption_item.h ('k') | ios/chrome/browser/ui/settings/cells/text_and_error_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698