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

Side by Side Diff: ios/chrome/browser/ui/suggestions/suggestions_collection_updater.mm

Issue 2640473002: Suggestions UI - favicon item (Closed)
Patch Set: Fix build Created 3 years, 11 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/suggestions/suggestions_collection_updater.h" 5 #import "ios/chrome/browser/ui/suggestions/suggestions_collection_updater.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #import "ios/chrome/browser/ui/collection_view/collection_view_controller.h" 9 #import "ios/chrome/browser/ui/collection_view/collection_view_controller.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/suggestions/suggestions_article_item.h" 11 #import "ios/chrome/browser/ui/suggestions/suggestions_article_item.h"
12 #import "ios/chrome/browser/ui/suggestions/suggestions_expandable_item.h" 12 #import "ios/chrome/browser/ui/suggestions/suggestions_expandable_item.h"
13 #import "ios/chrome/browser/ui/suggestions/suggestions_favicon_item.h"
13 #import "ios/chrome/browser/ui/suggestions/suggestions_item.h" 14 #import "ios/chrome/browser/ui/suggestions/suggestions_item.h"
14 #import "ios/chrome/browser/ui/suggestions/suggestions_stack_item.h" 15 #import "ios/chrome/browser/ui/suggestions/suggestions_stack_item.h"
15 #import "ios/chrome/browser/ui/suggestions/suggestions_view_controller.h" 16 #import "ios/chrome/browser/ui/suggestions/suggestions_view_controller.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."
19 #endif 20 #endif
20 21
21 @implementation SuggestionsCollectionUpdater 22 @implementation SuggestionsCollectionUpdater
22 23
23 @synthesize collectionViewController = _collectionViewController; 24 @synthesize collectionViewController = _collectionViewController;
24 25
25 #pragma mark - Properties 26 #pragma mark - Properties
26 27
27 - (void)setCollectionViewController: 28 - (void)setCollectionViewController:
28 (SuggestionsViewController*)collectionViewController { 29 (SuggestionsViewController*)collectionViewController {
29 _collectionViewController = collectionViewController; 30 _collectionViewController = collectionViewController;
30 [collectionViewController loadModel]; 31 [collectionViewController loadModel];
31 CollectionViewModel* model = collectionViewController.collectionViewModel; 32 CollectionViewModel* model = collectionViewController.collectionViewModel;
32 NSInteger sectionIdentifier = kSectionIdentifierEnumZero; 33 NSInteger sectionIdentifier = kSectionIdentifierEnumZero;
34
35 // Stack Item.
33 [model addSectionWithIdentifier:sectionIdentifier]; 36 [model addSectionWithIdentifier:sectionIdentifier];
34 [model addItem:[[SuggestionsStackItem alloc] initWithType:ItemTypeStack 37 [model addItem:[[SuggestionsStackItem alloc] initWithType:ItemTypeStack
35 title:@"The title" 38 title:@"The title"
36 subtitle:@"The subtitle"] 39 subtitle:@"The subtitle"]
37 toSectionWithIdentifier:sectionIdentifier++]; 40 toSectionWithIdentifier:sectionIdentifier++];
38 41
42 // Favicon Item.
43 [model addSectionWithIdentifier:sectionIdentifier];
44 SuggestionsFaviconItem* faviconItem =
45 [[SuggestionsFaviconItem alloc] initWithType:ItemTypeFavicon];
46 for (NSInteger i = 0; i < 6; i++) {
47 [faviconItem addFavicon:[UIImage imageNamed:@"bookmark_gray_star"]
48 withTitle:@"Super website! Incredible!"];
49 }
50 faviconItem.delegate = _collectionViewController;
51 [model addItem:faviconItem toSectionWithIdentifier:sectionIdentifier++];
52
39 for (NSInteger i = 0; i < 3; i++) { 53 for (NSInteger i = 0; i < 3; i++) {
40 [model addSectionWithIdentifier:sectionIdentifier]; 54 [model addSectionWithIdentifier:sectionIdentifier];
55
56 // Standard Item.
41 [model addItem:[[SuggestionsItem alloc] initWithType:ItemTypeText 57 [model addItem:[[SuggestionsItem alloc] initWithType:ItemTypeText
42 title:@"The title" 58 title:@"The title"
43 subtitle:@"The subtitle"] 59 subtitle:@"The subtitle"]
44 toSectionWithIdentifier:sectionIdentifier]; 60 toSectionWithIdentifier:sectionIdentifier];
61
62 // Article Item.
45 [model addItem:[[SuggestionsArticleItem alloc] 63 [model addItem:[[SuggestionsArticleItem alloc]
46 initWithType:ItemTypeArticle 64 initWithType:ItemTypeArticle
47 title:@"Title of an Article" 65 title:@"Title of an Article"
48 subtitle:@"This is the subtitle of an article, can " 66 subtitle:@"This is the subtitle of an article, can "
49 @"spawn on multiple lines" 67 @"spawn on multiple lines"
50 image:[UIImage 68 image:[UIImage
51 imageNamed:@"distillation_success"]] 69 imageNamed:@"distillation_success"]]
52 toSectionWithIdentifier:sectionIdentifier]; 70 toSectionWithIdentifier:sectionIdentifier];
71
72 // Expandable Item.
53 SuggestionsExpandableItem* expandableItem = 73 SuggestionsExpandableItem* expandableItem =
54 [[SuggestionsExpandableItem alloc] 74 [[SuggestionsExpandableItem alloc]
55 initWithType:ItemTypeExpand 75 initWithType:ItemTypeExpand
56 title:@"Title of an Expandable Article" 76 title:@"Title of an Expandable Article"
57 subtitle:@"This Article can be expanded to display " 77 subtitle:@"This Article can be expanded to display "
58 @"additional information or interaction " 78 @"additional information or interaction "
59 @"options" 79 @"options"
60 image:[UIImage imageNamed:@"distillation_fail"] 80 image:[UIImage imageNamed:@"distillation_fail"]
61 detailText:@"Details shown only when the article is " 81 detailText:@"Details shown only when the article is "
62 @"expanded. It can be displayed on " 82 @"expanded. It can be displayed on "
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 [_collectionViewController.collectionView performBatchUpdates:^{ 117 [_collectionViewController.collectionView performBatchUpdates:^{
98 [_collectionViewController.collectionView 118 [_collectionViewController.collectionView
99 insertItemsAtIndexPaths:@[ [NSIndexPath 119 insertItemsAtIndexPaths:@[ [NSIndexPath
100 indexPathForRow:numberOfItemsInSection 120 indexPathForRow:numberOfItemsInSection
101 inSection:sectionIndex] ]]; 121 inSection:sectionIndex] ]];
102 } 122 }
103 completion:nil]; 123 completion:nil];
104 } 124 }
105 125
106 - (BOOL)shouldUseCustomStyleForSection:(NSInteger)section { 126 - (BOOL)shouldUseCustomStyleForSection:(NSInteger)section {
107 return section == 0; 127 return section == 0 || section == 1;
108 } 128 }
109 129
110 @end 130 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698