| 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 <UIKit/UIKit.h> | 9 #import <UIKit/UIKit.h> |
| 10 | 10 |
| 11 #import "remoting/ios/app/host_collection_view_cell.h" | 11 #import "remoting/ios/app/host_collection_view_cell.h" |
| 12 | 12 |
| 13 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 13 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 14 #import "remoting/ios/app/remoting_theme.h" |
| 14 #import "remoting/ios/domain/host_info.h" | 15 #import "remoting/ios/domain/host_info.h" |
| 15 | 16 |
| 16 static const CGFloat kLinePadding = 2.f; | 17 static const CGFloat kLinePadding = 2.f; |
| 17 static const CGFloat kHostCardIconInset = 10.f; | 18 static const CGFloat kHostCardIconInset = 10.f; |
| 18 static const CGFloat kHostCardPadding = 4.f; | 19 static const CGFloat kHostCardPadding = 4.f; |
| 19 static const CGFloat kHostCardIconSize = 45.f; | 20 static const CGFloat kHostCardIconSize = 45.f; |
| 20 | 21 |
| 21 @interface HostCollectionViewCell () { | 22 @interface HostCollectionViewCell () { |
| 22 UIImageView* _imageView; | 23 UIImageView* _imageView; |
| 23 UILabel* _statusLabel; | 24 UILabel* _statusLabel; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 [self commonInit]; | 43 [self commonInit]; |
| 43 } | 44 } |
| 44 return self; | 45 return self; |
| 45 } | 46 } |
| 46 | 47 |
| 47 - (void)commonInit { | 48 - (void)commonInit { |
| 48 _imageView = [[UIImageView alloc] init]; | 49 _imageView = [[UIImageView alloc] init]; |
| 49 _imageView.translatesAutoresizingMaskIntoConstraints = NO; | 50 _imageView.translatesAutoresizingMaskIntoConstraints = NO; |
| 50 _imageView.contentMode = UIViewContentModeCenter; | 51 _imageView.contentMode = UIViewContentModeCenter; |
| 51 _imageView.alpha = 0.87f; | 52 _imageView.alpha = 0.87f; |
| 52 _imageView.backgroundColor = UIColor.lightGrayColor; | 53 _imageView.backgroundColor = RemotingTheme.offlineHostColor; |
| 53 _imageView.layer.cornerRadius = kHostCardIconSize / 2.f; | 54 _imageView.layer.cornerRadius = kHostCardIconSize / 2.f; |
| 54 _imageView.layer.masksToBounds = YES; | 55 _imageView.layer.masksToBounds = YES; |
| 55 [self.contentView addSubview:_imageView]; | 56 [self.contentView addSubview:_imageView]; |
| 56 | 57 |
| 57 // Holds both of the labels. | 58 // Holds both of the labels. |
| 58 _labelView = [[UIView alloc] init]; | 59 _labelView = [[UIView alloc] init]; |
| 59 _labelView.translatesAutoresizingMaskIntoConstraints = NO; | 60 _labelView.translatesAutoresizingMaskIntoConstraints = NO; |
| 60 [self.contentView addSubview:_labelView]; | 61 [self.contentView addSubview:_labelView]; |
| 61 | 62 |
| 62 _titleLabel = [[UILabel alloc] init]; | 63 _titleLabel = [[UILabel alloc] init]; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 125 |
| 125 #pragma mark - HostCollectionViewCell Public | 126 #pragma mark - HostCollectionViewCell Public |
| 126 | 127 |
| 127 - (void)populateContentWithHostInfo:(HostInfo*)hostInfo { | 128 - (void)populateContentWithHostInfo:(HostInfo*)hostInfo { |
| 128 _hostInfo = hostInfo; | 129 _hostInfo = hostInfo; |
| 129 | 130 |
| 130 _titleLabel.text = _hostInfo.hostName; | 131 _titleLabel.text = _hostInfo.hostName; |
| 131 | 132 |
| 132 _imageView.image = [UIImage imageNamed:@"ic_desktop"]; | 133 _imageView.image = [UIImage imageNamed:@"ic_desktop"]; |
| 133 | 134 |
| 134 // TODO(nicholss): These colors are incorrect for the final product. | |
| 135 // Need to update to the values in the mocks. | |
| 136 if ([_hostInfo.status isEqualToString:@"ONLINE"]) { | 135 if ([_hostInfo.status isEqualToString:@"ONLINE"]) { |
| 137 _imageView.backgroundColor = UIColor.greenColor; | 136 _imageView.backgroundColor = RemotingTheme.onlineHostColor; |
| 138 _statusLabel.text = @"Online"; | 137 _statusLabel.text = @"Online"; |
| 139 } else { | 138 } else { |
| 140 _imageView.backgroundColor = UIColor.lightGrayColor; | 139 _imageView.backgroundColor = RemotingTheme.offlineHostColor; |
| 141 _statusLabel.text = | 140 _statusLabel.text = |
| 142 [NSString stringWithFormat:@"Last online: %@", hostInfo.updatedTime]; | 141 [NSString stringWithFormat:@"Last online: %@", hostInfo.updatedTime]; |
| 143 } | 142 } |
| 144 } | 143 } |
| 145 | 144 |
| 146 #pragma mark - UICollectionReusableView | 145 #pragma mark - UICollectionReusableView |
| 147 | 146 |
| 148 - (void)prepareForReuse { | 147 - (void)prepareForReuse { |
| 149 [super prepareForReuse]; | 148 [super prepareForReuse]; |
| 150 _hostInfo = nil; | 149 _hostInfo = nil; |
| 151 _statusLabel.text = nil; | 150 _statusLabel.text = nil; |
| 152 _titleLabel.text = nil; | 151 _titleLabel.text = nil; |
| 153 } | 152 } |
| 154 | 153 |
| 155 @end | 154 @end |
| OLD | NEW |