Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #import "remoting/ios/app/host_collection_header_view.h" |
| 16 | 16 |
| 17 static NSString* const kReusableIdentifierItem = | 17 static NSString* const kReusableIdentifierItem = |
| 18 @"remotingHostCollectionViewControllerItem"; | 18 @"remotingHostCollectionViewControllerItem"; |
| 19 | 19 |
| 20 static CGFloat kHostCollectionViewControllerCellHeight = 70.f; | 20 static CGFloat kHostCollectionViewControllerCellHeight = 70.f; |
| 21 static CGFloat kHostCollectionHeaderViewHeight = 25.f; | 21 static CGFloat kHostCollectionHeaderViewHeight = 25.f; |
| 22 | 22 |
| 23 @implementation HostCollectionViewController | 23 @implementation HostCollectionViewController |
| 24 | 24 |
| 25 @synthesize delegate = _delegate; | 25 @synthesize delegate = _delegate; |
| 26 @synthesize flexHeaderContainerViewController = | 26 @synthesize scrollViewDelegate = _scrollViewDelegate; |
| 27 _flexHeaderContainerViewController; | |
| 28 | 27 |
| 29 - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout*)layout { | 28 - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout*)layout { |
| 30 self = [super initWithCollectionViewLayout:layout]; | 29 self = [super initWithCollectionViewLayout:layout]; |
| 31 if (self) { | 30 if (self) { |
| 32 self.collectionView.backgroundColor = [UIColor clearColor]; | 31 self.collectionView.backgroundColor = [UIColor clearColor]; |
| 33 [self.collectionView registerClass:[HostCollectionViewCell class] | 32 [self.collectionView registerClass:[HostCollectionViewCell class] |
| 34 forCellWithReuseIdentifier:NSStringFromClass( | 33 forCellWithReuseIdentifier:NSStringFromClass( |
| 35 [HostCollectionViewCell class])]; | 34 [HostCollectionViewCell class])]; |
| 36 | 35 |
| 37 [self.collectionView registerClass:[HostCollectionHeaderView class] | 36 [self.collectionView registerClass:[HostCollectionHeaderView class] |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 #pragma mark - MDCCollectionViewStylingDelegate | 107 #pragma mark - MDCCollectionViewStylingDelegate |
| 109 | 108 |
| 110 - (CGFloat)collectionView:(UICollectionView*)collectionView | 109 - (CGFloat)collectionView:(UICollectionView*)collectionView |
| 111 cellHeightAtIndexPath:(NSIndexPath*)indexPath { | 110 cellHeightAtIndexPath:(NSIndexPath*)indexPath { |
| 112 return kHostCollectionViewControllerCellHeight; | 111 return kHostCollectionViewControllerCellHeight; |
| 113 } | 112 } |
| 114 | 113 |
| 115 #pragma mark - UIScrollViewDelegate | 114 #pragma mark - UIScrollViewDelegate |
| 116 | 115 |
| 117 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { | 116 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { |
| 118 [self.flexHeaderContainerViewController.headerViewController | 117 [_scrollViewDelegate scrollViewDidScroll:scrollView]; |
| 119 scrollViewDidScroll:scrollView]; | |
| 120 } | 118 } |
| 121 | 119 |
| 122 #pragma mark - UICollectionViewDelegateFlowLayout | 120 #pragma mark - UICollectionViewDelegateFlowLayout |
| 123 | 121 |
| 124 - (CGSize)collectionView:(UICollectionView*)collectionView | 122 - (CGSize)collectionView:(UICollectionView*)collectionView |
| 125 layout: | 123 layout: |
| 126 (UICollectionViewLayout*)collectionViewLayout | 124 (UICollectionViewLayout*)collectionViewLayout |
| 127 referenceSizeForHeaderInSection:(NSInteger)section { | 125 referenceSizeForHeaderInSection:(NSInteger)section { |
| 128 return CGSizeMake(collectionView.bounds.size.width, | 126 return CGSizeMake(collectionView.bounds.size.width, |
| 129 kHostCollectionHeaderViewHeight); | 127 kHostCollectionHeaderViewHeight); |
| 130 } | 128 } |
| 131 | 129 |
| 132 #pragma mark - Private | |
| 133 | |
| 134 - (void)setFlexHeaderContainerViewController: | |
| 135 (MDCFlexibleHeaderContainerViewController*) | |
| 136 flexHeaderContainerViewController { | |
| 137 _flexHeaderContainerViewController = flexHeaderContainerViewController; | |
| 138 MDCFlexibleHeaderView* headerView = | |
| 139 _flexHeaderContainerViewController.headerViewController.headerView; | |
| 140 headerView.trackingScrollView = self.collectionView; | |
| 141 headerView.backgroundColor = [UIColor clearColor]; | |
| 142 | |
| 143 // Use a custom shadow under the flexible header. | |
| 144 MDCShadowLayer* shadowLayer = [MDCShadowLayer layer]; | |
|
Yuwei
2017/06/26 23:31:13
This logic has been moved to RemotingViewControlle
| |
| 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 | 130 @end |
| OLD | NEW |