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

Unified Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm

Issue 2751653008: Add header for the Content Suggestions (Closed)
Patch Set: Created 3 years, 9 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/content_suggestions/content_suggestions_collection_updater.mm
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm
index ee0f2048beb7027c49dbde1da124275bd466a787..8a5c799b81ad633714efe9a9310267a15beaa194 100644
--- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm
+++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm
@@ -17,6 +17,7 @@
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_expandable_item.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_favicon_item.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_footer_item.h"
+#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_header_item.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_image_fetcher.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_section_information.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_stack_item.h"
@@ -39,6 +40,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeStack,
ItemTypeFavicon,
ItemTypeFooter,
+ ItemTypeHeader,
};
typedef NS_ENUM(NSInteger, SectionIdentifier) {
@@ -166,8 +168,10 @@ SectionIdentifier SectionIdentifierForInfo(
- (void)reloadAllData {
[self resetModels];
- [self.collectionViewController
- addSuggestions:[self.dataSource allSuggestions]];
+ NSArray<ContentSuggestion*>* suggestions = [self.dataSource allSuggestions];
+ [self addSectionsForSuggestionsToModel:suggestions];
+ [self addSuggestionsToModel:suggestions];
+ [self.collectionViewController.collectionView reloadData];
gambard 2017/03/16 15:49:41 This is a bug fix, appearing only when you add hea
lpromero 2017/03/16 16:43:21 Can you explain more on the issue in a comment in
gambard 2017/03/17 09:33:39 Done.
}
- (void)clearSection:(ContentSuggestionsSectionInformation*)sectionInfo {
@@ -248,6 +252,7 @@ SectionIdentifier SectionIdentifierForInfo(
[indexSet addIndex:[model sectionForSectionIdentifier:sectionIdentifier]];
[self addFooterIfNeeded:suggestion.suggestionIdentifier.sectionInfo];
+ [self addHeader:suggestion.suggestionIdentifier.sectionInfo];
lpromero 2017/03/16 16:43:21 Optional nit: move one line up?
gambard 2017/03/17 09:33:39 Done.
}
}
return indexSet;
@@ -307,6 +312,21 @@ SectionIdentifier SectionIdentifierForInfo(
}
}
+// Adds the header corresponding to |sectionInfo| to the section.
+- (void)addHeader:(ContentSuggestionsSectionInformation*)sectionInfo {
+ NSInteger sectionIdentifier = SectionIdentifierForInfo(sectionInfo);
+
+ if (![self.collectionViewController.collectionViewModel
+ headerForSectionWithIdentifier:sectionIdentifier]) {
+ ContentSuggestionsHeaderItem* header =
+ [[ContentSuggestionsHeaderItem alloc] initWithType:ItemTypeHeader];
+ header.text = sectionInfo.title;
+ [self.collectionViewController.collectionViewModel
+ setHeader:header
+ forSectionWithIdentifier:sectionIdentifier];
+ }
+}
+
// Resets the models, removing the current CollectionViewItem and the
// SectionInfo.
- (void)resetModels {

Powered by Google App Engine
This is Rietveld 408576698