Chromium Code Reviews| Index: ios/chrome/browser/ui/suggestions/suggestions_collection_updater.mm |
| diff --git a/ios/chrome/browser/ui/suggestions/suggestions_collection_updater.mm b/ios/chrome/browser/ui/suggestions/suggestions_collection_updater.mm |
| index 01c6d0cd2c87f411be194210e937b26f01e9b839..538879f639f02324c2ce131761fee91e08c98116 100644 |
| --- a/ios/chrome/browser/ui/suggestions/suggestions_collection_updater.mm |
| +++ b/ios/chrome/browser/ui/suggestions/suggestions_collection_updater.mm |
| @@ -10,64 +10,60 @@ |
| #import "ios/chrome/browser/ui/suggestions/suggestions_article_item.h" |
| #import "ios/chrome/browser/ui/suggestions/suggestions_expandable_item.h" |
| #import "ios/chrome/browser/ui/suggestions/suggestions_item.h" |
| +#import "ios/chrome/browser/ui/suggestions/suggestions_stack_item.h" |
| #import "ios/chrome/browser/ui/suggestions/suggestions_view_controller.h" |
| #if !defined(__has_feature) || !__has_feature(objc_arc) |
| #error "This file requires ARC support." |
| #endif |
| -namespace { |
| -typedef NS_ENUM(NSInteger, ItemType) { |
| - ItemTypeText = kItemTypeEnumZero, |
| - ItemTypeArticle, |
| - ItemTypeExpand, |
| -}; |
| +@implementation SuggestionsCollectionUpdater |
| -} // namespace |
| +@synthesize collectionViewController = _collectionViewController; |
| -@implementation SuggestionsCollectionUpdater { |
| - SuggestionsViewController* _collectionViewController; |
| -} |
| +#pragma mark - Properties |
| -- (instancetype)initWithCollectionViewController: |
| +- (void)setCollectionViewController: |
| (SuggestionsViewController*)collectionViewController { |
| - self = [super init]; |
| - if (self) { |
| - _collectionViewController = collectionViewController; |
| - [collectionViewController loadModel]; |
| - CollectionViewModel* model = collectionViewController.collectionViewModel; |
| - NSInteger sectionIdentifier = kSectionIdentifierEnumZero; |
| - for (NSInteger i = 0; i < 3; i++) { |
| - [model addSectionWithIdentifier:sectionIdentifier]; |
| - [model addItem:[[SuggestionsItem alloc] initWithType:ItemTypeText |
| - title:@"The title" |
| - subtitle:@"The subtitle"] |
| - toSectionWithIdentifier:sectionIdentifier]; |
| - [model addItem: |
| - [[SuggestionsArticleItem alloc] |
| - initWithType:ItemTypeArticle |
| - title:@"Title of an Article" |
| - subtitle:@"This is the subtitle of an article, can " |
| - @"spawn on multiple lines" |
| - image:[UIImage imageNamed:@"distillation_success"]] |
| - toSectionWithIdentifier:sectionIdentifier]; |
| - SuggestionsExpandableItem* expandableItem = |
| - [[SuggestionsExpandableItem alloc] |
| - initWithType:ItemTypeExpand |
| - title:@"Title of an Expandable Article" |
| - subtitle:@"This Article can be expanded to display " |
| - @"additional information or interaction " |
| - @"options" |
| - image:[UIImage imageNamed:@"distillation_fail"] |
| - detailText:@"Details shown only when the article is " |
| - @"expanded. It can be displayed on " |
| - @"multiple lines."]; |
| - expandableItem.delegate = collectionViewController; |
| - [model addItem:expandableItem toSectionWithIdentifier:sectionIdentifier]; |
| - sectionIdentifier++; |
| - } |
| + _collectionViewController = collectionViewController; |
| + [collectionViewController loadModel]; |
| + CollectionViewModel* model = collectionViewController.collectionViewModel; |
| + NSInteger sectionIdentifier = kSectionIdentifierEnumZero; |
| + [model addSectionWithIdentifier:sectionIdentifier]; |
| + [model addItem:[[SuggestionsStackItem alloc] initWithType:ItemTypeStack |
| + title:@"The title" |
| + subtitle:@"The subtitle"] |
| + toSectionWithIdentifier:sectionIdentifier++]; |
| + |
| + for (NSInteger i = 0; i < 3; i++) { |
| + [model addSectionWithIdentifier:sectionIdentifier]; |
| + [model addItem:[[SuggestionsItem alloc] initWithType:ItemTypeText |
| + title:@"The title" |
| + subtitle:@"The subtitle"] |
| + toSectionWithIdentifier:sectionIdentifier]; |
| + [model addItem:[[SuggestionsArticleItem alloc] |
| + initWithType:ItemTypeArticle |
| + title:@"Title of an Article" |
| + subtitle:@"This is the subtitle of an article, can " |
| + @"spawn on multiple lines" |
| + image:[UIImage |
| + imageNamed:@"distillation_success"]] |
| + toSectionWithIdentifier:sectionIdentifier]; |
| + SuggestionsExpandableItem* expandableItem = |
| + [[SuggestionsExpandableItem alloc] |
| + initWithType:ItemTypeExpand |
| + title:@"Title of an Expandable Article" |
| + subtitle:@"This Article can be expanded to display " |
| + @"additional information or interaction " |
| + @"options" |
| + image:[UIImage imageNamed:@"distillation_fail"] |
| + detailText:@"Details shown only when the article is " |
| + @"expanded. It can be displayed on " |
| + @"multiple lines."]; |
| + expandableItem.delegate = _collectionViewController; |
| + [model addItem:expandableItem toSectionWithIdentifier:sectionIdentifier]; |
| + sectionIdentifier++; |
| } |
| - return self; |
| } |
| #pragma mark - Public methods |
| @@ -105,4 +101,8 @@ typedef NS_ENUM(NSInteger, ItemType) { |
| completion:nil]; |
| } |
| +- (BOOL)isCustomStyling:(NSInteger)section { |
|
lpromero
2017/01/17 13:47:20
s/isCustomStyling/shouldUseCustomStyleForSection?
gambard
2017/01/17 14:52:36
Done.
|
| + return section == 0; |
| +} |
| + |
| @end |