Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/ios/app/host_setup_view_controller.h" | |
| 10 | |
| 11 #import "ios/third_party/material_components_ios/src/components/ShadowElevations /src/MaterialShadowElevations.h" | |
| 12 #import "ios/third_party/material_components_ios/src/components/ShadowLayer/src/ MaterialShadowLayer.h" | |
| 13 #import "remoting/ios/app/host_setup_footer_view.h" | |
| 14 #import "remoting/ios/app/host_setup_header_view.h" | |
| 15 #import "remoting/ios/app/host_setup_view_cell.h" | |
| 16 #import "remoting/ios/app/remoting_theme.h" | |
| 17 | |
| 18 static NSString* const kReusableIdentifierItem = @"remotingSetupStepVCItem"; | |
| 19 | |
| 20 // TODO(yuweih): i18n | |
| 21 // Clang doesn't allow string literal concatenation in string array but | |
| 22 // `git cl format` will break down long lines into multiple string literals. | |
| 23 // This is to disable the warning until we move these to a better place. | |
| 24 #pragma clang diagnostic push | |
| 25 #pragma clang diagnostic ignored "-Wobjc-string-concatenation" | |
| 26 static NSArray<NSString*>* const kSetupSteps = @[ | |
| 27 // 1. | |
| 28 @"Go to the computer that you want to remotely access", | |
| 29 | |
| 30 // 2. | |
| 31 @"Visit google.com/remotedesktop from your Chrome browser", | |
| 32 | |
| 33 // 3. | |
| 34 @"Install the Chrome Remote Desktop software and follow the instructions to " | |
| 35 @"complete the setup", | |
|
nicholss
2017/06/27 16:36:02
you do not need to add the extra @ to the second l
Yuwei
2017/06/27 20:46:45
Done. Didn't know that you can drop the second @..
| |
| 36 | |
| 37 // 4. | |
| 38 @"After your remote device is setup, you can access it directly from this " | |
| 39 @"page", | |
| 40 ]; | |
| 41 #pragma clang diagnostic pop | |
| 42 | |
| 43 static const CGFloat kHeaderHeight = 80.f; | |
| 44 static const CGFloat kFooterHeight = 80.f; | |
| 45 | |
| 46 @implementation HostSetupViewController | |
| 47 | |
| 48 @synthesize scrollViewDelegate = _scrollViewDelegate; | |
| 49 | |
| 50 - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout*)layout { | |
| 51 self = [super initWithCollectionViewLayout:layout]; | |
| 52 if (self) { | |
| 53 self.collectionView.backgroundColor = UIColor.clearColor; | |
| 54 [self.collectionView registerClass:[HostSetupViewCell class] | |
| 55 forCellWithReuseIdentifier:kReusableIdentifierItem]; | |
| 56 | |
| 57 [self.collectionView registerClass:[HostSetupHeaderView class] | |
| 58 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader | |
| 59 withReuseIdentifier:UICollectionElementKindSectionHeader]; | |
| 60 | |
| 61 [self.collectionView registerClass:[HostSetupFooterView class] | |
| 62 forSupplementaryViewOfKind:UICollectionElementKindSectionFooter | |
| 63 withReuseIdentifier:UICollectionElementKindSectionFooter]; | |
| 64 } | |
| 65 return self; | |
| 66 } | |
| 67 | |
| 68 #pragma mark - UIViewController | |
| 69 | |
| 70 - (void)viewDidLoad { | |
| 71 [super viewDidLoad]; | |
| 72 self.styler.cellStyle = MDCCollectionViewCellStyleGrouped; | |
| 73 self.styler.cellLayoutType = MDCCollectionViewCellLayoutTypeList; | |
| 74 self.styler.shouldHideSeparators = YES; | |
| 75 } | |
| 76 | |
| 77 #pragma mark - UICollectionViewDataSource | |
| 78 | |
| 79 - (NSInteger)collectionView:(UICollectionView*)collectionView | |
| 80 numberOfItemsInSection:(NSInteger)section { | |
| 81 return kSetupSteps.count; | |
| 82 } | |
| 83 | |
| 84 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView | |
| 85 cellForItemAtIndexPath:(NSIndexPath*)indexPath { | |
| 86 HostSetupViewCell* cell = [collectionView | |
| 87 dequeueReusableCellWithReuseIdentifier:kReusableIdentifierItem | |
| 88 forIndexPath:indexPath]; | |
| 89 [cell setContentText:kSetupSteps[indexPath.item] number:indexPath.item + 1]; | |
| 90 return cell; | |
| 91 } | |
| 92 | |
| 93 - (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView | |
| 94 viewForSupplementaryElementOfKind:(NSString*)kind | |
| 95 atIndexPath:(NSIndexPath*)indexPath { | |
| 96 return [collectionView dequeueReusableSupplementaryViewOfKind:kind | |
| 97 withReuseIdentifier:kind | |
| 98 forIndexPath:indexPath]; | |
| 99 } | |
| 100 | |
| 101 #pragma mark - MDCCollectionViewStylingDelegate | |
| 102 | |
| 103 - (CGFloat)collectionView:(UICollectionView*)collectionView | |
| 104 cellHeightAtIndexPath:(NSIndexPath*)indexPath { | |
| 105 return MDCCellDefaultThreeLineHeight; | |
| 106 } | |
| 107 | |
| 108 #pragma mark - UICollectionViewDelegateFlowLayout | |
| 109 | |
| 110 - (CGSize)collectionView:(UICollectionView*)collectionView | |
| 111 layout: | |
| 112 (UICollectionViewLayout*)collectionViewLayout | |
| 113 referenceSizeForHeaderInSection:(NSInteger)section { | |
| 114 return CGSizeMake(collectionView.bounds.size.width, kHeaderHeight); | |
| 115 } | |
| 116 | |
| 117 - (CGSize)collectionView:(UICollectionView*)collectionView | |
| 118 layout: | |
| 119 (UICollectionViewLayout*)collectionViewLayout | |
| 120 referenceSizeForFooterInSection:(NSInteger)section { | |
| 121 return CGSizeMake(collectionView.bounds.size.width, kFooterHeight); | |
| 122 } | |
| 123 | |
| 124 #pragma mark - UIScrollViewDelegate | |
| 125 | |
| 126 - (void)scrollViewDidScroll:(UIScrollView*)scrollView { | |
| 127 [_scrollViewDelegate scrollViewDidScroll:scrollView]; | |
| 128 } | |
| 129 | |
| 130 @end | |
| OLD | NEW |