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

Unified Diff: ios/chrome/browser/ui/suggestions/suggestions_collection_updater.mm

Issue 2630313004: Suggestions UI - stack item (Closed)
Patch Set: Address comments 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 side-by-side diff with in-line comments
Download patch
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..272ef9833d841acbfa19625573d10ac592d7dd41 100644
--- a/ios/chrome/browser/ui/suggestions/suggestions_collection_updater.mm
+++ b/ios/chrome/browser/ui/suggestions/suggestions_collection_updater.mm
@@ -4,70 +4,67 @@
#import "ios/chrome/browser/ui/suggestions/suggestions_collection_updater.h"
+#include "base/logging.h"
#include "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_controller.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
#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
@@ -75,6 +72,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)addTextItem:(NSString*)title
subtitle:(NSString*)subtitle
toSection:(NSInteger)inputSection {
+ DCHECK(_collectionViewController);
SuggestionsItem* item = [[SuggestionsItem alloc] initWithType:ItemTypeText
title:title
subtitle:subtitle];
@@ -105,4 +103,8 @@ typedef NS_ENUM(NSInteger, ItemType) {
completion:nil];
}
+- (BOOL)shouldUseCustomStyleForSection:(NSInteger)section {
+ return section == 0;
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698