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_item.h" | 5 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" |
6 | 6 |
7 #import "base/logging.h" | 7 #import "base/logging.h" |
8 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item+Privat e.h" | |
8 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h" | 9 #import "ios/third_party/material_components_ios/src/components/CollectionCells/ src/MaterialCollectionCells.h" |
9 | 10 |
10 #if !defined(__has_feature) || !__has_feature(objc_arc) | 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
11 #error "This file requires ARC support." | 12 #error "This file requires ARC support." |
12 #endif | 13 #endif |
13 | 14 |
14 @implementation CollectionViewItem | 15 @implementation CollectionViewItem |
15 | 16 |
16 @synthesize type = _type; | 17 @synthesize type = _type; |
17 @synthesize cellClass = _cellClass; | 18 @synthesize cellClass = _cellClass; |
18 @synthesize accessibilityIdentifier = _accessibilityIdentifier; | 19 @synthesize accessibilityIdentifier = _accessibilityIdentifier; |
19 | 20 |
20 - (instancetype)initWithType:(NSInteger)type { | 21 - (instancetype)initWithType:(NSInteger)type { |
21 if ((self = [super init])) { | 22 if ((self = [super init])) { |
22 _type = type; | 23 _type = type; |
23 _cellClass = [MDCCollectionViewCell class]; | 24 _cellClass = [MDCCollectionViewCell class]; |
24 } | 25 } |
25 return self; | 26 return self; |
26 } | 27 } |
27 | 28 |
28 - (instancetype)init { | 29 - (instancetype)init { |
29 NOTREACHED(); | 30 return [self initWithType:0]; |
30 return nil; | |
31 } | 31 } |
32 | 32 |
33 - (void)setCellClass:(Class)cellClass { | 33 - (void)setCellClass:(Class)cellClass { |
34 DCHECK([cellClass isSubclassOfClass:[MDCCollectionViewCell class]]); | 34 DCHECK([cellClass isSubclassOfClass:[MDCCollectionViewCell class]]); |
35 _cellClass = cellClass; | 35 _cellClass = cellClass; |
36 } | 36 } |
37 | 37 |
38 - (void)configureCell:(MDCCollectionViewCell*)cell { | 38 - (void)configureCell:(MDCCollectionViewCell*)cell { |
39 DCHECK([cell class] == self.cellClass); | 39 DCHECK([cell class] == self.cellClass); |
40 cell.accessibilityTraits = self.accessibilityTraits; | 40 cell.accessibilityTraits = self.accessibilityTraits; |
41 cell.accessibilityIdentifier = self.accessibilityIdentifier; | 41 cell.accessibilityIdentifier = self.accessibilityIdentifier; |
42 } | 42 } |
43 | 43 |
44 @end | 44 @end |
45 | |
46 @implementation CollectionViewItem (Private) | |
47 | |
48 - (void)setType:(NSInteger)type { | |
49 _type = type; | |
lpromero
2017/04/13 21:42:59
DCHECK type >= kItemTypeEnumStart.
Moe
2017/04/14 02:55:38
This would create a dependency cycle:
//i/c/b/u/co
lpromero
2017/04/14 11:37:11
Acknowledged.
| |
50 } | |
51 | |
52 @end | |
OLD | NEW |