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

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

Issue 2871993003: Moving the iOS directory to be remoting top level. (Closed)
Patch Set: //remoting/ios was the old landing target for the internal iOS application. Fix. Created 3 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #if !defined(__has_feature) || !__has_feature(objc_arc)
6 #error "This file requires ARC support."
7 #endif
8
9 #import "remoting/client/ios/app/host_collection_view_controller.h"
10
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"
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"
15
16 static NSString* const kReusableIdentifierItem =
17 @"remotingHostCollectionViewControllerItem";
18
19 static CGFloat kHostCollectionViewControllerCellHeight = 70.f;
20 static CGFloat kHostCollectionViewControllerDefaultHeaderHeight = 100.f;
21 static CGFloat kHostCollectionViewControllerSmallHeaderHeight = 60.f;
22 static UIColor* kBackgroundColor =
23 [UIColor colorWithRed:0.f green:0.67f blue:0.55f alpha:1.f];
24
25 @interface HostCollectionViewController () {
26 MDCInkTouchController* _inkTouchController;
27 }
28 @end
29
30 @implementation HostCollectionViewController
31
32 @synthesize delegate = _delegate;
33 @synthesize flexHeaderContainerViewController =
34 _flexHeaderContainerViewController;
35
36 - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout*)layout {
37 self = [super initWithCollectionViewLayout:layout];
38 if (self) {
39 self.collectionView.backgroundColor = [UIColor whiteColor];
40 [self.collectionView registerClass:[HostCollectionViewCell class]
41 forCellWithReuseIdentifier:NSStringFromClass(
42 [HostCollectionViewCell class])];
43 }
44 return self;
45 }
46
47 #pragma mark - UIViewController
48
49 - (void)viewDidLoad {
50 [super viewDidLoad];
51 self.styler.cellStyle = MDCCollectionViewCellStyleCard;
52 self.styler.cellLayoutType = MDCCollectionViewCellLayoutTypeGrid;
53 self.styler.gridPadding = 0;
54 self.styler.gridColumnCount = 1;
55 }
56
57 - (void)viewWillTransitionToSize:(CGSize)size
58 withTransitionCoordinator:
59 (id<UIViewControllerTransitionCoordinator>)coordinator {
60 [self.collectionView.collectionViewLayout invalidateLayout];
61 }
62
63 - (void)viewWillAppear:(BOOL)animated {
64 [super viewWillAppear:animated];
65 [self.collectionView.collectionViewLayout invalidateLayout];
66 }
67
68 #pragma mark - UICollectionViewDataSource
69
70 - (NSInteger)collectionView:(UICollectionView*)collectionView
71 numberOfItemsInSection:(NSInteger)section {
72 return [_delegate getHostCount];
73 }
74
75 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView
76 cellForItemAtIndexPath:(NSIndexPath*)indexPath {
77 HostCollectionViewCell* cell =
78 [collectionView dequeueReusableCellWithReuseIdentifier:
79 NSStringFromClass([HostCollectionViewCell class])
80 forIndexPath:indexPath];
81 HostInfo* host = [_delegate getHostAtIndexPath:indexPath];
82 if (host) {
83 [cell populateContentWithHostInfo:host];
84 }
85 return cell;
86 }
87
88 #pragma mark - UICollectionViewDelegate
89
90 - (void)collectionView:(UICollectionView*)collectionView
91 didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
92 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath];
93 HostCollectionViewCell* cell = (HostCollectionViewCell*)[collectionView
94 cellForItemAtIndexPath:indexPath];
95 [_delegate didSelectCell:cell
96 completion:^{
97 }];
98 }
99
100 #pragma mark - MDCCollectionViewStylingDelegate
101
102 - (CGFloat)collectionView:(UICollectionView*)collectionView
103 cellHeightAtIndexPath:(NSIndexPath*)indexPath {
104 return kHostCollectionViewControllerCellHeight;
105 }
106
107 #pragma mark - UIScrollViewDelegate
108
109 - (void)scrollViewDidScroll:(UIScrollView*)scrollView {
110 [self.flexHeaderContainerViewController.headerViewController
111 scrollViewDidScroll:scrollView];
112 }
113
114 #pragma mark - Private
115
116 - (UIView*)hostsHeaderView {
117 CGRect headerFrame =
118 _flexHeaderContainerViewController.headerViewController.headerView.bounds;
119 UIView* hostsHeaderView = [[UIView alloc] initWithFrame:headerFrame];
120 hostsHeaderView.backgroundColor = kBackgroundColor;
121 hostsHeaderView.layer.masksToBounds = YES;
122 hostsHeaderView.autoresizingMask =
123 (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
124
125 _inkTouchController =
126 [[MDCInkTouchController alloc] initWithView:hostsHeaderView];
127 [_inkTouchController addInkView];
128
129 return hostsHeaderView;
130 }
131
132 - (void)setflexHeaderContainerViewController:
133 (MDCFlexibleHeaderContainerViewController*)
134 flexHeaderContainerViewController {
135 _flexHeaderContainerViewController = flexHeaderContainerViewController;
136 MDCFlexibleHeaderView* headerView =
137 _flexHeaderContainerViewController.headerViewController.headerView;
138 headerView.trackingScrollView = self.collectionView;
139 headerView.maximumHeight = kHostCollectionViewControllerDefaultHeaderHeight;
140 headerView.minimumHeight = kHostCollectionViewControllerSmallHeaderHeight;
141 [headerView addSubview:[self hostsHeaderView]];
142
143 // Use a custom shadow under the flexible header.
144 MDCShadowLayer* shadowLayer = [MDCShadowLayer layer];
145 [headerView setShadowLayer:shadowLayer
146 intensityDidChangeBlock:^(CALayer* layer, CGFloat intensity) {
147 CGFloat elevation = MDCShadowElevationAppBar * intensity;
148 [(MDCShadowLayer*)layer setElevation:elevation];
149 }];
150 }
151
152 @end
OLDNEW
« no previous file with comments | « remoting/client/ios/app/host_collection_view_controller.h ('k') | remoting/client/ios/app/host_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698