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

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

Issue 2618333005: Suggestions UI - Add Article items (Closed)
Patch Set: Rebase 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_data_source.h" 5 #import "ios/chrome/browser/ui/suggestions/suggestions_data_source.h"
6 6
7 #import "ios/chrome/browser/ui/collection_view/collection_view_controller.h" 7 #import "ios/chrome/browser/ui/collection_view/collection_view_controller.h"
8 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 8 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
9 #import "ios/chrome/browser/ui/suggestions/suggestions_article_item.h"
9 #import "ios/chrome/browser/ui/suggestions/suggestions_item.h" 10 #import "ios/chrome/browser/ui/suggestions/suggestions_item.h"
10 11
11 #if !defined(__has_feature) || !__has_feature(objc_arc) 12 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support." 13 #error "This file requires ARC support."
13 #endif 14 #endif
14 15
15 namespace { 16 namespace {
16 typedef NS_ENUM(NSInteger, ItemType) { 17 typedef NS_ENUM(NSInteger, ItemType) {
17 ItemTypeText = kItemTypeEnumZero, 18 ItemTypeText = kItemTypeEnumZero,
18 ItemTypeArticle, 19 ItemTypeArticle,
19 ItemTypeExpand, 20 ItemTypeExpand,
20 }; 21 };
21 22
22 } // namespace 23 } // namespace
23 24
24 @implementation SuggestionsDataSource { 25 @implementation SuggestionsDataSource {
25 NSMutableArray<NSMutableArray<CollectionViewItem*>*>* _items; 26 NSMutableArray<NSMutableArray<CollectionViewItem*>*>* _items;
26 } 27 }
27 28
28 @synthesize collectionViewController = _collectionViewController; 29 @synthesize collectionViewController = _collectionViewController;
29 30
30 - (instancetype)init { 31 - (instancetype)init {
31 self = [super init]; 32 self = [super init];
32 if (self) { 33 if (self) {
33 _items = [NSMutableArray arrayWithCapacity:1]; 34 _items = [NSMutableArray arrayWithCapacity:1];
34 for (NSInteger i = 0; i < 3; i++) { 35 for (NSInteger i = 0; i < 3; i++) {
35 NSMutableArray<CollectionViewItem*>* arrayToAdd = 36 NSMutableArray<CollectionViewItem*>* arrayToAdd =
36 [NSMutableArray arrayWithCapacity:3]; 37 [NSMutableArray arrayWithCapacity:3];
37 [arrayToAdd 38 [arrayToAdd
39 addObject:[[SuggestionsArticleItem alloc]
40 initWithType:ItemTypeArticle
41 title:@"Title of an Article"
42 subtitle:@"This is the subtitle of an article, can "
43 @"spawn on multiple lines"
44 image:[UIImage
45 imageNamed:@"distillation_success"]]];
46 [arrayToAdd
38 addObject:[[SuggestionsItem alloc] initWithType:ItemTypeText 47 addObject:[[SuggestionsItem alloc] initWithType:ItemTypeText
39 title:@"The title" 48 title:@"The title"
40 subtitle:@"The subtitle"]]; 49 subtitle:@"The subtitle"]];
41 [_items addObject:arrayToAdd]; 50 [_items addObject:arrayToAdd];
42 } 51 }
43 } 52 }
44 return self; 53 return self;
45 } 54 }
46 55
47 #pragma mark - Properties 56 #pragma mark - Properties
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 [NSIndexPath indexPathForRow:[[_items objectAtIndex:section] count] - 1 107 [NSIndexPath indexPathForRow:[[_items objectAtIndex:section] count] - 1
99 inSection:section] 108 inSection:section]
100 ]]; 109 ]];
101 } 110 }
102 completion:^(BOOL){ 111 completion:^(BOOL){
103 }]; 112 }];
104 } 113 }
105 } 114 }
106 115
107 @end 116 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698