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

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

Issue 2630313004: Suggestions UI - stack item (Closed)
Patch Set: Cleanup 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
index 0940e8db9b2fe0f8a11dfa179326090f669d3c53..e3b7e5c106d6c44da2a20b32e2bec7b3ac35ba25 100644
--- a/ios/chrome/browser/ui/suggestions/suggestions_view_controller.mm
+++ b/ios/chrome/browser/ui/suggestions/suggestions_view_controller.mm
@@ -11,12 +11,15 @@
#import "ios/chrome/browser/ui/suggestions/suggestions_collection_updater.h"
#import "ios/chrome/browser/ui/suggestions/suggestions_commands.h"
#import "ios/chrome/browser/ui/suggestions/suggestions_item_actions.h"
+#import "ios/chrome/browser/ui/suggestions/suggestions_stack_item.h"
+#import "ios/chrome/browser/ui/suggestions/suggestions_stack_item_actions.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
-@interface SuggestionsViewController ()<SuggestionsItemActions>
+@interface SuggestionsViewController ()<SuggestionsItemActions,
+ SuggestionsStackItemActions>
@property(nonatomic, strong) SuggestionsCollectionUpdater* collectionUpdater;
@@ -36,27 +39,22 @@
- (void)viewDidLoad {
[super viewDidLoad];
- _collectionUpdater = [[SuggestionsCollectionUpdater alloc]
- initWithCollectionViewController:self];
+ _collectionUpdater = [[SuggestionsCollectionUpdater alloc] init];
+ _collectionUpdater.collectionViewController = self;
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];
+#pragma mark - UICollectionViewDelegate
- return [MDCCollectionViewCell
- cr_preferredHeightForWidth:CGRectGetWidth(collectionView.bounds) -
- inset.left - inset.right
- forItem:item];
+- (void)collectionView:(UICollectionView*)collectionView
+ didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
+ [super collectionView:collectionView didSelectItemAtIndexPath:indexPath];
+ if ([[self.collectionViewModel itemAtIndexPath:indexPath]
+ isKindOfClass:[SuggestionsStackItem class]]) {
marq (ping after 24h) 2017/01/16 18:04:42 I don't like the runtime class membership test.
lpromero 2017/01/16 18:17:55 This should test the itemType property of the item
gambard 2017/01/17 13:28:11 I used the item type.
gambard 2017/01/17 13:28:11 The ItemType property is unique per class for now
+ [self.suggestionCommandHandler openReadingList];
+ }
}
#pragma mark - SuggestionsExpandableCellDelegate
@@ -85,6 +83,44 @@
toSection:inputSection];
}
+#pragma mark - SuggestionsStackItemActions
+
+- (void)topOfStackPressed:(id)sender {
+ [self.suggestionCommandHandler openFirstPageOfReadingList];
+}
+
+#pragma mark - MDCCollectionViewStylingDelegate
+
+- (nullable UIColor*)collectionView:(nonnull UICollectionView*)collectionView
marq (ping after 24h) 2017/01/16 18:04:42 I think we don't want nullability annotations on s
gambard 2017/01/17 13:28:11 Done.
+ cellBackgroundColorAtIndexPath:(nonnull NSIndexPath*)indexPath {
+ if ([self.collectionUpdater isCustomStyling:indexPath.section]) {
+ return [UIColor clearColor];
+ }
+ return [UIColor whiteColor];
+}
+
+- (BOOL)collectionView:(nonnull UICollectionView*)collectionView
+ shouldHideItemBackgroundAtIndexPath:(nonnull NSIndexPath*)indexPath {
+ if ([self.collectionUpdater isCustomStyling:indexPath.section]) {
+ return YES;
+ }
+ return NO;
+}
+
+- (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(collectionView.bounds) -
marq (ping after 24h) 2017/01/16 18:04:42 Taking edge inset width into account for cell heig
lpromero 2017/01/16 18:17:55 This is dependent on the cellStyle this controller
gambard 2017/01/17 13:28:11 Maybe we should add a method to CollectionViewCont
marq (ping after 24h) 2017/01/17 14:36:06 I meant CollectionViewController, since this is a
+ inset.left - inset.right
+ forItem:item];
+}
+
#pragma mark - Private
- (void)expand:(BOOL)expand cell:(UICollectionViewCell*)cell {

Powered by Google App Engine
This is Rietveld 408576698