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_view_controller.mm

Issue 2619353004: Creates the Suggestions UI (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_view_controller.mm
diff --git a/ios/chrome/browser/ui/suggestions/suggestions_view_controller.mm b/ios/chrome/browser/ui/suggestions/suggestions_view_controller.mm
new file mode 100644
index 0000000000000000000000000000000000000000..b52614653d20651a10a4f4f0ef78a17b33889243
--- /dev/null
+++ b/ios/chrome/browser/ui/suggestions/suggestions_view_controller.mm
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/suggestions/suggestions_view_controller.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/suggestions/suggestions_commands.h"
+#import "ios/chrome/browser/ui/suggestions/suggestions_item_actions.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@interface SuggestionsViewController ()<SuggestionsItemActions>
+
+@end
+
+@implementation SuggestionsViewController
+
+@synthesize suggestionCommandHandler = _suggestionCommandHandler;
+
+#pragma mark - UIViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ self.collectionView.delegate = self;
+ self.styler.cellStyle = MDCCollectionViewCellStyleCard;
+}
+
+#pragma mark - MDCCollectionViewStylingDelegate
+
+- (CGFloat)collectionView:(UICollectionView*)collectionView
+ cellHeightAtIndexPath:(NSIndexPath*)indexPath {
+ CollectionViewItem* item =
+ [self.collectionViewModel itemAtIndexPath:indexPath];
+ UIEdgeInsets inset = [self collectionView:collectionView
+ layout:collectionView.collectionViewLayout
+ insetForSectionAtIndex:indexPath.section];
+
+ return [MDCCollectionViewCell
+ cr_preferredHeightForWidth:CGRectGetWidth(self.view.bounds) - inset.left -
lpromero 2017/01/10 15:51:27 I'd rather compute from the collection view: CGRec
gambard 2017/01/10 16:56:35 Done.
+ inset.right
+ forItem:item];
+}
+
+#pragma mark - SuggestionsItemActions
+
+- (void)addItem:(id)sender {
+ [self.suggestionCommandHandler addEmptyItem];
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698