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

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

Issue 2630313004: Suggestions UI - stack item (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
index 84a8ef635f6a41f86dd66c6155c26715db906d38..035bccf5048d13d01f439696d51f7088a5e2eeb3 100644
--- a/ios/chrome/browser/ui/suggestions/suggestions_view_controller.mm
+++ b/ios/chrome/browser/ui/suggestions/suggestions_view_controller.mm
@@ -12,6 +12,8 @@
#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."
@@ -21,7 +23,8 @@ namespace {
const NSTimeInterval kAnimationDuration = 0.35;
} // namespace
-@interface SuggestionsViewController ()<SuggestionsItemActions>
+@interface SuggestionsViewController ()<SuggestionsItemActions,
+ SuggestionsStackItemActions>
@property(nonatomic, strong) SuggestionsCollectionUpdater* collectionUpdater;
@@ -41,27 +44,24 @@ const NSTimeInterval kAnimationDuration = 0.35;
- (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
+#pragma mark - UICollectionViewDelegate
+
+- (void)collectionView:(UICollectionView*)collectionView
+ didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
+ [super collectionView:collectionView didSelectItemAtIndexPath:indexPath];
-- (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) -
- inset.left - inset.right
- forItem:item];
+ if (item.type == ItemTypeStack) {
+ [self.suggestionCommandHandler openReadingList];
+ }
}
#pragma mark - SuggestionsExpandableCellDelegate
@@ -90,6 +90,46 @@ const NSTimeInterval kAnimationDuration = 0.35;
toSection:inputSection];
}
+#pragma mark - SuggestionsStackItemActions
+
+- (void)openReadingListFirstItem:(id)sender {
+ [self.suggestionCommandHandler openFirstPageOfReadingList];
+}
+
+#pragma mark - MDCCollectionViewStylingDelegate
+
+- (UIColor*)collectionView:(nonnull UICollectionView*)collectionView
+ cellBackgroundColorAtIndexPath:(nonnull NSIndexPath*)indexPath {
+ if ([self.collectionUpdater
+ shouldUseCustomStyleForSection:indexPath.section]) {
+ return [UIColor clearColor];
+ }
+ return [UIColor whiteColor];
+}
+
+- (BOOL)collectionView:(nonnull UICollectionView*)collectionView
+ shouldHideItemBackgroundAtIndexPath:(nonnull NSIndexPath*)indexPath {
+ if ([self.collectionUpdater
+ shouldUseCustomStyleForSection: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) -
+ 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