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

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

Issue 2957943002: [CRD iOS] Add the host setup instruction page (Closed)
Patch Set: Resolve Feedback Created 3 years, 5 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
« no previous file with comments | « remoting/ios/app/host_setup_view_controller.h ('k') | remoting/ios/app/remoting_theme.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 @"Go to the computer that you want to remotely access",
28 @"Visit google.com/remotedesktop from your Chrome browser",
29 @"Install the Chrome Remote Desktop software and follow the instructions to "
30 "complete the setup",
31 @"After your remote device is setup, you can access it directly from this "
32 "page",
33 ];
34 #pragma clang diagnostic pop
35
36 static const CGFloat kHeaderHeight = 80.f;
37 static const CGFloat kFooterHeight = 80.f;
38
39 @implementation HostSetupViewController
40
41 @synthesize scrollViewDelegate = _scrollViewDelegate;
42
43 - (instancetype)initWithCollectionViewLayout:(UICollectionViewLayout*)layout {
44 self = [super initWithCollectionViewLayout:layout];
45 if (self) {
46 self.collectionView.backgroundColor = UIColor.clearColor;
47 [self.collectionView registerClass:[HostSetupViewCell class]
48 forCellWithReuseIdentifier:kReusableIdentifierItem];
49
50 [self.collectionView registerClass:[HostSetupHeaderView class]
51 forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
52 withReuseIdentifier:UICollectionElementKindSectionHeader];
53
54 [self.collectionView registerClass:[HostSetupFooterView class]
55 forSupplementaryViewOfKind:UICollectionElementKindSectionFooter
56 withReuseIdentifier:UICollectionElementKindSectionFooter];
57 }
58 return self;
59 }
60
61 #pragma mark - UIViewController
62
63 - (void)viewDidLoad {
64 [super viewDidLoad];
65 self.styler.cellStyle = MDCCollectionViewCellStyleGrouped;
66 self.styler.cellLayoutType = MDCCollectionViewCellLayoutTypeList;
67 self.styler.shouldHideSeparators = YES;
68 }
69
70 #pragma mark - UICollectionViewDataSource
71
72 - (NSInteger)collectionView:(UICollectionView*)collectionView
73 numberOfItemsInSection:(NSInteger)section {
74 return kSetupSteps.count;
75 }
76
77 - (UICollectionViewCell*)collectionView:(UICollectionView*)collectionView
78 cellForItemAtIndexPath:(NSIndexPath*)indexPath {
79 HostSetupViewCell* cell = [collectionView
80 dequeueReusableCellWithReuseIdentifier:kReusableIdentifierItem
81 forIndexPath:indexPath];
82 [cell setContentText:kSetupSteps[indexPath.item] number:indexPath.item + 1];
83 return cell;
84 }
85
86 - (UICollectionReusableView*)collectionView:(UICollectionView*)collectionView
87 viewForSupplementaryElementOfKind:(NSString*)kind
88 atIndexPath:(NSIndexPath*)indexPath {
89 return [collectionView dequeueReusableSupplementaryViewOfKind:kind
90 withReuseIdentifier:kind
91 forIndexPath:indexPath];
92 }
93
94 #pragma mark - MDCCollectionViewStylingDelegate
95
96 - (CGFloat)collectionView:(UICollectionView*)collectionView
97 cellHeightAtIndexPath:(NSIndexPath*)indexPath {
98 return MDCCellDefaultThreeLineHeight;
99 }
100
101 #pragma mark - UICollectionViewDelegateFlowLayout
102
103 - (CGSize)collectionView:(UICollectionView*)collectionView
104 layout:
105 (UICollectionViewLayout*)collectionViewLayout
106 referenceSizeForHeaderInSection:(NSInteger)section {
107 return CGSizeMake(collectionView.bounds.size.width, kHeaderHeight);
108 }
109
110 - (CGSize)collectionView:(UICollectionView*)collectionView
111 layout:
112 (UICollectionViewLayout*)collectionViewLayout
113 referenceSizeForFooterInSection:(NSInteger)section {
114 return CGSizeMake(collectionView.bounds.size.width, kFooterHeight);
115 }
116
117 #pragma mark - UIScrollViewDelegate
118
119 - (void)scrollViewDidScroll:(UIScrollView*)scrollView {
120 [_scrollViewDelegate scrollViewDidScroll:scrollView];
121 }
122
123 @end
OLDNEW
« no previous file with comments | « remoting/ios/app/host_setup_view_controller.h ('k') | remoting/ios/app/remoting_theme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698