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..095bad7f9d4764540cc81bc45efff59095849026 |
--- /dev/null |
+++ b/ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.mm |
@@ -0,0 +1,62 @@ |
+// 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_roboto_font_loader_ios/src/src/MaterialRobotoFontLoader.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 title = _title; |
+ |
+- (instancetype)initWithFrame:(CGRect)frame { |
+ self = [super initWithFrame:frame]; |
+ if (self) { |
+ _faviconView = [[UIImageView alloc] init]; |
+ _title = [[UILabel alloc] init]; |
+ _title.numberOfLines = 2; |
+ _title.font = [[MDFRobotoFontLoader sharedInstance] lightFontOfSize:10]; |
lpromero
2017/01/18 09:34:38
It is not available via MDCTypography?
gambard
2017/01/18 12:37:57
Done.
It is but showcase does not load the roboto
lpromero
2017/01/18 15:10:42
https://codereview.chromium.org/2646483002/.
|
+ _title.textAlignment = NSTextAlignmentCenter; |
+ |
+ [self.contentView addSubview:_faviconView]; |
+ [self.contentView addSubview:_title]; |
+ _faviconView.translatesAutoresizingMaskIntoConstraints = NO; |
+ _title.translatesAutoresizingMaskIntoConstraints = NO; |
+ |
+ ApplyVisualConstraints(@[ @"V:|-[image]-[title]-|" ], |
+ @{ @"image" : _faviconView, |
+ @"title" : _title }); |
+ |
+ [NSLayoutConstraint activateConstraints:@[ |
+ [_title.centerXAnchor |
+ constraintEqualToAnchor:self.contentView.centerXAnchor], |
lpromero
2017/01/18 09:34:38
Since you set the leading and trailing for the tit
gambard
2017/01/18 12:37:57
Done.
|
+ [_faviconView.centerXAnchor |
+ constraintEqualToAnchor:self.contentView.centerXAnchor], |
+ [_title.leadingAnchor |
+ constraintEqualToAnchor:self.contentView.leadingAnchor], |
+ [_title.trailingAnchor |
+ constraintEqualToAnchor:self.contentView.trailingAnchor], |
+ [_faviconView.widthAnchor constraintEqualToConstant:kFaviconImageSize], |
+ [_faviconView.heightAnchor |
+ constraintEqualToAnchor:_faviconView.widthAnchor], |
+ ]]; |
+ } |
+ return self; |
+} |
+ |
++ (NSString*)reuseIdentifier { |
+ return @"faviconInternalCell"; |
+} |
+ |
+@end |