| OLD | NEW |
| 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 #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, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 32 _collectionViewController = collectionViewController; | 33 _collectionViewController = collectionViewController; |
| 33 [collectionViewController loadModel]; | 34 [collectionViewController loadModel]; |
| 34 CollectionViewModel* model = collectionViewController.collectionViewModel; | 35 CollectionViewModel* model = collectionViewController.collectionViewModel; |
| 35 NSInteger sectionIdentifier = kSectionIdentifierEnumZero; | 36 NSInteger sectionIdentifier = kSectionIdentifierEnumZero; |
| 36 for (NSInteger i = 0; i < 3; i++) { | 37 for (NSInteger i = 0; i < 3; i++) { |
| 37 [model addSectionWithIdentifier:sectionIdentifier]; | 38 [model addSectionWithIdentifier:sectionIdentifier]; |
| 38 [model addItem:[[SuggestionsItem alloc] initWithType:ItemTypeText | 39 [model addItem:[[SuggestionsItem alloc] initWithType:ItemTypeText |
| 39 title:@"The title" | 40 title:@"The title" |
| 40 subtitle:@"The subtitle"] | 41 subtitle:@"The subtitle"] |
| 41 toSectionWithIdentifier:sectionIdentifier]; | 42 toSectionWithIdentifier:sectionIdentifier]; |
| 43 [model addItem: |
| 44 [[SuggestionsArticleItem alloc] |
| 45 initWithType:ItemTypeArticle |
| 46 title:@"Title of an Article" |
| 47 subtitle:@"This is the subtitle of an article, can " |
| 48 @"spawn on multiple lines" |
| 49 image:[UIImage imageNamed:@"distillation_success"]] |
| 50 toSectionWithIdentifier:sectionIdentifier]; |
| 42 sectionIdentifier++; | 51 sectionIdentifier++; |
| 43 } | 52 } |
| 44 } | 53 } |
| 45 return self; | 54 return self; |
| 46 } | 55 } |
| 47 | 56 |
| 48 #pragma mark - Public methods | 57 #pragma mark - Public methods |
| 49 | 58 |
| 50 - (void)addTextItem:(NSString*)title | 59 - (void)addTextItem:(NSString*)title |
| 51 subtitle:(NSString*)subtitle | 60 subtitle:(NSString*)subtitle |
| (...skipping 22 matching lines...) Expand all Loading... |
| 74 [_collectionViewController.collectionView performBatchUpdates:^{ | 83 [_collectionViewController.collectionView performBatchUpdates:^{ |
| 75 [_collectionViewController.collectionView | 84 [_collectionViewController.collectionView |
| 76 insertItemsAtIndexPaths:@[ [NSIndexPath | 85 insertItemsAtIndexPaths:@[ [NSIndexPath |
| 77 indexPathForRow:numberOfItemsInSection | 86 indexPathForRow:numberOfItemsInSection |
| 78 inSection:sectionIndex] ]]; | 87 inSection:sectionIndex] ]]; |
| 79 } | 88 } |
| 80 completion:nil]; | 89 completion:nil]; |
| 81 } | 90 } |
| 82 | 91 |
| 83 @end | 92 @end |
| OLD | NEW |