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

Side by Side Diff: ios/chrome/browser/ui/authentication/account_control_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/authentication/account_control_item.h" 5 #import "ios/chrome/browser/ui/authentication/account_control_item.h"
6 6
7 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" 7 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
8 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 8 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
9 9
10 #if !defined(__has_feature) || !__has_feature(objc_arc) 10 #if !defined(__has_feature) || !__has_feature(objc_arc)
(...skipping 12 matching lines...) Expand all
23 23
24 // Padding between top label and detail label. 24 // Padding between top label and detail label.
25 const CGFloat kVerticalPaddingBetweenLabelAndDetailLabel = 8; 25 const CGFloat kVerticalPaddingBetweenLabelAndDetailLabel = 8;
26 } // namespace 26 } // namespace
27 27
28 @implementation AccountControlItem 28 @implementation AccountControlItem
29 29
30 @synthesize image = _image; 30 @synthesize image = _image;
31 @synthesize text = _text; 31 @synthesize text = _text;
32 @synthesize detailText = _detailText; 32 @synthesize detailText = _detailText;
33 @synthesize accessoryType = _accessoryType;
34 @synthesize shouldDisplayError = _shouldDisplayError; 33 @synthesize shouldDisplayError = _shouldDisplayError;
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 = [AccountControlCell class]; 38 self.cellClass = [AccountControlCell class];
40 self.accessibilityTraits |= UIAccessibilityTraitButton; 39 self.accessibilityTraits |= UIAccessibilityTraitButton;
41 } 40 }
42 return self; 41 return self;
43 } 42 }
44 43
45 #pragma mark - CollectionViewItem 44 #pragma mark - CollectionViewItem
46 45
47 - (void)configureCell:(AccountControlCell*)cell { 46 - (void)configureCell:(AccountControlCell*)cell {
48 [super configureCell:cell]; 47 [super configureCell:cell];
49 cell.imageView.image = self.image; 48 cell.imageView.image = self.image;
50 cell.accessoryType = self.accessoryType;
51 49
52 cell.textLabel.attributedText = 50 cell.textLabel.attributedText =
53 [self attributedStringForText:self.text 51 [self attributedStringForText:self.text
54 font:[MDCTypography body2Font] 52 font:[MDCTypography body2Font]
55 color:[[MDCPalette greyPalette] tint900]]; 53 color:[[MDCPalette greyPalette] tint900]];
56 54
57 UIColor* detailTextColor = [[MDCPalette greyPalette] tint700]; 55 UIColor* detailTextColor = [[MDCPalette greyPalette] tint700];
58 if (self.shouldDisplayError) { 56 if (self.shouldDisplayError) {
59 detailTextColor = [[MDCPalette cr_redPalette] tint700]; 57 detailTextColor = [[MDCPalette cr_redPalette] tint700];
60 } 58 }
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 [super layoutSubviews]; 193 [super layoutSubviews];
196 } 194 }
197 195
198 #pragma mark - UICollectionReusableView 196 #pragma mark - UICollectionReusableView
199 197
200 - (void)prepareForReuse { 198 - (void)prepareForReuse {
201 [super prepareForReuse]; 199 [super prepareForReuse];
202 self.imageView.image = nil; 200 self.imageView.image = nil;
203 self.textLabel.text = nil; 201 self.textLabel.text = nil;
204 self.detailTextLabel.text = nil; 202 self.detailTextLabel.text = nil;
205 self.accessoryType = MDCCollectionViewCellAccessoryNone;
206 self.detailTextLabel.textColor = [[MDCPalette greyPalette] tint700]; 203 self.detailTextLabel.textColor = [[MDCPalette greyPalette] tint700];
207 } 204 }
208 205
209 #pragma mark - NSObject(Accessibility) 206 #pragma mark - NSObject(Accessibility)
210 207
211 - (NSString*)accessibilityLabel { 208 - (NSString*)accessibilityLabel {
212 return [NSString stringWithFormat:@"%@, %@", self.textLabel.text, 209 return [NSString stringWithFormat:@"%@, %@", self.textLabel.text,
213 self.detailTextLabel.text]; 210 self.detailTextLabel.text];
214 } 211 }
215 212
216 @end 213 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698