| 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 #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 21 matching lines...) Expand all Loading... |
| 41 subtitle:@"The subtitle"] | 43 subtitle:@"The subtitle"] |
| 42 toSectionWithIdentifier:sectionIdentifier]; | 44 toSectionWithIdentifier:sectionIdentifier]; |
| 43 [model addItem: | 45 [model addItem: |
| 44 [[SuggestionsArticleItem alloc] | 46 [[SuggestionsArticleItem alloc] |
| 45 initWithType:ItemTypeArticle | 47 initWithType:ItemTypeArticle |
| 46 title:@"Title of an Article" | 48 title:@"Title of an Article" |
| 47 subtitle:@"This is the subtitle of an article, can " | 49 subtitle:@"This is the subtitle of an article, can " |
| 48 @"spawn on multiple lines" | 50 @"spawn on multiple lines" |
| 49 image:[UIImage imageNamed:@"distillation_success"]] | 51 image:[UIImage imageNamed:@"distillation_success"]] |
| 50 toSectionWithIdentifier:sectionIdentifier]; | 52 toSectionWithIdentifier:sectionIdentifier]; |
| 53 SuggestionsExpandableItem* expandableItem = |
| 54 [[SuggestionsExpandableItem alloc] |
| 55 initWithType:ItemTypeExpand |
| 56 title:@"Title of an Expandable Article" |
| 57 subtitle:@"This Article can be expanded to display " |
| 58 @"addition information or interaction " |
| 59 @"options" |
| 60 image:[UIImage imageNamed:@"distillation_fail"] |
| 61 detailText:@"Details shown only when the article is " |
| 62 @"expanded. It can be displayed on " |
| 63 @"multiple lines."]; |
| 64 expandableItem.collectionView = _collectionViewController.collectionView; |
| 65 [model addItem:expandableItem toSectionWithIdentifier:sectionIdentifier]; |
| 51 sectionIdentifier++; | 66 sectionIdentifier++; |
| 52 } | 67 } |
| 53 } | 68 } |
| 54 return self; | 69 return self; |
| 55 } | 70 } |
| 56 | 71 |
| 57 #pragma mark - Public methods | 72 #pragma mark - Public methods |
| 58 | 73 |
| 59 - (void)addTextItem:(NSString*)title | 74 - (void)addTextItem:(NSString*)title |
| 60 subtitle:(NSString*)subtitle | 75 subtitle:(NSString*)subtitle |
| (...skipping 22 matching lines...) Expand all Loading... |
| 83 [_collectionViewController.collectionView performBatchUpdates:^{ | 98 [_collectionViewController.collectionView performBatchUpdates:^{ |
| 84 [_collectionViewController.collectionView | 99 [_collectionViewController.collectionView |
| 85 insertItemsAtIndexPaths:@[ [NSIndexPath | 100 insertItemsAtIndexPaths:@[ [NSIndexPath |
| 86 indexPathForRow:numberOfItemsInSection | 101 indexPathForRow:numberOfItemsInSection |
| 87 inSection:sectionIndex] ]]; | 102 inSection:sectionIndex] ]]; |
| 88 } | 103 } |
| 89 completion:nil]; | 104 completion:nil]; |
| 90 } | 105 } |
| 91 | 106 |
| 92 @end | 107 @end |
| OLD | NEW |