Chromium Code Reviews| Index: ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.mm |
| diff --git a/ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.mm b/ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d568afda651dbb51fd32a22592644afed8946432 |
| --- /dev/null |
| +++ b/ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.mm |
| @@ -0,0 +1,67 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.h" |
| + |
| +#import "ios/chrome/browser/ui/uikit_ui_util.h" |
| +#import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h" |
| + |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +namespace { |
| +const CGFloat kFaviconImageSize = 50; |
| +} |
| + |
| +@implementation SuggestionsFaviconInternalCell |
| + |
| +@synthesize faviconView = _faviconView; |
| +@synthesize titleLabel = _titleLabel; |
| + |
| +- (instancetype)initWithFrame:(CGRect)frame { |
| + self = [super initWithFrame:frame]; |
| + if (self) { |
| + _faviconView = [[UIImageView alloc] init]; |
| + _titleLabel = [[UILabel alloc] init]; |
| + _titleLabel.numberOfLines = 2; |
| + _titleLabel.font = [[MDCTypography fontLoader] lightFontOfSize:10]; |
|
marq (ping after 24h)
2017/01/19 16:20:26
Either make this a constant or use a font size con
gambard
2017/01/19 17:37:32
Done.
|
| + _titleLabel.textAlignment = NSTextAlignmentCenter; |
| + |
| + _faviconView.translatesAutoresizingMaskIntoConstraints = NO; |
| + _titleLabel.translatesAutoresizingMaskIntoConstraints = NO; |
| + [self.contentView addSubview:_faviconView]; |
| + [self.contentView addSubview:_titleLabel]; |
| + |
| + ApplyVisualConstraints( |
| + @[ @"V:|-[image]-[title]-|" ], |
| + @{ @"image" : _faviconView, |
| + @"title" : _titleLabel }); |
| + |
| + [NSLayoutConstraint activateConstraints:@[ |
| + [_faviconView.centerXAnchor |
| + constraintEqualToAnchor:self.contentView.centerXAnchor], |
| + [_titleLabel.leadingAnchor |
| + constraintEqualToAnchor:self.contentView.leadingAnchor], |
| + [_titleLabel.trailingAnchor |
| + constraintEqualToAnchor:self.contentView.trailingAnchor], |
| + [_faviconView.widthAnchor constraintEqualToConstant:kFaviconImageSize], |
| + [_faviconView.heightAnchor |
| + constraintEqualToAnchor:_faviconView.widthAnchor], |
| + ]]; |
| + } |
| + return self; |
| +} |
| + |
| +- (void)prepareForReuse { |
|
marq (ping after 24h)
2017/01/19 16:20:25
nit: #pragma mark - UICollectionReusableView
gambard
2017/01/19 17:37:32
Done.
|
| + [super prepareForReuse]; |
| + self.faviconView.image = nil; |
| + self.titleLabel.text = nil; |
| +} |
| + |
| ++ (NSString*)reuseIdentifier { |
| + return @"faviconInternalCell"; |
| +} |
| + |
| +@end |