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

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

Issue 2625693002: Suggestions UI - expandable item (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 #include "base/mac/foundation_util.h"
7 #import "ios/chrome/browser/ui/collection_view/collection_view_controller.h" 8 #import "ios/chrome/browser/ui/collection_view/collection_view_controller.h"
8 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" 9 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
9 #import "ios/chrome/browser/ui/suggestions/suggestions_article_item.h" 10 #import "ios/chrome/browser/ui/suggestions/suggestions_article_item.h"
11 #import "ios/chrome/browser/ui/suggestions/suggestions_expandable_item.h"
10 #import "ios/chrome/browser/ui/suggestions/suggestions_item.h" 12 #import "ios/chrome/browser/ui/suggestions/suggestions_item.h"
11 13
12 #if !defined(__has_feature) || !__has_feature(objc_arc) 14 #if !defined(__has_feature) || !__has_feature(objc_arc)
13 #error "This file requires ARC support." 15 #error "This file requires ARC support."
14 #endif 16 #endif
15 17
16 namespace { 18 namespace {
17 typedef NS_ENUM(NSInteger, ItemType) { 19 typedef NS_ENUM(NSInteger, ItemType) {
18 ItemTypeText = kItemTypeEnumZero, 20 ItemTypeText = kItemTypeEnumZero,
19 ItemTypeArticle, 21 ItemTypeArticle,
(...skipping 20 matching lines...) Expand all
40 initWithType:ItemTypeArticle 42 initWithType:ItemTypeArticle
41 title:@"Title of an Article" 43 title:@"Title of an Article"
42 subtitle:@"This is the subtitle of an article, can " 44 subtitle:@"This is the subtitle of an article, can "
43 @"spawn on multiple lines" 45 @"spawn on multiple lines"
44 image:[UIImage 46 image:[UIImage
45 imageNamed:@"distillation_success"]]]; 47 imageNamed:@"distillation_success"]]];
46 [arrayToAdd 48 [arrayToAdd
47 addObject:[[SuggestionsItem alloc] initWithType:ItemTypeText 49 addObject:[[SuggestionsItem alloc] initWithType:ItemTypeText
48 title:@"The title" 50 title:@"The title"
49 subtitle:@"The subtitle"]]; 51 subtitle:@"The subtitle"]];
52 [arrayToAdd
53 addObject:[[SuggestionsExpandableItem alloc]
54 initWithType:ItemTypeExpand
55 title:@"Title of an Expandable Article"
lpromero 2017/01/11 13:19:20 Can you add a bug to track removing these? I guess
gambard 2017/01/12 14:39:40 Well the bug for creating the suggestions UI shoul
56 subtitle:@"This Article can be expanded to display "
57 @"addition information or interaction "
58 @"options"
59 image:[UIImage imageNamed:@"distillation_fail"]
60 detailText:@"Details shown only when the article is "
61 @"expanded. It can be displayed on "
62 @"multiple lines."]];
50 [_items addObject:arrayToAdd]; 63 [_items addObject:arrayToAdd];
51 } 64 }
52 } 65 }
53 return self; 66 return self;
54 } 67 }
55 68
56 #pragma mark - Properties 69 #pragma mark - Properties
57 70
58 - (void)setCollectionViewController: 71 - (void)setCollectionViewController:
59 (CollectionViewController*)collectionViewController { 72 (CollectionViewController*)collectionViewController {
60 _collectionViewController = collectionViewController; 73 _collectionViewController = collectionViewController;
61 if (!collectionViewController) { 74 if (!collectionViewController) {
62 return; 75 return;
63 } 76 }
64 [collectionViewController loadModel]; 77 [collectionViewController loadModel];
65 CollectionViewModel* model = collectionViewController.collectionViewModel; 78 CollectionViewModel* model = collectionViewController.collectionViewModel;
66 NSInteger sectionIdentifier = kSectionIdentifierEnumZero; 79 NSInteger sectionIdentifier = kSectionIdentifierEnumZero;
67 for (NSMutableArray<CollectionViewItem*>* arrayWithItems in _items) { 80 for (NSMutableArray<CollectionViewItem*>* arrayWithItems in _items) {
68 [model addSectionWithIdentifier:sectionIdentifier]; 81 [model addSectionWithIdentifier:sectionIdentifier];
69 for (CollectionViewItem* item in arrayWithItems) { 82 for (CollectionViewItem* item in arrayWithItems) {
83 if ([item isKindOfClass:[SuggestionsExpandableItem class]]) {
84 SuggestionsExpandableItem* expandableItem =
85 base::mac::ObjCCastStrict<SuggestionsExpandableItem>(item);
86 expandableItem.collectionView = collectionViewController.collectionView;
87 }
70 [model addItem:item toSectionWithIdentifier:sectionIdentifier]; 88 [model addItem:item toSectionWithIdentifier:sectionIdentifier];
71 } 89 }
72 sectionIdentifier++; 90 sectionIdentifier++;
73 } 91 }
74 } 92 }
75 93
76 #pragma mark - Public methods 94 #pragma mark - Public methods
77 95
78 - (void)addTextItem:(NSString*)title 96 - (void)addTextItem:(NSString*)title
79 subtitle:(NSString*)subtitle 97 subtitle:(NSString*)subtitle
(...skipping 27 matching lines...) Expand all
107 [NSIndexPath indexPathForRow:[[_items objectAtIndex:section] count] - 1 125 [NSIndexPath indexPathForRow:[[_items objectAtIndex:section] count] - 1
108 inSection:section] 126 inSection:section]
109 ]]; 127 ]];
110 } 128 }
111 completion:^(BOOL){ 129 completion:^(BOOL){
112 }]; 130 }];
113 } 131 }
114 } 132 }
115 133
116 @end 134 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698