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

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

Issue 2644123003: Move ios/ui/suggestions to ios/ui/content_suggestions (Closed)
Patch Set: Rebase 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_article_item.mm
diff --git a/ios/chrome/browser/ui/suggestions/suggestions_article_item.mm b/ios/chrome/browser/ui/suggestions/suggestions_article_item.mm
deleted file mode 100644
index a26ee1b02527ad6ed1c8a7b5f4e39171bc2f4eb9..0000000000000000000000000000000000000000
--- a/ios/chrome/browser/ui/suggestions/suggestions_article_item.mm
+++ /dev/null
@@ -1,115 +0,0 @@
-// 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_article_item.h"
-
-#import "ios/chrome/browser/ui/uikit_ui_util.h"
-
-#if !defined(__has_feature) || !__has_feature(objc_arc)
-#error "This file requires ARC support."
-#endif
-
-namespace {
-const CGFloat kImageSize = 100;
-}
-
-@interface SuggestionsArticleItem ()
-
-@property(nonatomic, copy) NSString* title;
-@property(nonatomic, copy) NSString* subtitle;
-@property(nonatomic, strong) UIImage* image;
-
-@end
-
-@implementation SuggestionsArticleItem
-
-@synthesize title = _title;
-@synthesize subtitle = _subtitle;
-@synthesize image = _image;
-
-- (instancetype)initWithType:(NSInteger)type
- title:(NSString*)title
- subtitle:(NSString*)subtitle
- image:(UIImage*)image {
- self = [super initWithType:type];
- if (self) {
- self.cellClass = [SuggestionsArticleCell class];
- _title = [title copy];
- _subtitle = [subtitle copy];
- _image = image;
- }
- return self;
-}
-
-- (void)configureCell:(SuggestionsArticleCell*)cell {
- [super configureCell:cell];
- cell.titleLabel.text = _title;
- cell.subtitleLabel.text = _subtitle;
- cell.imageView.image = _image;
-}
-
-@end
-
-@implementation SuggestionsArticleCell
-
-@synthesize titleLabel = _titleLabel;
-@synthesize subtitleLabel = _subtitleLabel;
-@synthesize imageView = _imageView;
-
-- (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- _titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- _subtitleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
- _imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
- UIView* imageContainer = [[UIView alloc] initWithFrame:CGRectZero];
-
- _subtitleLabel.numberOfLines = 0;
-
- imageContainer.translatesAutoresizingMaskIntoConstraints = NO;
- _imageView.translatesAutoresizingMaskIntoConstraints = NO;
- _titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
- _subtitleLabel.translatesAutoresizingMaskIntoConstraints = NO;
-
- [imageContainer addSubview:_imageView];
- [self.contentView addSubview:imageContainer];
- [self.contentView addSubview:_titleLabel];
- [self.contentView addSubview:_subtitleLabel];
-
- ApplyVisualConstraintsWithMetrics(
- @[
- @"H:|-[title]-[imageContainer(imageSize)]-|",
- @"H:|[image(imageSize)]", @"H:|-[text]-[imageContainer]",
- @"V:|[image(imageSize)]", @"V:|-[title]-[text]-|",
- @"V:|-[imageContainer(>=imageSize)]-|"
- ],
- @{
- @"image" : _imageView,
- @"imageContainer" : imageContainer,
- @"title" : _titleLabel,
- @"text" : _subtitleLabel
- },
- @{ @"imageSize" : @(kImageSize) });
- }
- return self;
-}
-
-#pragma mark - UIView
-
-// Implements -layoutSubviews as per instructions in documentation for
-// +[MDCCollectionViewCell cr_preferredHeightForWidth:forItem:].
-- (void)layoutSubviews {
- [super layoutSubviews];
-
- // Adjust the text label preferredMaxLayoutWidth when the parent's width
- // changes, for instance on screen rotation.
- CGFloat parentWidth = CGRectGetWidth(self.contentView.bounds);
- self.subtitleLabel.preferredMaxLayoutWidth = parentWidth - kImageSize - 3 * 8;
-
- // Re-layout with the new preferred width to allow the label to adjust its
- // height.
- [super layoutSubviews];
-}
-
-@end

Powered by Google App Engine
This is Rietveld 408576698