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

Side by Side Diff: remoting/ios/app/host_collection_view_controller.mm

Issue 2921413002: [CRD iOS] Finish up the host list UI (Closed)
Patch Set: Added sources to the target. Hopefully it will fix the issue Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #if !defined(__has_feature) || !__has_feature(objc_arc) 5 #if !defined(__has_feature) || !__has_feature(objc_arc)
6 #error "This file requires ARC support." 6 #error "This file requires ARC support."
7 #endif 7 #endif
8 8
9 #import "remoting/ios/app/host_collection_view_controller.h" 9 #import "remoting/ios/app/host_collection_view_controller.h"
10 10
11 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material Ink.h" 11 #import "ios/third_party/material_components_ios/src/components/Ink/src/Material Ink.h"
12 #import "ios/third_party/material_components_ios/src/components/NavigationBar/sr c/MaterialNavigationBar.h" 12 #import "ios/third_party/material_components_ios/src/components/NavigationBar/sr c/MaterialNavigationBar.h"
13 #import "ios/third_party/material_components_ios/src/components/ShadowElevations /src/MaterialShadowElevations.h" 13 #import "ios/third_party/material_components_ios/src/components/ShadowElevations /src/MaterialShadowElevations.h"
14 #import "ios/third_party/material_components_ios/src/components/ShadowLayer/src/ MaterialShadowLayer.h" 14 #import "ios/third_party/material_components_ios/src/components/ShadowLayer/src/ MaterialShadowLayer.h"
15 #import "remoting/ios/app/host_collection_header_view.h"
15 16
16 static NSString* const kReusableIdentifierItem = 17 static NSString* const kReusableIdentifierItem =
17 @"remotingHostCollectionViewControllerItem"; 18 @"remotingHostCollectionViewControllerItem";
18 19
19 static CGFloat kHostCollectionViewControllerCellHeight = 70.f; 20 static CGFloat kHostCollectionViewControllerCellHeight = 70.f;
21 static CGFloat kHostCollectionHeaderViewHeight = 25.f;
20 22
21 @implementation HostCollectionViewController 23 @implementation HostCollectionViewController
22 24
23 @synthesize delegate = _delegate; 25 @synthesize delegate = _delegate;
24 @synthesize flexHeaderContainerViewController = 26 @synthesize flexHeaderContainerViewController =
25 _flexHeaderContainerViewController; 27 _flexHeaderContainerViewController;
26 28
27 - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout*)layout { 29 - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout*)layout {
28 self = [super initWithCollectionViewLayout:layout]; 30 self = [super initWithCollectionViewLayout:layout];
29 if (self) { 31 if (self) {
30 self.collectionView.backgroundColor = [UIColor clearColor]; 32 self.collectionView.backgroundColor = [UIColor clearColor];
31 [self.collectionView registerClass:[HostCollectionViewCell class] 33 [self.collectionView registerClass:[HostCollectionViewCell class]
32 forCellWithReuseIdentifier:NSStringFromClass( 34 forCellWithReuseIdentifier:NSStringFromClass(
33 [HostCollectionViewCell class])]; 35 [HostCollectionViewCell class])];
36
37 [self.collectionView registerClass:[HostCollectionHeaderView class]
38 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
39 withReuseIdentifier:UICollectionElementKindSectionHeader];
34 } 40 }
35 return self; 41 return self;
36 } 42 }
37 43
38 #pragma mark - UIViewController 44 #pragma mark - UIViewController
39 45
40 - (void)viewDidLoad { 46 - (void)viewDidLoad {
41 [super viewDidLoad]; 47 [super viewDidLoad];
42 self.styler.cellStyle = MDCCollectionViewCellStyleGrouped; 48 self.styler.cellStyle = MDCCollectionViewCellStyleDefault;
43 self.styler.cellLayoutType = MDCCollectionViewCellLayoutTypeList; 49 self.styler.cellLayoutType = MDCCollectionViewCellLayoutTypeList;
44 } 50 }
45 51
46 - (void)viewWillTransitionToSize:(CGSize)size 52 - (void)viewWillTransitionToSize:(CGSize)size
47 withTransitionCoordinator: 53 withTransitionCoordinator:
48 (id<UIViewControllerTransitionCoordinator>)coordinator { 54 (id<UIViewControllerTransitionCoordinator>)coordinator {
49 [self.collectionView.collectionViewLayout invalidateLayout]; 55 [self.collectionView.collectionViewLayout invalidateLayout];
50 } 56 }
51 57
52 - (void)viewWillAppear:(BOOL)animated { 58 - (void)viewWillAppear:(BOOL)animated {
(...skipping 14 matching lines...) Expand all
67 [collectionView dequeueReusableCellWithReuseIdentifier: 73 [collectionView dequeueReusableCellWithReuseIdentifier:
68 NSStringFromClass([HostCollectionViewCell class]) 74 NSStringFromClass([HostCollectionViewCell class])
69 forIndexPath:indexPath]; 75 forIndexPath:indexPath];
70 HostInfo* host = [_delegate getHostAtIndexPath:indexPath]; 76 HostInfo* host = [_delegate getHostAtIndexPath:indexPath];
71 if (host) { 77 if (host) {
72 [cell populateContentWithHostInfo:host]; 78 [cell populateContentWithHostInfo:host];
73 } 79 }
74 return cell; 80 return cell;
75 } 81 }
76 82
83 - (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView
84 viewForSupplementaryElementOfKind:(NSString*)kind
85 atIndexPath:(NSIndexPath*)indexPath {
86 HostCollectionHeaderView* supplementaryView =
87 [collectionView dequeueReusableSupplementaryViewOfKind:kind
88 withReuseIdentifier:kind
89 forIndexPath:indexPath];
90 if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
91 supplementaryView.text = @"Remote devices";
92 }
93 return supplementaryView;
94 }
95
77 #pragma mark - UICollectionViewDelegate 96 #pragma mark - UICollectionViewDelegate
78 97
79 - (void)collectionView:(UICollectionView*)collectionView 98 - (void)collectionView:(UICollectionView*)collectionView
80 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { 99 didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
81 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; 100 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath];
82 HostCollectionViewCell* cell = (HostCollectionViewCell*)[collectionView 101 HostCollectionViewCell* cell = (HostCollectionViewCell*)[collectionView
83 cellForItemAtIndexPath:indexPath]; 102 cellForItemAtIndexPath:indexPath];
84 [_delegate didSelectCell:cell 103 [_delegate didSelectCell:cell
85 completion:^{ 104 completion:^{
86 }]; 105 }];
87 } 106 }
88 107
89 #pragma mark - MDCCollectionViewStylingDelegate 108 #pragma mark - MDCCollectionViewStylingDelegate
90 109
91 - (CGFloat)collectionView:(UICollectionView*)collectionView 110 - (CGFloat)collectionView:(UICollectionView*)collectionView
92 cellHeightAtIndexPath:(NSIndexPath*)indexPath { 111 cellHeightAtIndexPath:(NSIndexPath*)indexPath {
93 return kHostCollectionViewControllerCellHeight; 112 return kHostCollectionViewControllerCellHeight;
94 } 113 }
95 114
96 #pragma mark - UIScrollViewDelegate 115 #pragma mark - UIScrollViewDelegate
97 116
98 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { 117 - (void)scrollViewDidScroll:(UIScrollView*)scrollView {
99 [self.flexHeaderContainerViewController.headerViewController 118 [self.flexHeaderContainerViewController.headerViewController
100 scrollViewDidScroll:scrollView]; 119 scrollViewDidScroll:scrollView];
101 } 120 }
102 121
122 #pragma mark - UICollectionViewDelegateFlowLayout
123
124 - (CGSize)collectionView:(UICollectionView*)collectionView
125 layout:
126 (UICollectionViewLayout*)collectionViewLayout
127 referenceSizeForHeaderInSection:(NSInteger)section {
128 return CGSizeMake(collectionView.bounds.size.width,
129 kHostCollectionHeaderViewHeight);
130 }
131
103 #pragma mark - Private 132 #pragma mark - Private
104 133
105 - (void)setFlexHeaderContainerViewController: 134 - (void)setFlexHeaderContainerViewController:
106 (MDCFlexibleHeaderContainerViewController*) 135 (MDCFlexibleHeaderContainerViewController*)
107 flexHeaderContainerViewController { 136 flexHeaderContainerViewController {
108 _flexHeaderContainerViewController = flexHeaderContainerViewController; 137 _flexHeaderContainerViewController = flexHeaderContainerViewController;
109 MDCFlexibleHeaderView* headerView = 138 MDCFlexibleHeaderView* headerView =
110 _flexHeaderContainerViewController.headerViewController.headerView; 139 _flexHeaderContainerViewController.headerViewController.headerView;
111 headerView.trackingScrollView = self.collectionView; 140 headerView.trackingScrollView = self.collectionView;
112 headerView.backgroundColor = [UIColor clearColor]; 141 headerView.backgroundColor = [UIColor clearColor];
113 142
114 // Use a custom shadow under the flexible header. 143 // Use a custom shadow under the flexible header.
115 MDCShadowLayer* shadowLayer = [MDCShadowLayer layer]; 144 MDCShadowLayer* shadowLayer = [MDCShadowLayer layer];
116 [headerView setShadowLayer:shadowLayer 145 [headerView setShadowLayer:shadowLayer
117 intensityDidChangeBlock:^(CALayer* layer, CGFloat intensity) { 146 intensityDidChangeBlock:^(CALayer* layer, CGFloat intensity) {
118 CGFloat elevation = MDCShadowElevationAppBar * intensity; 147 CGFloat elevation = MDCShadowElevationAppBar * intensity;
119 [(MDCShadowLayer*)layer setElevation:elevation]; 148 [(MDCShadowLayer*)layer setElevation:elevation];
120 }]; 149 }];
121 } 150 }
122 151
123 @end 152 @end
OLDNEW
« no previous file with comments | « remoting/ios/app/host_collection_header_view.mm ('k') | remoting/ios/app/remoting_view_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698