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

Side by Side Diff: ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.mm

Issue 2640473002: Suggestions UI - favicon item (Closed)
Patch Set: Address comments 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 unified diff | Download patch
OLDNEW
(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 #import "ios/chrome/browser/ui/suggestions/suggestions_favicon_internal_cell.h"
6
7 #import "ios/chrome/browser/ui/uikit_ui_util.h"
8 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
9
10 #if !defined(__has_feature) || !__has_feature(objc_arc)
11 #error "This file requires ARC support."
12 #endif
13
14 namespace {
15 const CGFloat kFaviconImageSize = 50;
16 }
17
18 @implementation SuggestionsFaviconInternalCell
19
20 @synthesize faviconView = _faviconView;
21 @synthesize titleLabel = _titleLabel;
22
23 - (instancetype)initWithFrame:(CGRect)frame {
24 self = [super initWithFrame:frame];
25 if (self) {
26 _faviconView = [[UIImageView alloc] init];
27 _titleLabel = [[UILabel alloc] init];
28 _titleLabel.numberOfLines = 2;
29 _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.
30 _titleLabel.textAlignment = NSTextAlignmentCenter;
31
32 _faviconView.translatesAutoresizingMaskIntoConstraints = NO;
33 _titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
34 [self.contentView addSubview:_faviconView];
35 [self.contentView addSubview:_titleLabel];
36
37 ApplyVisualConstraints(
38 @[ @"V:|-[image]-[title]-|" ],
39 @{ @"image" : _faviconView,
40 @"title" : _titleLabel });
41
42 [NSLayoutConstraint activateConstraints:@[
43 [_faviconView.centerXAnchor
44 constraintEqualToAnchor:self.contentView.centerXAnchor],
45 [_titleLabel.leadingAnchor
46 constraintEqualToAnchor:self.contentView.leadingAnchor],
47 [_titleLabel.trailingAnchor
48 constraintEqualToAnchor:self.contentView.trailingAnchor],
49 [_faviconView.widthAnchor constraintEqualToConstant:kFaviconImageSize],
50 [_faviconView.heightAnchor
51 constraintEqualToAnchor:_faviconView.widthAnchor],
52 ]];
53 }
54 return self;
55 }
56
57 - (void)prepareForReuse {
marq (ping after 24h) 2017/01/19 16:20:25 nit: #pragma mark - UICollectionReusableView
gambard 2017/01/19 17:37:32 Done.
58 [super prepareForReuse];
59 self.faviconView.image = nil;
60 self.titleLabel.text = nil;
61 }
62
63 + (NSString*)reuseIdentifier {
64 return @"faviconInternalCell";
65 }
66
67 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698