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

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

Issue 2828113002: Provide HostView with data required for creating a new and session, and render for CRD iOS. (Closed)
Patch Set: fixing issue based on feedback. Created 3 years, 8 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 <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 10
11 #import "remoting/client/ios/app/host_collection_view_cell.h" 11 #import "remoting/client/ios/app/host_collection_view_cell.h"
12 12
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 "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 15 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
16 #import "remoting/client/ios/domain/host_info.h"
16 17
17 static const CGFloat kLinePadding = 2.f; 18 static const CGFloat kLinePadding = 2.f;
18 static const CGFloat kHostCardIconInset = 10.f; 19 static const CGFloat kHostCardIconInset = 10.f;
19 static const CGFloat kHostCardPadding = 4.f; 20 static const CGFloat kHostCardPadding = 4.f;
20 static const CGFloat kHostCardIconSize = 45.f; 21 static const CGFloat kHostCardIconSize = 45.f;
21 22
22 @interface HostCollectionViewCell () { 23 @interface HostCollectionViewCell () {
23 NSString* _status;
24 NSString* _title;
25 UIImageView* _imageView; 24 UIImageView* _imageView;
26 UILabel* _statusLabel; 25 UILabel* _statusLabel;
27 UILabel* _titleLabel; 26 UILabel* _titleLabel;
28 UIView* _cellView; 27 UIView* _cellView;
29 } 28 }
30 @end 29 @end
31 30
32 // 31 //
33 // This is the implementation of the info card for a host's status shown in 32 // This is the implementation of the info card for a host's status shown in
34 // the host list. This will also be the selection for which host to connect 33 // the host list. This will also be the selection for which host to connect
35 // to and other managements actions for a host in this list. 34 // to and other managements actions for a host in this list.
36 // 35 //
37 @implementation HostCollectionViewCell 36 @implementation HostCollectionViewCell
38 37
38 @synthesize hostInfo = _hostInfo;
39
39 + (Class)layerClass { 40 + (Class)layerClass {
40 return [MDCShadowLayer class]; 41 return [MDCShadowLayer class];
41 } 42 }
42 43
43 - (id)initWithFrame:(CGRect)frame { 44 - (id)initWithFrame:(CGRect)frame {
44 self = [super initWithFrame:frame]; 45 self = [super initWithFrame:frame];
45 if (self) { 46 if (self) {
46 self.backgroundColor = [UIColor clearColor]; 47 self.backgroundColor = [UIColor clearColor];
47 [self commonInit]; 48 [self commonInit];
48 } 49 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 _statusLabel.textColor = [UIColor colorWithWhite:0 alpha:0.60f]; 91 _statusLabel.textColor = [UIColor colorWithWhite:0 alpha:0.60f];
91 _statusLabel.frame = CGRectMake( 92 _statusLabel.frame = CGRectMake(
92 imageViewFrame.origin.x + imageViewFrame.size.width + kHostCardIconInset, 93 imageViewFrame.origin.x + imageViewFrame.size.width + kHostCardIconInset,
93 (self.frame.size.height / 2.f) + kHostCardPadding / 2.f, 94 (self.frame.size.height / 2.f) + kHostCardPadding / 2.f,
94 self.frame.size.width, _statusLabel.font.pointSize + kLinePadding); 95 self.frame.size.width, _statusLabel.font.pointSize + kLinePadding);
95 [_cellView addSubview:_statusLabel]; 96 [_cellView addSubview:_statusLabel];
96 } 97 }
97 98
98 #pragma mark - HostCollectionViewCell Public 99 #pragma mark - HostCollectionViewCell Public
99 100
100 - (void)populateContentWithTitle:(NSString*)title status:(NSString*)status { 101 - (void)populateContentWithHostInfo:(HostInfo*)hostInfo {
101 _title = title; 102 _hostInfo = hostInfo;
102 _titleLabel.text = title;
103 103
104 _status = status; 104 _titleLabel.text = _hostInfo.hostName;
105 _statusLabel.text = status; 105 _statusLabel.text = _hostInfo.status;
106 106
107 _imageView.image = [UIImage imageNamed:@"ic_desktop"]; 107 _imageView.image = [UIImage imageNamed:@"ic_desktop"];
108 108
109 // TODO(nicholss): These colors are incorrect for the final product. 109 // TODO(nicholss): These colors are incorrect for the final product.
110 // Need to update to the values in the mocks. 110 // Need to update to the values in the mocks.
111 if ([status isEqualToString:@"ONLINE"]) { 111 if ([_hostInfo.status isEqualToString:@"ONLINE"]) {
112 _imageView.backgroundColor = UIColor.greenColor; 112 _imageView.backgroundColor = UIColor.greenColor;
113 } else { 113 } else {
114 _imageView.backgroundColor = UIColor.lightGrayColor; 114 _imageView.backgroundColor = UIColor.lightGrayColor;
115 } 115 }
116 } 116 }
117 117
118 #pragma mark - UICollectionReusableView 118 #pragma mark - UICollectionReusableView
119 119
120 - (void)prepareForReuse { 120 - (void)prepareForReuse {
121 [super prepareForReuse]; 121 [super prepareForReuse];
122 _title = nil; 122 _hostInfo = nil;
123 _status = nil;
124 _statusLabel.text = nil; 123 _statusLabel.text = nil;
125 _titleLabel.text = nil; 124 _titleLabel.text = nil;
126 } 125 }
127 126
128 @end 127 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698