| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/content_suggestions_view_cont
roller.h" | 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_cont
roller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" | 8 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" |
| 9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" | 9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" |
| 10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| 11 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h" |
| 12 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_article_i
tem.h" |
| 11 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio
n_updater.h" | 13 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio
n_updater.h" |
| 12 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.
h" | 14 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.
h" |
| 13 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_item_acti
ons.h" | 15 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_item_acti
ons.h" |
| 14 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_stack_ite
m.h" | 16 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_stack_ite
m.h" |
| 15 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_stack_ite
m_actions.h" | 17 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_stack_ite
m_actions.h" |
| 16 #import "ios/chrome/browser/ui/content_suggestions/expandable_item.h" | 18 #import "ios/chrome/browser/ui/content_suggestions/expandable_item.h" |
| 17 | 19 |
| 18 #if !defined(__has_feature) || !__has_feature(objc_arc) | 20 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 19 #error "This file requires ARC support." | 21 #error "This file requires ARC support." |
| 20 #endif | 22 #endif |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 64 } |
| 63 | 65 |
| 64 #pragma mark - UICollectionViewDelegate | 66 #pragma mark - UICollectionViewDelegate |
| 65 | 67 |
| 66 - (void)collectionView:(UICollectionView*)collectionView | 68 - (void)collectionView:(UICollectionView*)collectionView |
| 67 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { | 69 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { |
| 68 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; | 70 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; |
| 69 | 71 |
| 70 CollectionViewItem* item = | 72 CollectionViewItem* item = |
| 71 [self.collectionViewModel itemAtIndexPath:indexPath]; | 73 [self.collectionViewModel itemAtIndexPath:indexPath]; |
| 72 if (item.type == ItemTypeStack) { | 74 switch (item.type) { |
| 73 [self.suggestionCommandHandler openReadingList]; | 75 case ItemTypeStack: |
| 76 [self.suggestionCommandHandler openReadingList]; |
| 77 break; |
| 78 case ItemTypeArticle: |
| 79 [self openArticle:item]; |
| 80 break; |
| 81 default: |
| 82 break; |
| 74 } | 83 } |
| 75 } | 84 } |
| 76 | 85 |
| 77 #pragma mark - ContentSuggestionsExpandableCellDelegate | 86 #pragma mark - ContentSuggestionsExpandableCellDelegate |
| 78 | 87 |
| 79 - (void)collapseCell:(UICollectionViewCell*)cell { | 88 - (void)collapseCell:(UICollectionViewCell*)cell { |
| 80 [self expand:NO cell:cell]; | 89 [self expand:NO cell:cell]; |
| 81 } | 90 } |
| 82 | 91 |
| 83 - (void)expandCell:(UICollectionViewCell*)cell { | 92 - (void)expandCell:(UICollectionViewCell*)cell { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 inSectionWithIdentifier:sectionIdentifier]; | 172 inSectionWithIdentifier:sectionIdentifier]; |
| 164 | 173 |
| 165 [UIView | 174 [UIView |
| 166 animateWithDuration:kAnimationDuration | 175 animateWithDuration:kAnimationDuration |
| 167 animations:^{ | 176 animations:^{ |
| 168 [self.collectionView.collectionViewLayout invalidateLayout]; | 177 [self.collectionView.collectionViewLayout invalidateLayout]; |
| 169 }]; | 178 }]; |
| 170 } | 179 } |
| 171 } | 180 } |
| 172 | 181 |
| 182 - (void)openArticle:(CollectionViewItem*)item { |
| 183 ContentSuggestionsArticleItem* article = |
| 184 base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(item); |
| 185 [self.suggestionCommandHandler openURL:article.articleURL]; |
| 186 } |
| 187 |
| 173 @end | 188 @end |
| OLD | NEW |