OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/tab_switcher/tab_switcher_panel_view.h" | 5 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_view.h" |
6 | 6 |
7 #import "base/mac/scoped_nsobject.h" | |
8 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" | 7 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_cell.h" |
9 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_collection_view_l
ayout.h" | 8 #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_panel_collection_view_l
ayout.h" |
10 | 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 11 #error "This file requires ARC support." |
| 12 #endif |
| 13 |
11 @interface TabSwitcherPanelView () { | 14 @interface TabSwitcherPanelView () { |
12 base::scoped_nsobject<UICollectionView> _collectionView; | 15 UICollectionView* _collectionView; |
13 base::scoped_nsobject<TabSwitcherPanelCollectionViewLayout> | 16 TabSwitcherPanelCollectionViewLayout* _collectionViewLayout; |
14 _collectionViewLayout; | |
15 TabSwitcherSessionType _sessionType; | 17 TabSwitcherSessionType _sessionType; |
16 } | 18 } |
17 | 19 |
18 @end | 20 @end |
19 | 21 |
20 @implementation TabSwitcherPanelView | 22 @implementation TabSwitcherPanelView |
21 | 23 |
22 - (instancetype)initWithSessionType:(TabSwitcherSessionType)sessionType { | 24 - (instancetype)initWithSessionType:(TabSwitcherSessionType)sessionType { |
23 self = [super initWithFrame:CGRectZero]; | 25 self = [super initWithFrame:CGRectZero]; |
24 if (self) { | 26 if (self) { |
(...skipping 25 matching lines...) Expand all Loading... |
50 }]; | 52 }]; |
51 } | 53 } |
52 | 54 |
53 - (CGSize)cellSize { | 55 - (CGSize)cellSize { |
54 return [_collectionViewLayout itemSize]; | 56 return [_collectionViewLayout itemSize]; |
55 } | 57 } |
56 | 58 |
57 #pragma mark - Private | 59 #pragma mark - Private |
58 | 60 |
59 - (void)loadSubviews { | 61 - (void)loadSubviews { |
60 _collectionViewLayout.reset( | 62 _collectionViewLayout = [[TabSwitcherPanelCollectionViewLayout alloc] init]; |
61 [[TabSwitcherPanelCollectionViewLayout alloc] init]); | 63 _collectionView = |
62 _collectionView.reset([[UICollectionView alloc] | 64 [[UICollectionView alloc] initWithFrame:self.bounds |
63 initWithFrame:self.bounds | 65 collectionViewLayout:_collectionViewLayout]; |
64 collectionViewLayout:_collectionViewLayout.get()]); | |
65 if (_sessionType == TabSwitcherSessionType::DISTANT_SESSION) { | 66 if (_sessionType == TabSwitcherSessionType::DISTANT_SESSION) { |
66 [_collectionView registerClass:[TabSwitcherDistantSessionCell class] | 67 [_collectionView registerClass:[TabSwitcherDistantSessionCell class] |
67 forCellWithReuseIdentifier:[TabSwitcherDistantSessionCell identifier]]; | 68 forCellWithReuseIdentifier:[TabSwitcherDistantSessionCell identifier]]; |
68 } else { | 69 } else { |
69 [_collectionView registerClass:[TabSwitcherLocalSessionCell class] | 70 [_collectionView registerClass:[TabSwitcherLocalSessionCell class] |
70 forCellWithReuseIdentifier:[TabSwitcherLocalSessionCell identifier]]; | 71 forCellWithReuseIdentifier:[TabSwitcherLocalSessionCell identifier]]; |
71 } | 72 } |
72 [_collectionView setBackgroundColor:[UIColor clearColor]]; | 73 [_collectionView setBackgroundColor:[UIColor clearColor]]; |
73 [self addSubview:_collectionView]; | 74 [self addSubview:_collectionView]; |
74 [_collectionView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | | 75 [_collectionView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | |
75 UIViewAutoresizingFlexibleWidth]; | 76 UIViewAutoresizingFlexibleWidth]; |
76 } | 77 } |
77 | 78 |
78 @end | 79 @end |
OLD | NEW |