Commit c6d67b48 authored by Roberto Moura's avatar Roberto Moura Committed by Commit Bot

Update the defaultLayout property on the Grid View Controller.

Refactor |willTransitionToLayout:completion| and update |defaultLayout|
after a layout transition.

Bug: 1127604
Change-Id: I46832b073db56b189cb46f046229e7e99c3f48ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450278
Auto-Submit: Roberto Moura <mouraroberto@google.com>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814580}
parent e7e501aa
...@@ -696,22 +696,23 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -696,22 +696,23 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
- (void)willTransitionToLayout:(LayoutSwitcherState)nextState - (void)willTransitionToLayout:(LayoutSwitcherState)nextState
completion: completion:
(void (^)(BOOL completed, BOOL finished))completion { (void (^)(BOOL completed, BOOL finished))completion {
auto completionBlock = ^(BOOL completed, BOOL finished) { TabSwitcherLayout* nextLayout;
completion(completed, finished);
self.collectionView.scrollEnabled = YES;
};
switch (nextState) { switch (nextState) {
case LayoutSwitcherState::Horizontal: case LayoutSwitcherState::Horizontal:
self.gridHorizontalTransitionLayout = [self.collectionView nextLayout = self.horizontalLayout;
startInteractiveTransitionToCollectionViewLayout:self.horizontalLayout
completion:completionBlock];
break; break;
case LayoutSwitcherState::Full: case LayoutSwitcherState::Full:
self.gridHorizontalTransitionLayout = [self.collectionView nextLayout = self.gridLayout;
startInteractiveTransitionToCollectionViewLayout:self.gridLayout
completion:completionBlock];
break; break;
} }
auto completionBlock = ^(BOOL completed, BOOL finished) {
completion(completed, finished);
self.collectionView.scrollEnabled = YES;
self.defaultLayout = nextLayout;
};
self.gridHorizontalTransitionLayout = [self.collectionView
startInteractiveTransitionToCollectionViewLayout:nextLayout
completion:completionBlock];
// Stops collectionView scrolling when the animation starts. // Stops collectionView scrolling when the animation starts.
[self.collectionView setContentOffset:self.collectionView.contentOffset [self.collectionView setContentOffset:self.collectionView.contentOffset
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment