| 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
|
| +// 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]]) {
|
| + SuggestionsExpandableItem* expandableItem =
|
| + base::mac::ObjCCast<SuggestionsExpandableItem>(item);
|
| +
|
| + NSInteger sectionIdentifier = [self.collectionViewModel
|
| + sectionIdentifierForSection:indexPath.section];
|
| +
|
| + expandableItem.expanded = expand;
|
| + [self reconfigureCellsForItems:@[ expandableItem ]
|
| + inSectionWithIdentifier:sectionIdentifier];
|
| +
|
| + [UIView
|
| + animateWithDuration:1
|
| + animations:^{
|
| + [self.collectionView.collectionViewLayout invalidateLayout];
|
| + }];
|
| + }
|
| +}
|
| +
|
| @end
|
|
|