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

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm

Issue 2798963002: Remove unused code (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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/cells/content_suggestions_art icle_item.h" 11 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_art icle_item.h"
12 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_but ton_item_actions.h"
13 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_rea ding_list_item.h" 12 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_rea ding_list_item.h"
14 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_sta ck_item.h"
15 #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_sta ck_item_actions.h"
16 #import "ios/chrome/browser/ui/content_suggestions/cells/expandable_item.h"
17 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h" 13 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h"
18 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_updater.h" 14 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_updater.h"
19 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands. h" 15 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands. h"
20 #include "url/gurl.h" 16 #include "url/gurl.h"
21 17
22 #if !defined(__has_feature) || !__has_feature(objc_arc) 18 #if !defined(__has_feature) || !__has_feature(objc_arc)
23 #error "This file requires ARC support." 19 #error "This file requires ARC support."
24 #endif 20 #endif
25 21
26 namespace { 22 @interface ContentSuggestionsViewController ()
27 const NSTimeInterval kAnimationDuration = 0.35;
28 } // namespace
29
30 @interface ContentSuggestionsViewController ()<SuggestionsStackItemActions>
31 23
32 @property(nonatomic, strong) 24 @property(nonatomic, strong)
33 ContentSuggestionsCollectionUpdater* collectionUpdater; 25 ContentSuggestionsCollectionUpdater* collectionUpdater;
34 26
35 // Expand or collapse the |cell|, if it is a ContentSuggestionsExpandableCell,
36 // according to |expand|.
37 - (void)expand:(BOOL)expand cell:(UICollectionViewCell*)cell;
38
39 @end 27 @end
40 28
41 @implementation ContentSuggestionsViewController 29 @implementation ContentSuggestionsViewController
42 30
43 @synthesize suggestionCommandHandler = _suggestionCommandHandler; 31 @synthesize suggestionCommandHandler = _suggestionCommandHandler;
44 @synthesize collectionUpdater = _collectionUpdater; 32 @synthesize collectionUpdater = _collectionUpdater;
45 @dynamic collectionViewModel; 33 @dynamic collectionViewModel;
46 34
47 #pragma mark - Public 35 #pragma mark - Public
48 36
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 [self openReadingListItem:item]; 133 [self openReadingListItem:item];
146 break; 134 break;
147 case ContentSuggestionTypeArticle: 135 case ContentSuggestionTypeArticle:
148 [self openArticle:item]; 136 [self openArticle:item];
149 break; 137 break;
150 case ContentSuggestionTypeEmpty: 138 case ContentSuggestionTypeEmpty:
151 break; 139 break;
152 } 140 }
153 } 141 }
154 142
155 #pragma mark - ContentSuggestionsExpandableCellDelegate
156
157 - (void)collapseCell:(UICollectionViewCell*)cell {
158 [self expand:NO cell:cell];
159 }
160
161 - (void)expandCell:(UICollectionViewCell*)cell {
162 [self expand:YES cell:cell];
163 }
164
165 #pragma mark - ContentSuggestionsFaviconCellDelegate
166
167 - (void)openFaviconAtIndexPath:(NSIndexPath*)innerIndexPath {
168 [self.suggestionCommandHandler openFaviconAtIndex:innerIndexPath.item];
169 }
170
171 #pragma mark - SuggestionsStackItemActions
172
173 - (void)openReadingListFirstItem:(id)sender {
174 [self.suggestionCommandHandler openFirstPageOfReadingList];
175 }
176
177 #pragma mark - MDCCollectionViewStylingDelegate 143 #pragma mark - MDCCollectionViewStylingDelegate
178 144
179 - (UIColor*)collectionView:(nonnull UICollectionView*)collectionView 145 - (UIColor*)collectionView:(nonnull UICollectionView*)collectionView
180 cellBackgroundColorAtIndexPath:(nonnull NSIndexPath*)indexPath { 146 cellBackgroundColorAtIndexPath:(nonnull NSIndexPath*)indexPath {
181 if ([self.collectionUpdater 147 if ([self.collectionUpdater
182 shouldUseCustomStyleForSection:indexPath.section]) { 148 shouldUseCustomStyleForSection:indexPath.section]) {
183 return [UIColor clearColor]; 149 return [UIColor clearColor];
184 } 150 }
185 return [UIColor whiteColor]; 151 return [UIColor whiteColor];
186 } 152 }
(...skipping 21 matching lines...) Expand all
208 insetForSectionAtIndex:indexPath.section]; 174 insetForSectionAtIndex:indexPath.section];
209 175
210 return [MDCCollectionViewCell 176 return [MDCCollectionViewCell
211 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) - 177 cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) -
212 inset.left - inset.right 178 inset.left - inset.right
213 forItem:item]; 179 forItem:item];
214 } 180 }
215 181
216 #pragma mark - Private 182 #pragma mark - Private
217 183
218 - (void)expand:(BOOL)expand cell:(UICollectionViewCell*)cell {
219 NSIndexPath* indexPath = [self.collectionView indexPathForCell:cell];
220 CollectionViewItem* item =
221 [self.collectionViewModel itemAtIndexPath:indexPath];
222 if ([item conformsToProtocol:@protocol(ExpandableItem)]) {
223 id<ExpandableItem> expandableItem = (id<ExpandableItem>)item;
224
225 NSInteger sectionIdentifier = [self.collectionViewModel
226 sectionIdentifierForSection:indexPath.section];
227
228 expandableItem.expanded = expand;
229 [self reconfigureCellsForItems:@[ item ]
230 inSectionWithIdentifier:sectionIdentifier];
231
232 [UIView
233 animateWithDuration:kAnimationDuration
234 animations:^{
235 [self.collectionView.collectionViewLayout invalidateLayout];
236 }];
237 }
238 }
239
240 // Opens the Reading List entry associated with |item|. |item| must be a 184 // Opens the Reading List entry associated with |item|. |item| must be a
241 // ContentSuggestionsReadingListItem. 185 // ContentSuggestionsReadingListItem.
242 - (void)openReadingListItem:(CollectionViewItem*)item { 186 - (void)openReadingListItem:(CollectionViewItem*)item {
243 ContentSuggestionsReadingListItem* readingListItem = 187 ContentSuggestionsReadingListItem* readingListItem =
244 base::mac::ObjCCastStrict<ContentSuggestionsReadingListItem>(item); 188 base::mac::ObjCCastStrict<ContentSuggestionsReadingListItem>(item);
245 [self.suggestionCommandHandler openURL:readingListItem.url]; 189 [self.suggestionCommandHandler openURL:readingListItem.url];
246 } 190 }
247 191
248 // Opens the article associated with |item|. |item| must be a 192 // Opens the article associated with |item|. |item| must be a
249 // ContentSuggestionsArticleItem. 193 // ContentSuggestionsArticleItem.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 - (void)addEmptySectionPlaceholderIfNeeded:(NSInteger)section { 235 - (void)addEmptySectionPlaceholderIfNeeded:(NSInteger)section {
292 if ([self.collectionViewModel numberOfItemsInSection:section] > 0) 236 if ([self.collectionViewModel numberOfItemsInSection:section] > 0)
293 return; 237 return;
294 238
295 NSIndexPath* emptyItem = 239 NSIndexPath* emptyItem =
296 [self.collectionUpdater addEmptyItemForSection:section]; 240 [self.collectionUpdater addEmptyItemForSection:section];
297 [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]]; 241 [self.collectionView insertItemsAtIndexPaths:@[ emptyItem ]];
298 } 242 }
299 243
300 @end 244 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698