| Index: ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.mm
|
| diff --git a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item.mm b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.mm
|
| similarity index 84%
|
| copy from ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item.mm
|
| copy to ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.mm
|
| index 985d5828e83410ff73049671b6e7b1c72390579f..bf407ab379fe7bb928bd927903ceaeec44e67fe4 100644
|
| --- a/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_item.mm
|
| +++ b/ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.mm
|
| @@ -2,18 +2,14 @@
|
| // 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/content_suggestions/cells/content_suggestions_item.h"
|
| +#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_cell.h"
|
|
|
| -#include "base/time/time.h"
|
| #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
|
| -#import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier.h"
|
| -#import "ios/chrome/browser/ui/favicon/favicon_attributes.h"
|
| #import "ios/chrome/browser/ui/favicon/favicon_view.h"
|
| #import "ios/chrome/browser/ui/uikit_ui_util.h"
|
| #import "ios/chrome/browser/ui/util/i18n_string.h"
|
| #import "ios/third_party/material_components_ios/src/components/Palettes/src/MaterialPalettes.h"
|
| #import "ios/third_party/material_components_ios/src/components/Typography/src/MaterialTypography.h"
|
| -#include "url/gurl.h"
|
|
|
| #if !defined(__has_feature) || !__has_feature(objc_arc)
|
| #error "This file requires ARC support."
|
| @@ -45,68 +41,6 @@ const CGFloat kNoImageBackgroundWhite = 0.95;
|
| const CGFloat kAnimationDuration = 0.3;
|
| }
|
|
|
| -@interface ContentSuggestionsItem ()
|
| -
|
| -@property(nonatomic, copy) NSString* subtitle;
|
| -// Used to check if the image has already been fetched. There is no way to
|
| -// discriminate between failed image download and nonexitent image. The
|
| -// suggestion tries to download the image only once.
|
| -@property(nonatomic, assign) BOOL imageFetched;
|
| -
|
| -@end
|
| -
|
| -#pragma mark - ContentSuggestionsItem
|
| -
|
| -@implementation ContentSuggestionsItem
|
| -
|
| -@synthesize title = _title;
|
| -@synthesize subtitle = _subtitle;
|
| -@synthesize image = _image;
|
| -@synthesize URL = _URL;
|
| -@synthesize publisher = _publisher;
|
| -@synthesize publishDate = _publishDate;
|
| -@synthesize suggestionIdentifier = _suggestionIdentifier;
|
| -@synthesize delegate = _delegate;
|
| -@synthesize imageFetched = _imageFetched;
|
| -@synthesize attributes = _attributes;
|
| -@synthesize hasImage = _hasImage;
|
| -@synthesize availableOffline = _availableOffline;
|
| -
|
| -- (instancetype)initWithType:(NSInteger)type
|
| - title:(NSString*)title
|
| - subtitle:(NSString*)subtitle
|
| - url:(const GURL&)url {
|
| - self = [super initWithType:type];
|
| - if (self) {
|
| - self.cellClass = [ContentSuggestionsCell class];
|
| - _title = [title copy];
|
| - _subtitle = [subtitle copy];
|
| - _URL = url;
|
| - }
|
| - return self;
|
| -}
|
| -
|
| -- (void)configureCell:(ContentSuggestionsCell*)cell {
|
| - [super configureCell:cell];
|
| - if (self.hasImage && !self.imageFetched) {
|
| - self.imageFetched = YES;
|
| - // Fetch the image. During the fetch the cell's image should still be set.
|
| - [self.delegate loadImageForSuggestedItem:self];
|
| - }
|
| - [cell.faviconView configureWithAttributes:self.attributes];
|
| - cell.titleLabel.text = self.title;
|
| - [cell setSubtitleText:self.subtitle];
|
| - cell.displayImage = self.hasImage;
|
| - [cell setContentImage:self.image];
|
| - [cell setAdditionalInformationWithPublisherName:self.publisher
|
| - date:self.publishDate
|
| - offlineAvailability:self.availableOffline];
|
| -}
|
| -
|
| -@end
|
| -
|
| -#pragma mark - ContentSuggestionsCell
|
| -
|
| @interface ContentSuggestionsCell ()
|
|
|
| @property(nonatomic, strong) UILabel* additionalInformationLabel;
|
| @@ -223,9 +157,8 @@ const CGFloat kAnimationDuration = 0.3;
|
| }
|
|
|
| - (void)setAdditionalInformationWithPublisherName:(NSString*)publisherName
|
| - date:(base::Time)publishDate
|
| + date:(NSDate*)date
|
| offlineAvailability:(BOOL)availableOffline {
|
| - NSDate* date = [NSDate dateWithTimeIntervalSince1970:publishDate.ToDoubleT()];
|
| NSString* dateString =
|
| [NSDateFormatter localizedStringFromDate:date
|
| dateStyle:NSDateFormatterMediumStyle
|
|
|