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

Unified Diff: ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.mm

Issue 2640473002: Suggestions UI - favicon item (Closed)
Patch Set: Fix build Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
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..384d682186336ab070a51992082cbb5f493e0481
--- /dev/null
+++ b/ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.mm
@@ -0,0 +1,70 @@
+// 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;
+const CGFloat kFontSize = 10;
+}
+
+@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:kFontSize];
+ _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;
+}
+
+#pragma mark - UICollectionReusableView
+
+- (void)prepareForReuse {
+ [super prepareForReuse];
+ self.faviconView.image = nil;
+ self.titleLabel.text = nil;
+}
+
++ (NSString*)reuseIdentifier {
+ return @"faviconInternalCell";
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698