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

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

Issue 2625693002: Suggestions UI - expandable item (Closed)
Patch Set: Update tests 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 a27da97a063afef0786224ca5511cfd72ae5fbe0..0940e8db9b2fe0f8a11dfa179326090f669d3c53 100644
--- a/ios/chrome/browser/ui/suggestions/suggestions_view_controller.mm
+++ b/ios/chrome/browser/ui/suggestions/suggestions_view_controller.mm
@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/suggestions/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"
@@ -19,6 +20,10 @@
@property(nonatomic, strong) SuggestionsCollectionUpdater* collectionUpdater;
+// Applies |interaction| to the item corresponding to |cell| if it is a
marq (ping after 24h) 2017/01/16 17:16:42 |interaction| isn't defined.
gambard 2017/01/17 09:59:00 Done.
+// SuggestionsExpandableCell.
+- (void)expand:(BOOL)expand cell:(UICollectionViewCell*)cell;
+
@end
@implementation SuggestionsViewController
@@ -54,6 +59,16 @@
forItem:item];
}
+#pragma mark - SuggestionsExpandableCellDelegate
+
+- (void)retractCell:(UICollectionViewCell*)cell {
+ [self expand:NO cell:cell];
+}
+
+- (void)expandCell:(UICollectionViewCell*)cell {
+ [self expand:YES cell:cell];
+}
+
#pragma mark - SuggestionsItemActions
- (void)addNewItem:(id)sender {
@@ -70,4 +85,29 @@
toSection:inputSection];
}
+#pragma mark - Private
+
+- (void)expand:(BOOL)expand cell:(UICollectionViewCell*)cell {
+ NSIndexPath* indexPath = [self.collectionView indexPathForCell:cell];
+ CollectionViewItem* item =
+ [self.collectionViewModel itemAtIndexPath:indexPath];
+ if ([item isKindOfClass:[SuggestionsExpandableItem class]]) {
marq (ping after 24h) 2017/01/16 17:16:42 As soon as you start checking for class membership
gambard 2017/01/17 09:59:00 Done.
lpromero 2017/01/17 10:38:49 This should just check the item type.
gambard 2017/01/17 11:55:29 As I am checking if it conforms to protocol, the i
marq (ping after 24h) 2017/01/17 13:42:16 Part of the benefit of the protocol is that you do
gambard 2017/01/17 14:46:56 Yes, I was meaning different objects conforming to
+ SuggestionsExpandableItem* expandableItem =
+ base::mac::ObjCCast<SuggestionsExpandableItem>(item);
+
+ NSInteger sectionIdentifier = [self.collectionViewModel
+ sectionIdentifierForSection:indexPath.section];
+
+ expandableItem.expanded = expand;
marq (ping after 24h) 2017/01/16 17:16:42 lpromero@ -- The cycle of: - Collection item chan
lpromero 2017/01/17 10:38:49 It is a design decision to have the controller exp
marq (ping after 24h) 2017/01/17 13:42:16 I was thinking more of some way for the view item
+ [self reconfigureCellsForItems:@[ expandableItem ]
+ inSectionWithIdentifier:sectionIdentifier];
+
+ [UIView
+ animateWithDuration:1
marq (ping after 24h) 2017/01/16 17:16:42 use a constant for animation duration. one second
gambard 2017/01/17 09:59:00 Done.
+ animations:^{
+ [self.collectionView.collectionViewLayout invalidateLayout];
+ }];
+ }
+}
+
@end

Powered by Google App Engine
This is Rietveld 408576698