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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/ui/suggestions/suggestions_view_controller.h"
6
7 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom e.h"
8 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h"
9 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
10 #import "ios/chrome/browser/ui/suggestions/suggestions_commands.h"
11 #import "ios/chrome/browser/ui/suggestions/suggestions_item_actions.h"
12
13 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support."
15 #endif
16
17 @interface SuggestionsViewController ()<SuggestionsItemActions>
18
19 @end
20
21 @implementation SuggestionsViewController
22
23 @synthesize suggestionCommandHandler = _suggestionCommandHandler;
24
25 #pragma mark - UIViewController
26
27 - (void)viewDidLoad {
28 [super viewDidLoad];
29
30 self.collectionView.delegate = self;
31 self.styler.cellStyle = MDCCollectionViewCellStyleCard;
32 }
33
34 #pragma mark - MDCCollectionViewStylingDelegate
35
36 - (CGFloat)collectionView:(UICollectionView*)collectionView
37 cellHeightAtIndexPath:(NSIndexPath*)indexPath {
38 CollectionViewItem* item =
39 [self.collectionViewModel itemAtIndexPath:indexPath];
40 UIEdgeInsets inset = [self collectionView:collectionView
41 layout:collectionView.collectionViewLayout
42 insetForSectionAtIndex:indexPath.section];
43
44 return [MDCCollectionViewCell
45 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.
46 inset.right
47 forItem:item];
48 }
49
50 #pragma mark - SuggestionsItemActions
51
52 - (void)addItem:(id)sender {
53 [self.suggestionCommandHandler addEmptyItem];
54 }
55
56 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698