| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_ite
m.h" | 5 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_ite
m.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 8 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 9 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion
_identifier.h" |
| 9 #import "ios/chrome/browser/ui/favicon/favicon_attributes.h" | 10 #import "ios/chrome/browser/ui/favicon/favicon_attributes.h" |
| 10 #import "ios/chrome/browser/ui/favicon/favicon_view.h" | 11 #import "ios/chrome/browser/ui/favicon/favicon_view.h" |
| 11 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 12 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 12 #import "ios/chrome/browser/ui/util/i18n_string.h" | 13 #import "ios/chrome/browser/ui/util/i18n_string.h" |
| 13 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" | 14 #import "ios/third_party/material_components_ios/src/components/Palettes/src/Mat
erialPalettes.h" |
| 14 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" | 15 #import "ios/third_party/material_components_ios/src/components/Typography/src/M
aterialTypography.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 #if !defined(__has_feature) || !__has_feature(objc_arc) | 18 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 18 #error "This file requires ARC support." | 19 #error "This file requires ARC support." |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 @synthesize suggestionIdentifier = _suggestionIdentifier; | 68 @synthesize suggestionIdentifier = _suggestionIdentifier; |
| 68 @synthesize delegate = _delegate; | 69 @synthesize delegate = _delegate; |
| 69 @synthesize imageFetched = _imageFetched; | 70 @synthesize imageFetched = _imageFetched; |
| 70 @synthesize attributes = _attributes; | 71 @synthesize attributes = _attributes; |
| 71 @synthesize hasImage = _hasImage; | 72 @synthesize hasImage = _hasImage; |
| 72 @synthesize availableOffline = _availableOffline; | 73 @synthesize availableOffline = _availableOffline; |
| 73 | 74 |
| 74 - (instancetype)initWithType:(NSInteger)type | 75 - (instancetype)initWithType:(NSInteger)type |
| 75 title:(NSString*)title | 76 title:(NSString*)title |
| 76 subtitle:(NSString*)subtitle | 77 subtitle:(NSString*)subtitle |
| 77 delegate:(id<ContentSuggestionsItemDelegate>)delegate | |
| 78 url:(const GURL&)url { | 78 url:(const GURL&)url { |
| 79 self = [super initWithType:type]; | 79 self = [super initWithType:type]; |
| 80 if (self) { | 80 if (self) { |
| 81 self.cellClass = [ContentSuggestionsCell class]; | 81 self.cellClass = [ContentSuggestionsCell class]; |
| 82 _title = [title copy]; | 82 _title = [title copy]; |
| 83 _subtitle = [subtitle copy]; | 83 _subtitle = [subtitle copy]; |
| 84 _URL = url; | 84 _URL = url; |
| 85 _delegate = delegate; | |
| 86 } | 85 } |
| 87 return self; | 86 return self; |
| 88 } | 87 } |
| 89 | 88 |
| 90 - (void)configureCell:(ContentSuggestionsCell*)cell { | 89 - (void)configureCell:(ContentSuggestionsCell*)cell { |
| 91 [super configureCell:cell]; | 90 [super configureCell:cell]; |
| 92 if (self.hasImage && !self.imageFetched) { | 91 if (self.hasImage && !self.imageFetched) { |
| 93 self.imageFetched = YES; | 92 self.imageFetched = YES; |
| 94 // Fetch the image. During the fetch the cell's image should still be set. | 93 // Fetch the image. During the fetch the cell's image should still be set. |
| 95 [self.delegate loadImageForSuggestionItem:self]; | 94 [self.delegate loadImageForSuggestedItem:self]; |
| 96 } | 95 } |
| 97 [cell.faviconView configureWithAttributes:self.attributes]; | 96 [cell.faviconView configureWithAttributes:self.attributes]; |
| 98 cell.titleLabel.text = self.title; | 97 cell.titleLabel.text = self.title; |
| 99 [cell setSubtitleText:self.subtitle]; | 98 [cell setSubtitleText:self.subtitle]; |
| 100 cell.displayImage = self.hasImage; | 99 cell.displayImage = self.hasImage; |
| 101 [cell setContentImage:self.image]; | 100 [cell setContentImage:self.image]; |
| 102 [cell setAdditionalInformationWithPublisherName:self.publisher | 101 [cell setAdditionalInformationWithPublisherName:self.publisher |
| 103 date:self.publishDate | 102 date:self.publishDate |
| 104 offlineAvailability:self.availableOffline]; | 103 offlineAvailability:self.availableOffline]; |
| 105 } | 104 } |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 @"title" : _titleLabel, | 385 @"title" : _titleLabel, |
| 387 @"text" : _subtitleLabel, | 386 @"text" : _subtitleLabel, |
| 388 @"additional" : _additionalInformationLabel, | 387 @"additional" : _additionalInformationLabel, |
| 389 @"favicon" : _faviconView, | 388 @"favicon" : _faviconView, |
| 390 }, | 389 }, |
| 391 @{ @"space" : @(kStandardSpacing), | 390 @{ @"space" : @(kStandardSpacing), |
| 392 @"small" : @(kSmallSpacing) }); | 391 @"small" : @(kSmallSpacing) }); |
| 393 } | 392 } |
| 394 | 393 |
| 395 @end | 394 @end |
| OLD | NEW |