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

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

Issue 2887073002: Layout Most Visited for ContentSuggestions (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm
index c4b3d26637bc4681c108648a06712e5359297bf5..a25a4ec13486e6b1a83f178facdc37a208f8bf8f 100644
--- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm
+++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.mm
@@ -4,10 +4,13 @@
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_controller.h"
+#include "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrome.h"
#import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
#import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
+#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_cell.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.h"
+#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@@ -142,6 +145,43 @@ using CSCollectionViewItem = CollectionViewItem<SuggestedContent>;
}
}
+#pragma mark - UICollectionViewDelegateFlowLayout
+
+- (CGSize)collectionView:(UICollectionView*)collectionView
+ layout:(UICollectionViewLayout*)collectionViewLayout
+ sizeForItemAtIndexPath:(NSIndexPath*)indexPath {
+ if ([self.collectionUpdater isMostVisitedSection:indexPath.section])
lody 2017/05/17 08:23:33 It looks like single-line ifs in this file use { }
gambard 2017/05/17 09:39:43 Done.
+ return [ContentSuggestionsMostVisitedCell defaultSize];
+ return [super collectionView:collectionView
+ layout:collectionViewLayout
+ sizeForItemAtIndexPath:indexPath];
+}
+
+- (UIEdgeInsets)collectionView:(UICollectionView*)collectionView
+ layout:(UICollectionViewLayout*)collectionViewLayout
+ insetForSectionAtIndex:(NSInteger)section {
+ if ([self.collectionUpdater isMostVisitedSection:section]) {
+ CGFloat margin = content_suggestions::centeredTilesMarginForWidth(
+ collectionView.frame.size.width);
+ return UIEdgeInsetsMake(0, margin, 0, margin);
+ }
+ return [super collectionView:collectionView
+ layout:collectionViewLayout
+ insetForSectionAtIndex:section];
+}
+
+- (CGFloat)collectionView:(UICollectionView*)collectionView
+ layout:(UICollectionViewLayout*)
+ collectionViewLayout
+ minimumLineSpacingForSectionAtIndex:(NSInteger)section {
+ if ([self.collectionUpdater isMostVisitedSection:section]) {
+ return content_suggestions::spacingBetweenTiles();
+ }
+ return [super collectionView:collectionView
+ layout:collectionViewLayout
+ minimumLineSpacingForSectionAtIndex:section];
+}
+
#pragma mark - MDCCollectionViewStylingDelegate
- (UIColor*)collectionView:(nonnull UICollectionView*)collectionView
« no previous file with comments | « ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698