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" | 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" | 12 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_article_i
tem.h" |
13 #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" |
14 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.
h" | 14 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.
h" |
15 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_item_acti
ons.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.h" |
17 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_stack_ite
m_actions.h" | 16 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_stack_ite
m_actions.h" |
| 17 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_text_item
_actions.h" |
18 #import "ios/chrome/browser/ui/content_suggestions/expandable_item.h" | 18 #import "ios/chrome/browser/ui/content_suggestions/expandable_item.h" |
19 | 19 |
20 #if !defined(__has_feature) || !__has_feature(objc_arc) | 20 #if !defined(__has_feature) || !__has_feature(objc_arc) |
21 #error "This file requires ARC support." | 21 #error "This file requires ARC support." |
22 #endif | 22 #endif |
23 | 23 |
24 namespace { | 24 namespace { |
25 const NSTimeInterval kAnimationDuration = 0.35; | 25 const NSTimeInterval kAnimationDuration = 0.35; |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 @interface ContentSuggestionsViewController ()<SuggestionsItemActions, | 28 @interface ContentSuggestionsViewController ()<SuggestionsStackItemActions> |
29 SuggestionsStackItemActions> | |
30 | 29 |
31 @property(nonatomic, strong) | 30 @property(nonatomic, strong) |
32 ContentSuggestionsCollectionUpdater* collectionUpdater; | 31 ContentSuggestionsCollectionUpdater* collectionUpdater; |
33 | 32 |
34 // Expand or collapse the |cell|, if it is a ContentSuggestionsExpandableCell, | 33 // Expand or collapse the |cell|, if it is a ContentSuggestionsExpandableCell, |
35 // according to |expand|. | 34 // according to |expand|. |
36 - (void)expand:(BOOL)expand cell:(UICollectionViewCell*)cell; | 35 - (void)expand:(BOOL)expand cell:(UICollectionViewCell*)cell; |
37 | 36 |
38 @end | 37 @end |
39 | 38 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 - (void)expandCell:(UICollectionViewCell*)cell { | 93 - (void)expandCell:(UICollectionViewCell*)cell { |
95 [self expand:YES cell:cell]; | 94 [self expand:YES cell:cell]; |
96 } | 95 } |
97 | 96 |
98 #pragma mark - ContentSuggestionsFaviconCellDelegate | 97 #pragma mark - ContentSuggestionsFaviconCellDelegate |
99 | 98 |
100 - (void)openFaviconAtIndexPath:(NSIndexPath*)innerIndexPath { | 99 - (void)openFaviconAtIndexPath:(NSIndexPath*)innerIndexPath { |
101 [self.suggestionCommandHandler openFaviconAtIndex:innerIndexPath.item]; | 100 [self.suggestionCommandHandler openFaviconAtIndex:innerIndexPath.item]; |
102 } | 101 } |
103 | 102 |
104 #pragma mark - SuggestionsItemActions | |
105 | |
106 - (void)addNewItem:(id)sender { | |
107 [self.suggestionCommandHandler addEmptyItem]; | |
108 } | |
109 | |
110 #pragma mark - ContentSuggestionsCollectionUpdater forwarding | |
111 | |
112 - (void)addTextItem:(NSString*)title | |
113 subtitle:(NSString*)subtitle | |
114 toSection:(NSInteger)inputSection { | |
115 [self.collectionUpdater addTextItem:title | |
116 subtitle:subtitle | |
117 toSection:inputSection]; | |
118 } | |
119 | |
120 #pragma mark - SuggestionsStackItemActions | 103 #pragma mark - SuggestionsStackItemActions |
121 | 104 |
122 - (void)openReadingListFirstItem:(id)sender { | 105 - (void)openReadingListFirstItem:(id)sender { |
123 [self.suggestionCommandHandler openFirstPageOfReadingList]; | 106 [self.suggestionCommandHandler openFirstPageOfReadingList]; |
124 } | 107 } |
125 | 108 |
126 #pragma mark - MDCCollectionViewStylingDelegate | 109 #pragma mark - MDCCollectionViewStylingDelegate |
127 | 110 |
128 - (UIColor*)collectionView:(nonnull UICollectionView*)collectionView | 111 - (UIColor*)collectionView:(nonnull UICollectionView*)collectionView |
129 cellBackgroundColorAtIndexPath:(nonnull NSIndexPath*)indexPath { | 112 cellBackgroundColorAtIndexPath:(nonnull NSIndexPath*)indexPath { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 } | 195 } |
213 | 196 |
214 ContentSuggestionsArticleItem* articleItem = | 197 ContentSuggestionsArticleItem* articleItem = |
215 base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(touchedItem); | 198 base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(touchedItem); |
216 | 199 |
217 [self.suggestionCommandHandler displayContextMenuForArticle:articleItem | 200 [self.suggestionCommandHandler displayContextMenuForArticle:articleItem |
218 atPoint:touchLocation]; | 201 atPoint:touchLocation]; |
219 } | 202 } |
220 | 203 |
221 @end | 204 @end |
OLD | NEW |