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_cell.h" |
| 10 |
| 11 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 12 #import "remoting/ios/app/remoting_theme.h" |
| 13 |
| 14 static const CGFloat kNumberIconPadding = 16.f; |
| 15 static const CGFloat kNumberIconSize = 45.f; |
| 16 static const CGFloat kCellPadding = 22.f; |
| 17 |
| 18 @interface HostSetupViewCell () { |
| 19 UIView* _numberContainerView; |
| 20 UILabel* _numberLabel; |
| 21 UILabel* _contentLabel; |
| 22 } |
| 23 @end |
| 24 |
| 25 @implementation HostSetupViewCell |
| 26 |
| 27 - (instancetype)initWithFrame:(CGRect)frame { |
| 28 if (self = [super initWithFrame:frame]) { |
| 29 [self commonInit]; |
| 30 } |
| 31 return self; |
| 32 } |
| 33 |
| 34 - (void)commonInit { |
| 35 self.backgroundColor = RemotingTheme.setupListBackgroundColor; |
| 36 |
| 37 _numberContainerView = [[UIView alloc] init]; |
| 38 _numberLabel = [[UILabel alloc] init]; |
| 39 _contentLabel = [[UILabel alloc] init]; |
| 40 |
| 41 _numberContainerView.translatesAutoresizingMaskIntoConstraints = NO; |
| 42 _numberLabel.translatesAutoresizingMaskIntoConstraints = NO; |
| 43 _contentLabel.translatesAutoresizingMaskIntoConstraints = NO; |
| 44 |
| 45 _contentLabel.lineBreakMode = NSLineBreakByWordWrapping; |
| 46 _contentLabel.numberOfLines = 0; |
| 47 |
| 48 _numberContainerView.backgroundColor = RemotingTheme.onlineHostColor; |
| 49 _numberLabel.textColor = RemotingTheme.setupListNumberColor; |
| 50 _contentLabel.textColor = RemotingTheme.setupListTextColor; |
| 51 _numberLabel.font = MDCTypography.titleFont; |
| 52 _contentLabel.font = MDCTypography.subheadFont; |
| 53 _numberContainerView.layer.cornerRadius = kNumberIconSize / 2.f; |
| 54 |
| 55 [self.contentView addSubview:_numberContainerView]; |
| 56 [self.contentView addSubview:_contentLabel]; |
| 57 [_numberContainerView addSubview:_numberLabel]; |
| 58 |
| 59 NSArray* constraints = @[ |
| 60 [_numberContainerView.leadingAnchor |
| 61 constraintEqualToAnchor:self.contentView.leadingAnchor |
| 62 constant:kCellPadding], |
| 63 [_numberContainerView.centerYAnchor |
| 64 constraintEqualToAnchor:self.contentView.centerYAnchor], |
| 65 [_numberContainerView.widthAnchor |
| 66 constraintEqualToConstant:kNumberIconSize], |
| 67 [_numberContainerView.heightAnchor |
| 68 constraintEqualToConstant:kNumberIconSize], |
| 69 |
| 70 [_numberLabel.centerXAnchor |
| 71 constraintEqualToAnchor:_numberContainerView.centerXAnchor], |
| 72 [_numberLabel.centerYAnchor |
| 73 constraintEqualToAnchor:_numberContainerView.centerYAnchor], |
| 74 |
| 75 [_contentLabel.leadingAnchor |
| 76 constraintEqualToAnchor:_numberContainerView.trailingAnchor |
| 77 constant:kNumberIconPadding], |
| 78 [_contentLabel.trailingAnchor |
| 79 constraintEqualToAnchor:self.contentView.trailingAnchor |
| 80 constant:-kCellPadding], |
| 81 [_contentLabel.centerYAnchor |
| 82 constraintEqualToAnchor:self.contentView.centerYAnchor], |
| 83 ]; |
| 84 [NSLayoutConstraint activateConstraints:constraints]; |
| 85 } |
| 86 |
| 87 - (void)setContentText:(NSString*)text number:(NSInteger)number { |
| 88 _contentLabel.text = text; |
| 89 _numberLabel.text = [@(number) stringValue]; |
| 90 } |
| 91 |
| 92 @end |
OLD | NEW |